Skip to content

fix(scanner): 5 correctness and FP improvements#1

Merged
ashvinctrl merged 3 commits into
mainfrom
fix/scanner-improvements
Jun 2, 2026
Merged

fix(scanner): 5 correctness and FP improvements#1
ashvinctrl merged 3 commits into
mainfrom
fix/scanner-improvements

Conversation

@ashvinctrl

Copy link
Copy Markdown
Owner

Summary

  • Custom pattern caching (regex_scan.rs): user-defined patterns were compiled fresh on every line of the diff. Now compiled once per scan via compile_custom_patterns().
  • All regex matches per line (regex_scan.rs): scan_line previously returned on the first match. A line with both an AWS key and an OpenAI key would silently drop one. Now returns all matches sorted by confidence, with two new tests covering this.
  • Expanded entropy FP filter (entropy.rs): added UUID detection, all standard hash lengths (MD5/SHA1/SHA512), npm/yarn/pip integrity hash prefixes, and dotted version strings — the most common sources of day-to-day entropy noise.
  • All AST matches per file (ast.rs): scan_node previously returned on the first sensitive assignment found during the tree walk. A file with both system_prompt and api_key assignments would only report one. Now accumulates all matches via &mut Vec. Also replaced binary confidence scoring (length-only) with entropy-aware scoring.
  • Parallel L3 for multiple ambiguous candidates (mod.rs): the ambiguous pool was Option<ScanResult> — only the single best candidate reached semantic inference. A diff with 3 ambiguous lines would send 1 to L3 and silently drop 2. Now a Vec capped at 3, fanned out to L3 in parallel via std::thread::spawn.

Test plan

  • CI build passes (cargo build --release)
  • Unit tests pass (cargo test)
  • detects_all_sensitive_assignments (new) confirms AST multi-match
  • returns_all_matches_on_multi_secret_line (new) confirms regex multi-match
  • skips_uuid / skips_npm_integrity_hash (new) confirm entropy FP filter

- regex: compile custom patterns once before scan loop, not per line
- regex: return all matches per line instead of first-match-wins
- entropy: expand FP filter with UUIDs, all hash lengths, npm integrity hashes, version strings
- ast: collect all sensitive assignments per file instead of stopping at first
- mod: fan out L3 semantic inference to top-3 ambiguous candidates in parallel
…rets

The CI scan checks the whole file, so test assertion strings that embed
realistic-looking fake keys (AWS keys, OpenAI keys, private key headers)
were tripping provn's own scanner. All affected lines now carry
// provn:allow so the bootstrap problem is suppressed.
parse_file (used by `provn check`) was treating every line as a
candidate without applying the provn:allow / provn:skip-file filters
that parse_diff_text already had. This meant the annotation only worked
in pre-commit scan mode, not when scanning a file directly — the path
taken by the CI scan script. Both filters are now applied consistently.
@ashvinctrl
ashvinctrl merged commit 2dc7c6b into main Jun 2, 2026
1 check passed
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.

1 participant