Skip to content

test: exhaustive coverage for the #91-#96 behavior - #97

Merged
pixincreate merged 1 commit into
masterfrom
test/exhaustive-coverage
Sep 5, 2026
Merged

test: exhaustive coverage for the #91-#96 behavior#97
pixincreate merged 1 commit into
masterfrom
test/exhaustive-coverage

Conversation

@pixincreate

Copy link
Copy Markdown
Owner

Summary

Adds 32 tests pinning everything the recent PRs changed, at three levels:

Unit (src/detector.rs)

  • Verhoeff matrix: canonical 2363/2362, separators, digit-suffix filtering, embedded id runs, degenerate inputs (empty, no digits, all-zero — the p-permutation breaks the identity chain, so the classic dummy does not validate), single digits.
  • Luhn matrix: known cards, separators, sub-13-digit rejection, non-digit input.
  • shannon_entropy: information-theory identities (uniform = 0, two-symbol = 1.0), 64-hex near the 4.0 ceiling, multi-byte input.
  • is_multiline: (?s), grouped (?s:...), combined (?is), (?i)-only, plain — and the test caught a real bug: combined flags like (?is) missed the contains("(?s") check, so such patterns were scanned line-by-line and silently missed multiline secrets. is_multiline now parses flag groups properly.
  • ContentValidator::from_str: lowercase, case handling, unknown validator.

Detector set (tests/detector_tests.rs)

Every allowlist entry from #96 exercised in both directions through the real detector set: AWS example key (allowlisted; any other AKIA reported), placeholders in five shapes across Password and GenericKeyValue detectors (mixed-case stays reported), example-domain/noreply emails vs real domains, 555 numbers vs real-shaped ones, checksum prefixes vs plain quoted strings.

Integration (tests/fixtures/fp_corpus + tests/fp_corpus_tests.rs)

The false-positive corpus from #96 is now a permanent regression fixture scanned end to end: exactly the two documented residuals may appear, and a second test asserts the six most-noisy detector types never fire on it. Plus a wire-format round-trip test (Finding serializes as plugin_name, deserializes from both keys), a hostile-git-config test for --git-history (pins GIT_DIFF_FRAMING_ARGS coverage for log, mirroring the staged one), and a stdin-NUL scan-through test.

Tests

232 pass (was 216; +16). fmt/clippy clean.

- Verhoeff: canonical examples, separators, embedded id runs, degenerate
  inputs (the p-permutation breaks the all-zero identity chain).
- Luhn: known cards, separators, sub-13-digit rejection.
- shannon_entropy: information-theory identities, hex near-ceiling,
  multi-byte input.
- is_multiline: (?s), grouped (?s:...), combined (?is), negative flags,
  plain patterns — and a real fix the test caught: combined flags like
  (?is) missed the substring check, so such patterns were scanned
  line-by-line and silently missed multiline secrets. is_multiline now
  parses flag groups.
- Every FP allowlist entry exercised in both directions through the real
  detector set (AWS example key, placeholders, example-domain emails,
  555 numbers, checksum prefixes).
- The false-positive corpus is committed under tests/fixtures and scanned
  end to end: exactly the two documented residuals may appear.
- Finding derives Deserialize with a wire-format round-trip test: the
  historical plugin_name key and the detector_name alias both parse.
- git-history mode gets a hostile-git-config test mirroring the staged
  one (pins GIT_DIFF_FRAMING_ARGS coverage for log).
- stdin scans through NUL bytes; the secret after a NUL line is found.
@pixincreate
pixincreate merged commit 35c40c1 into master Sep 5, 2026
7 checks passed
@pixincreate
pixincreate deleted the test/exhaustive-coverage branch September 5, 2026 14:42
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