Skip to content

Commit 0423144

Browse files
Add ClusterFuzzLite set up (#154)
* Add ClusterFuzzLite set up Signed-off-by: David Korczynski <[email protected]> * Extend ClusterFuzzLite README Signed-off-by: David Korczynski <[email protected]> * Add newlines to ClusterFuzzLite Signed-off-by: David Korczynski <[email protected]> * ClusterFuzzLite: nit Signed-off-by: David Korczynski <[email protected]> --------- Signed-off-by: David Korczynski <[email protected]>
1 parent 8c7ba86 commit 0423144

File tree

6 files changed

+74
-0
lines changed

6 files changed

+74
-0
lines changed

.clusterfuzzlite/Dockerfile

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

.clusterfuzzlite/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ClusterFuzzLite set up
2+
3+
This folder contains a fuzzing set for [ClusterFuzzLite](https://google.github.io/clusterfuzzlite).
4+
5+
6+
## Running the fuzzer locally
7+
8+
To reproduce the fuzzing by way of [OSS-Fuzz](https://github.com/google/oss-fuzz) (which ClusterFuzzLite will be using):
9+
10+
```sh
11+
git clone https://github.com/google/oss-fuzz
12+
13+
# Notice the destination folder shuold be in lower case.
14+
git clone https://github.com/FreeRTOS/coreJSON corejson
15+
cd corejson
16+
17+
# Build the fuzzers in .clusterfuzzlite
18+
python3 ../oss-fuzz/infra/helper.py build_fuzzers --external $PWD
19+
20+
# Run the fuzzer for 180 seconds
21+
python3 ../oss-fuzz/infra/helper.py run_fuzzer --external $PWD validate_fuzzer -- -max_total_time=180
22+
```

.clusterfuzzlite/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash -eu
2+
3+
# Copy the fuzzer executable to $OUT/
4+
$CC $CFLAGS $LIB_FUZZING_ENGINE \
5+
$SRC/corejson/.clusterfuzzlite/validate_fuzzer.c \
6+
$SRC/corejson/source/core_json.c \
7+
-I$SRC/corejson/source/include \
8+
-o $OUT/validate_fuzzer

.clusterfuzzlite/project.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
language: c

.clusterfuzzlite/validate_fuzzer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <core_json.h>
2+
#include <stdint.h>
3+
4+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
5+
JSON_Validate((char *)data, size);
6+
return 0;
7+
}

.github/workflows/cflite_pr.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ClusterFuzzLite PR fuzzing
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
branches: [ main ]
6+
permissions: read-all
7+
jobs:
8+
PR:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
sanitizer: [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+
language: c
21+
bad-build-check: false
22+
- name: Run Fuzzers (${{ matrix.sanitizer }})
23+
id: run
24+
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
25+
with:
26+
github-token: ${{ secrets.GITHUB_TOKEN }}
27+
fuzz-seconds: 180
28+
mode: 'code-change'
29+
report-unreproducible-crashes: false
30+
sanitizer: ${{ matrix.sanitizer }}

0 commit comments

Comments
 (0)