Skip to content

feat(modules): bind nuclei url-part vars in dsl matchers - #385

Open
TBX3D wants to merge 8 commits into
vmfunc:mainfrom
TBX3D:lane/dsl-url-part-vars
Open

feat(modules): bind nuclei url-part vars in dsl matchers#385
TBX3D wants to merge 8 commits into
vmfunc:mainfrom
TBX3D:lane/dsl-url-part-vars

Conversation

@TBX3D

@TBX3D TBX3D commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

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

a pasted nuclei expression referencing baseurl or rooturl or tld hits an undefined variable, which is now a load-time failure rather than a silent miss, so this binds the capitalized url-part set and the dns vars alongside the response ones. it delegates to nuclei's own utils.GenerateVariables rather than reimplementing them, because the semantics are deliberately counterintuitive, host is the hostname without port while hostname carries it, path is the directory, port defaults by scheme, and a hand copy would drift on every nuclei bump. nuclei is already a direct dependency, so go.mod and go.sum are unchanged.

TBX3D added 8 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.
expose the capitalized url-part variables (baseurl, rooturl, hostname,
host, port, path, query, file, scheme) and the dns vars (fqdn, rdn, dn,
tld, sd) to dsl matchers so a pasted nuclei expression referencing them
behaves as a nuclei user expects.

delegate to nuclei's own utils.GenerateVariables rather than
reimplementing: its semantics are deliberately counterintuitive (host is
the hostname without port while hostname carries it, path is the
directory, port defaults by scheme) and a hand copy would drift on every
nuclei bump. nuclei is already a direct dependency so go.mod and go.sum
are unchanged.
@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 size/xl 500+ lines changed labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown

pr summary

12 files changed (+618 -34)

category files
go source 10
tests 6
deps 1

@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.69421% 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.18% 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     #385   +/-   ##
=======================================
  Coverage        ?   65.32%           
=======================================
  Files           ?       89           
  Lines           ?     7965           
  Branches        ?        0           
=======================================
  Hits            ?     5203           
  Misses          ?     2369           
  Partials        ?      393           

☔ 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.

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