feat(modules): bind nuclei url-part vars in dsl matchers - #385
Open
TBX3D wants to merge 8 commits into
Open
Conversation
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.
pr summary12 files changed (+618 -34)
|
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
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.
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.