-
Notifications
You must be signed in to change notification settings - Fork 2
326 lines (290 loc) · 11.2 KB
/
Copy pathfuzz.yml
File metadata and controls
326 lines (290 loc) · 11.2 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
name: Fuzz Testing
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch:
inputs:
duration:
description: 'Fuzzing duration in seconds'
required: false
default: '600'
target:
description: 'Fuzz target to run (all_protocols or validate_with_python)'
required: false
default: 'all_protocols'
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
fuzz-fast:
name: Fast Fuzzing (all_protocols)
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || github.event_name == 'push'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f
with:
toolchain: nightly-2026-04-16
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked --version 0.13.1
- name: Cache fuzz corpus
uses: actions/cache@v4
with:
path: fuzz/corpus/all_protocols
key: fuzz-corpus-all-protocols-${{ github.sha }}
restore-keys: |
fuzz-corpus-all-protocols-
- name: Run fast fuzzing (5 minutes)
run: |
cargo fuzz run all_protocols -- \
-max_total_time=300 \
-print_final_stats=1 \
-verbosity=1
continue-on-error: true
- name: Check for crashes
if: always()
run: |
if [ -d "fuzz/artifacts/all_protocols" ]; then
# Only fail on actual crashes, not memory leaks (often false positives)
if ls fuzz/artifacts/all_protocols/crash-* 2>/dev/null || \
ls fuzz/artifacts/all_protocols/timeout-* 2>/dev/null || \
ls fuzz/artifacts/all_protocols/oom-* 2>/dev/null; then
echo "::error::Fuzzing found crashes!"
ls -la fuzz/artifacts/all_protocols/
exit 1
fi
# Log leaks but don't fail
if ls fuzz/artifacts/all_protocols/leak-* 2>/dev/null; then
echo "::warning::Memory leaks detected (not failing build)"
ls -la fuzz/artifacts/all_protocols/leak-*
fi
else
echo "::error::Fuzzing did not create fuzz/artifacts/all_protocols. cargo fuzz likely failed before execution."
exit 1
fi
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes-all-protocols
path: fuzz/artifacts/all_protocols/
if-no-files-found: ignore
fuzz-thorough:
name: Thorough Fuzzing (validate_with_python)
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f
with:
toolchain: nightly-2026-04-16
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked --version 0.13.1
- name: Cache fuzz corpus
uses: actions/cache@v4
with:
path: fuzz/corpus/validate_with_python
key: fuzz-corpus-validate-python-${{ github.sha }}
restore-keys: |
fuzz-corpus-validate-python-
- name: Determine fuzzing duration
id: duration
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_DURATION: ${{ github.event.inputs.duration }}
run: |
duration=1800
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
case "$INPUT_DURATION" in
''|*[!0-9]*)
echo "::error::workflow_dispatch input 'duration' must be a whole number of seconds"
exit 1
;;
esac
duration="$INPUT_DURATION"
fi
printf 'duration=%s\n' "$duration" >> "$GITHUB_OUTPUT"
- name: Run thorough fuzzing with Python validation
env:
FUZZ_DURATION: ${{ steps.duration.outputs.duration }}
PICKLE_FUZZ_PYTHON_ENV_POLICY: strip_setup_python_and_ld_library_path
run: |
cargo fuzz run validate_with_python -- \
-max_total_time="$FUZZ_DURATION" \
-print_final_stats=1 \
-verbosity=1
continue-on-error: true
- name: Check for crashes
if: always()
run: |
if [ -d "fuzz/artifacts/validate_with_python" ]; then
# Only fail on actual crashes, not memory leaks (often false positives)
if ls fuzz/artifacts/validate_with_python/crash-* 2>/dev/null || \
ls fuzz/artifacts/validate_with_python/timeout-* 2>/dev/null || \
ls fuzz/artifacts/validate_with_python/oom-* 2>/dev/null; then
echo "::error::Fuzzing found crashes!"
ls -la fuzz/artifacts/validate_with_python/
exit 1
fi
# Log leaks but don't fail
if ls fuzz/artifacts/validate_with_python/leak-* 2>/dev/null; then
echo "::warning::Memory leaks detected (not failing build)"
ls -la fuzz/artifacts/validate_with_python/leak-*
fi
else
echo "::error::Fuzzing did not create fuzz/artifacts/validate_with_python. cargo fuzz likely failed before execution."
exit 1
fi
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes-validate-python
path: fuzz/artifacts/validate_with_python/
if-no-files-found: ignore
fuzz-custom:
name: Custom Fuzzing Run
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f
with:
toolchain: nightly-2026-04-16
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked --version 0.13.1
- name: Validate custom fuzz target
id: target
env:
INPUT_TARGET: ${{ github.event.inputs.target }}
run: |
case "$INPUT_TARGET" in
all_protocols|validate_with_python)
printf 'target=%s\n' "$INPUT_TARGET" >> "$GITHUB_OUTPUT"
;;
*)
echo "::error::workflow_dispatch input 'target' must be one of: all_protocols, validate_with_python"
exit 1
;;
esac
- name: Cache fuzz corpus
uses: actions/cache@v4
with:
path: fuzz/corpus/${{ steps.target.outputs.target }}
key: fuzz-corpus-${{ steps.target.outputs.target }}-${{ github.sha }}
restore-keys: |
fuzz-corpus-${{ steps.target.outputs.target }}-
- name: Validate custom fuzz duration
id: duration
env:
INPUT_DURATION: ${{ github.event.inputs.duration }}
run: |
case "$INPUT_DURATION" in
''|*[!0-9]*)
echo "::error::workflow_dispatch input 'duration' must be a whole number of seconds"
exit 1
;;
esac
printf 'duration=%s\n' "$INPUT_DURATION" >> "$GITHUB_OUTPUT"
- name: Run custom fuzzing
env:
FUZZ_TARGET: ${{ steps.target.outputs.target }}
FUZZ_DURATION: ${{ steps.duration.outputs.duration }}
PICKLE_FUZZ_PYTHON_ENV_POLICY: strip_setup_python_and_ld_library_path
run: |
cargo fuzz run "$FUZZ_TARGET" -- \
-max_total_time="$FUZZ_DURATION" \
-print_final_stats=1 \
-verbosity=1
continue-on-error: true
- name: Check for crashes
if: always() && steps.target.outputs.target != ''
env:
FUZZ_TARGET: ${{ steps.target.outputs.target }}
run: |
if [ -d "fuzz/artifacts/$FUZZ_TARGET" ]; then
# Only fail on actual crashes, not memory leaks (often false positives)
if ls "fuzz/artifacts/$FUZZ_TARGET"/crash-* 2>/dev/null || \
ls "fuzz/artifacts/$FUZZ_TARGET"/timeout-* 2>/dev/null || \
ls "fuzz/artifacts/$FUZZ_TARGET"/oom-* 2>/dev/null; then
echo "::error::Fuzzing found crashes!"
ls -la "fuzz/artifacts/$FUZZ_TARGET"/
exit 1
fi
# Log leaks but don't fail
if ls "fuzz/artifacts/$FUZZ_TARGET"/leak-* 2>/dev/null; then
echo "::warning::Memory leaks detected (not failing build)"
ls -la "fuzz/artifacts/$FUZZ_TARGET"/leak-*
fi
else
echo "::error::Fuzzing did not create fuzz/artifacts/$FUZZ_TARGET. cargo fuzz likely failed before execution."
exit 1
fi
- name: Upload crash artifacts
if: failure() && steps.target.outputs.target != ''
uses: actions/upload-artifact@v4
with:
name: fuzz-crashes-${{ steps.target.outputs.target }}
path: fuzz/artifacts/${{ steps.target.outputs.target }}/
if-no-files-found: ignore
minimize-corpus:
name: Minimize Corpus
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
needs: [fuzz-thorough]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@0f1b44df7e9cbb178d781a242338dfa5e243ad7f
with:
toolchain: nightly-2026-04-16
- name: Install cargo-fuzz
run: cargo install cargo-fuzz --locked --version 0.13.1
- name: Restore corpus
uses: actions/cache@v4
with:
path: |
fuzz/corpus/all_protocols
fuzz/corpus/validate_with_python
key: fuzz-corpus-all-${{ github.sha }}
restore-keys: |
fuzz-corpus-all-
- name: Minimize all_protocols corpus
run: cargo fuzz cmin all_protocols
continue-on-error: true
- name: Minimize validate_with_python corpus
run: cargo fuzz cmin validate_with_python
continue-on-error: true
- name: Report corpus stats
run: |
echo "## Corpus Statistics" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### all_protocols" >> $GITHUB_STEP_SUMMARY
echo "Files: $(find fuzz/corpus/all_protocols -type f | wc -l)" >> $GITHUB_STEP_SUMMARY
echo "Size: $(du -sh fuzz/corpus/all_protocols | cut -f1)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### validate_with_python" >> $GITHUB_STEP_SUMMARY
echo "Files: $(find fuzz/corpus/validate_with_python -type f | wc -l)" >> $GITHUB_STEP_SUMMARY
echo "Size: $(du -sh fuzz/corpus/validate_with_python | cut -f1)" >> $GITHUB_STEP_SUMMARY