
* run qemu fuzzers (qemu_systemmode only for now) in self-hosted runners * Remove qemu-related fuzzers to general fuzzers * fix * Install dependencies before anything else * Do not use sudo * Install sudo * Revert "Install dependencies before anything else" This reverts commit 107addad5d9f68dec5a9af50831112cd72c28f4d. * added qemu specific prerequisites * add -y flag * Format with nightly * Do not use nightly only. Install fmt and clippy for stable as well. * Install qemu-img for qemu * fix qemu-img install * apt update * Changed timeout. * Fix qemu_systemmode test * fmt * clippy + decorrelate build and run for qemu_systemmode. * fix fuzzer * clippy * add sqlite3-dev to package prerequisites. * add arm-none-eabi-gcc * fix profile dir * fix condition. * Run less QEMU stuff faster --------- Co-authored-by: Toka <tokazerkje@outlook.com>
204 lines
4.2 KiB
TOML
204 lines
4.2 KiB
TOML
env_scripts = [
|
|
'''
|
|
#!@duckscript
|
|
profile = get_env PROFILE
|
|
|
|
if eq ${profile} "dev"
|
|
set_env PROFILE_DIR debug
|
|
else
|
|
set_env PROFILE_DIR ${profile}
|
|
end
|
|
''',
|
|
'''
|
|
#!@duckscript
|
|
runs_on_ci = get_env RUN_ON_CI
|
|
|
|
if ${runs_on_ci}
|
|
cargo_target_dir = get_env CARGO_MAKE_CRATE_TARGET_DIRECTORY
|
|
set_env TARGET_DIR ${cargo_target_dir}
|
|
set_env KERNEL ${cargo_target_dir}/example.elf
|
|
end
|
|
'''
|
|
]
|
|
|
|
[env]
|
|
PROFILE = { value = "release", condition = { env_not_set = ["PROFILE"] } }
|
|
TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/${FEATURE}"
|
|
LIBAFL_QEMU_CLONE_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/qemu-libafl-bridge"
|
|
KERNEL = "${TARGET_DIR}/example.elf"
|
|
|
|
[tasks.target_dir]
|
|
condition = { files_not_exist = [ "${TARGET_DIR}" ] }
|
|
script_runner="@shell"
|
|
script='''
|
|
mkdir -p ${TARGET_DIR}
|
|
'''
|
|
|
|
[tasks.image]
|
|
dependencies = ["target_dir"]
|
|
condition = { files_not_exist = [ "${TARGET_DIR}/dummy.qcow2" ] }
|
|
script_runner="@shell"
|
|
script='''
|
|
qemu-img create -f qcow2 ${TARGET_DIR}/dummy.qcow2 32M
|
|
'''
|
|
|
|
[tasks.target]
|
|
dependencies = ["target_dir"]
|
|
condition = { env_set = [ "TARGET_DEFINE" ] }
|
|
command = "arm-none-eabi-gcc"
|
|
args = [
|
|
"-ggdb",
|
|
"-ffreestanding",
|
|
"-nostartfiles",
|
|
"-lgcc",
|
|
"-T", "${CARGO_MAKE_WORKING_DIRECTORY}/example/mps2_m3.ld",
|
|
"-mcpu=cortex-m3",
|
|
"${CARGO_MAKE_WORKING_DIRECTORY}/example/main.c",
|
|
"${CARGO_MAKE_WORKING_DIRECTORY}/example/startup.c",
|
|
"-D", "${TARGET_DEFINE}",
|
|
"-I", "${TARGET_DIR}/${PROFILE_DIR}/include",
|
|
"-o", "${TARGET_DIR}/example.elf",
|
|
]
|
|
|
|
[tasks.build_fuzzer]
|
|
condition = { env_set = [ "FEATURE" ] }
|
|
command = "cargo"
|
|
args = [
|
|
"build",
|
|
"--profile",
|
|
"${PROFILE}",
|
|
"--no-default-features",
|
|
"--features", "std,${FEATURE}",
|
|
"--target-dir", "${TARGET_DIR}",
|
|
]
|
|
dependencies = ["image"]
|
|
|
|
[tasks.run_fuzzer]
|
|
command = "${TARGET_DIR}/${PROFILE_DIR}/qemu_systemmode"
|
|
args = [
|
|
"-icount", "shift=auto,align=off,sleep=off",
|
|
"-machine", "mps2-an385",
|
|
"-monitor", "null",
|
|
"-kernel", "${TARGET_DIR}/example.elf",
|
|
"-serial", "null",
|
|
"-nographic",
|
|
"-snapshot",
|
|
"-drive", "if=none,format=qcow2,file=${TARGET_DIR}/dummy.qcow2",
|
|
"-S",
|
|
]
|
|
dependencies = ["target"]
|
|
|
|
[tasks.test_fuzzer]
|
|
condition = { env_set = [ "FEATURE" ] }
|
|
script_runner="@shell"
|
|
script='''
|
|
TMP_DIR=$(mktemp -d)
|
|
|
|
cargo make build_$FEATURE
|
|
timeout 15s cargo make ${FEATURE} | tee $TMP_DIR/fuzz.log 2>&1 || true
|
|
|
|
if [ -z "$(grep 'Objective' $TMP_DIR/fuzz.log)" ]; then
|
|
echo "qemu_systemmode ${FEATURE}: Fuzzer did not find the objective in $TMP_DIR/fuzz.log"
|
|
exit 1
|
|
else
|
|
echo "qemu_systemmode ${FEATURE}: Objective found."
|
|
fi
|
|
'''
|
|
|
|
[tasks.build_classic]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=classic",
|
|
"-e", "TARGET_DEFINE=TARGET_CLASSIC",
|
|
"build_fuzzer",
|
|
]
|
|
|
|
[tasks.test_classic]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=classic",
|
|
"test_fuzzer",
|
|
]
|
|
|
|
[tasks.build_breakpoint]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=breakpoint",
|
|
"-e", "TARGET_DEFINE=TARGET_BREAKPOINT",
|
|
"build_fuzzer",
|
|
]
|
|
|
|
[tasks.test_breakpoint]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=breakpoint",
|
|
"test_fuzzer",
|
|
]
|
|
|
|
[tasks.build_sync_exit]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=sync_exit",
|
|
"-e", "TARGET_DEFINE=TARGET_SYNC_EXIT",
|
|
"build_fuzzer",
|
|
]
|
|
|
|
[tasks.test_sync_exit]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=sync_exit",
|
|
"test_fuzzer",
|
|
]
|
|
|
|
[tasks.classic]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=classic",
|
|
"-e", "TARGET_DEFINE=TARGET_CLASSIC",
|
|
"run_fuzzer",
|
|
]
|
|
|
|
[tasks.breakpoint]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=breakpoint",
|
|
"-e", "TARGET_DEFINE=TARGET_BREAKPOINT",
|
|
"run_fuzzer",
|
|
]
|
|
|
|
[tasks.sync_exit]
|
|
command = "cargo"
|
|
args = [
|
|
"make",
|
|
"-e", "FEATURE=sync_exit",
|
|
"-e", "TARGET_DEFINE=TARGET_SYNC_EXIT",
|
|
"run_fuzzer",
|
|
]
|
|
|
|
[tasks.test]
|
|
clear = true
|
|
run_task = { name = ["test_classic", "test_breakpoint", "test_sync_exit"] }
|
|
|
|
[tasks.build]
|
|
clear = true
|
|
run_task = { name = ["build_classic", "build_breakpoint", "build_sync_exit"] }
|
|
|
|
[tasks.run]
|
|
alias="classic"
|
|
|
|
[tasks.clean]
|
|
clear = true
|
|
script_runner="@shell"
|
|
script='''
|
|
rm -rf ${CARGO_MAKE_CRATE_TARGET_DIRECTORY}
|
|
cargo clean
|
|
'''
|