Skip to content

Commit dd37c05

Browse files
Jonathan D.A. Jewellclaude
andcommitted
feat: add ClusterFuzzLite fuzzing configuration
Add comprehensive fuzzing infrastructure: - cargo-fuzz configuration - ClusterFuzzLite Docker build - PR fuzzing workflow (5 min) - Weekly batch fuzzing (30 min) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent a12ff30 commit dd37c05

File tree

7 files changed

+103
-0
lines changed

7 files changed

+103
-0
lines changed

.clusterfuzzlite/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM gcr.io/oss-fuzz-base/base-builder-rust
2+
RUN apt-get update && apt-get install -y make autoconf automake libtool
3+
COPY . $SRC/project
4+
WORKDIR $SRC/project
5+
COPY .clusterfuzzlite/build.sh $SRC/

.clusterfuzzlite/build.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash -eu
2+
3+
cd $SRC/project
4+
cargo +nightly fuzz build --release
5+
cp fuzz/target/*/release/fuzz_* $OUT/

.clusterfuzzlite/project.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
language: rust
2+
sanitizers:
3+
- address
4+
- undefined

.github/workflows/cflite_batch.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
name: ClusterFuzzLite Batch
3+
on:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
permissions: read-all
7+
jobs:
8+
BatchFuzzing:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
sanitizer: [address, undefined]
14+
steps:
15+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
16+
- uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
17+
with:
18+
sanitizer: ${{ matrix.sanitizer }}
19+
language: rust
20+
- uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
fuzz-seconds: 1800
24+
sanitizer: ${{ matrix.sanitizer }}
25+
mode: batch
26+
output-sarif: true
27+
- uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3
28+
if: always()
29+
with:
30+
sarif_file: vulnerabilities.sarif

.github/workflows/cflite_pr.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SPDX-License-Identifier: PMPL-1.0-or-later
2+
name: ClusterFuzzLite PR
3+
on:
4+
pull_request:
5+
paths:
6+
- '**/*.rs'
7+
permissions: read-all
8+
jobs:
9+
PR:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
sanitizer: [address, undefined]
15+
steps:
16+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
17+
- uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
18+
with:
19+
sanitizer: ${{ matrix.sanitizer }}
20+
language: rust
21+
- uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
22+
with:
23+
github-token: ${{ secrets.GITHUB_TOKEN }}
24+
fuzz-seconds: 300
25+
sanitizer: ${{ matrix.sanitizer }}
26+
mode: code-change
27+
output-sarif: true
28+
- uses: github/codeql-action/upload-sarif@662472033e021d55d94146f66f6058822b0b39fd # v3
29+
if: always()
30+
with:
31+
sarif_file: vulnerabilities.sarif

fuzz/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "fuzz"
3+
version = "0.0.0"
4+
publish = false
5+
edition = "2021"
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4"
12+
13+
[dependencies.conative-gating]
14+
path = ".."
15+
16+
[[bin]]
17+
name = "fuzz_main"
18+
path = "fuzz_targets/fuzz_main.rs"
19+
test = false
20+
doc = false

fuzz/fuzz_targets/fuzz_main.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![no_main]
2+
use libfuzzer_sys::fuzz_target;
3+
4+
fuzz_target!(|data: &[u8]| {
5+
// TODO: Customize fuzzing logic for this repo
6+
// Example: parse input, test functions, etc.
7+
let _ = std::str::from_utf8(data);
8+
});

0 commit comments

Comments
 (0)