cmark: Update seed corpus (#9564)

Generate seed corpus from our own test suite instead of relying on an
external repo.

Also remove redundant $SRC/cmark from paths.
This commit is contained in:
Nick Wellnhofer 2023-02-02 19:08:38 +01:00 committed by GitHub
parent 77250f109b
commit d6dd123afc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 14 deletions

View File

@ -15,7 +15,7 @@
################################################################################
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y make cmake
RUN apt-get update && apt-get install -y make cmake python3
RUN git clone --depth 1 https://github.com/commonmark/cmark.git cmark
WORKDIR cmark
COPY build.sh *.dict *.options $SRC/

View File

@ -17,22 +17,14 @@
make -j$(nproc) cmake_build
$CC $CFLAGS -Isrc -Ibuild/src -c $SRC/cmark/test/cmark-fuzz.c -o cmark_fuzzer.o
$CC $CFLAGS -Isrc -Ibuild/src -c test/cmark-fuzz.c -o cmark_fuzzer.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE cmark_fuzzer.o build/src/libcmark.a -o $OUT/cmark_fuzzer
cp $SRC/*.options $OUT/
cp $SRC/cmark/test/fuzzing_dictionary $OUT/cmark.dict
cp test/fuzzing_dictionary $OUT/cmark.dict
mkdir -p corpus
cp $SRC/cmark/test/afl_test_cases/* corpus
git clone --depth 1 https://github.com/michelf/mdtest.git mdtest
find mdtest/*.mdtest -type f -name '*.text' | while read in_file
do
# Genreate unique name for each input...
out_file=$(sha1sum "$in_file" | cut -c 1-32)
# ... and prepend a four-byte 'options' header
printf "\0\0\0\0" > "corpus/$out_file"
cat "$in_file" >> "corpus/$out_file"
done
python3 test/spec_tests.py --fuzz-corpus corpus --spec test/spec.txt
python3 test/spec_tests.py --fuzz-corpus corpus --spec test/regression.txt
python3 test/spec_tests.py --fuzz-corpus corpus --spec test/smart_punct.txt
zip -j $OUT/cmark_fuzzer_seed_corpus.zip corpus/*