Skip to content

feat(modules): add a dsl matcher over response variables - #384

Open
TBX3D wants to merge 6 commits into
vmfunc:mainfrom
TBX3D:lane/dsl-matcher
Open

feat(modules): add a dsl matcher over response variables#384
TBX3D wants to merge 6 commits into
vmfunc:mainfrom
TBX3D:lane/dsl-matcher

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

stacked on #379, so only the commits above it are this pr's.

modules can match on words, regex, status and size, but not on a relation between them, so anything like "200 and body contains x and it took under 2s" needs a new matcher type each time. this adds a dsl matcher over the nuclei expression language with a curated helper allowlist, compiled at load so bad syntax, a non-allowlisted function or an over-length expression fails before scan time rather than silently missing. host is bound to host[:port] from the parsed url, not the full url, so a nuclei-style host == "..." behaves the way someone pasting it expects.

TBX3D added 6 commits July 30, 2026 19:12
checkMatchers/checkMatcher took (resp, body), so every matcher type that
needs anything else (the request url, how long the round trip took,
extractor output) forces another signature change through the whole engine
and all of its callers.

collect the per-response state into a MatchContext built once at each of the
two call sites (single request and chain step) and thread that instead. no
matcher behavior changes: the classic types read Resp and Body exactly as
before.

extraction moves above the matcher check in executeHTTPRequest. runExtractors
is side-effect-free and the finding is only built on a match, so the order is
behavior-preserving, and it lets a matcher read extractor values from the
context. in a chain step the context carries the running variable set, so a
matcher there also sees earlier steps' values.
add the dsl matcher type with a curated helper allowlist and load-time
compile validation (bad syntax, non-allowlisted functions, empty or
over-length expressions all rejected before scan time). evaluation
lands in a follow-up; a loaded dsl matcher currently misses at match
time.
drives a live httptest server through ExecuteHTTPModule with a dsl
matcher bound to status_code and body, mirroring the existing favicon
integration test, and asserts exactly one finding.
parse the request url and expose host[:port] so a nuclei-style
host == "..." expression matches; dedupe the header serialization.
covers the bound variables, the helper allowlist and the load-time compile, so a
module author does not have to read dsl.go to know what an expression can touch.
@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 docs documentation changes tests test changes deps dependency updates 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

❌ Patch coverage is 96.63866% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@a38ba0a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
internal/modules/dsl.go 95.06% 2 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #384   +/-   ##
=======================================
  Coverage        ?   65.28%           
=======================================
  Files           ?       89           
  Lines           ?     7963           
  Branches        ?        0           
=======================================
  Hits            ?     5199           
  Misses          ?     2370           
  Partials        ?      394           

☔ 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 github-actions Bot added the size/xl 500+ lines changed label Jul 31, 2026
@github-actions

Copy link
Copy Markdown

pr summary

12 files changed (+517 -34)

category files
go source 10
tests 6
deps 1

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

Labels

deps dependency updates docs documentation changes modules changes to scan modules size/xl 500+ lines changed tests test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants