From dd3e38d3e86c76c869ad2ffbe7cd77c38c106c06 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sat, 20 Jul 2024 18:55:39 +0200 Subject: [PATCH] sharp: add seed corpus (#12256) --- projects/sharp/Dockerfile | 2 ++ projects/sharp/build.sh | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/projects/sharp/Dockerfile b/projects/sharp/Dockerfile index c16814970..e155b8e94 100644 --- a/projects/sharp/Dockerfile +++ b/projects/sharp/Dockerfile @@ -16,6 +16,8 @@ FROM gcr.io/oss-fuzz-base/base-builder-javascript +RUN mkdir afl-testcases +RUN curl https://lcamtuf.coredump.cx/afl/demo/afl_testcases.tgz | tar xzC afl-testcases RUN git clone --depth 1 https://github.com/lovell/sharp.git COPY build.sh $SRC/ diff --git a/projects/sharp/build.sh b/projects/sharp/build.sh index 041a61ff5..b05303671 100644 --- a/projects/sharp/build.sh +++ b/projects/sharp/build.sh @@ -22,3 +22,12 @@ npm install --save-dev @jazzer.js/core # Build Fuzzers. compile_javascript_fuzzer sharp fuzz.js -i sharp + +# Merge the seed corpus in a single directory, exclude files larger than 4k +mkdir -p fuzz/corpus +find \ + $SRC/afl-testcases/{gif*,jpeg*,png,tiff,webp}/full/images \ + test/fixtures \ + -type f -size -4k \ + -exec bash -c 'hash=($(sha1sum {})); mv {} fuzz/corpus/$hash' \; +zip -jrq $OUT/fuzz_seed_corpus.zip fuzz/corpus