Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/fuzzing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ on:
jobs:
fuzz-utils:
runs-on: ubuntu-22.04
permissions:
actions: read
timeout-minutes: 30
steps:
- name: Checkout source code
Expand Down Expand Up @@ -37,6 +39,17 @@ jobs:
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"
- name: Conan build
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"
- name: Restore previous fuzzing corpora artifact
continue-on-error: true #can fail if no previous fuzzing-corpora-artifact exists
env:
GH_TOKEN: ${{ github.token }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
#retrieve lastest master / Celix Fuzzing run id
RUN_ID=$(gh run list --branch "${BRANCH_NAME}" --workflow "${{ github.workflow }}" --json databaseId --jq '.[0].databaseId')
gh run download "$RUN_ID" --name fuzzing-corpora-artifact
mkdir -p build/libs/utils/fuzzing
tar -xzf fuzzing-corpora-artifact.tar.gz -C fuzzing-previous
- name: Set fuzzer run time
id: set-runtime
run: |
Expand All @@ -57,3 +70,18 @@ jobs:
run: |
source build/conanrun.sh
./build/libs/utils/fuzzing/celix_filter_fuzzer -max_total_time=$FUZZ_TIME ./build/libs/utils/fuzzing/filter_corpus
- name: Package fuzzing corpora artifacts
if: always() #Always package & upload updated fuzzing corpora artifacts
run: |
mkdir -p fuzzing-artifact
for path in build/libs/utils/fuzzing/*_corpus; do
cp -a "$path" fuzzing-artifact/
done
tar -czf fuzzing-corpora-artifact.tar.gz -C fuzzing-artifact .
- name: Upload fuzzing artifacts
#Always package & upload updated fuzzing corpora artifact on the master branch
if: always() && github.ref == 'refs/heads/master'
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 #v4.3.1
with:
name: fuzzing-corpora-artifact
path: fuzzing-corpora-artifact.tar.gz
16 changes: 12 additions & 4 deletions documents/building/fuzz_testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ limitations under the License.
# Fuzz Testing with libFuzzer

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

Fuzzing is enabled when using the Clang compiler and the `UTILS_LIBFUZZER` CMake
option.

## Building
Expand Down Expand Up @@ -70,5 +71,12 @@ This will display all available LibFuzzer options.

## Continuous Fuzzing

A GitHub Actions workflow runs the fuzzer periodically. The workflow
configuration can be found at `.github/workflows/fuzzing.yml`.
Each Celix Fuzzing run attempts to download the latest fuzzing artifact from the same branch and unpack any
existing corpora before executing the fuzzers so new inputs build on the most recent discoveries.

### Maintaining the seed corpus

The Celix Fuzzing workflow uploads the generated corpora files as a build artifact
named `fuzzing-corpora-artifact`.
The master version of the `fuzzing-corpora-artifactz` artifact is used to keep
the seed corpus in `libs/utils/fuzzing/{filter,properties,version}_corpus` updated.
Loading