Enable the minifier fuzzer (fixes #530) (#694)

This enables the minify fuzzer, which has been disabled because it did not pass the oss-fuzz instrumentation test. Now it does, after changes in simdjson (https://github.com/lemire/simdjson/issues/186).

 * get minify running (api change)
 * disable benchmarks when compiling fuzzers
 * catch exceptions from the minify fuzzer
 * enable repeated corpus creation without recursive inclusion of zip
 * remove leftover comment
This commit is contained in:
Paul Dreik 2020-04-12 18:47:24 +02:00 committed by GitHub
parent 4af7d6f108
commit fa637fcecb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

View File

@ -27,7 +27,7 @@ set(SIMDJSON_FUZZ_LDFLAGS "" CACHE STRING "LDFLAGS for the fuzz targets")
set(SOURCES
fuzz_parser.cpp
# fuzz_minify.cpp # <--- does not pass the build check test on oss-fuzz, says "partially instrumented". help needed!
fuzz_minify.cpp
fuzz_dump.cpp
fuzz_print_json.cpp
fuzz_dump_raw_tape.cpp

View File

@ -4,11 +4,18 @@
#include <string>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
auto begin = (const char *)Data;
auto end = begin + Size;
auto begin = (const char *)Data;
auto end = begin + Size;
std::string str(begin, end);
std::string str(begin, end);
simdjson::json_minify(str.data(), str.size(), str.data());
return 0;
try {
simdjson::dom::parser parser;
simdjson::dom::element doc = parser.parse(str);
std::string minified=simdjson::minify(doc);
(void)minified;
} catch (...) {
}
return 0;
}

View File

@ -30,6 +30,7 @@ cmake .. \
-DCMAKE_BUILD_TYPE=Debug \
-DSIMDJSON_BUILD_STATIC=On \
-DENABLE_FUZZING=On \
-DSIMDJSON_COMPETITION=Off \
-DSIMDJSON_FUZZ_LINKMAIN=Off \
-DSIMDJSON_FUZZ_LDFLAGS=$LIB_FUZZING_ENGINE
@ -38,6 +39,6 @@ cmake --build .
cp fuzz/fuzz_* $OUT
# all corpora are equal, they all take json as input
for f in $OUT/fuzz* ; do
for f in $(ls $OUT/fuzz* |grep -v '.zip$') ; do
cp ../corpus.zip $OUT/$(basename $f).zip
done