Skip to content

Commit ca1f3f7

Browse files
authored
Merge pull request #411 from filecoin-project/feat/clusterfuzzlite
Add clusterfuzzlite integration
2 parents 75aed98 + 3e82286 commit ca1f3f7

File tree

16 files changed

+231
-5
lines changed

16 files changed

+231
-5
lines changed

.clusterfuzzlite/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright 2021 Google LLC.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
################################################################################
16+
17+
FROM gcr.io/oss-fuzz-base/base-builder-rust
18+
COPY . $SRC/ref-fvm
19+
copy ./.clusterfuzzlite/build.sh $SRC
20+
WORKDIR $SRC

.clusterfuzzlite/build.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash -eu
2+
# Copyright 2021 Google LLC.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
cd "$SRC"
19+
20+
declare -a PROJECTS=(amt hamt)
21+
declare -A PROJECT_PATHS=(
22+
[amt]="ref-fvm/ipld/amt/fuzz"
23+
[hamt]="ref-fvm/ipld/hamt/fuzz"
24+
)
25+
26+
export CARGO_TARGET_DIR="$SRC/target"
27+
FUZZ_TARGET_OUTPUT_DIR="$CARGO_TARGET_DIR/x86_64-unknown-linux-gnu/release"
28+
29+
30+
for project in "${PROJECTS[@]}"; do
31+
pushd "${PROJECT_PATHS[$project]}"
32+
33+
cargo +nightly fuzz build -O --debug-assertions
34+
35+
for f in fuzz_targets/*.rs; do
36+
FUZZ_TARGET_NAME=$(basename "${f%.*}")
37+
FUZZ_OUT_NAME="${project}_${FUZZ_TARGET_NAME}"
38+
39+
cp "$FUZZ_TARGET_OUTPUT_DIR/$FUZZ_TARGET_NAME" "$OUT/$FUZZ_OUT_NAME"
40+
done
41+
42+
popd
43+
done
44+
45+
exit 0

.clusterfuzzlite/project.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
homepage: "https://github.com/filecoin-project/ref-fvm"
2+
main_repo: "https://github.com/filecoin-project/ref-fvm"
3+
primary_contact: "[email protected]"
4+
auto_ccs :
5+
6+
7+
8+
language: rust
9+
fuzzing_engines:
10+
- libfuzzer
11+
sanitizers:
12+
- address

.github/workflows/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Fuzzing setup
2+
3+
ref-fvm uses [ClusterFuzzLite](https://google.github.io/clusterfuzzlite/) for contious fuzzing.
4+
This consists of four workflows:
5+
- `cflite_pr.yml` - responsible for running fuzzing for PRs, it will only fuzz targets when diff affects files covered by given fuzzing target
6+
- `cflite_build.yml` - responsible for building fuzzing targets on master branch and storing them for recall. These recalled targets are used to detect if crasher is a new thing caused by changes or a newely discovered input which will also cause crash on master.
7+
- `cflite_batch.yml` - periodically (every 6h for 1h) runs fuzzing to develop the corpus which will be used for other on-demand fuzzing and as seed corpus for OSS-Fuzz.
8+
- `cflite_cron.yml` - every day generates coverage reports, as well as, prunes and mimizes the corpus.
9+
10+
11+
Corpus and coverage data is stored within https://github.com/filecoin-project/ref-fvm-fuzz-corpora
12+
13+

.github/workflows/cflite_batch.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: ClusterFuzzLite batch fuzzing
2+
on:
3+
schedule:
4+
- cron: '0 0/6 * * *' # Every 6th hour. Change this to whatever is suitable.
5+
permissions: read-all
6+
jobs:
7+
BatchFuzzing:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
sanitizer:
13+
- address
14+
steps:
15+
- name: Build Fuzzers (${{ matrix.sanitizer }})
16+
id: build
17+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
18+
with:
19+
sanitizer: ${{ matrix.sanitizer }}
20+
- name: Run Fuzzers (${{ matrix.sanitizer }})
21+
id: run
22+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
23+
with:
24+
github-token: ${{ secrets.GITHUB_TOKEN }}
25+
fuzz-seconds: 3600
26+
mode: 'batch'
27+
sanitizer: ${{ matrix.sanitizer }}
28+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
29+
storage-repo-branch: master
30+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
31+

.github/workflows/cflite_build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: ClusterFuzzLite continuous builds
2+
on:
3+
push:
4+
branches:
5+
- master
6+
permissions: read-all
7+
jobs:
8+
Build:
9+
runs-on: ubuntu-latest
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
sanitizer:
17+
- address
18+
steps:
19+
- name: Build Fuzzers (${{ matrix.sanitizer }})
20+
id: build
21+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
22+
with:
23+
sanitizer: ${{ matrix.sanitizer }}
24+
upload-build: true
25+

.github/workflows/cflite_cron.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: ClusterFuzzLite cron tasks
2+
on:
3+
schedule:
4+
- cron: '30 1 * * *' # Once a day at 1:30 to run past batch job
5+
permissions: read-all
6+
jobs:
7+
Pruning:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Build Fuzzers
11+
id: build
12+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
13+
- name: Run Fuzzers
14+
id: run
15+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
16+
with:
17+
github-token: ${{ secrets.GITHUB_TOKEN }}
18+
fuzz-seconds: 600
19+
mode: 'prune'
20+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
21+
storage-repo-branch: master
22+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
23+
Coverage:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Build Fuzzers
27+
id: build
28+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
29+
with:
30+
sanitizer: coverage
31+
- name: Run Fuzzers
32+
id: run
33+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
34+
with:
35+
github-token: ${{ secrets.GITHUB_TOKEN }}
36+
fuzz-seconds: 600
37+
mode: 'coverage'
38+
sanitizer: 'coverage'
39+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
40+
storage-repo-branch: master
41+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
42+

.github/workflows/cflite_pr.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ClusterFuzzLite PR fuzzing
2+
on:
3+
pull_request:
4+
paths:
5+
- '**'
6+
permissions: read-all
7+
jobs:
8+
PR:
9+
runs-on: ubuntu-latest
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
sanitizer:
17+
- address
18+
steps:
19+
- name: Build Fuzzers (${{ matrix.sanitizer }})
20+
id: build
21+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
sanitizer: ${{ matrix.sanitizer }}
25+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
26+
storage-repo-branch: master
27+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
28+
- name: Run Fuzzers (${{ matrix.sanitizer }})
29+
id: run
30+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
31+
with:
32+
github-token: ${{ secrets.GITHUB_TOKEN }}
33+
fuzz-seconds: 600
34+
mode: 'code-change'
35+
sanitizer: ${{ matrix.sanitizer }}
36+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
37+
storage-repo-branch: master
38+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
39+

ipld/amt/fuzz/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
target
3-
corpus
43
artifacts
54
Cargo.lock
65
/fuzz-*

ipld/amt/fuzz/corpus

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)