From 2f13f989d9c9c31c076a89b81fd2e3bfc9c83cd8 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Thu, 21 Dec 2023 06:46:29 -0800 Subject: [PATCH 1/2] Add ClusterFuzzLite integration Signed-off-by: David Korczynski --- .clusterfuzzlite/Dockerfile | 6 ++++++ .clusterfuzzlite/README.md | 3 +++ .clusterfuzzlite/build.sh | 7 +++++++ .clusterfuzzlite/parser_fuzzer.cpp | 11 +++++++++++ .clusterfuzzlite/project.yaml | 1 + .github/workflows/cflite_pr.yml | 30 ++++++++++++++++++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 .clusterfuzzlite/Dockerfile create mode 100644 .clusterfuzzlite/README.md create mode 100644 .clusterfuzzlite/build.sh create mode 100644 .clusterfuzzlite/parser_fuzzer.cpp create mode 100644 .clusterfuzzlite/project.yaml create mode 100644 .github/workflows/cflite_pr.yml diff --git a/.clusterfuzzlite/Dockerfile b/.clusterfuzzlite/Dockerfile new file mode 100644 index 0000000..117769a --- /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/maddy +COPY .clusterfuzzlite/build.sh $SRC/build.sh +WORKDIR $SRC/maddy \ No newline at end of file diff --git a/.clusterfuzzlite/README.md b/.clusterfuzzlite/README.md new file mode 100644 index 0000000..01b79f5 --- /dev/null +++ b/.clusterfuzzlite/README.md @@ -0,0 +1,3 @@ +# 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 0000000..a330105 --- /dev/null +++ b/.clusterfuzzlite/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +# Copy all fuzzer executables to $OUT/ +$CXX $CFLAGS $LIB_FUZZING_ENGINE \ + $SRC/maddy/.clusterfuzzlite/parser_fuzzer.cpp \ + -o $OUT/parser_fuzzer \ + -I$SRC/maddy/include diff --git a/.clusterfuzzlite/parser_fuzzer.cpp b/.clusterfuzzlite/parser_fuzzer.cpp new file mode 100644 index 0000000..583675f --- /dev/null +++ b/.clusterfuzzlite/parser_fuzzer.cpp @@ -0,0 +1,11 @@ +#include "maddy/parser.h" +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + std::string payload(reinterpret_cast(data), size); + auto parser = std::make_shared(); + std::stringstream markdown(payload); + parser->Parse(markdown); + + return 0; +} \ No newline at end of file diff --git a/.clusterfuzzlite/project.yaml b/.clusterfuzzlite/project.yaml new file mode 100644 index 0000000..7f563eb --- /dev/null +++ b/.clusterfuzzlite/project.yaml @@ -0,0 +1 @@ +language: c++ \ 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 0000000..b6d47da --- /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 }} \ No newline at end of file From e2bdd02f73fd4d7f397c8657fba5098430efd0e2 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Sat, 23 Dec 2023 03:22:27 -0800 Subject: [PATCH 2/2] cflite: fix branch name Signed-off-by: David Korczynski --- .github/workflows/cflite_pr.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cflite_pr.yml b/.github/workflows/cflite_pr.yml index b6d47da..6ac7bd1 100644 --- a/.github/workflows/cflite_pr.yml +++ b/.github/workflows/cflite_pr.yml @@ -2,7 +2,7 @@ name: ClusterFuzzLite PR fuzzing on: workflow_dispatch: pull_request: - branches: [ main ] + branches: [ master ] permissions: read-all jobs: PR: @@ -27,4 +27,4 @@ jobs: fuzz-seconds: 180 mode: 'code-change' report-unreproducible-crashes: false - sanitizer: ${{ matrix.sanitizer }} \ No newline at end of file + sanitizer: ${{ matrix.sanitizer }}