Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClusterFuzzLite in CI featuring PR fuzzing, batch fuzzing and fuzz coverage reports #820

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/oss-fuzz-base/base-builder-rust:v1
RUN rustup install nightly-2024-09-24 && rustup default nightly-2024-09-24
RUN rustup component add rust-src --toolchain nightly-2024-09-24
ENV RUSTUP_TOOLCHAIN=nightly-2024-09-24
COPY . $SRC/fuel-vm
WORKDIR fuel-vm
COPY .clusterfuzzlite/build.sh $SRC/
5 changes: 5 additions & 0 deletions .clusterfuzzlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ClusterFuzzLite

This directory contains the configuration for [ClusterFuzzLite](https://google.github.io/clusterfuzzlite/). CFL is used in the GitHub Actions CI in several workflows.

The corpus and more documentation can be found in [FuelLabs/fuel-fuzzing-corpus](https://github.com/FuelLabs/fuel-fuzzing-corpus).
9 changes: 9 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash -eu

cd $SRC/fuel-vm

cd fuel-vm

cargo fuzz build -O --sanitizer none

cp fuzz/target/x86_64-unknown-linux-gnu/release/grammar_aware_advanced $OUT/
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: rust
33 changes: 33 additions & 0 deletions .github/workflows/cflite_batch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: ClusterFuzzLite batch fuzzing
on:
workflow_dispatch:
schedule:
- cron: '0 0/24 * * *' # Every 24th hour
permissions: read-all
jobs:
BatchFuzzing:
runs-on: ubuntu-latest
steps:
- name: Get fuzzer auth token
uses: actions/create-github-app-token@v1
id: fuzzer-token
with:
owner: ${{ github.repository_owner }}
app-id: ${{ vars.FUEL_FUZZING_CORPUS_APP_ID }}
private-key: ${{ secrets.FUEL_FUZZING_CORPUS_APP_KEY }}
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
language: rust
- name: Run Fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 3600
mode: 'batch'
output-sarif: true
storage-repo: https://oauth2:${{ steps.fuzzer-token.outputs.token }}@github.com/FuelLabs/fuel-fuzzing-corpus.git
storage-repo-branch: main
storage-repo-branch-coverage: gh-pages
60 changes: 60 additions & 0 deletions .github/workflows/cflite_cron.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: ClusterFuzzLite cron tasks
on:
workflow_dispatch:
schedule:
- cron: '0 0/72 * * *'
permissions: read-all
jobs:
Pruning:
runs-on: ubuntu-latest
steps:
- name: Get fuzzer auth token
uses: actions/create-github-app-token@v1
id: fuzzer-token
with:
owner: ${{ github.repository_owner }}
app-id: ${{ vars.FUEL_FUZZING_CORPUS_APP_ID }}
private-key: ${{ secrets.FUEL_FUZZING_CORPUS_APP_KEY }}
- name: Build Fuzzers
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
language: rust
- name: Run Fuzzers
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 600
mode: 'prune'
output-sarif: true
storage-repo: https://oauth2:${{ steps.fuzzer-token.outputs.token }}@github.com/FuelLabs/fuel-fuzzing-corpus.git
storage-repo-branch: main
storage-repo-branch-coverage: gh-pages
Coverage:
runs-on: ubuntu-latest
steps:
- name: Get fuzzer auth token
uses: actions/create-github-app-token@v1
id: fuzzer-token
with:
owner: ${{ github.repository_owner }}
app-id: ${{ vars.FUEL_FUZZING_CORPUS_APP_ID }}
private-key: ${{ secrets.FUEL_FUZZING_CORPUS_APP_KEY }}
- name: Build Fuzzers
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
language: rust
sanitizer: coverage
- name: Run Fuzzers
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 600
mode: 'coverage'
sanitizer: 'coverage'
storage-repo: https://oauth2:${{ steps.fuzzer-token.outputs.token }}@github.com/FuelLabs/fuel-fuzzing-corpus.git
storage-repo-branch: main
storage-repo-branch-coverage: gh-pages
38 changes: 38 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ClusterFuzzLite PR fuzzing

on:
pull_request:
workflow_dispatch:

permissions: read-all
jobs:
PR:
runs-on: ubuntu-latest
steps:
- name: Get fuzzer auth token
uses: actions/create-github-app-token@v1
id: fuzzer-token
with:
owner: ${{ github.repository_owner }}
app-id: ${{ vars.FUEL_FUZZING_CORPUS_APP_ID }}
private-key: ${{ secrets.FUEL_FUZZING_CORPUS_APP_KEY }}
- name: Build Fuzzers
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
language: rust
github-token: ${{ secrets.GITHUB_TOKEN }}
storage-repo: https://oauth2:${{ steps.fuzzer-token.outputs.token }}@github.com/FuelLabs/fuel-fuzzing-corpus.git
storage-repo-branch: main
storage-repo-branch-coverage: gh-pages
- name: Run Fuzzers
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 600
mode: 'code-change'
output-sarif: true
storage-repo: https://oauth2:${{ steps.fuzzer-token.outputs.token }}@github.com/FuelLabs/fuel-fuzzing-corpus.git
storage-repo-branch: main
storage-repo-branch-coverage: gh-pages
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added
- [#838](https://github.com/FuelLabs/fuel-vm/pull/838): Implemented `AsRef<[u8]>` and `TryFrom<&[u8]>` for DA compression types: ScriptCode, PredicateCode, RegistryKey.
- [#820](https://github.com/FuelLabs/fuel-vm/pull/820): Add fuzzing in CI with ClusterFuzzLite.

### Removed

Expand Down
Loading