Skip to content

fix(modules): reject empty word and regex matchers at load - #382

Open
TBX3D wants to merge 1 commit into
vmfunc:mainfrom
TBX3D:lane/matcher-validation
Open

fix(modules): reject empty word and regex matchers at load#382
TBX3D wants to merge 1 commit into
vmfunc:mainfrom
TBX3D:lane/matcher-validation

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

a word matcher with no words evaluates to true under the default AND condition, so it matches every response instead of never matching, and a regex matcher with no patterns does the same. the ways to hit it are all yaml typos: word: instead of words:, a forgotten list, indentation nulling it out, and words: [""] gets there too through strings.Contains(x, "") always being true. rejected in validateMatchers, which http, dns and tcp configs all route through.

a word matcher with no words (or a regex matcher with no patterns)
evaluates to true under the default AND condition, so it silently
matches every response instead of never matching. this is easy to hit
via a yaml typo: word: instead of words:, a forgotten words: list, or
bad indentation nulling the list. a words: [""] list hits the same bug
through strings.Contains(x, ""), which is always true.

reject both cases in validateMatchers, the shared load-time check
http, dns, and tcp module configs all route through, so the guard
applies to every transport that accepts word/regex matchers.
@TBX3D
TBX3D requested a review from vmfunc as a code owner July 31, 2026 02:30
@github-actions github-actions Bot added modules changes to scan modules tests test changes size/s <50 lines changed labels Jul 31, 2026
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@a38ba0a). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #382   +/-   ##
=======================================
  Coverage        ?   64.96%           
=======================================
  Files           ?       88           
  Lines           ?     7867           
  Branches        ?        0           
=======================================
  Hits            ?     5111           
  Misses          ?     2365           
  Partials        ?      391           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

pr summary

2 files changed (+31 -2)

category files
go source 2
tests 1

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

Labels

modules changes to scan modules size/s <50 lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants