Skip to content

feat(modules): named payload sets with streaming generation - #386

Open
TBX3D wants to merge 13 commits into
vmfunc:mainfrom
TBX3D:lane/fuzz-payload-sets
Open

feat(modules): named payload sets with streaming generation#386
TBX3D wants to merge 13 commits into
vmfunc:mainfrom
TBX3D:lane/fuzz-payload-sets

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.

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.

TBX3D added 13 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.
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.
@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 90.10239% with 29 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/executor.go 92.63% 7 Missing and 5 partials ⚠️
internal/modules/yaml.go 78.37% 6 Missing and 2 partials ⚠️
sif.go 0.00% 5 Missing ⚠️
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     #386   +/-   ##
=======================================
  Coverage        ?   65.56%           
=======================================
  Files           ?       89           
  Lines           ?     8082           
  Branches        ?        0           
=======================================
  Hits            ?     5299           
  Misses          ?     2382           
  Partials        ?      401           

☔ 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 size/xl 500+ lines changed modules changes to scan modules docs documentation changes tests test changes config configuration changes deps dependency updates labels Jul 31, 2026
@github-actions

Copy link
Copy Markdown

pr summary

18 files changed (+1183 -118)

category files
go source 15
tests 8
deps 1

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

Labels

config configuration changes 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