ci: add fuzzer workflow

Squashed commit of the following:

commit b13ab5d298da1472e27254b801e21b26fe8c5e3f
Merge: 2feb35e 26212f3
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Mon Jun 17 00:08:04 2024 +0900

    [skip appveyor] Merge branch 'main' into fuzzing

commit 2feb35e83e3f2f9b68f5e2074c9ddbce9a8b0ebc
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Mon Jun 17 00:07:34 2024 +0900

    fix: call destructor correctly

commit c6078b5afec054bd7f488c4de8cbbd719fa89d3b
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Mon Jun 17 00:07:12 2024 +0900

    feat: add SFINAE to template ctor of result

commit 850ea75bae7c7f54bde653cd99c066240bd95674
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Sun Jun 16 22:16:17 2024 +0900

    fix: path to fuzzer impl

commit e91edeae96b48b243b97c96f36ca027cace6925b
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Sun Jun 16 22:10:07 2024 +0900

    ci[skip appveyor]: move fuzzing dir to default dir

commit 3bd51f2047936e9abb6dd47e627379b04d711d2b
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Sun Jun 16 21:46:56 2024 +0900

    ci[skip appveyor]: temporary remove other workflows

    until fuzzer works

commit 847a76e089e12302557ba7ffd699d2b26e3e954a
Author: ToruNiina <niina.toru.68u@gmail.com>
Date:   Sun Jun 16 21:46:02 2024 +0900

    ci[skip appveyor]: add fuzzer workflow
This commit is contained in:
ToruNiina 2024-06-17 00:20:45 +09:00
parent 26212f3536
commit f317cc0448
6 changed files with 56 additions and 0 deletions

View File

@ -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/toml11
COPY .clusterfuzzlite/build.sh $SRC/build.sh
WORKDIR $SRC/toml11

View File

@ -0,0 +1,3 @@
# ClusterFuzzLite set up
This folder contains a fuzzing set for [ClusterFuzzLite](https://google.github.io/clusterfuzzlite).

View File

@ -0,0 +1,6 @@
#!/bin/bash -eu
# Copy fuzzer executable to $OUT/
$CXX $CFLAGS $LIB_FUZZING_ENGINE \
$SRC/toml11/.clusterfuzzlite/parse_fuzzer.cpp \
-o $OUT/parse_fuzzer \
-I$SRC/toml11/include/

View File

@ -0,0 +1,10 @@
#include <toml.hpp>
#include <string>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
std::string s(reinterpret_cast<const char *>(data), size);
const auto ref = toml::try_parse_str(s);
return 0;
}

View File

@ -0,0 +1 @@
language: c++

30
.github/workflows/fuzzing.yml vendored Normal file
View File

@ -0,0 +1,30 @@
name: ClusterFuzzLite fuzzing
on: [push, pull_request]
permissions: read-all
jobs:
fuzzing:
runs-on: ubuntu-22.04
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: 240
mode: 'code-change'
report-unreproducible-crashes: false
sanitizer: ${{ matrix.sanitizer }}