From cc21e612d93a8beeb82b3f735b328ac2a9d62b43 Mon Sep 17 00:00:00 2001 From: Raj Shah Date: Fri, 18 Nov 2022 22:57:03 +0000 Subject: [PATCH] Add harness --- .github/workflows/mayhem.yml | 3 ++- mayhem/Dockerfile | 5 ++++- mayhem/{Mayhemfile => Mayhemfile_cnip} | 0 mayhem/Mayhemfile_fullDir | 6 ++++++ mayhem/fuzz_fullDir.cpp | 19 +++++++++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) rename mayhem/{Mayhemfile => Mayhemfile_cnip} (100%) create mode 100644 mayhem/Mayhemfile_fullDir create mode 100644 mayhem/fuzz_fullDir.cpp diff --git a/.github/workflows/mayhem.yml b/.github/workflows/mayhem.yml index f7e20fcf..c4672aab 100644 --- a/.github/workflows/mayhem.yml +++ b/.github/workflows/mayhem.yml @@ -51,7 +51,8 @@ jobs: fail-fast: false matrix: mayhemfile: - - mayhem/Mayhemfile + - mayhem/Mayhemfile_cnip + - mayhem/Mayhemfile_fullDir steps: - uses: actions/checkout@v2 diff --git a/mayhem/Dockerfile b/mayhem/Dockerfile index 9cf875f4..278b5ffa 100644 --- a/mayhem/Dockerfile +++ b/mayhem/Dockerfile @@ -1,15 +1,18 @@ FROM --platform=linux/amd64 ubuntu:22.04 as builder RUN apt-get update -RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake +RUN DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential cmake clang COPY . /repo WORKDIR /repo/build RUN cmake .. RUN make -j8 +WORKDIR /repo +RUN clang++ /repo/mayhem/fuzz.cpp utility/*.cpp tools/*.cpp -fsanitize=fuzzer -o /fuzz -Iutility/ -I. FROM ubuntu:22.04 as package COPY --from=builder /repo/build/cnip / COPY --from=builder /repo/build/C/* /deps/ COPY --from=builder /repo/build/common/* /deps/ +COPY --from=builder /fuzz /fuzz_fulldir ENV LD_LIBRARY_PATH=/deps \ No newline at end of file diff --git a/mayhem/Mayhemfile b/mayhem/Mayhemfile_cnip similarity index 100% rename from mayhem/Mayhemfile rename to mayhem/Mayhemfile_cnip diff --git a/mayhem/Mayhemfile_fullDir b/mayhem/Mayhemfile_fullDir new file mode 100644 index 00000000..1c7652e7 --- /dev/null +++ b/mayhem/Mayhemfile_fullDir @@ -0,0 +1,6 @@ +project: psychec +target: fulldir + +cmds: + - cmd: /fuzz_fullDir + libfuzzer: true \ No newline at end of file diff --git a/mayhem/fuzz_fullDir.cpp b/mayhem/fuzz_fullDir.cpp new file mode 100644 index 00000000..fe07d41c --- /dev/null +++ b/mayhem/fuzz_fullDir.cpp @@ -0,0 +1,19 @@ + +#include +#include +#include +#include +#include +#include +#include "utility/FileInfo.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + FuzzedDataProvider provider(data, size); + std::string str = provider.ConsumeRandomLengthString(); + + psy::FileInfo fi(str); + fi.fullDir(); + + return 0; +} \ No newline at end of file