-
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (155 loc) · 4.95 KB
/
fuzz.yml
File metadata and controls
177 lines (155 loc) · 4.95 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
# Fuzzing workflow for WRAITH Protocol
# Runs cargo-fuzz on nightly Rust to find crashes and undefined behavior
name: Fuzz
on:
# Run on manual trigger
workflow_dispatch:
inputs:
duration:
description: 'Fuzz duration in seconds per target'
required: false
default: '60'
type: string
target:
description: 'Specific fuzz target (leave empty for all)'
required: false
default: ''
type: string
# Run weekly on Sunday at midnight UTC
schedule:
- cron: '0 0 * * 0'
# Run on PRs that modify fuzz targets or core crypto code
pull_request:
paths:
- 'fuzz/**'
- 'crates/wraith-crypto/**'
- 'crates/wraith-core/src/frame.rs'
- 'crates/wraith-discovery/src/dht/**'
- 'crates/wraith-obfuscation/src/padding.rs'
- 'crates/wraith-files/src/tree_hash.rs'
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
jobs:
fuzz:
name: Fuzz ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- fuzz_frame_parser
- fuzz_dht_message
- fuzz_crypto
- fuzz_padding
- fuzz_tree_hash
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-fuzz-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-fuzz-
- name: Create corpus directory
run: mkdir -p fuzz/corpus/${{ matrix.target }}
- name: Download existing corpus (if available)
continue-on-error: true
uses: actions/download-artifact@v6
with:
name: corpus-${{ matrix.target }}
path: fuzz/corpus/${{ matrix.target }}
- name: Run fuzzer
env:
FUZZ_DURATION: ${{ github.event.inputs.duration || '60' }}
FUZZ_TARGET_INPUT: ${{ github.event.inputs.target }}
FUZZ_TARGET: ${{ matrix.target }}
RUST_BACKTRACE: '1'
run: |
# If specific target requested and doesn't match, skip
if [ -n "$FUZZ_TARGET_INPUT" ] && [ "$FUZZ_TARGET_INPUT" != "$FUZZ_TARGET" ]; then
echo "Skipping $FUZZ_TARGET (requested: $FUZZ_TARGET_INPUT)"
exit 0
fi
echo "Fuzzing $FUZZ_TARGET for ${FUZZ_DURATION} seconds..."
cd fuzz
cargo +nightly fuzz run "$FUZZ_TARGET" -- \
-max_total_time="${FUZZ_DURATION}" \
-max_len=16384 \
-print_final_stats=1
- name: Upload corpus
if: always()
uses: actions/upload-artifact@v6
with:
name: corpus-${{ matrix.target }}
path: fuzz/corpus/${{ matrix.target }}
retention-days: 30
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v6
with:
name: crashes-${{ matrix.target }}
path: |
fuzz/artifacts/${{ matrix.target }}
fuzz/corpus/${{ matrix.target }}/crash-*
retention-days: 90
# Summary job that fails if any fuzzer found a crash
fuzz-summary:
name: Fuzz Summary
runs-on: ubuntu-latest
needs: fuzz
if: always()
steps:
- name: Check fuzz results
env:
FUZZ_RESULT: ${{ needs.fuzz.result }}
run: |
if [ "$FUZZ_RESULT" != "success" ]; then
echo "One or more fuzzers found issues!"
exit 1
fi
echo "All fuzzers completed successfully"
# Coverage-guided fuzzing with longer duration (weekly only)
extended-fuzz:
name: Extended Fuzz (Coverage)
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Install cargo-fuzz
run: cargo install cargo-fuzz
- name: Extended fuzzing (all targets)
run: |
cd fuzz
for target in fuzz_frame_parser fuzz_dht_message fuzz_crypto fuzz_padding fuzz_tree_hash; do
echo "Extended fuzzing $target for 300 seconds..."
cargo +nightly fuzz run "$target" -- \
-max_total_time=300 \
-max_len=65536 \
-print_final_stats=1 || true
done
- name: Upload all artifacts
if: always()
uses: actions/upload-artifact@v6
with:
name: extended-fuzz-results
path: |
fuzz/artifacts/
fuzz/corpus/
retention-days: 90