Registry Mirror
Skip to content

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

github-actions Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

pr summary

10 files changed (+597 -19)

category files
go source 8
tests 4
deps 1

@codecov-commenter

codecov-commenter commented Jul 31, 2026 •

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@e9d578a). 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     #385   +/-   ##
=======================================
  Coverage        ?   68.96%           
=======================================
  Files           ?       90           
  Lines           ?     9004           
  Branches        ?        0           
=======================================
  Hits            ?     6210           
  Misses          ?     2390           
  Partials        ?      404           

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

vmfunc commented Aug 22, 2026

Copy link
Copy Markdown
Owner

delegating to GenerateVariables is the right call - won't drift on a nuclei bump. holding til #384 is in; rebase on top once it lands and this drops to just the url-part diff.


Generated by Claude Code

TBX3D added 8 commits August 22, 2026 11:54
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.
getPart read resp.Header unguarded, so evaluating a dsl matcher without a
response panicked instead of binding zero values.
@TBX3D
TBX3D force-pushed the lane/dsl-url-part-vars branch from fec9544 to b46bacb Compare August 22, 2026 20:05
Copilot AI lite review requested due to automatic review settings August 22, 2026 20:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes appear correct and well-tested; only minor documentation/metadata nits were identified.

Pull request overview

Adds Nuclei-compatible DSL matcher support by binding Nuclei URL-part/DNS variables into the matcher evaluation environment and validating DSL expressions at module load time, so pasted Nuclei DSL snippets don’t fail due to missing variables.

Changes:

  • Extend matcher schema to support type: dsl with dsl: []string expressions and execute them during matching.
  • Validate/compile DSL expressions during module load to fail fast on syntax errors or disallowed helpers.
  • Bind Nuclei URL-part + DNS variables via nucleiutils.GenerateVariables and add end-to-end/unit tests plus documentation.
File summaries
File Description
internal/modules/module.go Adds Matcher.DSL field for type: dsl matchers.
internal/modules/matchers_test.go Adds YAML parsing test coverage for DSL matcher compile-time validation.
internal/modules/favicon.go Extends shared matcher validation to include DSL non-empty + compile checks.
internal/modules/favicon_test.go Adds table-driven tests for DSL validation behavior and allowlist enforcement.
internal/modules/executor.go Wires dsl into matcher execution and factors header extraction into a nil-tolerant helper.
internal/modules/executor_test.go Adds executor-level integration tests proving DSL evaluation and URL-part var binding end-to-end.
internal/modules/dsl.go Implements DSL allowlist, compilation cache, variable binding (incl. Nuclei URL/DNS vars), and evaluation.
internal/modules/dsl_test.go Adds focused unit tests for compilation rules, variable binding semantics, and fail-closed behavior.
go.mod Promotes projectdiscovery/dsl and projectdiscovery/govaluate to direct deps due to new imports.
docs/modules.md Documents the new DSL matcher, bound variables, and helper allowlist/limits.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/modules.md
matchers:
- type: dsl
dsl:
- "status_code == 200 && contains(body, 'admin')"
Comment thread go.mod
Comment on lines 9 to 15
github.com/charmbracelet/log v1.0.0
github.com/gocolly/colly/v2 v2.3.0
github.com/likexian/whois v1.15.7
github.com/projectdiscovery/dsl v0.8.20
github.com/projectdiscovery/goflags v0.1.76
github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
github.com/projectdiscovery/nuclei/v3 v3.11.0
Comment on lines +111 to +113
// DSL holds one or more boolean expressions evaluated against the response
// (dsl matchers only). Compiled and validated at module load.
DSL []string `yaml:"dsl,omitempty"`

@vmfunc vmfunc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delegating to GenerateVariables is the right call. Two things:

  1. This PR carries #384's dsl allowlist, so it has the same issue I raised there: replace, replace_regex, hex_encode, html_escape, and url_encode let output grow beyond what the 4096-byte expression cap implies.
  2. In dslVars, mc.Extracted is copied after the GenerateVariables values. An unnamed kv extractor stores response headers under their canonical names, so a response header such as Host, Hostname, Path, Port, Query, File, Scheme, or Input can overwrite the new URL variables in modules that use one. Named kv extractors aren't affected, because of the name. prefix. Could you merge the URL variables last, or namespace the extracted values?
  • Software Builder, lamb's AI assistant

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using nuclei's utils.GenerateVariables instead of reimplementing it makes sense, and the URL-part and port-default table tests cover the important cases. A few things need fixing before merge:

  1. Merge conflict in go.mod (8 commits behind main). This is the only file that conflicts. To resolve it, take main's go.mod (goflags v0.2.0, retryabledns v1.0.116, utils v0.11.8, fastdialer v0.5.20, …). Then move github.com/projectdiscovery/dsl v0.8.20 and github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e from the // indirect block into the direct require block, or just run go mod tidy. Main's go.sum already has both modules' hashes. See the separate comment for the exact commands.
  2. Header values from extractors can overwrite URL-part variables (inline, dsl.go:133). This is the issue vmfunc already raised, and it's still in this branch.
  3. Helpers that grow their output are still allowlisted (inline, dsl.go:45/51). This comes from #384.
  4. Stacking. This branch still carries all of #384, which is unmerged. Its last commit (b46bacb) is a re-roll of #384's 28fc3b3 with roughly 100 lines of differences. Please land #384 first, or close it in favour of this PR, so the two copies don't drift apart.
  5. Nit: the PR description and the 9f992c6 commit message say "go.mod and go.sum are unchanged", but the diff promotes dsl and govaluate to direct dependencies (needed for #384's imports). Please update the description.

Written by Devin

Comment thread internal/modules/dsl.go
for k, v := range nucleiutils.GenerateVariables(mc.URL, false, nil) {
vars[k] = v
}
for k, v := range mc.Extracted {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mc.Extracted is merged after the GenerateVariables output, so an unnamed kv extractor (runExtractors stores headers under their canonical names, e.g. Host, Path, Port, Query, File, Scheme) overwrites the URL-part variable with a header value. A server it targets can then decide what Host == "..." or Path == "/admin" evaluates against. Suggested fix: keep the documented rule that a named extractor can shadow a builtin, but don't let unnamed kv header keys overwrite the URL-part set. For example, merge mc.Extracted first and then write the GenerateVariables keys only where vars[k] isn't already set by a named extractor. Or, simpler, namespace unnamed kv output. Please add a test with a response header Host: evil and an unnamed kv extractor, asserting that Host == "sub.example.com" still matches.

Comment thread internal/modules/dsl.go
"line_starts_with", "line_ends_with", "equals_any", "len", "index",
// string transforms
"to_lower", "to_upper", "trim", "trim_left", "trim_right", "trim_space",
"trim_prefix", "trim_suffix", "split", "join", "replace", "replace_regex",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(carried from #384) replace and replace_regex can make the output far longer than the 4096-byte expression cap suggests. For example, replace(body, "", body) grows quadratically with body size, and chaining calls compounds it. Consider dropping these from the allowlist or wrapping them with an output-length cap. The same applies to hex_encode, url_encode and html_escape on line 51 (each up to 2–6x per call, also compounding when chained).

Comment thread internal/modules/dsl.go
// the capitalized nuclei url-part vars, plus the dns ones. nuclei's own
// generator keeps them faithful: Host is the hostname without port while
// Hostname carries it, Path is the directory, Port defaults by scheme.
for k, v := range nucleiutils.GenerateVariables(mc.URL, false, nil) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: GenerateVariables (URL parse plus public-suffix lookup) runs again for every dsl matcher on every response because dslVars is rebuilt in each evalDSL. That's fine for now, but if a module has several dsl matchers, consider computing it once per MatchContext.

@devin-ai-integration

Copy link
Copy Markdown

How to resolve the conflict with main. I can't push to this fork branch, so here are the steps instead.

The only conflicting file is go.mod. Since the branch forked, main has bumped goflags, retryabledns, utils, blackrock, fastdialer, gologger, hmap and others. This branch promotes dsl and govaluate to direct dependencies.

git fetch upstream main            # upstream = vmfunc/sif
git checkout lane/dsl-url-part-vars
git merge upstream/main            # or: git rebase upstream/main
git checkout upstream/main -- go.mod
go mod tidy                        # promotes dsl + govaluate to direct deps
go build ./... && go test ./...
git add go.mod go.sum && git commit   # (or git rebase --continue)
git push

When it's done, git diff upstream/main -- go.mod should show only these two moves:

 	github.com/likexian/whois v1.15.7
+	github.com/projectdiscovery/dsl v0.8.20
 	github.com/projectdiscovery/goflags v0.2.0
+	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
 ...
-	github.com/projectdiscovery/dsl v0.8.20 // indirect
 ...
-	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e // indirect

Main's go.sum already contains both modules, so go.sum shouldn't change. Nothing else conflicts; the workflow changes from main merge in cleanly. Checking "Allow edits by maintainers" on this PR would let maintainers push fixes like this directly.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

Conflict update: main is now at 6cb9451, 26 commits ahead of this branch. My earlier steps still work. Pushing to the fork returns 403, so I'm posting the result here instead.

I ran git rebase origin/main on b46bacb. Only go.mod conflicts, and only in the first commit (feat(modules): validate and compile dsl matchers at load). The other 7 commits replay cleanly, and so do main's changes to executor.go, yaml.go and the new lint.go/moduletest.go.

When the conflict stops the rebase:

git checkout upstream/main -- go.mod
# move dsl + govaluate from the // indirect block to the direct block (or: go mod tidy)
git add go.mod && git rebase --continue

Afterwards, git diff upstream/main -- go.mod should show only this. isatty is a direct dependency on main now, so the context line differs from my earlier comment:

 	github.com/mattn/go-isatty v0.0.22
+	github.com/projectdiscovery/dsl v0.8.20
 	github.com/projectdiscovery/goflags v0.2.0
+	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
 ...
-	github.com/projectdiscovery/dsl v0.8.20 // indirect
 ...
-	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e // indirect

Other notes:

  • go.sum doesn't need changes, because main already has both modules. The rebased diff against main is the same 10 files, +597/−19.
  • Main now has go 1.26.0 (fix(ci): align toolchain references on go 1.26 #421), so build and test with Go 1.26.
  • The new sif modules lint (feat(modules): add lint and test subcommands #422) only pre-compiles regex matchers. dsl matchers are still checked by your load-time validation in favicon.go, so nothing more is needed for lint.
  • I couldn't run go build ./... or go test ./... here because the toolchain download was blocked. Please run both after rebasing.
  • The open review points still apply: URL-part variables can be overwritten by kv extracted headers, the allowlisted helpers can grow output, and the branch is still stacked on unmerged feat(modules): add a dsl matcher over response variables #384.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

Correction to my previous note: main is now 5ed3a4c. #433 bumped goflags to v0.2.1, so the expected go.mod diff in that note is out of date. The steps themselves still work. Pushing to the fork still returns 403.

I rebased b46bacb onto 5ed3a4c. As before, the only conflict is go.mod in the first commit, and the other 7 commits replay cleanly. When the rebase stops there:

git checkout upstream/main -- go.mod
# move dsl + govaluate from the // indirect block into the direct block
git add go.mod && git rebase --continue

Afterwards, git diff upstream/main -- go.mod should show exactly this:

 	github.com/mattn/go-isatty v0.0.22
+	github.com/projectdiscovery/dsl v0.8.20
 	github.com/projectdiscovery/goflags v0.2.1
+	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
 	github.com/projectdiscovery/nuclei/v3 v3.11.0
 ...
-	github.com/projectdiscovery/dsl v0.8.20 // indirect
 	github.com/projectdiscovery/fastdialer v0.5.20 // indirect
 ...
-	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e // indirect
  • go.sum doesn't need changes. The rebased diff against main is still 10 files, +597/−19.
  • I still couldn't run go build ./... / go test ./..., because downloading the Go toolchain was blocked in my environment. Please run both with Go 1.26 after rebasing.

Written by Devin

@devin-ai-integration

Copy link
Copy Markdown

This branch conflicts with main (5ed3a4c, 32 commits ahead of the merge base e9d578a). I can't push to the fork, so here's how to rebase.

Only go.mod conflicts, on the first commit (610d371, "validate and compile dsl matchers at load"). The other 7 commits replay cleanly, and go.sum needs no change.

git fetch upstream
git rebase upstream/main
# conflict in go.mod on 610d371
git checkout --ours go.mod   # take main's go.mod (goflags v0.2.1, utils v0.11.8, teatest, isatty, x/term, ...)

Then re-apply this PR's intent on top of main's go.mod: move projectdiscovery/dsl and projectdiscovery/govaluate from the indirect block to the direct require block, keeping their versions.

 	github.com/mattn/go-isatty v0.0.22
+	github.com/projectdiscovery/dsl v0.8.20
 	github.com/projectdiscovery/goflags v0.2.1
+	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e
 	github.com/projectdiscovery/nuclei/v3 v3.11.0
 ...
-	github.com/projectdiscovery/dsl v0.8.20 // indirect
 	github.com/projectdiscovery/fastdialer v0.5.20 // indirect
 ...
-	github.com/projectdiscovery/govaluate v0.0.0-20260615100919-5ee2581bbf7e // indirect
git add go.mod && git rebase --continue
go build ./... && go test ./...
git push --force-with-lease

After the rebase, the diff against main is the same 10 files (+597 -19). I checked the code main added since the merge base (sif modules lint/test in lint.go, the Tests field in yaml.go) and found no semantic overlap with the dsl matcher. I could not run go build/go test in my environment, so please confirm locally.

Since this is stacked on #384, rebasing #384 first gives the same go.mod resolution, and then this branch rebases onto it. #388 will need a rebase after this one. The open review feedback is unchanged: the dsl helper allowlist lets output grow past the 4096-byte expression cap, and unnamed kv extractor headers can overwrite the url-part vars in dslVars.

Written by Devin

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.

4 participants