Skip to content

test(detectors): add unit tests for knownbadsignatures module#1956

Open
NickNojiri wants to merge 1 commit into
NVIDIA:mainfrom
NickNojiri:test/knownbadsignatures-detector-coverage
Open

test(detectors): add unit tests for knownbadsignatures module#1956
NickNojiri wants to merge 1 commit into
NVIDIA:mainfrom
NickNojiri:test/knownbadsignatures-detector-coverage

Conversation

@NickNojiri

Copy link
Copy Markdown

PR title (paste exactly — no issue numbers in titles, per repo guidelines)
test(detectors): add unit tests for knownbadsignatures module

PR description (paste below)
What this PR does
Adds detector-unique unit tests for garak/detectors/knownbadsignatures.py (EICAR / GTUBE / GTphish), which previously had no coverage beyond the generic plugin-load checks. Follows the structure of the recently merged snowball detector tests (#1824).

Covered behaviour (parametrized across all three detector classes):

hit (1.0) on the exact signature, on the signature embedded in surrounding text, and on a lowercased signature (StringDetector defaults to case_sensitive=False)
no hit (0.0) on refusals, truncated signatures, and empty output
None output yields None (inconclusive), matching detector conventions
mixed multi-output attempts score per-output
distinctness: no detector fires on another probe's signature, which matters because the GTUBE and GTphish signatures share a common prefix
Not a duplicate
Checked open PRs and issues on 2026-07-13 per the repo's contribution guidance: #1853 covers the any/goodside/leakreplay/lmrc/visual_jailbreak detector modules and #1863 covers dan — neither touches knownbadsignatures, and no open issue or PR requests tests for it.

Tests run
python -m pytest tests/detectors/test_detectors_knownbadsignatures.py -v
28 passed in 0.16s
Formatted with black 25.1.0 (repo pre-commit rev). Developed and run on Windows 11 / Python 3.13.

AI assistance disclosure
This PR was developed with AI assistance (Claude Code). I have reviewed every line, run the tests locally, and can explain and defend the change. Commit is signed off (DCO).

The EICAR / GTUBE / GTphish detectors had no detector-unique unit tests.
Add parametrized coverage for the shared StringDetector behaviour (hit on
exact, embedded, and lowercased signatures; no hit on refusals, truncated
signatures, or empty output; None output yields None) plus distinctness
checks so no detector fires on another probe signature, despite GTUBE and
GTphish sharing a common prefix.

Signed-off-by: NickNojiri <nickthe20@gmail.com>
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