File: get_ossfuzz_corpora

package info (click to toggle)
libidn 1.43-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,376 kB
  • sloc: java: 14,167; ansic: 7,085; cs: 1,974; sh: 1,283; perl: 1,238; makefile: 680; lisp: 231; php: 214; xml: 88; python: 9
file content (46 lines) | stat: -rwxr-xr-x 1,499 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh -eu

# First step. In the top directory execute:
# export CC=clang-6.0
# export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize-coverage=trace-pc-guard,trace-cmp"
# ./configure --enable-static --disable-doc
# make clean
# make -j$(nproc) LIB_FUZZING_ENGINE="-lFuzzer"
# cd fuzz
# make -j$(nproc) check

# 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 libidn_tounicode_fuzzer"
  exit 1
fi

fuzzer=$1
project=libidn

# sync/copy the OSS-Fuzz corpora into the .new directory
mkdir -p ${fuzzer}.new
cp -fp ${fuzzer}.in/* ${fuzzer}.new
gsutil cp $(gsutil ls gs://${project}-backup.clusterfuzz-external.appspot.com/corpus/libFuzzer/${fuzzer}|tail -n 1) ${fuzzer}.new
(cd ${fuzzer}.new && unzip -q -f -o *.zip && rm *.zip)

# create fuzzer target
BUILD_ONLY=1 ./run-clang.sh ${fuzzer}

# merge the corpora into the .in directory
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new

# now clear .new dir and put all corpora there
rm -f ${fuzzer}.new/*
mv ${fuzzer}.in ${fuzzer}.new
mkdir ${fuzzer}.in

# now merge again (optimizes number of corpora)
./${fuzzer} -merge=1 ${fuzzer}.in ${fuzzer}.new

echo
echo "If new files have been added, 'git add' and 'git commit' them."