Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClusterFuzzLite integration #122

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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/simdzone
COPY .clusterfuzzlite/build.sh $SRC/build.sh
WORKDIR $SRC/simdzone
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).

13 changes: 13 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: c
43 changes: 43 additions & 0 deletions .clusterfuzzlite/zone_parse_string_fuzzer.c
Original file line number Diff line number Diff line change
@@ -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;
}
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: 180
mode: 'code-change'
report-unreproducible-crashes: false
sanitizer: ${{ matrix.sanitizer }}