2017-06-26 12:58:21 +02:00
|
|
|
#!/bin/sh -eu
|
|
|
|
|
2022-01-16 12:59:23 +01:00
|
|
|
# As a first step see README.md and follow the steps under "Running a fuzzer using clang".
|
|
|
|
|
|
|
|
# You might need 'gsutil' to download new corpora from the Google cloud:
|
2017-06-26 12:58:21 +02:00
|
|
|
# Read the docs at https://github.com/google/oss-fuzz/blob/master/docs/corpora.md
|
|
|
|
# then install 'google-cloud-sdk' and execute 'gcloud init'.
|
|
|
|
# Now 'gsutil' should be ready to use.
|
|
|
|
|
|
|
|
if test -z "$1"; then
|
|
|
|
echo "Usage: $0 <fuzzer target>"
|
|
|
|
echo "Example: $0 libpsl_fuzzer"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-01-16 12:59:23 +01:00
|
|
|
if ! grep -q FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION Makefile; then
|
|
|
|
echo "The fuzzers haven't been built for fuzzing (maybe for regression testing !?)"
|
|
|
|
echo "Please built regarding README.md and try again."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-06-26 12:58:21 +02:00
|
|
|
fuzzer=$1
|
|
|
|
project=$(echo $1 | cut -d'_' -f1)
|
|
|
|
|
|
|
|
# sync/copy the OSS-Fuzz corpora into the .new directory
|
2022-01-16 12:59:23 +01:00
|
|
|
mkdir -p ${fuzzer}.in ${fuzzer}.new
|
|
|
|
cp -fp ${fuzzer}.in/* ${fuzzer}.new 2>/dev/null || true
|
|
|
|
gsutil cp $(gsutil ls gs://${project}-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/${fuzzer}|tail -n 1) ${fuzzer}.new/
|
|
|
|
(cd ${fuzzer}.new && unzip -o *.zip && mv *.zip ..)
|
2017-06-26 12:58:21 +02:00
|
|
|
|
|
|
|
# create fuzzer target
|
|
|
|
BUILD_ONLY=1 ./run-clang.sh ${fuzzer}
|
|
|
|
|
|
|
|
# merge the corpora into the .in directory
|
|
|
|
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new
|
|
|
|
|
2017-06-30 19:55:55 +02:00
|
|
|
# now clear .new dir and put all corpora there
|
2022-01-16 12:59:23 +01:00
|
|
|
rm -rf ${fuzzer}.new
|
|
|
|
mv ${fuzzer}.in ${fuzzer}.new
|
|
|
|
mkdir ${fuzzer}.in
|
2017-06-30 19:55:55 +02:00
|
|
|
|
|
|
|
# now merge again (optimizes number of corpora)
|
|
|
|
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new
|
|
|
|
|
2017-06-26 12:58:21 +02:00
|
|
|
echo
|
|
|
|
echo "If new files have been added, 'git add' and 'git commit' them."
|