Skip to content

Commit fc6124e

Browse files
Jonathan D.A. Jewellclaude
andcommitted
Add ClusterFuzzLite fuzzing infrastructure
- Add .clusterfuzzlite/ with project.yaml, Dockerfile, build.sh - Add fuzz/ with generic fuzz target - Add PR and batch fuzzing workflows Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 6037fce commit fc6124e

File tree

7 files changed

+123
-0
lines changed

7 files changed

+123
-0
lines changed

.clusterfuzzlite/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
FROM gcr.io/oss-fuzz-base/base-builder-rust@sha256:73c1d5648db54100639339d411a5d192cbc8bf413ee91e843a07cf6f0e319dc7
3+
4+
COPY . $SRC/echidna
5+
WORKDIR $SRC/echidna
6+
7+
COPY .clusterfuzzlite/build.sh $SRC/

.clusterfuzzlite/build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash -eu
2+
# SPDX-License-Identifier: PMPL-1.0
3+
cd $SRC/echidna
4+
cargo +nightly fuzz build
5+
for target in $(cargo +nightly fuzz list); do
6+
cp ./target/x86_64-unknown-linux-gnu/release/$target $OUT/
7+
done

.clusterfuzzlite/project.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
language: rust

.github/workflows/cflite_batch.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
name: ClusterFuzzLite batch fuzzing
3+
on:
4+
schedule:
5+
- cron: '0 3 * * 0'
6+
workflow_dispatch:
7+
8+
permissions: read-all
9+
10+
jobs:
11+
BatchFuzzing:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
sanitizer: [address]
17+
steps:
18+
- name: Build Fuzzers (${{ matrix.sanitizer }})
19+
id: build
20+
uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
21+
with:
22+
language: rust
23+
sanitizer: ${{ matrix.sanitizer }}
24+
25+
- name: Run Fuzzers (${{ matrix.sanitizer }})
26+
id: run
27+
uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
28+
with:
29+
github-token: ${{ secrets.GITHUB_TOKEN }}
30+
fuzz-seconds: 1800
31+
mode: batch
32+
sanitizer: ${{ matrix.sanitizer }}

.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
2+
name: ClusterFuzzLite PR fuzzing
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
permissions: read-all
8+
9+
jobs:
10+
PR:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
sanitizer: [address]
16+
steps:
17+
- name: Build Fuzzers (${{ matrix.sanitizer }})
18+
id: build
19+
uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
20+
with:
21+
language: rust
22+
sanitizer: ${{ matrix.sanitizer }}
23+
24+
- name: Run Fuzzers (${{ matrix.sanitizer }})
25+
id: run
26+
uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
fuzz-seconds: 300
30+
mode: code-change
31+
sanitizer: ${{ matrix.sanitizer }}

fuzz/Cargo.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: PMPL-1.0
2+
[package]
3+
name = "echidna-fuzz"
4+
version = "0.0.0"
5+
authors = ["hyperpolymath"]
6+
publish = false
7+
edition = "2021"
8+
9+
[package.metadata]
10+
cargo-fuzz = true
11+
12+
[dependencies]
13+
libfuzzer-sys = "0.4"
14+
arbitrary = { version = "1", features = ["derive"] }
15+
16+
[dependencies.echidna]
17+
path = ".."
18+
19+
[[bin]]
20+
name = "fuzz_input"
21+
path = "fuzz_targets/fuzz_input.rs"
22+
test = false
23+
doc = false
24+
bench = false

fuzz/fuzz_targets/fuzz_input.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: PMPL-1.0
2+
//! Generic fuzz target for arbitrary input processing
3+
4+
#![no_main]
5+
6+
use libfuzzer_sys::fuzz_target;
7+
8+
fuzz_target!(|data: &[u8]| {
9+
// Fuzz with arbitrary byte input
10+
// This exercises any parsing/processing functions with random data
11+
if let Ok(input) = std::str::from_utf8(data) {
12+
// Try to process the input as text
13+
let _ = input.trim();
14+
let _ = input.lines().count();
15+
}
16+
17+
// Exercise the data directly as bytes
18+
let _ = data.len();
19+
let _ = data.is_empty();
20+
});

0 commit comments

Comments
 (0)