Skip to content

Fix case-insensitive word matcher missing dynamic (rendered) values#7523

Open
Synvoya wants to merge 1 commit into
projectdiscovery:devfrom
Synvoya:fix/case-insensitive-dynamic-word
Open

Fix case-insensitive word matcher missing dynamic (rendered) values#7523
Synvoya wants to merge 1 commit into
projectdiscovery:devfrom
Synvoya:fix/case-insensitive-dynamic-word

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 3, 2026

Copy link
Copy Markdown

Description

A word matcher with case-insensitive: true fails to match when a template word (e.g. {{host}}, or a value chained from a prior extractor) resolves to a value containing uppercase letters.

MatchWords lowercases the corpus, and compile lowercases the literal words, but the rendered dynamic word is never lowercased. So strings.Contains(lowercasedCorpus, "Example.COM") never matches — a missed detection / false negative for any case-insensitive word matcher backed by a dynamic value (extractor output, response headers like Server:/Set-Cookie:, tokens, etc.).

Fix

Lowercase the rendered word when CaseInsensitive is set. The literal-word path is unchanged (already folded to lowercase at compile time).

} else {
    word = result.Text
    if matcher.CaseInsensitive {
        word = strings.ToLower(word)
    }
}

Test

Added TestMatchWords_CaseInsensitive_DynamicValue in pkg/operators/matchers/match_test.go. go test ./pkg/operators/matchers/ passes (new test + existing).

Summary by CodeRabbit

  • Bug Fixes

    • Improved case-insensitive word matching so dynamic values are compared using consistent lowercase text, making matches more reliable.
    • Fixed an issue where matched values could retain mixed casing; results are now normalized when case-insensitive matching is enabled.
  • Tests

    • Added coverage for case-insensitive matching with dynamic values to verify both successful matching and lowercase normalization.

MatchWords lowercased the corpus and literal words but not the rendered template word, so a case-insensitive word matcher backed by a {{var}} that resolved to an uppercase value never matched (false negative). Lowercase the rendered word when CaseInsensitive is set.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8983f8d-669f-4e2f-b138-70cf3ce52cde

📥 Commits

Reviewing files that changed from the base of the PR and between e4a83ad and c933be6.

📒 Files selected for processing (2)
  • pkg/operators/matchers/match.go
  • pkg/operators/matchers/match_test.go

Walkthrough

Modified MatchWords in the matchers package to lowercase the rendered word value when CaseInsensitive is enabled before performing the containment check against the corpus. Added a corresponding test verifying case-insensitive matching with a dynamic placeholder value.

Changes

Case-Insensitive Word Matching Fix

Layer / File(s) Summary
Lowercase rendered word on case-insensitive match
pkg/operators/matchers/match.go
Rendered word is lowercased before strings.Contains check when CaseInsensitive is true.
Test for dynamic value case-insensitivity
pkg/operators/matchers/match_test.go
New test validates that a {{host}} placeholder matches mixed-case corpus and returns a lowercased matched word.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Poem

A word once rendered, mixed in case,
Now smooths to lowercase, finds its place,
"Example.COM" no longer strays,
Matched clean in lowercase ways,
Hop, hop, tests pass — a rabbit's grace! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: case-insensitive word matching now handles rendered dynamic values.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant