From cd02d2fa5931e81b650f7f216f557af99ed18df8 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Thu, 21 Dec 2023 14:04:57 -0800 Subject: [PATCH] Add ClusterFuzzLite set up Signed-off-by: David Korczynski --- .clusterfuzzlite/Dockerfile | 6 ++++++ .clusterfuzzlite/README.md | 4 ++++ .clusterfuzzlite/build.sh | 8 ++++++++ .clusterfuzzlite/project.yaml | 1 + .clusterfuzzlite/validate_fuzzer.c | 7 +++++++ .github/workflows/cflite_pr.yml | 30 ++++++++++++++++++++++++++++++ 6 files changed, 56 insertions(+) create mode 100644 .clusterfuzzlite/Dockerfile create mode 100644 .clusterfuzzlite/README.md create mode 100644 .clusterfuzzlite/build.sh create mode 100644 .clusterfuzzlite/project.yaml create mode 100644 .clusterfuzzlite/validate_fuzzer.c create mode 100644 .github/workflows/cflite_pr.yml diff --git a/.clusterfuzzlite/Dockerfile b/.clusterfuzzlite/Dockerfile new file mode 100644 index 00000000..014f0c0c --- /dev/null +++ b/.clusterfuzzlite/Dockerfile @@ -0,0 +1,6 @@ +FROM gcr.io/oss-fuzz-base/base-builder +RUN apt-get update && apt-get install -y make autoconf automake libtool + +COPY . $SRC/corejson +COPY .clusterfuzzlite/build.sh $SRC/build.sh +WORKDIR $SRC/corejson \ No newline at end of file diff --git a/.clusterfuzzlite/README.md b/.clusterfuzzlite/README.md new file mode 100644 index 00000000..6461d7a0 --- /dev/null +++ b/.clusterfuzzlite/README.md @@ -0,0 +1,4 @@ +# ClusterFuzzLite set up + +This folder contains a fuzzing set for [ClusterFuzzLite](https://google.github.io/clusterfuzzlite). + \ No newline at end of file diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh new file mode 100644 index 00000000..bbdc35ce --- /dev/null +++ b/.clusterfuzzlite/build.sh @@ -0,0 +1,8 @@ +#!/bin/bash -eu + +# Copy the fuzzer executable to $OUT/ +$CC $CFLAGS $LIB_FUZZING_ENGINE \ + $SRC/corejson/.clusterfuzzlite/validate_fuzzer.c \ + $SRC/corejson/source/core_json.c \ + -I$SRC/corejson/source/include \ + -o $OUT/validate_fuzzer diff --git a/.clusterfuzzlite/project.yaml b/.clusterfuzzlite/project.yaml new file mode 100644 index 00000000..e196c5cc --- /dev/null +++ b/.clusterfuzzlite/project.yaml @@ -0,0 +1 @@ +language: c \ No newline at end of file diff --git a/.clusterfuzzlite/validate_fuzzer.c b/.clusterfuzzlite/validate_fuzzer.c new file mode 100644 index 00000000..3b1b8e47 --- /dev/null +++ b/.clusterfuzzlite/validate_fuzzer.c @@ -0,0 +1,7 @@ +#include +#include + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + JSON_Validate((char *)data, size); + return 0; +} \ No newline at end of file diff --git a/.github/workflows/cflite_pr.yml b/.github/workflows/cflite_pr.yml new file mode 100644 index 00000000..1c8f7cc3 --- /dev/null +++ b/.github/workflows/cflite_pr.yml @@ -0,0 +1,30 @@ +name: ClusterFuzzLite PR fuzzing +on: + workflow_dispatch: + pull_request: + branches: [ main ] +permissions: read-all +jobs: + PR: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sanitizer: [address] + steps: + - name: Build Fuzzers (${{ matrix.sanitizer }}) + id: build + uses: google/clusterfuzzlite/actions/build_fuzzers@v1 + with: + sanitizer: ${{ matrix.sanitizer }} + language: c + bad-build-check: false + - name: Run Fuzzers (${{ matrix.sanitizer }}) + id: run + uses: google/clusterfuzzlite/actions/run_fuzzers@v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fuzz-seconds: 180 + mode: 'code-change' + report-unreproducible-crashes: false + sanitizer: ${{ matrix.sanitizer }}