-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds [ClusterFuzzLite](https://github.com/google/clusterfuzzlite) integration with an accompanying fuzzer. In short, this will run the fuzzer on each PR and report if any issues are found in the code. Signed-off-by: David Korczynski <[email protected]>
- Loading branch information
1 parent
05d2b4e
commit 1c4a22c
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/yazi-json | ||
COPY .clusterfuzzlite/build.sh $SRC/build.sh | ||
WORKDIR $SRC/yazi-json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ClusterFuzzLite set up | ||
This folder contains a fuzzing set for [ClusterFuzzLite](https://google.github.io/clusterfuzzlite). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash -eu | ||
sed -i 's/g++/${CXX}/g' Makefile | ||
sed -i 's/-Werror//g' Makefile | ||
make | ||
|
||
# Copy all fuzzer executables to $OUT/ | ||
$CXX $CFLAGS $LIB_FUZZING_ENGINE \ | ||
$SRC/yazi-json/.clusterfuzzlite/parse_fuzzer.cpp \ | ||
-o $OUT/parse_fuzzer \ | ||
-I$SRC/yazi-json/json \ | ||
json/Parser.o json/Json.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <Json.h> | ||
#include <string> | ||
|
||
using namespace yazi::json; | ||
|
||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
std::string fuzz_input(reinterpret_cast<const char *>(data), size); | ||
|
||
Json json; | ||
try { | ||
json.parse(fuzz_input.c_str()); | ||
} catch (...) { | ||
} | ||
json.clear(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
language: c++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |