Conversation
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #386 +/- ##
=======================================
Coverage ? 69.15%
=======================================
Files ? 90
Lines ? 9121
Branches ? 0
=======================================
Hits ? 6308
Misses ? 2400
Partials ? 413 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
pr summary16 files changed (+1158 -89)
|
|
the streaming rewrite is the right move - dropping the product-sized channel especially. it sits on #384 and collides with the ssl branch on the same executor refactor. once #384 lands, rebase and i'll take this + #387 as a pair. Generated by Claude Code |
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.
overload the payloads field with a custom unmarshaler: a yaml sequence is the
legacy single set named "payload", a mapping is ordered named sets injectable
at {{name}}. generation moves to a lazy iter.Seq that never materializes the
product, and substitution now reaches header values. file-backed sets parse but
are rejected until the loader lands.
a named set whose yaml value is a scalar string is a local wordlist path, loaded via the existing loadWordlist at resolve time. resolveSets is the single point set resolution can fail.
per fuzzing-module-per-target request cap, default 25000, 0 = unlimited. threaded into modules.Options; enforced by the executor in a follow-up.
ExecuteHTTPModule consumes streamRequests directly instead of materializing the full product and sizing the results channel to it. a fixed worker pool pulls from an unbuffered feed, a single collector owns the findings slice (dropping the mutex), and the producer enforces -fuzz-max-requests with a one-shot truncation log.
the existing cancel test only ever passes an already-cancelled context, so the producer returns at its up-front ctx.Err() check and never reaches the send-select guarding reqCh. add a regression test that cancels while a large payload set is mid-flight against a blocking server, so the producer's and workers' send-selects both get exercised, and assert ExecuteHTTPModule still returns promptly with no goroutine leak.
substitute header values on the no-payload path too, matching the payload and chain paths; warn when a resolved payload set is empty so a misconfigured wordlist is not mistaken for a clean no-findings run. harden the mid-stream cancel test to poll for goroutine drain instead of a fixed sleep.
the payloads field grew two shapes (named sets, file-backed sets) and a scan-wide cap; none of that was discoverable without reading yaml.go.
the yaml shape rejections and the clusterbomb empty-set short-circuit were unexercised; removing either left the suite green.
8c43e96 to
43ba2b2
Compare
There was a problem hiding this comment.
🟡 Changes recommended
There are a few correctness/performance/documentation issues in the changed code (notably payload set name validation and per-request header allocations) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR enhances the HTTP modules system by expanding fuzzing payload support beyond a single anonymous list and by switching request generation/execution to a streaming model to avoid materializing large cross-products in memory. It also adds a DSL-based matcher (nuclei-style) with helper allowlisting and load-time compilation/validation, plus a per-module per-target request budget flag.
Changes:
- Add ordered, named payload sets (mapping form) with support for file-backed sets, while preserving legacy sequence payload behavior.
- Stream fuzz request generation via
iter.Seqinto a fixed worker pool, with-fuzz-max-requeststo cap per-module request volume. - Add
dslmatcher type with load-time compilation/validation, curated helper allowlist, and tests/docs.
File summaries
| File | Description |
|---|---|
| sif.go | Plumbs FuzzMaxRequests from app settings into module execution options. |
| internal/config/config.go | Adds -fuzz-max-requests flag and persists setting. |
| internal/modules/yaml.go | Changes payloads schema to PayloadSets with custom YAML unmarshalling + validation. |
| internal/modules/module.go | Extends module Options and adds Matcher.DSL field. |
| internal/modules/executor.go | Implements streaming request generation, request budget enforcement, and DSL matcher evaluation hook. |
| internal/modules/dsl.go | Adds DSL compilation cache, helper allowlist, variable binding, and evaluation logic. |
| internal/modules/favicon.go | Validates DSL matchers at load time alongside existing matcher validation. |
| internal/modules/matchers_test.go | Updates HTTP request generation tests for legacy payload compatibility and adds DSL parse test. |
| internal/modules/executor_test.go | Adds end-to-end DSL matcher execution test and updates payload expansion tests. |
| internal/modules/attack_modes_test.go | Updates attack mode tests to use legacy payload wrapper. |
| internal/modules/favicon_test.go | Adds DSL validation test cases. |
| internal/modules/dsl_test.go | Adds focused unit tests for DSL compile/eval semantics and variable binding. |
| internal/modules/fuzz_test.go | Adds payload-set parsing/ordering/file-resolution tests and executor streaming/budget/cancel regression tests. |
| go.mod | Promotes projectdiscovery/dsl and projectdiscovery/govaluate to direct deps. |
| docs/usage.md | Documents -fuzz-max-requests usage. |
| docs/modules.md | Documents named payload sets and the new DSL matcher. |
Review details
- Files reviewed: 16/16 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.
| switch s.Name { | ||
| case "BaseURL", "baseurl": | ||
| return fmt.Errorf("payloads: set name %q collides with the base-url builtin", s.Name) | ||
| } |
| // both keys are inline here (not file-backed): a file-backed entry is | ||
| // rejected by validate() in this task (see TestPayloadSetsValidation), so | ||
| // mixing one in would make this parse fail rather than exercise ordering. |
| headers := cfg.Headers | ||
| if len(cfg.Headers) > 0 { | ||
| headers = make(map[string]string, len(cfg.Headers)) | ||
| for k, v := range cfg.Headers { | ||
| headers[k] = sub(v) | ||
| } | ||
| } |
vmfunc
left a comment
There was a problem hiding this comment.
Really like the streaming rewrite, dropping the product-sized channel is a big win. A few things for the rebase onto #384:
- This branch carries an older copy of #384 (no
headersOfnil-safety, missing two dsl tests), so please rebase on main once #384 is merged. PayloadSets.validate(yaml.go:134): please also reject an empty set name andPayload(it can't be referenced, since{{Payload}}is the legacy builtin).- The scalar branch (yaml.go:110) accepts any scalar as a file path. Restricting it to a non-empty
!!strwould makeuser: 123/user: ""fail at parse time. newFuzzRequestcopies headers per request even when no header has a{{…}}. Could it copy only when substitution applies, as the comment says?- Minor: the stale fuzz_test.go comment about file-backed sets being rejected, and a note in the PR description that cancelled runs now return a nil error.
- Software Builder, lamb's AI assistant
There was a problem hiding this comment.
Review of the payload-set / streaming part of this PR (commits 4f55124..43ba2b2). The producer → fixed worker pool → single collector design looks right: no goroutine leaks on cancel, the budget warning only fires when a (budget+1)th combination actually exists, and the cancellation test is a good addition. CI is green on the current head.
Not mergeable yet:
- Stale base. This branch still has an older copy of #384 (
610d371,17c1703,6f3b2a4,c042230,2e16c1e). It's missing #384's later28fc3b3("tolerate a matcher with no response"). The only textual conflict withmainisgo.mod, inside610d371: main bumped goflags, utils, retryabledns, fastdialer and others, while #384 promotesprojectdiscovery/dslandgovaluateto direct deps. I checked locally that the 8 commits that belong to this PR rebase onto currentmainwith no conflicts. So once #384 lands:If you rebase before #384 merges, takegit fetch upstream git rebase --onto upstream/main 2e16c1e lane/fuzz-payload-sets # drops the stale #384 copy go mod tidy && go build ./... && go test ./... # main now builds with go 1.26 git push --force-with-lease
main'sgo.mod/go.sumand rungo mod tidyto resolve the conflict. I didn't push a rebase here because that would publish the stale #384 copy, which goes against the merge order @vmfunc asked for. - @vmfunc's 2026-10-08 points are still open on this head: reject
""andPayloadas set names, restrict the scalar branch to a non-empty!!str, copy headers only when a{{…}}is present, fix the stalefuzz_test.go:54-56comment, and note in the description that cancelled runs now returnnilinstead ofctx.Err().
New findings (inline):
substituteVariablesWithVarsranges over a map and callsReplaceAllonce per name. If one set's value contains another set's{{name}}, the request you get depends on map iteration order. Also, becausepayloadis now invarstoo, a legacy value that literally contains{{payload}}gets substituted twice, which the oldnewPayloadRequestdidn't do. A single-passstrings.NewReplacerfixes both and should allocate less per request.- Set names aren't restricted to a safe character set. Keys like
a b,x}}or a non-scalar key are accepted, and you can't reference them cleanly. Validating against an identifier pattern would also cover the empty-name case. -fuzz-max-requestsalso caps plainpaths/wordlistmodules that have no payload sets. A converted dirlist module with a >25k-line wordlist now gets silently cut off by default. Either scope the budget to modules with sets, or say clearly in the docs that it applies to every non-chain HTTP module.- Small:
resolveSetsre-reads file-backed sets once per target, andgenerateHTTPRequestsis now only used by tests.
Merge check: not merged. There's no human approval on the latest commit, the PR conflicts with main, and it depends on #384.
| // substitution could apply, preserving the shared cfg.Headers map otherwise. | ||
| func newFuzzRequest(method, target, path string, vars map[string]string, cfg *HTTPConfig) *httpRequest { | ||
| pv := vars["payload"] // drives {{payload}}/{{Payload}}; "" when no such set | ||
| sub := func(s string) string { return substituteVariablesWithVars(s, target, pv, vars) } |
There was a problem hiding this comment.
substituteVariablesWithVars ranges over vars, which is a map, and runs one ReplaceAll per name. That makes multi-set substitution order-dependent. Example: template /{{a}}/{{b}} with a = {{b}} comes out as either /B/B or /{{b}}/B, depending on iteration order. Separately, substituteVariables already replaced {{payload}}, and then the loop replaces it again because payload is also a key in vars. So a legacy payload value that literally contains {{payload}} now gets expanded twice; the old newPayloadRequest didn't do that.
Suggestion: build one strings.NewReplacer per combination with {{BaseURL}}, {{baseurl}}, {{payload}}, {{Payload}} and every {{name}} (it's single-pass and never rescans replaced text), and use it for the URL, body and headers. That also lets you skip copying headers when none of them contains {{.
| case yaml.MappingNode: | ||
| sets := make([]PayloadSet, 0, len(value.Content)/2) | ||
| for i := 0; i+1 < len(value.Content); i += 2 { | ||
| name := value.Content[i].Value |
There was a problem hiding this comment.
On top of rejecting "" and Payload: the key node's Kind/Tag isn't checked, so a non-scalar key (? [a]: [...]) quietly becomes name "". Names like a b or x}} are also accepted even though you can't use them cleanly as {{name}}. I'd check value.Content[i].Kind == yaml.ScalarNode and validate the name against an identifier pattern such as ^[A-Za-z_][A-Za-z0-9_]*$ in validate(). That covers the empty-name case too, and the error shows up at load time.
| go func() { | ||
| defer close(reqCh) | ||
| var sent int | ||
| budget := opts.FuzzMaxRequests |
There was a problem hiding this comment.
opts.FuzzMaxRequests also applies when len(sets) == 0, i.e. plain paths + wordlist modules. With the 25000 default, a dirlist-style module with a large wordlist now gets truncated silently, apart from one warning line. The docs call this a "fuzzing module" budget aimed at combinatorial blowups. Please either apply it only when payload sets exist, or document that it caps every non-chain HTTP module, and add a test for whichever you choose.
| out[i] = s | ||
| continue | ||
| } | ||
| vals, err := loadWordlist(s.File) |
There was a problem hiding this comment.
Minor: ExecuteHTTPModule runs once per target, so a file-backed set gets re-read from disk for every target. Not a problem for small lists, but resolving once at load time, or caching by path, would avoid repeated I/O on big scans. Also, the relative path is resolved against the process CWD rather than the module file's directory. That matches wordlist:, but it would help to say so in docs/modules.md.
|
Conflict update against current There's still only one textual conflict: Resolving
Suggested rebase, keeping the #384 stack: it also picks up #384's git fetch upstream main pull/384/head:dsl-384
git checkout -b tmp dsl-384 && git rebase upstream/main # fix go.mod as above, then: git add go.mod && git rebase --continue
git cherry-pick 2e16c1e..lane/fuzz-payload-sets # 4f55124..43ba2b2, applies cleanly
go mod tidy && go build ./... && go test ./...
git branch -f lane/fuzz-payload-sets tmp && git push --force-with-lease origin lane/fuzz-payload-setsIf #384 merges first, use The resulting tree only differs from |
|
Small update to my previous conflict notes: The steps are the same, and After the resolution, the direct block should read: In the indirect block, keep I ran the steps from the previous note locally: rebased #384 onto I couldn't run |
|
@TBX3D this branch conflicts with git fetch upstream # upstream = github.com/vmfunc/sif
git checkout lane/fuzz-payload-sets
git rebase upstream/main # stops on 610d371 with go.mod conflictedResolve
git add go.mod && git rebase --continue
go mod tidy && go build ./... && go test ./...
git push --force-with-lease origin lane/fuzz-payload-setsNotes:
|
stacked on #384, so only the commits above it are this pr's.
the payloads field only took one anonymous list, so a fuzzing module could vary exactly one thing, and generation materialized the whole cross product before sending anything.
a mapping now declares ordered named sets injectable at {{name}}, a scalar names a local wordlist loaded through the existing loadWordlist, and a sequence still means the legacy single set. generation becomes a lazy iter.Seq consumed by a fixed worker pool over an unbuffered feed with one collector owning the findings slice, so the mutex and the product-sized results channel both go away. -fuzz-max-requests caps a module at 25000 requests per target by default.