Skip to content

Commit dfc2270

Browse files
committed
Add upload and download fuzz corpus to the fuzzing ci
1 parent effe33a commit dfc2270

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

.github/workflows/fuzzing.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ on:
99
jobs:
1010
fuzz-utils:
1111
runs-on: ubuntu-22.04
12+
permissions:
13+
actions: read
1214
timeout-minutes: 30
1315
steps:
1416
- name: Checkout source code
@@ -37,6 +39,17 @@ jobs:
3739
run: conan install . --output-folder=build --build=missing -o "celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True" -o "celix/*:enable_address_sanitizer=True" -o "celix/*:enable_undefined_sanitizer=True"
3840
- name: Conan build
3941
run: conan build . --output-folder=build -o "celix/*:build_utils=True" -o "celix/*:enable_fuzzing=True" -o "celix/*:enable_address_sanitizer=True" -o "celix/*:enable_undefined_sanitizer=True" -o "celix/*:celix_err_buffer_size=5120"
42+
- name: Restore previous fuzzing corpora artifact
43+
continue-on-error: true #can fail if no previous fuzzing-corpora-artifact exists
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
47+
run: |
48+
#retrieve lastest master / Celix Fuzzing run id
49+
RUN_ID=$(gh run list --branch "${BRANCH_NAME}" --workflow "${{ github.workflow }}" --json databaseId --jq '.[0].databaseId')
50+
gh run download "$RUN_ID" --name fuzzing-corpora-artifact
51+
mkdir -p build/libs/utils/fuzzing
52+
tar -xzf fuzzing-corpora-artifact.tar.gz -C fuzzing-previous
4053
- name: Set fuzzer run time
4154
id: set-runtime
4255
run: |
@@ -57,3 +70,17 @@ jobs:
5770
run: |
5871
source build/conanrun.sh
5972
./build/libs/utils/fuzzing/celix_filter_fuzzer -max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/filter_corpus
73+
- name: Package fuzzing corpora artifacts
74+
if: always() #Always package & upload updated fuzzing corpora artifacts
75+
run: |
76+
mkdir -p fuzzing-artifact
77+
for path in build/libs/utils/fuzzing/*_corpus; do
78+
cp -a "$path" fuzzing-artifact/
79+
done
80+
tar -czf fuzzing-corpora-artifact.tar.gz -C fuzzing-artifact .
81+
- name: Upload fuzzing artifacts
82+
if: always() #Always package & upload updated fuzzing corpora artifact
83+
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 #v4.3.1
84+
with:
85+
name: fuzzing-corpora-artifact
86+
path: fuzzing-corpora-artifact.tar.gz

documents/building/fuzz_testing.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ limitations under the License.
2222
# Fuzz Testing with libFuzzer
2323

2424
The utilities library contains fuzz targets that can be built with
25-
[LLVM libFuzzer](https://llvm.org/docs/LibFuzzer.html). Fuzzing is
26-
enabled when using the Clang compiler and the `UTILS_LIBFUZZER` CMake
25+
[LLVM libFuzzer](https://llvm.org/docs/LibFuzzer.html).
26+
27+
Fuzzing is enabled when using the Clang compiler and the `UTILS_LIBFUZZER` CMake
2728
option.
2829

2930
## Building
@@ -70,5 +71,12 @@ This will display all available LibFuzzer options.
7071

7172
## Continuous Fuzzing
7273

73-
A GitHub Actions workflow runs the fuzzer periodically. The workflow
74-
configuration can be found at `.github/workflows/fuzzing.yml`.
74+
Each Celix Fuzzing run attempts to download the latest fuzzing artifact from the same branch and unpack any
75+
existing corpora before executing the fuzzers so new inputs build on the most recent discoveries.
76+
77+
### Maintaining the seed corpus
78+
79+
The Celix Fuzzing workflow uploads the generated corpora files as a build artifact
80+
named `fuzzing-corpora-artifact`.
81+
The master version of the `fuzzing-corpora-artifactz` artifact is used to keep
82+
the seed corpus in `libs/utils/fuzzing/{filter,properties,version}_corpus` updated.

0 commit comments

Comments
 (0)