Repository navigation
fix(detection): port the verified guard-core reference fixes (passive log reason, semantic header opt-out, Cookie pair scan) - #137
Merged
Conversation
A passive-mode suspicious line without trigger info (a rate-limit hit) now reads '[PASSIVE MODE] Suspicious activity detected ... - Reason: ...' instead of dropping the reason under a 'Penetration attempt' label, and the rate-limit stage passes its passive_mode to the log.
The field doc now names the bans, unbans, patterns and the replaced settings, mirroring the reference docs, and says a rule changes nothing else.
Add excluded_semantic_detection_headers (global, route and the detection_exclusion decorator): header names whose values skip the semantic analyzer only, matched case-insensitively after trimming and merged between the global and route sets. Regex category scanning of those headers is unchanged. Default empty.
As one value, the semicolons between cookies counted as command separators in the semantic score, so an ordinary logged-in header (a JWT session cookie plus theme and _ga) reached 0.711 against the 0.7 threshold. Each pair now takes the normal header path and counts against the value budget. Empty pairs are skipped and only spaces around a pair are trimmed, so a CR or LF stays in the scanned value. Ports guard-core #162.
This was referenced Oct 15, 2026
Merged
Merged
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.
Closes #136
Four commits, one per point, each ported from the merged Python reference (Guard-Core/guard-core #162 and #165, and the semantic header exclusion) and cross-checked against the Go port.
fix(logging): a passive-mode suspicious line without trigger info now reads[PASSIVE MODE] Suspicious activity detected from ... - Reason: ... - Headers: ..., and the rate-limit stage passes its realpassive_modeto the log instead of a hardcodedfalse.docs(config): theenable_dynamic_rulesfield doc lists exactly what a rule changes.feat(detection): opt-inexcluded_semantic_detection_headers(default empty) onSecurityConfig,RouteConfig,DetectionExclusionConfigandRouteDetectionExclusions, plus asemantic_headersargument on thedetection_exclusiondecorator. Listed headers skip only the semantic analyzer (detect_with_semantic_skip), the regex scan is unchanged, names are trimmed and matched case-insensitively, and the route set merges with the global set.fix(detection): the Cookie header is scanned onename=valuepair at a time. Pairs split on;, only spaces are trimmed so CR/LF stay in the value, empty pairs are skipped, each pair counts against the value budget, and the semantic opt-out applies per pair.ResolvedExclusions,DetectionExclusionConfig,RouteDetectionExclusions,RouteConfigandSecurityConfiggain a public field, andSecurityDecorator::detection_exclusiongains a trailing argument, so struct literals and callers of those need updating on the next release.The conformance gates are unchanged and green. The corpus is untouched.