feat(detection): B3.1 graduated anomaly-scoring machinery (behavior-neutral)#36
Merged
Conversation
…ll held) (#37) * feat(detection): SELECT..FROM corroboration scoring (low weight + star/WHERE signals) * feat(detection): tighten ORDER BY / DDL / ERB / NoSQL patterns to require attack context * test(attack-sim): expand benign corpus + re-baseline after B3.2 FP reduction (fp 0.125 -> 0.0) --------- Co-authored-by: Renn F <rennf93@users.noreply.github.com>
…ontract; harden SusPatternsManager singleton isolation in reset_state
rennf93
added a commit
that referenced
this pull request
Jul 1, 2026
…-mirror repair (#38) Assembles the 3.3.0 release from the detection work merged since v3.2.0 (#33-#37) plus the ipinfo-None deprecation fix from the 3.2.1 line. - ipinfo_token/ipinfo_db_path DeprecationWarning no longer fires when the field is explicitly None (spurious warning for callers forwarding an optional setting). - Declare SusPatternsManager._threat_score_threshold and coerce _regex_anomaly to float, fixing the mypy attr-defined / no-any-return errors introduced by #36. - Exclude the async-only attack_simulation harness from unasync mirroring (its data corpus is not Python-transformable) and regenerate the previously-missing sync test mirrors; check-sync is green. - Bump version to 3.3.0 and add CHANGELOG / release-notes entries. Co-authored-by: Renn F <rennf93@users.noreply.github.com>
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.
Installs the scoring lever for false-positive reduction — in the "off" position. Behavior is identical to today; this is pure infrastructure for B3.2 (which turns ambiguous-pattern weights down to actually cut false positives).
What changed
SecurityConfig.detection_threat_score_thresholdfield (default 1.0).DETECTION_CATEGORY_WEIGHTS(every category → 1.0) + an emptyDETECTION_PATTERN_WEIGHT_OVERRIDESmap +_resolve_pattern_weight(). Each regex threat dict now carries aweight._calculate_threat_scoreis now additive (sum of matched-pattern weights, capped at 1.0) instead of a flat 1.0.is_threatis gated:anomaly >= threshold or any-semantic-threat.Why it's behavior-neutral
Every weight = 1.0 and threshold = 1.0 ⇒ any single regex match gives anomaly ≥ 1.0 ⇒
is_threat = True, exactly as before. Semantic-only threats still flag via their presence.Verification
Next (B3.2, separate)
Expand the benign corpus (the pressure test already found Phase B introduced 4 new FP vectors) + lower ambiguous-pattern weights below threshold + surgical tightening → drop fp_rate while the recall ratchet (≥ 0.857) holds.
No API/route changes.
detection_threat_score_thresholdis a new config field; the downstream guard-core-app SecurityConfig catalog will need regen when it next bumps the dependency (separate cross-repo).