-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·52 lines (41 loc) · 1.42 KB
/
run.sh
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
47
#!/bin/bash -e
command -v gopls &> /dev/null || {
echo "gopls not found: try 'GO111MODULE=on go get golang.org/x/tools/gopls@latest' or check PATH is set"
exit
}
command -v go-fuzz-build &> /dev/null || {
echo "go-fuzz-build not installed: try 'go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build' or check PATH is set"
exit
}
function fuzz() {
echo "Running fuzzers in $1"
pushd "$1" &> /dev/null
go-fuzz-build
for f in ./*.go; do
[ -f "$f" ] && {
gopls symbols "$f"|grep "Fuzz"|cut -f 1 -d' '|while read -r func; do
echo "Running $func"
start=$SECONDS
workdir=$(mktemp -d)
go-fuzz -bin "$1"-fuzz.zip -workdir "$workdir" -func "$func" 2>&1 | while read -r line; do
echo "$line" | grep -q "crashers: [1-9][0-9]*" && {
break
}
done
end=$SECONDS
duration=$(( end - start ))
echo -n "Found crasher for $func after $duration seconds: "
find "$workdir/crashers" -name "*.quoted" -exec cat {} \; | while read -r line; do
echo "$line"
done
rm -rf "$workdir"
done
}
done
popd &> /dev/null
}
dirs=("sonar" "literals" "bigevent")
for dir in "${dirs[@]}"
do
fuzz "$dir"
done