134 lines
3.2 KiB
TOML
134 lines
3.2 KiB
TOML
# Variables
|
|
[env]
|
|
FUZZER_NAME='fuzzer_mozjpeg'
|
|
CARGO_TARGET_DIR = { value = "${PROJECT_DIR}/target", condition = { env_not_set = ["CARGO_TARGET_DIR"] } }
|
|
PROFILE = { value = "release", condition = {env_not_set = ["PROFILE"]} }
|
|
PROFILE_DIR = {value = "release", condition = {env_not_set = ["PROFILE_DIR"] }}
|
|
LIBAFL_CC = '${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cc'
|
|
LIBAFL_CXX = '${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cxx'
|
|
FUZZER = '${CARGO_TARGET_DIR}/${PROFILE_DIR}/${FUZZER_NAME}'
|
|
PROJECT_DIR = { script = ["pwd"] }
|
|
|
|
[tasks.unsupported]
|
|
script_runner="@shell"
|
|
script='''
|
|
echo "Cargo-make not integrated yet on this platform"
|
|
'''
|
|
|
|
# libpng
|
|
[tasks.mozjpeg]
|
|
linux_alias = "mozjpeg_unix"
|
|
mac_alias = "mozjpeg_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.mozjpeg_unix]
|
|
condition = { files_not_exist = ["./mozjpeg-4.0.3"]}
|
|
script_runner="@shell"
|
|
script='''
|
|
wget https://github.com/mozilla/mozjpeg/archive/v4.0.3.tar.gz
|
|
tar -xzvf v4.0.3.tar.gz
|
|
'''
|
|
|
|
# Compilers
|
|
[tasks.cxx]
|
|
linux_alias = "cxx_unix"
|
|
mac_alias = "cxx_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.cxx_unix]
|
|
command = "cargo"
|
|
args = ["build" , "--profile", "${PROFILE}"]
|
|
|
|
[tasks.cc]
|
|
linux_alias = "cc_unix"
|
|
mac_alias = "cc_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.cc_unix]
|
|
command = "cargo"
|
|
args = ["build" , "--profile", "${PROFILE}"]
|
|
|
|
# Library
|
|
[tasks.lib]
|
|
linux_alias = "lib_unix"
|
|
mac_alias = "lib_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.lib_unix]
|
|
script='''
|
|
cd mozjpeg-4.0.3 && cmake . -DENABLE_SHARED=false -DPNG_SUPPORTED=false -DCMAKE_C_COMPILER="${LIBAFL_CC}" -DCMAKE_CXX_COMPILER="${LIBAFL_CXX}" -G "Unix Makefiles"
|
|
cd "${PROJECT_DIR}"
|
|
make -C mozjpeg-4.0.3
|
|
'''
|
|
dependencies = [ "mozjpeg", "cxx", "cc" ]
|
|
|
|
|
|
# Harness
|
|
[tasks.fuzzer]
|
|
linux_alias = "fuzzer_unix"
|
|
mac_alias = "fuzzer_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.fuzzer_unix]
|
|
command = "${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cxx"
|
|
args = ["${PROJECT_DIR}/harness.cc", "${PROJECT_DIR}/mozjpeg-4.0.3/libjpeg.a", "${PROJECT_DIR}/mozjpeg-4.0.3/libturbojpeg.a", "-I", "${PROJECT_DIR}/mozjpeg-4.0.3/", "-o", "${FUZZER_NAME}", "-lm", "-lz"]
|
|
dependencies = [ "lib", "cxx", "cc" ]
|
|
|
|
# Run the fuzzer
|
|
[tasks.run]
|
|
linux_alias = "run_unix"
|
|
mac_alias = "run_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.run_unix]
|
|
script_runner = "@shell"
|
|
script='''
|
|
./${FUZZER_NAME} &
|
|
sleep 0.2
|
|
./${FUZZER_NAME}
|
|
'''
|
|
dependencies = [ "fuzzer" ]
|
|
|
|
# Test
|
|
[tasks.test]
|
|
linux_alias = "test_linux"
|
|
mac_alias = "test_mac"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.test_linux]
|
|
script_runner = "@shell"
|
|
script='''
|
|
rm -rf libafl_unix_shmem_server || true
|
|
(timeout 31s ./${FUZZER_NAME} | tee fuzz_stdout.log 2>/dev/null || true) &
|
|
sleep 0.2
|
|
timeout 30s ./${FUZZER_NAME} >/dev/null 2>/dev/null || true
|
|
if grep -qa "corpus: 30" fuzz_stdout.log; then
|
|
echo "Fuzzer is working"
|
|
else
|
|
echo "Fuzzer does not generate any testcases or any crashes"
|
|
exit 1
|
|
fi
|
|
'''
|
|
dependencies = [ "fuzzer" ]
|
|
|
|
[tasks.test_mac]
|
|
script='''
|
|
echo "Skipping build on MacOS as libpng in Github is ancient, see LibAFL GH issue #254"
|
|
'''
|
|
|
|
# Clean up
|
|
[tasks.clean]
|
|
linux_alias = "clean_unix"
|
|
mac_alias = "clean_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.clean_unix]
|
|
# Disable default `clean` definition
|
|
clear = true
|
|
script_runner="@shell"
|
|
script='''
|
|
rm -f ./${FUZZER_NAME}
|
|
make -C mozjpeg-4.0.3 clean
|
|
cargo clean
|
|
'''
|