forked from rlane/ubpf
-
Notifications
You must be signed in to change notification settings - Fork 141
150 lines (126 loc) · 4.05 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
# 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
jobs:
build:
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.platform }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: 'recursive'
- name: Generate the cache key
id: cache_key
run: echo "VALUE=platform-${{ matrix.platform }}_type=fuzzing" >> $GITHUB_OUTPUT
- name: Update the cache (ccache)
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.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-latest'
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
- name: Build/install libbpf From Source
if: matrix.platform == 'ubuntu-latest'
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 \
llvm
- name: Configure uBPF
run: |
export CCACHE_DIR="$(pwd)/ccache"
if ("${{matrix.platform}}" == "macos-latest") {
export PATH="/usr/local/opt/llvm/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
export CXXFLAGS="-I/usr/local/opt/llvm/include"
}
${command_prefix} cmake \
-G Ninja \
-S . \
-B build \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DUBPF_ENABLE_LIBFUZZER=1 \
-DCMAKE_BUILD_TYPE=Debug
- name: Build uBPF
run: |
export CCACHE_DIR="$(pwd)/ccache"
${command_prefix} cmake \
--build build
- name: Upload fuzzer as artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: fuzzer
path: build/bin/ubpf_fuzzer
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
submodules: 'recursive'
ref: fuzz/corpus
- name: Download fuzzer artifacts
uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e
with:
name: fuzzer
- name: Setup directory for fuzzing
run: |
ls -la
mkdir -p new_corpus
mkdir -p fuzz/corpus
cp -r fuzz/corpus/* new_corpus
mkdir -p artifacts
chmod a+x ubpf_fuzzer
- name: Run fuzzing
run: |
./ubpf_fuzzer new_corpus -artifact_prefix=artifacts/ -use_value_profile=1 -max_total_time=300
- name: Merge corpus into fuzz/corpus
run: |
./ubpf_fuzzer -merge=1 fuzz/corpus new_corpus
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@82c141cc518b40d92cc801eee768e7aafc9c2fa2
with:
name: fuzzing-artifacts
path: artifacts/