Skip to content

Commit

Permalink
ClusterFuzzLite integration
Browse files Browse the repository at this point in the history
Signed-off-by: David Korczynski <[email protected]>
  • Loading branch information
DavidKorczynski committed Dec 21, 2023
1 parent f032c52 commit a19a891
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/rapidcsv
COPY .clusterfuzzlite/build.sh $SRC/build.sh
WORKDIR $SRC/rapidcsv
4 changes: 4 additions & 0 deletions .clusterfuzzlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ClusterFuzzLite set up

This folder holds logic for fuzzing by way of [ClusterfuzzLite](https://google.github.io/clusterfuzzlite).

5 changes: 5 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copy all fuzzer executables to $OUT/
$CXX $CFLAGS $LIB_FUZZING_ENGINE \
$SRC/rapidcsv/.clusterfuzzlite/fuzz_parser.cpp \
-o $OUT/fuzz_parser \
-I$SRC/rapidcsv/src
18 changes: 18 additions & 0 deletions .clusterfuzzlite/fuzz_parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <fstream>
#include <rapidcsv.h>
#include <string>

using namespace std;

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
std::string fuzz_payload(reinterpret_cast<const char *>(data), size);

ofstream myfile;
myfile.open("/tmp/fuzz.csv");
myfile << fuzz_payload;
myfile.close();

rapidcsv::Document doc("/tmp/fuzz.csv");

return 0;
}
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: c++
30 changes: 30 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -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: 100
mode: 'code-change'
report-unreproducible-crashes: false
sanitizer: ${{ matrix.sanitizer }}

0 comments on commit a19a891

Please sign in to comment.