Labels: bug, checks-crate
Crate: checks
Description
Closed issue #232 established that checks walking file/contractimpl_functions() without excluding #[cfg(test)] code produce false positives when the checks crate scans its own test fixtures, and fixed the checks affected at the time via crate::util::contractimpl_functions_excluding_test. Four checks added since then never got this treatment — they call visit::visit_file(&mut visitor, file) directly and walk every #[contractimpl] Item::Impl they encounter, test modules included:
crates/checks/src/unsafe_randomness.rs:15-19
crates/checks/src/unprotected_upgrade.rs:16-19 — its own #[cfg(test)] mod tests block literally contains #[contractimpl] impl C { pub fn upgrade(...) { env.invoke_wasm(...); } } with no auth call, the exact shape this check flags
crates/checks/src/unprotected_token_mint.rs:16-19
crates/checks/src/unprotected_contract_deployment.rs:16-19
Scanning the soroban-guard-checks crate's own source with these checks active would produce false positives straight out of these files' own unit tests, and any real contract that puts a fixture/mock #[contractimpl] block inside a #[cfg(test)] module will get flagged the same way.
Acceptance Criteria
Difficulty: intermediate
Labels: bug, checks-crate
Crate: checks
Description
Closed issue #232 established that checks walking
file/contractimpl_functions()without excluding#[cfg(test)]code produce false positives when the checks crate scans its own test fixtures, and fixed the checks affected at the time viacrate::util::contractimpl_functions_excluding_test. Four checks added since then never got this treatment — they callvisit::visit_file(&mut visitor, file)directly and walk every#[contractimpl]Item::Implthey encounter, test modules included:crates/checks/src/unsafe_randomness.rs:15-19crates/checks/src/unprotected_upgrade.rs:16-19— its own#[cfg(test)] mod testsblock literally contains#[contractimpl] impl C { pub fn upgrade(...) { env.invoke_wasm(...); } }with no auth call, the exact shape this check flagscrates/checks/src/unprotected_token_mint.rs:16-19crates/checks/src/unprotected_contract_deployment.rs:16-19Scanning the
soroban-guard-checkscrate's own source with these checks active would produce false positives straight out of these files' own unit tests, and any real contract that puts a fixture/mock#[contractimpl]block inside a#[cfg(test)]module will get flagged the same way.Acceptance Criteria
crate::util::contractimpl_functions_excluding_test(or its type-paired sibling) instead of manually walkingvisit::visit_file.#[cfg(test)] mod testsblock produces no finding.Difficulty: intermediate