From a9bf69128a305de2efc930a18317521bb34a4879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Foidl?= Date: Tue, 5 Nov 2019 01:05:37 +0100 Subject: [PATCH] wip --- .azure/pipelines/jobs/fuzzing.yml | 2 +- fuzz/init-system.sh | 23 +++++++++++++++++++++++ fuzz/init.sh | 2 ++ fuzz/run.sh | 5 +++++ fuzz/setup.sh | 7 ------- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.azure/pipelines/jobs/fuzzing.yml b/.azure/pipelines/jobs/fuzzing.yml index 361ba47..8600843 100644 --- a/.azure/pipelines/jobs/fuzzing.yml +++ b/.azure/pipelines/jobs/fuzzing.yml @@ -32,7 +32,7 @@ jobs: - bash: | cd fuzz ./run.sh $(TIMEOUT) ${{ parameters.method }} - displayName: run + displayName: run - task: PublishBuildArtifacts@1 condition: failed() diff --git a/fuzz/init-system.sh b/fuzz/init-system.sh index d3d991b..c8613ac 100644 --- a/fuzz/init-system.sh +++ b/fuzz/init-system.sh @@ -1,3 +1,26 @@ #!/bin/bash +aptUpdated=0 + +# make, gcc, patch, etc. get installed if not available +which gcc > /dev/null +if [[ $? -ne 0 ]]; then + if [ $aptUpdated -eq 0 ]]; then + apt update + aptUpdated=1 + fi + + apt install -y build-essential +fi + +which rename > /dev/null +if [[ $? -ne 0 ]]; then + if [ $aptUpdated -eq 0 ]]; then + apt update + aptUpdated=1 + fi + + apt install -y rename +fi + echo core > /proc/sys/kernel/core_pattern diff --git a/fuzz/init.sh b/fuzz/init.sh index 6d1c053..9d64c5d 100644 --- a/fuzz/init.sh +++ b/fuzz/init.sh @@ -12,3 +12,5 @@ mkdir -p ./instrumented cp ../source/gfoidl.Base64/bin/Release/netcoreapp3.0/$lib ./instrumented/$lib sharpfuzz ./instrumented/$lib + +echo "$lib instrumented and ready to go" diff --git a/fuzz/run.sh b/fuzz/run.sh index 8aee275..9ed9258 100644 --- a/fuzz/run.sh +++ b/fuzz/run.sh @@ -22,5 +22,10 @@ timeout --preserve-status $duration afl-fuzz -i testcases -o findings -m 10000 - # when there are any reports in ./findings/crashes, so there are failures if [[ $(ls ./findings/crashes | wc -l) -gt 0 ]]; then + cd findings/crashes + + rename 's|:|-|g' * + ls -la + exit 1 fi diff --git a/fuzz/setup.sh b/fuzz/setup.sh index f81ec16..db14711 100644 --- a/fuzz/setup.sh +++ b/fuzz/setup.sh @@ -2,13 +2,6 @@ set -e -# make, gcc, patch, etc. get installed if not available -which gcc > /dev/null -if [[ $? -ne 0 ]]; then - apt update - apt install -y build-essential -fi - # Download and extract the latest afl-fuzz source package wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz tar -xvf afl-latest.tgz