Skip to content

fix(worker): gate test_config() behind test-utils feature#390

Merged
intendednull merged 1 commit into
mainfrom
audit/test-config-gate
Apr 26, 2026
Merged

fix(worker): gate test_config() behind test-utils feature#390
intendednull merged 1 commit into
mainfrom
audit/test-config-gate

Conversation

@intendednull
Copy link
Copy Markdown
Owner

file:line

crates/worker/src/config.rs:20WorkerConfig::test_config()

fix sketch

  • Wrap impl WorkerConfig { test_config() } with #[cfg(any(test, feature = "test-utils"))] (matches the convention from crates/network/src/mem.rs).
  • Add [features] test-utils = [] to crates/worker/Cargo.toml.
  • Sole call site lives inside the same file's #[cfg(test)] mod tests, so no production callers needed updating.

why (security)

test_config() was unconditionally pub, leaking the hardcoded /tmp/test-worker.key path string into any release binary that depends on willow-worker. Gating it removes the test scaffolding from non-test builds.

closes #331

verification

  • cargo check -p willow-worker (default features)
  • cargo check -p willow-worker --features test-utils
  • cargo test -p willow-worker --no-run
  • cargo fmt -p willow-worker
  • rg -n 'test_config\(\)' crates/ — only the def + the in-file #[cfg(test)] test

https://claude.ai/code/session_01KvXynFPgSaqWTBo65iMnD9


Generated by Claude Code

crates/worker/src/config.rs:20 - WorkerConfig::test_config()
returned a struct hardcoding /tmp/test-worker.key. Without a cfg
gate this scaffolding (and its insecure path string) compiled
into release binaries that depend on willow-worker.

Follow the willow convention from crates/network/src/mem.rs:
gate behind #[cfg(any(test, feature = "test-utils"))] and add
the test-utils feature to crates/worker/Cargo.toml.

Verification:
- cargo check -p willow-worker (default features): ok
- cargo check -p willow-worker --features test-utils: ok
- cargo test -p willow-worker --no-run: ok
- cargo fmt -p willow-worker: clean

Closes #331

https://claude.ai/code/session_01KvXynFPgSaqWTBo65iMnD9
@intendednull intendednull merged commit 6e92492 into main Apr 26, 2026
7 checks passed
@intendednull intendednull deleted the audit/test-config-gate branch April 26, 2026 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TD-13] pub fn test_config() (with /tmp/test-worker.key) lives in non-test module

2 participants