FUZZING.md
Nuclei uses go-fuzz for targeted harnesses behind the gofuzz build tag.
The Makefile exposes these go-fuzz targets:
make build-fuzz GOFUZZ_PACKAGE=./pkg/operators/matchers
make fuzz GOFUZZ_PACKAGE=./pkg/operators/matchers
Required variable:
GOFUZZ_PACKAGE: any package path that go list can resolve from the repo root. The normal form in this repo is a relative package path such as ./pkg/operators/matchers.build-fuzz, fuzz, and fuzz-ci derive everything else from that package path:
<package>/.gofuzz/<package>/testdata/gofuzz-corpus/<package>/.gofuzz/<pkgname>-fuzz.zipdiscover-fuzz-packages emits the GitHub Actions matrix JSON to stdout, and writes matrix=... to GITHUB_OUTPUT when that file is present.
fuzz-ci wraps make fuzz in the CI timeout.
build-fuzz and fuzz fail immediately if GOFUZZ_PACKAGE is missing, the package cannot be resolved, or the seed corpus directory is missing or empty.
Operators (matchers & extractors) harness:
make fuzz GOFUZZ_PACKAGE=./pkg/operators/matchers
make fuzz GOFUZZ_PACKAGE=./pkg/operators/extractors
Harness Coverage:
Matchers exercise Matcher.CompileMatchers() through a compact line-based grammar. Supported keys are:
typeconditionpartencodingnegativecase-insensitivematch-allnamevaluestatussizeExtractors exercise Extractor.CompileExtractors() and the matching extraction path with fixed local corpora. Supported keys are:
typepartnameinternalcase-insensitivegroupattributevalueregexkvaljsonxpathdslEach run writes under <package>/.gofuzz/:
corpus/: evolving seed corpus used by go-fuzz.crashers/: saved crashing inputs.*-fuzz.zip: the instrumented build output created by go-fuzz-build.Promote real crashers into ordinary regression tests in the owning package once the underlying issue is fixed.
The repository also has a dedicated GitHub Actions fuzz workflow in .github/workflows/fuzz.yaml.
workflow_dispatch and a weekly schedule.projectdiscovery/nuclei; manual dispatch still works in forks.testdata/gofuzz-corpus/ and a sibling fuzz.go harness../pkg/operators/matchers and ./pkg/operators/extractors.make discover-fuzz-packages, and each package runs CI=true make fuzz-ci GOFUZZ_PACKAGE=... FUZZ_DURATION=15m.<package>/.gofuzz/ as the artifacts.