fix(worker): gate test_config() behind test-utils feature#390
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
file:line
crates/worker/src/config.rs:20—WorkerConfig::test_config()fix sketch
impl WorkerConfig { test_config() }with#[cfg(any(test, feature = "test-utils"))](matches the convention fromcrates/network/src/mem.rs).[features] test-utils = []tocrates/worker/Cargo.toml.#[cfg(test)] mod tests, so no production callers needed updating.why (security)
test_config()was unconditionallypub, leaking the hardcoded/tmp/test-worker.keypath string into any release binary that depends onwillow-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-utilscargo test -p willow-worker --no-runcargo fmt -p willow-workerrg -n 'test_config\(\)' crates/— only the def + the in-file#[cfg(test)]testhttps://claude.ai/code/session_01KvXynFPgSaqWTBo65iMnD9
Generated by Claude Code