Repository navigation
Commit bc3fef2
committed
feat(fuzz): add cargo-fuzz targets + CI, fix RangeExpr overflow panics
Adds a coverage-guided libFuzzer suite (via cargo-fuzz) over the crates that
parse or evaluate untrusted input, and a GitHub Actions workflow that smoke-
fuzzes every target on PRs/pushes and runs a deeper corpus-accumulating pass on
a nightly schedule.
Motivation: the quality-evaluation reports in reports/ kept re-discovering the
same class of defect by hand — arithmetic overflow and char-boundary panics
reachable from attacker-controlled expression text, templates, and manifests
(e.g. the expr report's exploratory findings). Encoding that class as a
permanent executable check stops it from being re-litigated every review cycle.
Six targets, each asserting "any input returns Ok or Err — never panic, abort,
or hang":
- expr_parse ParsedExpression::new
- expr_evaluate parse + evaluate against a fuzzer-seeded symbol table
- range_expr RangeExpr::from_str + len/get/iter
- format_string FormatString::new + resolve_string_with
- model_decode document_string_to_object + decode_{job,environment}_template
- snapshot_decode decode_manifest + Manifest::validate
The fuzz crate is outside the root workspace (its own empty [workspace] table)
so the stable build/test/clippy/MSRV jobs are untouched; it builds only under a
pinned nightly with AddressSanitizer, overflow-checks, and debug-assertions on.
Small curated seed corpora (mined from the crates' own tests and sample
templates) live in fuzz/seeds/ and are committed; the evolving runtime corpus
and crash artifacts are git-ignored and cached by CI.
The range_expr target immediately reproduced two live overflow panics (expr
report finding X1 and a multi-chunk variant), both fixed here at the root:
- IntRange::new: normalization arithmetic ((end-start)/step+1 and the
endpoint computation) now uses checked ops and returns a parse error for
endpoints whose element count or span overflows i64 (e.g.
"0-9223372036854775807", full i64-span ranges).
- RangeExpr merge: the adjacency test last.end + r.step now uses checked_add,
treating overflow as "not adjacent" instead of panicking/wrapping.
Adds a huge_span_does_not_overflow regression test. All 3356 existing
openjd-expr tests still pass; clippy -D warnings is clean.
Signed-off-by: Stephen Crowe <6042774+crowecawcaw@users.noreply.github.com>1 parent 1eec70b commit bc3fef2
623 files changed
Lines changed: 5230 additions & 7 deletions
File tree
- .github/workflows
- crates/openjd-expr/src
- fuzz
- fuzz_targets
- seeds
- expr_evaluate
- expr_parse
- format_string
- model_decode
- range_expr
- snapshot_decode
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
119 | 126 | | |
120 | 127 | | |
121 | | - | |
122 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
127 | 135 | | |
128 | 136 | | |
129 | 137 | | |
130 | | - | |
131 | | - | |
| 138 | + | |
| 139 | + | |
132 | 140 | | |
133 | 141 | | |
134 | 142 | | |
| |||
137 | 145 | | |
138 | 146 | | |
139 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
140 | 172 | | |
141 | 173 | | |
142 | | - | |
143 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
144 | 179 | | |
145 | 180 | | |
146 | 181 | | |
| |||
320 | 355 | | |
321 | 356 | | |
322 | 357 | | |
323 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
324 | 368 | | |
325 | 369 | | |
326 | 370 | | |
| |||
779 | 823 | | |
780 | 824 | | |
781 | 825 | | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
782 | 842 | | |
783 | 843 | | |
784 | 844 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments