Fuzzing
rk can mutate the messages a flow sends, to find inputs that crash or confuse the network function under test. Fuzzing needs the licence feature robustness.fuzz.
Two pieces are involved:
- A
fuzz:block in a flow turns mutation on. No command-line flag does. rk fuzzruns fuzz campaigns across several targets, each judged by an oracle.
The fuzz: block
YAML
rk schema lists every key the block accepts.
- Scope: the block can sit on the flow, on a state, or on a single
send. The most specific one wins. - Strategies:
bitflip(the default),truncate,extend,field,ie-drop,ie-dup,ie-reorder,nest,unknown-ie,downgrade. - Seed on the command line:
-fuzz-seed <n>replaces the template's seed.autoorrandompicks a new one each run.
Every mutated run writes its artifacts to -fuzz-out. When that's not set, it uses $D3X_FUZZ_OUT, then ./fuzz-runs. Each run gets a directory named after the time and the flow:
| File | What it holds |
|---|---|
campaign.json | the seed and where it came from, every mutation, and a digest to reproduce the run |
repro.txt | how to reproduce the run |
mutations/ | each mutated message, as hex before and after |
oracle.json | the oracle's verdict |
corpus/ | wire mutations in Go's fuzz-corpus format |
Oracles: did the target break?
Two ways to judge a fuzzed run, on run-flow or in the manifest:
- Panic counter:
-fuzz-metrics-url <url>reads the target'sd3x_recovered_panics_totalbefore and after the run. Any increase fails the run. - Known-good replay:
-fuzz-known-good <flow>replays a normal flow after the campaign (and every-fuzz-known-good-everyseconds, if set). If it no longer passes, the target's state was corrupted, and the run fails.
rk fuzz: campaigns
Shell
| Flag | Default | What it does |
|---|---|---|
-target | required: a name, a list, all, or nf=<role>, protocol=<p>, schedule_class=<c> | |
-manifest | fuzz/targets.yaml | the target list, searched in the current directory and up to 8 levels above |
-budget | 2m | the total wall time, divided equally across targets |
-templates, -c, -s | templates, environment (single target only) and subscribers | |
-fuzz-seed, -fuzz-out, -fuzz-metrics-url, -fuzz-known-good | as on run-flow | |
-output-file | stdout | the JSON report |
Each manifest target names:
- its
base_flow(which must have afuzz:block); nf,protocol,strategiesand itsoracle;- a
schedule_class:parallel,serial-per-upforlab-exclusive.
Targets that need a lab aren't run by rk fuzz; they're reported as inconclusive.
Each target's status:
- fail: the oracle judged the target unclean;
- error: the campaign errored;
- inconclusive: no mutation was applied, or no oracle ran;
- pass: none of these.
The exit code:
1if any target failed;- otherwise the first errored target's code;
- otherwise
3if nothing passed; - otherwise
0.
The report is always JSON.