forked from rlane/ubpf
-
Notifications
You must be signed in to change notification settings - Fork 138
268 lines (224 loc) · 7.72 KB
/
fuzzing.yml
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
# Copyright (c) uBPF contributors
# SPDX-License-Identifier: MIT
name: Fuzzing
permissions:
contents: write
on:
schedule: # Run every day at 21:00 UTC
- cron: '00 21 * * *'
workflow_dispatch: # Run manually
workflow_call:
inputs:
regression_test:
description: 'Run the fuzzer over the corpus as a regression test.'
required: false
default: false
type: boolean
jobs:
build-posix:
strategy:
matrix:
platform:
- ubuntu-24.04
arch:
- x86_64
runs-on: ${{ matrix.platform }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'recursive'
- name: Generate the cache key
id: cache_key
run: echo "VALUE=platform-${{ matrix.platform }}_arch=${{ matrix.arch }}_type=fuzzing" >> $GITHUB_OUTPUT
- name: Update the cache (ccache)
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ccache
key: ${{ steps.cache_key.outputs.VALUE }}_ccache
- name: Create the build folders
run: |
mkdir -p \
ccache
- name: Install system dependencies (Linux)
if: matrix.platform == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get install -y \
ccache \
ninja-build \
cmake \
lcov \
libboost-dev \
libboost-program-options-dev \
libboost-filesystem-dev \
libelf-dev \
libyaml-cpp-dev
if [[ "${{ matrix.arch }}" == "arm64" ]] ; then
sudo apt install -y \
g++-aarch64-linux-gnu \
gcc-aarch64-linux-gnu \
qemu-user
fi
- name: Build/install libbpf From Source
if: matrix.platform == 'ubuntu-24.04'
run: ./.github/scripts/build-libbpf.sh
shell: bash
- name: Install system dependencies (macOS)
if: matrix.platform == 'macos-latest'
run: |
brew install \
cmake \
ninja \
ccache \
lcov \
boost
- name: Configure uBPF
run: |
export CCACHE_DIR="$(pwd)/ccache"
${command_prefix} cmake \
-G Ninja \
-S . \
-B build \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DUBPF_ENABLE_LIBFUZZER=1 \
${arch_flags}
- name: Build uBPF
run: |
export CCACHE_DIR="$(pwd)/ccache"
${command_prefix} cmake \
--build build
- name: Generate dictionary
run: |
python ubpf/dictionary_generator.py >build/bin/dictionary.txt
- name: Upload fuzzer as artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: fuzzer-${{ matrix.platform }}-${{ matrix.arch }}
path: build/bin/*
build-windows:
strategy:
matrix:
platform:
- windows-latest
arch:
- x86_64
runs-on: ${{ matrix.platform }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
with:
egress-policy: audit
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'recursive'
- name: Cache the build folder
uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a
env:
cache-name: cache-nuget-modules
with:
path: build
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('**/CMakeLists.txt') }}
- name: Configure uBPF
run: |
cmake -S . -B build -DUBPF_ENABLE_LIBFUZZER=1
- name: Build uBPF
run: |
cmake --build build --config RelWithDebInfo
- name: Generate dictionary
run: |
python ubpf\dictionary_generator.py >build\bin\RelWithDebInfo\dictionary.txt
- name: Gather dependencies
shell: cmd
run: |
dir "C:\Program Files\Microsoft Visual Studio\2022"
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
copy "%VCToolsInstallDir%"\bin\hostx64\x64\clang* build\bin\RelWithDebInfo
copy "%VCToolsRedistDir%\x64\Microsoft.VC143.CRT" build\bin\RelWithDebInfo
dir build\bin\RelWithDebInfo
- name: Upload fuzzer as artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: fuzzer-${{ matrix.platform }}-${{ matrix.arch }}
path: |
build/bin/RelWithDebInfo
run_fuzzer:
needs:
- build-posix
- build-windows
strategy:
matrix:
platform:
- ubuntu-24.04
- windows-latest
arch:
- x86_64
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: 'recursive'
ref: fuzz/corpus
- name: Install system dependencies (Linux)
if: matrix.platform == 'ubuntu-24.04'
run: |
sudo apt-get update
sudo apt-get install -y \
libboost-dev \
libboost-program-options-dev \
libboost-filesystem-dev \
libelf-dev \
libyaml-cpp-dev
- name: Download fuzzer artifacts
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: fuzzer-${{ matrix.platform }}-${{ matrix.arch }}
- name: Setup directory for fuzzing
run: |
ls
mkdir -p new_corpus
cp -r fuzz/corpus/* new_corpus
mkdir -p artifacts
- name: Make fuzzer executable
if: matrix.platform == 'ubuntu-24.04'
run: chmod a+x ubpf_fuzzer
# If this is a workflow call, run ubpf_fuzzer over each file in the corpus as a regression test.
- name: Run fuzzing regression
if: inputs.regression_test == true
run: |
./ubpf_fuzzer -merge=1 fuzz/corpus new_corpus
# If this is a scheduled run or a manual run, run ubpf_fuzzer to attempt to find new crashes. Runs for 2 hours.
- name: Run fuzzing
if: matrix.platform == 'ubuntu-24.04' && inputs.regression_test != true
run: |
ls
UBPF_FUZZER_CONSTRAINT_CHECK=1 ./ubpf_fuzzer new_corpus -artifact_prefix=artifacts/ -use_value_profile=1 -max_total_time=3600 -dict=dictionary.txt -timeout=60
# If this is a scheduled run or a manual run, run ubpf_fuzzer to attempt to find new crashes. Runs for 2 hours.
- name: Run fuzzing
if: matrix.platform == 'windows-latest' && inputs.regression_test != true
run: |
ls
./ubpf_fuzzer new_corpus -artifact_prefix=artifacts/ -use_value_profile=1 -max_total_time=3600 -timeout=60
# Merge the new corpus into the existing corpus and push the changes to the repository.
- name: Merge corpus into fuzz/corpus
if: inputs.regression_test != true
run: |
./ubpf_fuzzer -merge=1 fuzz/corpus new_corpus
git pull
git add fuzz/corpus
git config --global user.email '[email protected]'
git config --global user.name 'Github Action'
git commit -sm "Update fuzzing corpus"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{github.repository}}.git
git push
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: fuzzing-artifacts-${{ matrix.platform }}-${{ matrix.arch }}
path: artifacts/