Skip to content

Commit 3543bab

Browse files
committed
Add clusterfuzzlite integration
Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 75aed98 commit 3543bab

File tree

7 files changed

+225
-0
lines changed

7 files changed

+225
-0
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/cflite_batch.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: ClusterFuzzLite batch fuzzing
2+
on:
3+
schedule:
4+
- cron: '0 0/12 * * *' # Every 12th 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+
# Optional but recommended: For storing certain artifacts from fuzzing.
29+
# See later section on "Git repo for storage".
30+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
31+
storage-repo-branch: lite
32+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
33+

.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 # Use your actual default branch here.
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: '0 0 * * *' # Once a day at midnight.
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: lite
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: lite
41+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
42+

.github/workflows/cflite_pr.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
# Override this with the sanitizers you want.
19+
# - undefined
20+
# - memory
21+
steps:
22+
- name: Build Fuzzers (${{ matrix.sanitizer }})
23+
id: build
24+
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
sanitizer: ${{ matrix.sanitizer }}
28+
# Optional but recommended: used to only run fuzzers that are affected
29+
# by the PR.
30+
# See later section on "Git repo for storage".
31+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
32+
storage-repo-branch: lite
33+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
34+
- name: Run Fuzzers (${{ matrix.sanitizer }})
35+
id: run
36+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
37+
with:
38+
github-token: ${{ secrets.GITHUB_TOKEN }}
39+
fuzz-seconds: 600
40+
mode: 'code-change'
41+
sanitizer: ${{ matrix.sanitizer }}
42+
# Optional but recommended: used to download the corpus produced by
43+
# batch fuzzing.
44+
# See later section on "Git repo for storage".
45+
storage-repo: https://${{ secrets.FILHELPER_PAT }}@github.com/filecoin-project/ref-fvm-fuzz-corpora.git
46+
storage-repo-branch: lite
47+
storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
48+

0 commit comments

Comments
 (0)