fix(fingerprinthub): preserve original body case for DSL/regex matchers#14
Open
wuchulonly wants to merge 1 commit into
Open
fix(fingerprinthub): preserve original body case for DSL/regex matchers#14wuchulonly wants to merge 1 commit into
wuchulonly wants to merge 1 commit into
Conversation
WebMatch was lowercasing the entire body before passing it to the InternalEvent, which broke case-sensitive DSL expressions like contains(body, "<title>Nacos"). Word matchers already handle case-insensitivity internally (MatchWords lowercases both corpus and keywords), so the ToLower at the WebMatch level was redundant for them but destructive for DSL and regex matchers. Now the AC keyword index receives the lowercased body for prefiltering, while the InternalEvent (used by matchRequest → DSL/regex evaluation) receives the original-case body. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Problem
WebMatchlowercases the entire HTTP body before passing it to theInternalEventused by matchers. This breaks DSL matchers and regex matchers that use case-sensitive patterns.For example, a template with:
...will never match because the body in the event is already lowercased to
<title>nacos.This affects all fingerprinthub templates using DSL
contains()with mixed-case literals, or regex patterns with case-sensitive anchors.Root Cause
Line 381 in
fingerprinthub.go:The lowercased body is then passed to
buildInternalEvent, which setsevent["body"] = bodyStr. WhenmatchRequestcallsreq.Match(event, matcher), DSL expressions evaluatecontains(body, ...)against the already-lowercased body.Word matchers are unaffected because
MatchWordsalready lowercases both the corpus and keywords internally (matcher.go:144, 185).Fix
webTemplateIndex.Match)buildInternalEventso DSL/regex matchers see the real contentTesting
TestWebMatch_DSLCaseSensitivity— constructs a DSL template with mixed-case literals and verifies it matchesTestWebMatchConsistency_StaticandTestTemplateKeywordIndex_*tests pass unchanged