Skip to content

fix(detection): port the verified guard-core reference fixes (passive log reason, semantic header opt-out, Cookie pair scan) - #137

Merged
rennf93 merged 4 commits into
masterfrom
fix/feedback-wave
Oct 15, 2026
Merged

rennf93 merged 4 commits into
masterfrom
fix/feedback-wave

Conversation

@rennf93

@rennf93 rennf93 commented Oct 15, 2026

Copy link
Copy Markdown
Member

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 real passive_mode to the log instead of a hardcoded false.
  • docs(config): the enable_dynamic_rules field doc lists exactly what a rule changes.
  • feat(detection): opt-in excluded_semantic_detection_headers (default empty) on SecurityConfig, RouteConfig, DetectionExclusionConfig and RouteDetectionExclusions, plus a semantic_headers argument on the detection_exclusion decorator. 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 one name=value pair 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, RouteConfig and SecurityConfig gain a public field, and SecurityDecorator::detection_exclusion gains 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.

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.
@github-actions github-actions Bot added area: engine Touches crates/guard-core-engine/ (compiler, preprocessor, semantic, detect, patterns) area: facade Touches crates/guard-core-rs/ (published facade crate) area: conformance Touches the spec 4.0.2 corpus, ledger, or xfail baseline labels Oct 15, 2026
@rennf93
rennf93 merged commit bb9c2df into master Oct 15, 2026
23 of 28 checks passed
@rennf93
rennf93 deleted the fix/feedback-wave branch October 15, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: conformance Touches the spec 4.0.2 corpus, ledger, or xfail baseline area: engine Touches crates/guard-core-engine/ (compiler, preprocessor, semantic, detect, patterns) area: facade Touches crates/guard-core-rs/ (published facade crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port the verified guard-core reference fixes: passive log reason, dynamic-rules docs, semantic header opt-out, Cookie pair scan

1 participant