How hacking-by-heart/js-mutator works
js-mutator is a JavaScript-aware libFuzzer custom mutator: libFuzzer supplies seed bytes, the adapter calls the mutation or crossover API, and the library returns bounded JavaScript that is valid by default or deliberately malformed according to configuration. Internally, mutation uses seed-aware editing and grammar-based generation. The repository also provides V8 fuzzing targets for ordinary parsing, lazy compilation, and streaming compilation. The excerpts establish adapter/API and harness/helper links; the mutator-to-generator dispatch is shown as unverified because its call site was not excerpted.
Main entry points: common.h Harness helpers · parser.cc Parse target · parse.h Parse support · compile.cc Lazy compile
Components 13
Mutation engine
- Mutator API
include/js_mutator/mutator.h - Seed mutation
src/mutator.cc - Grammar generation
src/generator.cc - Generation model
src/generator.h
Fuzzer interface
- Callback adapter
adapters/libfuzzer.cc
V8 fuzz targets
- Harness helpers
harness/common.h - Parse support
harness/parse.h - Parse target
harness/parser.cc - Lazy compile
harness/compile.cc - Streaming compile
harness/streaming.cc - Parse diff
harness/diff.cc
Other components
- libFuzzer
- V8 parser/compiler
Connections 15
- libFuzzer → Callback adapter: invokes callbacks
README.md - Callback adapter → Mutator API: calls mutate/crossover
adapters/libfuzzer.cc - Mutator API → Seed mutation: implemented by
src/mutator.cc - Seed mutation → Grammar generation: dispatches generation
- Grammar generation → Generation model: uses definitions
src/generator.cc - Parse target → Parse support: calls parse pass
harness/parser.cc - Parse target → Harness helpers: uses helpers
harness/parser.cc - Parse support → Harness helpers: uses helpers
harness/parse.h - Lazy compile → Harness helpers: uses helpers
harness/compile.cc - Streaming compile → Harness helpers: uses helpers
harness/streaming.cc - Parse target → V8 parser/compiler: parses input
harness/parser.cc - Lazy compile → V8 parser/compiler: compiles functions
harness/compile.cc - Streaming compile → V8 parser/compiler: streams compilation
harness/streaming.cc - Parse diff → Parse support: uses parse pass
harness/diff.cc - Parse diff → Harness helpers: uses helpers
harness/diff.cc