diff --git a/.clusterfuzzlite/Dockerfile b/.clusterfuzzlite/Dockerfile new file mode 100644 index 0000000..1a2c119 --- /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/simdzone +COPY .clusterfuzzlite/build.sh $SRC/build.sh +WORKDIR $SRC/simdzone \ No newline at end of file diff --git a/.clusterfuzzlite/README.md b/.clusterfuzzlite/README.md new file mode 100644 index 0000000..175ac4a --- /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..8028c10 --- /dev/null +++ b/.clusterfuzzlite/build.sh @@ -0,0 +1,13 @@ +#!/bin/bash -eu +mkdir build +cd build +cmake .. +make + +# Copy all fuzzer executables to $OUT/ +$CC $CFLAGS $LIB_FUZZING_ENGINE \ + $SRC/simdzone/.clusterfuzzlite/zone_parse_string_fuzzer.c \ + -o $OUT/zone_parse_string_fuzzer \ + -I$SRC/simdzone/include \ + -I$SRC/simdzone/build/include \ + $SRC/simdzone/build/libzone.a diff --git a/.clusterfuzzlite/project.yaml b/.clusterfuzzlite/project.yaml new file mode 100644 index 0000000..e196c5c --- /dev/null +++ b/.clusterfuzzlite/project.yaml @@ -0,0 +1 @@ +language: c \ No newline at end of file diff --git a/.clusterfuzzlite/zone_parse_string_fuzzer.c b/.clusterfuzzlite/zone_parse_string_fuzzer.c new file mode 100644 index 0000000..80b4cec --- /dev/null +++ b/.clusterfuzzlite/zone_parse_string_fuzzer.c @@ -0,0 +1,43 @@ +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "zone.h" + +static int32_t add_rr(zone_parser_t *parser, const zone_name_t *owner, + uint16_t type, uint16_t class, uint32_t ttl, + uint16_t rdlength, const uint8_t *rdata, + void *user_data) { + (void)parser; + (void)owner; + (void)type; + (void)class; + (void)ttl; + (void)rdlength; + (void)rdata; + (void)user_data; + return ZONE_SUCCESS; +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + size_t size_of_input = size + ZONE_BLOCK_SIZE + 1; + char *null_terminated = (char*)malloc(size_of_input); + memcpy(null_terminated, data, size); + null_terminated[size] = '\0'; + + zone_parser_t parser = {0}; + zone_name_buffer_t name; + zone_rdata_buffer_t rdata; + zone_buffers_t buffers = {1, &name, &rdata}; + zone_options_t options = {0}; + + options.accept.callback = add_rr; + options.origin = "example.com."; + options.default_ttl = 3600; + options.default_class = 1; + + zone_parse_string(&parser, &options, &buffers, null_terminated, size, NULL); + + free(null_terminated); + return 0; +} diff --git a/.github/workflows/cflite_pr.yml b/.github/workflows/cflite_pr.yml new file mode 100644 index 0000000..1c8f7cc --- /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 }}