Skip to content

AuthAfterStorageWriteCheck is registered twice, and scan_directory_with_checks never deduplicates — real scans emit duplicate findings #371

Description

@unrealtim-tech

Labels: bug, checks-crate, analyzer-crate
Crate: checks

Description
crates/checks/src/lib.rs registers Box::new(AuthAfterStorageWriteCheck) twice in both all_checks_base() (lines 199 and 230) and default_checks_with_config() (lines 261 and 292) — two independent hardcoded 35-item lists, exactly the "no single source of truth" pattern issue #236 was supposed to fix, still duplicated and now out of sync with itself. Because default_checks_with_config() runs the same check object twice, auth-after-storage-write findings are produced twice for every offending line.

Critically, crates/analyzer/src/lib.rs's scan_directory_with_checks — confirmed by issue #309 to be the function the actual CLI calls — never calls dedup_findings (unlike scan_directory/scan_files, which do). So this duplication is not silently absorbed: real soroban-guard scan runs report every auth-after-storage-write finding twice, doubling counts in --json's summary.total, doubling rows in --markdown/SARIF output, etc.

Acceptance Criteria

  • Remove the duplicate AuthAfterStorageWriteCheck registration from both lists.
  • Make default_checks_with_config() build from all_checks_base() plus config-driven modifications instead of maintaining a second hand-written list, so this class of drift can't recur.
  • Add a test asserting default_checks()/default_checks_with_config() contain no duplicate check names, and a CLI-level test scanning a fixture that would trip auth-after-storage-write, asserting exactly one finding via scan_directory_with_checks.

Difficulty: intermediate

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions