on master help sign in
#6, make sure the CI detects if you have got any crashes
d796da6Neil Mitchell
afl.sh+8−3
@@ -1,6 +1,6 @@
1# Script based on code from https://github.com/ndmitchell/hexml/issues/6
1# Script based on code from https://github.com/ndmitchell/hexml/issues/6
2# More examples of things to do are at that ticket
2# More examples of things to do are at that ticket
3−set -eu
3+set -e
4
4
5# First install AFL
5# First install AFL
6if ! command -v afl-clang-fast > /dev/null ; then
6if ! command -v afl-clang-fast > /dev/null ; then
@@ -21,8 +21,13 @@ AFL_HARDEN=1 afl-clang-fast -O2 -Icbits cbits/fuzz.c -o $PWD/hexml-fuzz
21if ! grep -q core /proc/sys/kernel/core_pattern ; then
21if ! grep -q core /proc/sys/kernel/core_pattern ; then
22 echo core | sudo tee /proc/sys/kernel/core_pattern
22 echo core | sudo tee /proc/sys/kernel/core_pattern
23fi
23fi
24+if [ -z "$CI" ] ; then
25+ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@
26+else
24−AFL_EXIT_WHEN_DONE=1 AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@
27+ AFL_EXIT_WHEN_DONE=1 AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so timeout 5m afl-fuzz -T hexml -x /usr/local/share/afl/dictionaries/xml.dict -i $PWD/xml -o $PWD/afl-results -- $PWD/hexml-fuzz @@ > /dev/null || true
25−cat afl-results/fuzzer_stats
28+ cat afl-results/fuzzer_stats
29+ grep "unique_crashes *: 0" afl-results/fuzzer_stats # fail if there are failures
30+fi
26
31
27# Minimize failures
32# Minimize failures
28# $ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-cmin -i results/crashes/ -o results.shrunk -- $PWD/a.out @@
33# $ AFL_PRELOAD=/usr/local/lib/afl/libdislocator.so afl-cmin -i results/crashes/ -o results.shrunk -- $PWD/a.out @@