feat(detection): Phase B recall hardening — fix comment-stripping + add coverage (recall 0.42→0.86)#35
Merged
Merged
Conversation
…ategory breakdowns
…ct word-glued comment injection)
…s; normalize fullwidth separators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacks on #34 (base =
feat/attack-campaign). Fast-forward, no conflict. Retarget tomasterafter #33/#34 land.Remediates the gaps the attack-sim harness + campaign measured. Pure recall pass — false positives held flat (the SELECT-in-prose FP is deferred to a separate precision pass).
Result (harness)
What changed (each async + hand-mirrored to
guard_core/sync/, TDD with a detection test + a benign near-miss)ContentPreprocessorno longer mergesSELECT/**/FROM→SELECTFROM; preserves MySQL/*!…*/conditional comments; word-glued comment injection (SEL/**/ECT) is now a detection signal. Quote-flanked comments still strip correctly (1'/**/OR→1' OR).ORDER BYenumeration, and a'1'='1tautology pattern (also catches the pre-existing boolean-SQLi miss)."$gt","$ne", …).<%= %>and expression-bearing${…}(method call /@class@/ arithmetic).-e,/dev/tcp) patterns; fullwidth separators (;|&) normalized.proto_pollutionandcode_injection, fully registered (contexts,ALL_DETECTION_CATEGORIES,CATEGORY_CONTEXT_MAP, catalog tests incl. the sync mirror).ruff checkE501/I001.Verification
340 tests pass (incl. the catalog test + sync mirror + the attack-sim ratchet).
ruff check+ruff format --checkclean; vulture clean. Patterns are ReDoS-conscious (no nested quantifiers); async/sync handler pattern lists are byte-identical.Deferred (noted, not in this PR)
templaterecall (0.45) — encoded mutation variants of${…}/{{…}}still evade.#-bearing OGNL (${#ctx…}) is truncated by the#SQL-line-comment stripper — a preprocessor/precision issue.prose_sql_keywordsfalse positive (0.67) — the dedicated precision pass (B3).Test-only + detection-code edits; no API/route changes. Pre-existing
sync-mirror --checkCI may be red, unrelated.