CI: speedups and fixes (#855)

* scripts/clippy.sh: remove cargo clean step

Clippy used to only report warnings in code that was not part of the
incremental cache. This has changed since and I believe we can safely
drop the `cargo clean` step.

* Revert "ci: install z3 to avoid building from source"

This reverts commit 6ff1c4088811040dcfdbd12273f0baf507a4308b.
This doesn't do anything as we're using `static-link-z3` explicitly.

* refactor test_all_fuzzers

nyx tests were not included in `time_record` before this

* nyx fuzzer: move modprobe logic out of setup_libxml2.sh
This commit is contained in:
Mrmaxmeier 2022-10-23 01:58:33 +02:00 committed by GitHub
parent b035b70f4e
commit 64bc5d5bdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 39 deletions

View File

@ -156,7 +156,7 @@ jobs:
- uses: lyricwulf/abc@v1
with:
# todo: remove afl++-clang when nyx support samcov_pcguard
linux: llvm llvm-dev clang nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgtk-3-dev afl++-clang pax-utils z3 libz3-dev
linux: llvm llvm-dev clang nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgtk-3-dev afl++-clang pax-utils
# update bash for macos to support `declare -A` command`
macos: llvm libpng nasm coreutils z3 bash
- name: pip install

View File

@ -28,6 +28,18 @@ script='''
./setup_libxml2.sh
'''
[tasks.enable_kvm_vmware_hypercall]
script_runner = "@shell"
script='''
if [ ! -e /sys/module/kvm/parameters/enable_vmware_backdoor ] ||
! grep -qF Y /sys/module/kvm/parameters/enable_vmware_backdoor; then
sudo modprobe -r kvm-intel # or kvm-amd for AMD
sudo modprobe -r kvm
sudo modprobe kvm enable_vmware_backdoor=y
sudo modprobe kvm-intel
fi;
'''
# Run the fuzzer
[tasks.run]
linux_alias = "run_unix"
@ -39,7 +51,7 @@ script_runner = "@shell"
script='''
cargo run
'''
dependencies = [ "libxml2" ]
dependencies = [ "libxml2", "enable_kvm_vmware_hypercall" ]
# Clean up
[tasks.clean]

View File

@ -23,7 +23,3 @@ python3 "../../libafl_nyx/packer/packer/nyx_packer.py" \
--purge || exit
python3 ../../libafl_nyx/packer/packer/nyx_config_gen.py /tmp/nyx_libxml2/ Kernel || exit
sudo modprobe -r kvm-intel # or kvm-amd for AMD
sudo modprobe -r kvm
sudo modprobe kvm enable_vmware_backdoor=y
sudo modprobe kvm-intel

View File

@ -28,6 +28,18 @@ script='''
./setup_libxml2.sh
'''
[tasks.enable_kvm_vmware_hypercall]
script_runner = "@shell"
script='''
if [ ! -e /sys/module/kvm/parameters/enable_vmware_backdoor ] ||
! grep -qF Y /sys/module/kvm/parameters/enable_vmware_backdoor; then
sudo modprobe -r kvm-intel # or kvm-amd for AMD
sudo modprobe -r kvm
sudo modprobe kvm enable_vmware_backdoor=y
sudo modprobe kvm-intel
fi;
'''
# Run the fuzzer
[tasks.run]
linux_alias = "run_unix"
@ -39,7 +51,7 @@ script_runner = "@shell"
script='''
cargo run
'''
dependencies = [ "libxml2" ]
dependencies = [ "libxml2", "enable_kvm_vmware_hypercall" ]
# Clean up
[tasks.clean]

View File

@ -21,9 +21,3 @@ python3 "../../libafl_nyx/packer/packer/nyx_packer.py" \
-file "/tmp/input" \
--fast_reload_mode \
--purge || exit
python3 ../../libafl_nyx/packer/packer/nyx_config_gen.py /tmp/nyx_libxml2/ Kernel || exit
sudo modprobe -r kvm-intel # or kvm-amd for AMD
sudo modprobe -r kvm
sudo modprobe kvm enable_vmware_backdoor=y
sudo modprobe kvm-intel

View File

@ -2,12 +2,6 @@
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
cd "$SCRIPT_DIR/.." || exit 1
# Clippy checks
if [ "$1" != "--no-clean" ]; then
# Usually, we want to clean, since clippy won't work otherwise.
echo "[+] Cleaning up previous builds..."
cargo clean -p libafl
fi
RUST_BACKTRACE=full cargo +nightly clippy --all --all-features --release --tests -- -Z macro-backtrace \
-D clippy::all \
-D clippy::pedantic \

View File

@ -10,6 +10,9 @@ backtrace_fuzzers=$(find ./fuzzers/backtrace_baby_fuzzers -mindepth 1 -maxdepth
libafl=$(pwd)
# build with a shared target dir for all fuzzers. this should speed up
# compilation a bit, and allows for easier artifact management (caching and
# cargo clean).
export CARGO_TARGET_DIR="$libafl/target"
mkdir -p "$CARGO_TARGET_DIR"
@ -34,23 +37,8 @@ declare -A time_record || (echo "declare -A not avaliable, please update your ba
# shellcheck disable=SC2116
for fuzzer in $(echo "$fuzzers" "$backtrace_fuzzers");
do
# for nyx examples
if [[ $fuzzer == *"nyx_"* ]]; then
# only test on linux
if [[ $(uname -s) == "Linux" ]]; then
cd "$fuzzer" || exit 1
if [ "$1" != "--no-fmt" ]; then
echo "[*] Checking fmt for $fuzzer"
cargo fmt --all -- --check || exit 1
echo "[*] Running clippy for $fuzzer"
cargo clippy || exit 1
else
echo "[+] Skipping fmt and clippy for $fuzzer (--no-fmt specified)"
fi
cargo make build
cd - || exit
fi
# skip nyx test on non-linux platforms
if [[ $fuzzer == *"nyx_"* ]] && [[ $(uname -s) != "Linux" ]]; then
continue
fi
@ -67,10 +55,14 @@ do
echo "[+] Skipping fmt and clippy for $fuzzer (--no-fmt specified)"
fi
if [ -e ./Makefile.toml ]; then
if [ -e ./Makefile.toml ] && grep -qF "skip_core_tasks = true" Makefile.toml; then
echo "[*] Building $fuzzer (running tests is not supported in this context)"
cargo make build || exit 1
echo "[+] Done building $fuzzer"
elif [ -e ./Makefile.toml ]; then
echo "[*] Testing $fuzzer"
cargo make test || exit 1
echo "[+] Done testing $fuzzer"
echo "[+] Done testing $fuzzer"
else
echo "[*] Building $fuzzer"
cargo build || exit 1
@ -82,7 +74,7 @@ do
# Save disk space
cargo clean -p "$(basename "$fuzzer")"
cargo clean --release -p "$(basename "$fuzzer")" 2> /dev/null
# Leaving these in the cache results in lots of duplicate build artefacts
# Leaving these in the cache results in lots of duplicate build artifacts
# (many different feature flag combinations, ...), so let's prune them.
for clean_pkgid in libafl libafl_targets libafl_sugar; do
cargo clean -p "$clean_pkgid" 2> /dev/null