142 lines
3.4 KiB
TOML
142 lines
3.4 KiB
TOML
# Variables
|
|
[env]
|
|
FUZZER_NAME = 'fuzzer_libafl_cc'
|
|
CARGO_TARGET_DIR = { value = "${PROJECT_DIR}/target", condition = { env_not_set = [
|
|
"CARGO_TARGET_DIR",
|
|
] } }
|
|
PROFILE = { value = "release", condition = { env_not_set = ["PROFILE"] } }
|
|
PROFILE_DIR = { source = "${PROFILE}", default_value = "release", mapping = { "release" = "release", "dev" = "debug" }, 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"
|
|
'''
|
|
|
|
# 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}"]
|
|
|
|
[tasks.crash_cxx]
|
|
linux_alias = "crash_cxx_unix"
|
|
mac_alias = "crash_cxx_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.crash_cxx_unix]
|
|
command = "cargo"
|
|
args = ["build", "--profile", "${PROFILE}", "--features=crash"]
|
|
|
|
[tasks.crash_cc]
|
|
linux_alias = "crash_cc_unix"
|
|
mac_alias = "crash_cc_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.crash_cc_unix]
|
|
command = "cargo"
|
|
args = ["build", "--profile", "${PROFILE}", "--features=crash"]
|
|
|
|
# Harness
|
|
[tasks.fuzzer]
|
|
linux_alias = "fuzzer_unix"
|
|
mac_alias = "fuzzer_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.fuzzer_unix]
|
|
command = "${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cc"
|
|
args = ["${PROJECT_DIR}/src/program.c", "-o", "${FUZZER_NAME}", "-lm"]
|
|
dependencies = ["cxx", "cc"]
|
|
|
|
# Crashing Harness
|
|
[tasks.fuzzer_crash]
|
|
linux_alias = "fuzzer_crash_unix"
|
|
mac_alias = "fuzzer_crash_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.fuzzer_crash_unix]
|
|
command = "${CARGO_TARGET_DIR}/${PROFILE_DIR}/libafl_cc"
|
|
args = ["${PROJECT_DIR}/src/program.c", "-o", "${FUZZER_NAME}_crash", "-lm"]
|
|
dependencies = ["crash_cxx", "crash_cc"]
|
|
|
|
# Run the fuzzer
|
|
[tasks.run]
|
|
linux_alias = "run_unix"
|
|
mac_alias = "run_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.run_unix]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
taskset -c 1 ${CARGO_TARGET_DIR}/${PROFILE_DIR}/${CARGO_MAKE_PROJECT_NAME} ./${FUZZER_NAME} ./corpus/ -t 1000
|
|
'''
|
|
dependencies = ["fuzzer"]
|
|
|
|
|
|
# Run the fuzzer with a crash
|
|
[tasks.crash]
|
|
linux_alias = "crash_unix"
|
|
mac_alias = "crash_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.crash_unix]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
taskset -c 1 ${CARGO_TARGET_DIR}/${PROFILE_DIR}/${CARGO_MAKE_PROJECT_NAME} ./${FUZZER_NAME}_crash ./corpus/ -t 1000
|
|
'''
|
|
dependencies = ["fuzzer_crash"]
|
|
|
|
# Test
|
|
[tasks.test]
|
|
linux_alias = "test_unix"
|
|
mac_alias = "test_unix"
|
|
windows_alias = "unsupported"
|
|
|
|
[tasks.test_unix]
|
|
script_runner = "@shell"
|
|
script = '''
|
|
timeout 30s ${CARGO_TARGET_DIR}/${PROFILE_DIR}/${CARGO_MAKE_PROJECT_NAME} ./${FUZZER_NAME} ./corpus/ -t 1000 | tee fuzz_stdout.log || true
|
|
if grep -qa "objectives: 1" fuzz_stdout.log; then
|
|
echo "Fuzzer is working"
|
|
else
|
|
echo "Fuzzer does not generate any testcases or any crashes"
|
|
exit 1
|
|
fi
|
|
|
|
'''
|
|
dependencies = ["fuzzer"]
|
|
|
|
# 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}
|
|
cargo clean
|
|
'''
|