| 1 |
#!/bin/sh -eu |
| 2 |
|
| 3 |
# As a first step see README.md and follow the steps under "Running a fuzzer using clang". |
| 4 |
|
| 5 |
# You might need 'gsutil' to download new corpora from the Google cloud: |
| 6 |
# Read the docs at https://github.com/google/oss-fuzz/blob/master/docs/corpora.md |
| 7 |
# then install 'google-cloud-sdk' and execute 'gcloud init'. |
| 8 |
# Now 'gsutil' should be ready to use. |
| 9 |
|
| 10 |
if test -z "$1"; then |
| 11 |
echo "Usage: $0 <fuzzer target>" |
| 12 |
echo "Example: $0 libpsl_fuzzer" |
| 13 |
exit 1 |
| 14 |
fi |
| 15 |
|
| 16 |
if ! grep -q FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION Makefile; then |
| 17 |
echo "The fuzzers haven't been built for fuzzing (maybe for regression testing !?)" |
| 18 |
echo "Please built regarding README.md and try again." |
| 19 |
exit 1 |
| 20 |
fi |
| 21 |
|
| 22 |
fuzzer=$1 |
| 23 |
project=$(echo $1 | cut -d'_' -f1) |
| 24 |
|
| 25 |
# sync/copy the OSS-Fuzz corpora into the .new directory |
| 26 |
mkdir -p ${fuzzer}.in ${fuzzer}.new |
| 27 |
cp -fp ${fuzzer}.in/* ${fuzzer}.new 2>/dev/null || true |
| 28 |
gsutil cp $(gsutil ls gs://${project}-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/${fuzzer}|tail -n 1) ${fuzzer}.new/ |
| 29 |
(cd ${fuzzer}.new && unzip -o *.zip && mv *.zip ..) |
| 30 |
|
| 31 |
# create fuzzer target |
| 32 |
BUILD_ONLY=1 ./run-clang.sh ${fuzzer} |
| 33 |
|
| 34 |
# merge the corpora into the .in directory |
| 35 |
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new |
| 36 |
|
| 37 |
# now clear .new dir and put all corpora there |
| 38 |
rm -rf ${fuzzer}.new |
| 39 |
mv ${fuzzer}.in ${fuzzer}.new |
| 40 |
mkdir ${fuzzer}.in |
| 41 |
|
| 42 |
# now merge again (optimizes number of corpora) |
| 43 |
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new |
| 44 |
|
| 45 |
echo |
| 46 |
echo "If new files have been added, 'git add' and 'git commit' them." |