1
+ name : Fuzzing
2
+
3
+ on :
4
+ schedule :
5
+ # Run daily at 2 AM UTC
6
+ - cron : ' 0 2 * * *'
7
+ workflow_dispatch :
8
+ pull_request :
9
+ paths :
10
+ - ' src/**'
11
+ - ' fuzz/**'
12
+ - ' .github/workflows/fuzz.yml'
13
+
14
+ env :
15
+ CARGO_TERM_COLOR : always
16
+
17
+ jobs :
18
+ fuzz :
19
+ name : Fuzz Testing
20
+ runs-on : ubuntu-latest
21
+ strategy :
22
+ matrix :
23
+ target :
24
+ - protocol_parsing
25
+ - jsonrpc_handling
26
+ - transport_layer
27
+ - auth_flows
28
+
29
+ steps :
30
+ - uses : actions/checkout@v4
31
+
32
+ - name : Install Rust nightly
33
+ uses : dtolnay/rust-toolchain@nightly
34
+ with :
35
+ components : llvm-tools-preview
36
+
37
+ - name : Install cargo-fuzz
38
+ run : cargo install cargo-fuzz
39
+
40
+ - name : Cache fuzz corpus
41
+ uses : actions/cache@v3
42
+ with :
43
+ path : fuzz/corpus
44
+ key : fuzz-corpus-${{ matrix.target }}-${{ github.sha }}
45
+ restore-keys : |
46
+ fuzz-corpus-${{ matrix.target }}-
47
+
48
+ - name : Run fuzzing (${{ matrix.target }})
49
+ run : |
50
+ cargo fuzz run ${{ matrix.target }} -- \
51
+ -max_total_time=300 \
52
+ -print_final_stats=1 \
53
+ -detect_leaks=0
54
+ timeout-minutes : 10
55
+
56
+ - name : Minimize corpus
57
+ if : github.event_name == 'schedule'
58
+ run : cargo fuzz cmin ${{ matrix.target }}
59
+
60
+ - name : Upload crash artifacts
61
+ if : failure()
62
+ uses : actions/upload-artifact@v3
63
+ with :
64
+ name : fuzz-crashes-${{ matrix.target }}
65
+ path : fuzz/artifacts/${{ matrix.target }}/
66
+
67
+ - name : Upload corpus
68
+ if : github.event_name == 'schedule'
69
+ uses : actions/upload-artifact@v3
70
+ with :
71
+ name : fuzz-corpus-${{ matrix.target }}
72
+ path : fuzz/corpus/${{ matrix.target }}/
73
+
74
+ fuzz-coverage :
75
+ name : Fuzzing Coverage
76
+ runs-on : ubuntu-latest
77
+ if : github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
78
+
79
+ steps :
80
+ - uses : actions/checkout@v4
81
+
82
+ - name : Install Rust nightly
83
+ uses : dtolnay/rust-toolchain@nightly
84
+ with :
85
+ components : llvm-tools-preview
86
+
87
+ - name : Install tools
88
+ run : |
89
+ cargo install cargo-fuzz
90
+ cargo install rustfilt
91
+
92
+ - name : Generate coverage
93
+ run : |
94
+ for target in protocol_parsing jsonrpc_handling transport_layer auth_flows; do
95
+ cargo fuzz coverage $target
96
+ done
97
+
98
+ - name : Upload coverage reports
99
+ uses : actions/upload-artifact@v3
100
+ with :
101
+ name : fuzz-coverage
102
+ path : fuzz/coverage/
103
+
104
+ fuzz-24h :
105
+ name : 24-Hour Fuzzing
106
+ runs-on : ubuntu-latest
107
+ if : github.event_name == 'workflow_dispatch'
108
+
109
+ steps :
110
+ - uses : actions/checkout@v4
111
+
112
+ - name : Install Rust nightly
113
+ uses : dtolnay/rust-toolchain@nightly
114
+
115
+ - name : Install cargo-fuzz
116
+ run : cargo install cargo-fuzz
117
+
118
+ - name : Run 24-hour fuzzing
119
+ run : |
120
+ # Run each target for 6 hours (total 24 hours)
121
+ for target in protocol_parsing jsonrpc_handling transport_layer auth_flows; do
122
+ echo "Starting 6-hour fuzz for $target"
123
+ cargo fuzz run $target -- \
124
+ -max_total_time=21600 \
125
+ -print_final_stats=1 \
126
+ -detect_leaks=0 || true
127
+ done
128
+ timeout-minutes : 1440 # 24 hours
129
+
130
+ - name : Upload results
131
+ uses : actions/upload-artifact@v3
132
+ with :
133
+ name : fuzz-24h-results
134
+ path : |
135
+ fuzz/corpus/
136
+ fuzz/artifacts/
137
+ fuzz/*.log
0 commit comments