Repository navigation
268 lines (233 loc) · 8.46 KB
/
Copy pathfuzz.yml
File metadata and controls
268 lines (233 loc) · 8.46 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
name: Fuzz Testing
on:
schedule:
- cron: '0 2 * * *' # Daily at 2 AM UTC
workflow_dispatch:
inputs:
duration:
description: 'Fuzz duration per target in seconds'
required: false
default: '3600'
type: string
target:
description: 'Specific target to fuzz (or "all")'
required: false
default: 'all'
type: choice
options:
- all
- module_parse
- wit_deserialize
- memory_access
- func_call
- module_serialize
- error_message
- wit_serialize
- jni_callback
java_duration:
description: 'Java fuzz duration in seconds'
required: false
default: '1800'
type: string
push:
paths:
- 'wasmtime4j-native/fuzz/**'
- 'wasmtime4j-tests/fuzz/**'
- '.github/workflows/fuzz.yml'
branches: [master]
env:
CARGO_TERM_COLOR: always
jobs:
# Quick smoke test on push to fuzz-related files
smoke-test:
if: github.event_name == 'push'
name: Fuzz Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Compile and run quick fuzz (60s each)
working-directory: wasmtime4j-native
run: |
for target in module_parse wit_deserialize memory_access func_call module_serialize error_message wit_serialize jni_callback; do
echo "::group::Fuzzing $target"
cargo +nightly fuzz run $target -- -max_total_time=60 || true
echo "::endgroup::"
done
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: fuzz-crashes-smoke
path: wasmtime4j-native/fuzz/artifacts/
if-no-files-found: ignore
# Java fuzz smoke test on push
java-fuzz-smoke:
if: github.event_name == 'push'
name: Java Fuzz Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '23'
- uses: dtolnay/rust-toolchain@stable
- name: Build native library
run: cargo build --release
- name: Build Java
run: |
COMMON_ARGS="-B -P skip-native -q -DskipQuality -Dmaven.javadoc.skip=true -Dgpg.skip=true -Dcheckstyle.skip=true -Dspotless.check.skip=true"
./mvnw install $COMMON_ARGS -Dmaven.test.skip=true -pl '!:wasmtime4j-tests-stress'
./mvnw test-compile $COMMON_ARGS -pl wasmtime4j-tests/fuzz
- name: Run Java fuzz tests (60s)
run: ./mvnw verify -P fuzz -pl wasmtime4j-tests/fuzz -Dfuzz.duration=60 -DskipQuality -Dcheckstyle.skip=true
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: java-fuzz-crashes-smoke
path: wasmtime4j-tests/fuzz/**/hs_err_*.log
if-no-files-found: ignore
# Full fuzz testing (scheduled or manual)
fuzz:
if: github.event_name != 'push'
name: Fuzz ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- module_parse
- wit_deserialize
- memory_access
- func_call
- module_serialize
- error_message
- wit_serialize
- jni_callback
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@nightly
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Cache fuzz corpus
uses: actions/cache@v6
with:
path: wasmtime4j-native/fuzz/corpus/${{ matrix.target }}
key: fuzz-corpus-${{ matrix.target }}-${{ github.sha }}
restore-keys: fuzz-corpus-${{ matrix.target }}-
- name: Generate seed corpus
working-directory: wasmtime4j-native/fuzz
run: |
if [ -x generate_corpus.sh ]; then
./generate_corpus.sh
fi
- name: Determine fuzz duration
id: duration
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "seconds=3600" >> "$GITHUB_OUTPUT"
else
echo "seconds=${{ inputs.duration || '300' }}" >> "$GITHUB_OUTPUT"
fi
- name: Run fuzzer
working-directory: wasmtime4j-native
run: |
echo "Fuzzing ${{ matrix.target }} for ${{ steps.duration.outputs.seconds }}s"
cargo +nightly fuzz run ${{ matrix.target }} \
fuzz/corpus/${{ matrix.target }} \
-- -max_total_time=${{ steps.duration.outputs.seconds }}
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: fuzz-crashes-${{ matrix.target }}
path: wasmtime4j-native/fuzz/artifacts/${{ matrix.target }}/
if-no-files-found: ignore
- name: Upload updated corpus
uses: actions/upload-artifact@v7
with:
name: fuzz-corpus-${{ matrix.target }}
path: wasmtime4j-native/fuzz/corpus/${{ matrix.target }}/
if-no-files-found: ignore
# Full Java fuzz testing (scheduled or manual)
java-fuzz:
if: github.event_name != 'push'
name: Java Fuzz Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '23'
- uses: dtolnay/rust-toolchain@stable
- name: Build native library
run: cargo build --release
- name: Build Java
run: |
COMMON_ARGS="-B -P skip-native -q -DskipQuality -Dmaven.javadoc.skip=true -Dgpg.skip=true -Dcheckstyle.skip=true -Dspotless.check.skip=true"
./mvnw install $COMMON_ARGS -Dmaven.test.skip=true -pl '!:wasmtime4j-tests-stress'
./mvnw test-compile $COMMON_ARGS -pl wasmtime4j-tests/fuzz
- name: Determine fuzz duration
id: duration
run: |
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "seconds=1800" >> "$GITHUB_OUTPUT"
else
echo "seconds=${{ inputs.java_duration || '1800' }}" >> "$GITHUB_OUTPUT"
fi
- name: Run Java fuzz tests
run: ./mvnw verify -P fuzz -pl wasmtime4j-tests/fuzz -Dfuzz.duration=${{ steps.duration.outputs.seconds }} -DskipQuality -Dcheckstyle.skip=true
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: java-fuzz-crashes
path: wasmtime4j-tests/fuzz/**/hs_err_*.log
if-no-files-found: ignore
# Create issue on crash during scheduled runs
notify-crashes:
if: github.event_name == 'schedule' && failure()
needs: [fuzz, java-fuzz]
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Create issue for crashes
uses: actions/github-script@v9
with:
script: |
const today = new Date().toISOString().split('T')[0];
const title = `Fuzz testing found crashes - ${today}`;
// Check if issue already exists today
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'fuzz-crash',
per_page: 10
});
if (issues.some(i => i.title.includes(today))) return;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: [
'## Fuzz Testing Crash Report',
'',
`**Run:** ${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
`**Date:** ${new Date().toISOString()}`,
'',
'### Next steps',
'1. Download crash artifacts from the workflow run',
'2. Reproduce: `cargo +nightly fuzz run <target> <crash_file>`',
'3. Minimize: `cargo +nightly fuzz tmin <target> <crash_file>`',
'4. Save minimized input to `wasmtime4j-native/fuzz/regressions/<target>/`',
'5. Fix the bug and verify the regression input no longer crashes',
].join('\n'),
labels: ['fuzz-crash', 'bug']
});