2023-03-22 17:18:07 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
REPO_DIR=$(git rev-parse --show-toplevel)
|
|
|
|
|
|
|
|
listTargetFiles() {
|
2023-03-22 14:10:36 +00:00
|
|
|
pushd "$REPO_DIR/fuzz" > /dev/null || exit 1
|
2023-03-22 17:18:07 +00:00
|
|
|
find fuzz_targets/ -type f -name "*.rs"
|
2023-03-22 14:10:36 +00:00
|
|
|
popd > /dev/null || exit 1
|
2023-03-22 17:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
targetFileToName() {
|
|
|
|
echo "$1" \
|
|
|
|
| sed 's/^fuzz_targets\///' \
|
|
|
|
| sed 's/\.rs$//' \
|
|
|
|
| sed 's/\//_/g'
|
|
|
|
}
|
|
|
|
|
2023-03-22 13:55:08 +00:00
|
|
|
targetFileToHFuzzInputArg() {
|
|
|
|
baseName=$(basename "$1")
|
|
|
|
dirName="${baseName%.*}"
|
|
|
|
if [ -d "hfuzz_input/$dirName" ]; then
|
|
|
|
echo "HFUZZ_INPUT_ARGS=\"-f hfuzz_input/$FILE/input\""
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-03-22 17:18:07 +00:00
|
|
|
listTargetNames() {
|
|
|
|
for target in $(listTargetFiles); do
|
|
|
|
targetFileToName "$target"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-03-22 13:55:08 +00:00
|
|
|
# Utility function to avoid CI failures on Windows
|
|
|
|
checkWindowsFiles() {
|
|
|
|
incorrectFilenames=$(find . -type f -name "*,*" -o -name "*:*" -o -name "*<*" -o -name "*>*" -o -name "*|*" -o -name "*\?*" -o -name "*\**" -o -name "*\"*" | wc -l)
|
|
|
|
if [ "$incorrectFilenames" -gt 0 ]; then
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
}
|
2023-03-22 17:18:07 +00:00
|
|
|
|
2023-03-22 13:55:08 +00:00
|
|
|
# Checks whether a fuzz case output some report, and dumps it in hex
|
|
|
|
checkReport() {
|
|
|
|
reportFile="hfuzz_workspace/$1/HONGGFUZZ.REPORT.TXT"
|
|
|
|
if [ -f "$reportFile" ]; then
|
|
|
|
cat "$reportFile"
|
|
|
|
for CASE in "hfuzz_workspace/$1/SIG"*; do
|
|
|
|
xxd -p -c10000 < "$CASE"
|
|
|
|
done
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|