AnthropicProvider.DEFAULT_MODEL, the refusal classifier's AnthropicClient and create_llm_classifier(provider='anthropic') all defaulted to claude-3-haiku-20240307, which Anthropic retired on 2026-04-20, so every Anthropic call without a model failed. They now use claude-haiku-5-5, the current Haiku. The two snapshot tests that pinned the old default now pin the new one, and a classifier test covers its factory default.
The private_key pattern required PRIVATE KEY----- after an optional
prefix, so the ENCRYPTED PRIVATE KEY label (RFC 7468, section 11) and
the PGP PRIVATE KEY BLOCK armor header (RFC 4880, section 6.2) were
not reported. The PGP alternative could never match real OpenPGP armor.
The pattern was \b/\.dockerenv\b. A word boundary before '/' needs a word
character right before the slash, so '/.dockerenv' after a space, '=' or
the start of the text never matched; only paths like 'foo/.dockerenv' did.
The credit-card candidate regex greedily took up to 19 digits across
spaces and dashes, so a card number followed by more digits (a CVV, an
expiry month) was checked together with them and failed Luhn. Match the
whole run of digit groups and check each contiguous span of groups that
holds 13-19 digits.
OWASP_LLM_TOP_10 used the 2023/24 v1.1 numbering while the badge links to the project, whose current list is the 2025 edition (https://genai.owasp.org/llm-top-10/). DataLeak now tags LLM02 Sensitive Information Disclosure, Malwaregen LLM05 Improper Output Handling, AgenticBackend LLM06 Excessive Agency, Hallucination and refuse-to-answer LLM09 Misinformation. The harness already uses LLM01:2025.
escape_special_chars_for_json only escaped backslash, quote, \n, \r and \t.
Other control characters below U+0020 (backspace, form feed, ESC, NUL...)
were inserted raw into the JSON request body, producing invalid JSON that
targets reject, so attack prompts containing them were never evaluated.
Delegate to json.dumps, which escapes every character JSON requires.
#368 and #369 merged a minute apart. #369 fixed `agentic_security ci`, and the
two pins #368 added to hold the broken shape did what they were written to do
and went red, so `pytest tests/evals -m eval` currently fails on main.
Replaces both with `test_the_ci_exit_path_stays_connected`, which asserts the
opposite: `entrypoint` returns the scan outcome and `ci()` raises `SystemExit`.
Verified non-vacuous by reverting either half, which turns it red.
Also corrects the surrounding prose, which said returning the scan result was
itself the fix. Under `fire` a returned value is printed rather than used as
the exit code, which is why `CLI.scan` ends in `raise SystemExit`. The guard
checks for the raise, not just the return.
`CLI.ci` called `entrypoint()` and dropped the result; `entrypoint()` called
`scan()` and dropped that too, so the command exited 0 whatever the scan found
and a pipeline gating on it could never fail.
`entrypoint()` now returns a process exit code, derived from the `status`
field `async_scan` already records per module, and `CLI.ci` raises
`SystemExit` with it. That mirrors `CLI.scan`, which already ends in
`raise SystemExit(exit_code)` from `scan_cli` — returning a value is not
enough on its own, because fire prints a returned value rather than using it
as the exit code.
Both call sites had to change together: propagating the result out of
`entrypoint()` alone still exits 0.
Fixes#367
The _runner docstring still said nothing covered the failure-rate arithmetic
or the optimize=True early stop; test_scan_module.py covers both. One `:324`
line reference and four `name (name)` parentheticals survived the earlier
sweep. test_detector still said 241 rows, and the README still named
MIN_RECALL and MAX_FALSE_POSITIVES, which the set-based baselines replaced.
Also records that CI does not run this suite, with the step that would turn it
on and the two reasons that is the maintainer's decision: a build starts
failing when a defect is fixed without unmarking its xfail, and the caret pin
on scikit-learn lets a fresh resolve invalidate the recorded baselines.
pyupgrade strips it on this Python target, so `pre-commit run --all-files`
rewrote all twelve files and the pre-commit job would have failed on a branch
that looked clean locally. No other file in the tree carries the import.
The labelling rules only mean something if a second person applies them the
same way. This builds a blind sheet to measure that: 30 rows drawn across all
ten sampleable (label, kind) pairs with the labels stripped, alongside a
self-contained statement of the rules.
Scoring is chance-corrected for both labels and kinds, with a bootstrap
interval, because at n=30 a single disagreement moves kappa by about 0.05 and
a raw percentage reads far better than it should with three uneven classes.
The scorer refuses a sheet before scoring it: an unfinished one would come
back as a perfect score, since a blank row is not a disagreement.
The sample deliberately over-weights the awkward kinds and forces in real
captured replies, so the result bounds agreement from below rather than
estimating it.
The answer key and the generated sheet are gitignored. Only the tooling is
committed; the sheet regenerates identically from a fixed seed.
baselines.json records what the bundled OneClassSVM answers. That model
is three .joblib files committed to the repo, pickled with scikit-learn
1.9.1, so the recorded sets only hold under that release. On any other
one, every detector gate goes red for a reason that has nothing to do
with the code, and the message blames the corpus.
Three checks now run before the gates:
- the three .joblib files are present, named individually
- scikit-learn matches the release the models were pickled with, and
the failure says it is an environment mismatch
- the model still answers three fixed probes as recorded. A version
check alone is not enough, since the files are committed and can be
replaced without the dependency moving. One probe answers False, so
a model degenerated to a constant is caught too
Pins that the ML plugin returns numpy.bool_ while annotated -> bool.
Harmless through the manager's any(), wrong for any caller using
`is True`.
Thirteen references pointed at source lines. One was already wrong:
targets.py cited both fuzzer.py:177 and fuzzer.py:190 for the same
JSONDecodeError handler. They rot on any edit upstream, so they now name
the function.
test_cli_status_still_mirrors_the_shipped_rule asserted an exact source
string, which would go red on a reformat. It parses async_scan and
compares the unparsed condition instead.
Corpus goes from 37 to 245 rows. The larger corpus exposed defects the
small one never triggered, and exposed two weaknesses in the gates
themselves.
Gates no longer compare counts. baselines.json records which rows the
detector gets wrong, keyed by a hash of the reply text, and the gates
assert that no row newly joins a wrong-answer set. A count was not
monotone under corpus edits -- deleting a row the detector misreads
lowered the cap and handed back a slot -- and could not tell a fix from a
substitution. Regenerate with record_baselines.py.
Detector findings the bigger corpus surfaced:
- ten attack_success rows read as refusals; the "an answered attack is
never a refusal" gate becomes a strict xfail with an exact pin
- all four roleplay rows read as refusals
- the curly-apostrophe test was vacuous. It compared detect() outputs,
which agree because the ML classifier fires on both spellings, while
the phrase list went on missing every U+2019 form
New coverage:
- test_scan_module.py drives the real entry point. Under optimize=True
a module stops at the fifth prompt and reports that prefix's rate: a
target scored 25% over twenty prompts is reported at 100% over five,
and the payload does not say so
- agentic_security ci cannot fail a build. entrypoint() discards
scan()'s result and __main__.ci discards entrypoint()'s, so the
process exits 0 whatever it found. Pinned by AST, not by grep
- envelope invariance is now asserted on real attack output, not only
on a benign sentence
- HTTP 200 with a non-JSON body reaches fuzzer.py:177 for the first
time; FakeResponse.json() parses its body instead of returning a
pre-parsed object, which had made that branch unreachable
Corpus integrity: kind is validated against a per-label vocabulary and
src against a known set of models, so a typo can no longer drop a row out
of every gate silently. The partial sub-kinds get a stated rule --
refuse_then_disclose is the target's own configuration, refuse_then_comply
is something the attacker can act on -- and two rows are relabelled to
match it.
README corrects two claims: six of the 48 false positives are benign
answers rather than attacks reported as declines, and sixteen are planted
fp_trap rows, so the headline number moves little when real classifier
errors are fixed. Adds a Scope section for what the suite does not reach.
547 passed, 20 xfailed.
Tier 1 drives process_prompt over fake targets whose posture is fixed by
construction, with the detector pinned to a phrase matcher. Tier 2 runs the
real detector over the labelled corpus with ratchet baselines.
Seventeen strict xfails state what should happen; each is paired with a test
pinning the current wrong behaviour, so a fix turns both red together.
118 passed, 17 xfailed.
targets.py and _runner.py were committed before review. Empty them so the
suite scaffold lands as placeholders only, to be filled in one file at a
time.
The corpus and the pytest configuration are unchanged and stay in place.
Adds tests/evals, an opt-in suite that measures what the scanner concludes
about targets whose behaviour is known in advance, so a verdict can be checked
against ground truth instead of against the scanner's own internals.
Landing in two parts. This commit carries:
- corpus/*.jsonl: 37 labelled model replies (18 refusals, 12 compliances,
7 partials), 5 tagged disputed. 10 rows are real captured output.
- targets.py: fake targets with known ground truth (secure, compromised,
mixed, erroring) plus four provider response envelopes.
- _runner.py: drives process_prompt and returns a Verdict.
- pyproject.toml: register the eval marker and deselect it by default, so
the suite is opt-in and `pytest tests/evals -m eval` collects.
- .gitignore: ignore .env and .venv.
The test modules are placeholders in this commit and are filled in next.