Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/argparse
COPY .clusterfuzzlite/build.sh $SRC/build.sh
WORKDIR $SRC/argparse
3 changes: 3 additions & 0 deletions .clusterfuzzlite/README.md
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).
6 changes: 6 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copy all fuzzer executables to $OUT/
$CXX $CFLAGS $LIB_FUZZING_ENGINE \
$SRC/argparse/.clusterfuzzlite/fuzz_argparse.cpp \
-o $OUT/fuzz_argparse \
-std=gnu++17 \
-I$SRC/argparse/include
34 changes: 34 additions & 0 deletions .clusterfuzzlite/fuzz_argparse.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <argparse/argparse.hpp>
#include <fuzzer/FuzzedDataProvider.h>
#include <string>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
FuzzedDataProvider fdp(data, size);

int args_to_generate = fdp.ConsumeIntegralInRange<int>(1, 10);
std::vector<std::string> fuzz_args;
for (int i = 0; i < args_to_generate; i++) {
fuzz_args.push_back(fdp.ConsumeRandomLengthString());
}

// Ensure none of the strings have sequences that cause exit:
// "-h", "--help", "-v", "--version"
for (int i = 0; i < args_to_generate; i++) {
if (fuzz_args[i].find("-h") != std::string::npos ||
fuzz_args[i].find("-v") != std::string::npos) {
return 0;
}
}

argparse::ArgumentParser program("test");
program.add_argument("--config");
program.add_argument("--test");
program.add_argument("--fuzzval");
program.add_argument("--param");
try {
program.parse_args(fuzz_args);
} catch (...) {
}

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for setting id in here? I don't see it required anywhere.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not needed! Removed them.

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: 120
mode: 'code-change'
report-unreproducible-crashes: false
sanitizer: ${{ matrix.sanitizer }}