Skip to content

security/leaked-secrets: keyword prefilter, bounded look-behind and near-miss cases in the test suite #363

Closed

Description

@nc9

Three test-suite habits from trufflehog's detector tests, to land with or before the pattern work:

  1. Prefilter assertion: once a keyword prefilter (Aho-Corasick or a single alternation) gates which patterns run, every positive case in the corpus harness must also assert that the prefilter selects that pattern for the input. A pattern whose keyword is not in its own positives is a test failure.
  2. Bounded look-behind for CONTEXT patterns: replace the ±500-char window with keyword → at most 40 chars → word-bounded value, matching trufflehog's PrefixRegex helper. Assert both directions: keyword 30 chars before the value fires, keyword 60 chars before does not, keyword after the value does not.
  3. Near-miss negatives: for every pattern, one case with a single corrupted character, one with the prefix mid-token (fooghp_…), and one duplicate value that must collapse to one finding. Generated mechanically from the generator, not hand-written.

Acceptance Criteria

  • A meta-test fails if any pattern in FAST_PATTERNS or CONTEXT_PATTERNS lacks a positive, a near-miss negative and a prefilter assertion in the corpus
  • CONTEXT patterns use a bounded look-behind; the three-direction assertions pass for every context pattern
  • expected.json snapshot updated and the README gap list shrinks accordingly

Activity

  1. added
    enhancement
    on Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions