forked from aviggiano/fuzzer-evaluation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevaluate.sh
executable file
·59 lines (48 loc) · 1.55 KB
/
evaluate.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
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -ux
SEED="$1"
MUTANT="$2"
FUZZER="$3"
TIMEOUT=86400
RESULTS="$(pwd)/results.txt"
PARAMETERS="$(pwd)/parameters.txt"
WORKERS=$(cat /proc/cpuinfo | grep processor | wc -l)
if [ $WORKERS -eq 0 ]; then
WORKERS=1
fi
echo "instance=$(wget -q -O - http://instance-data/latest/meta-data/instance-type)" > $PARAMETERS
echo "echidna=$(echidna --version)" >> $PARAMETERS
echo "slither=$(slither --version)" >> $PARAMETERS
echo "forge=$(forge --version)" >> $PARAMETERS
echo "solc=$(solc --version | head -2 | tail -1)" >> $PARAMETERS
echo "fuzzer,protocol,seed,mutant,time,result" > $RESULTS
for PROTOCOL in $(ls protocols); do
cd protocols/$PROTOCOL
for MUTANT_FILE in $(find mutants -type f | sort -r -t'/' -k 3,3 | grep "$MUTANT"); do
git apply $MUTANT_FILE
MUTANT=$(echo $MUTANT_FILE | grep -o '[0-9][0-9]')
if [ $(echo "$FUZZER" | grep "foundry" | wc -l) -gt 0 ]; then
forge clean
START=$(date +%s)
timeout -k 10 $TIMEOUT forge test --fuzz-seed $SEED
RESULT=$?
END=$(date +%s)
TIME=$(echo "$END - $START" | bc)
echo "foundry,$PROTOCOL,$SEED,$MUTANT,$TIME,$RESULT" >> $RESULTS
fi
if [ $(echo "$FUZZER" | grep "echidna" | wc -l) -gt 0 ]; then
forge clean
START=$(date +%s)
timeout -k 10 $TIMEOUT echidna . --contract EchidnaTester --config test/config.yaml --workers $WORKERS --seed $SEED >/dev/null
RESULT=$?
END=$(date +%s)
TIME=$(echo "$END - $START" | bc)
echo "echidna,$PROTOCOL,$SEED,$MUTANT,$TIME,$RESULT" >> $RESULTS
fi
# cleanup
git checkout .
done
cd -
done
sleep 90
sudo shutdown -h now