From a0361f5d5b0582f9c21b7fb93a5bbd9b111fb50f Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Fri, 21 Mar 2025 13:56:45 +0100 Subject: [PATCH 1/2] Move all tests to just --- .github/workflows/build_and_test.yml | 119 +++++------ justfile | 293 +++++++++++++++++++++++++++ libafl_targets/src/windows_asan.rs | 7 +- scripts/check_tested_fuzzers.sh | 15 +- scripts/fmt_all.sh | 2 + 5 files changed, 357 insertions(+), 79 deletions(-) create mode 100644 justfile diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 51d5d11d24e..bd3873c48e1 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -52,27 +52,13 @@ jobs: - name: Check for binary blobs if: runner.os == 'Linux' run: ./scripts/check_for_blobs.sh - - name: Build libafl debug - run: cargo build -p libafl - - name: Test the book (Linux) - # TODO: fix books test fail with updated windows-rs - if: runner.os == 'Linux' - run: cd docs && mdbook test -L ../target/debug/deps - - name: Test the book (MacOS) - if: runner.os == 'MacOS' - run: cd docs && mdbook test -L ../target/debug/deps $(python3-config --ldflags | cut -d ' ' -f1) - - name: Run tests (Windows) - if: runner.os == 'Windows' - run: cargo test -- --test-threads 1 - - name: Run tests (Linux) + - name: Test the book if: runner.os != 'Windows' - run: cargo test -- --test-threads 1 + run: just test-docs + - name: Run tests + run: just test - name: Test libafl no_std - run: cd libafl && cargo test --no-default-features - - name: Test libafl_bolts no_std no_alloc - run: cd libafl_bolts && cargo test --no-default-features - - name: Test libafl_targets no_std - run: cd libafl_targets && cargo test --no-default-features + run: just test-no-std ubuntu-doc-build: runs-on: ubuntu-24.04 @@ -82,7 +68,7 @@ jobs: - uses: Swatinem/rust-cache@v2 # ---- doc check ---- - name: Build Docs - run: RUSTFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps + run: just doc ubuntu-doc-test: runs-on: ubuntu-24.04 @@ -92,7 +78,7 @@ jobs: - uses: Swatinem/rust-cache@v2 # ---- doc check ---- - name: Test Docs - run: RUSTFLAGS="--cfg docsrs" cargo +nightly test --doc --all-features + run: test-docs ubuntu-miri: runs-on: ubuntu-24.04 @@ -105,7 +91,7 @@ jobs: - uses: Swatinem/rust-cache@v2 # --- miri undefined behavior test -- - name: Run miri tests - run: RUST_BACKTRACE=1 MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test + run: just test-miri ubuntu: runs-on: ubuntu-24.04 @@ -120,16 +106,16 @@ jobs: - name: Check pcguard edges run: cargo check --features=sancov_pcguard_edges - name: run shellcheck - run: shellcheck ./scripts/*.sh + run: just shellcheck # ---- build normal and examples ---- - name: Run a normal build - run: cargo build --verbose + run: just default # - name: Run libafl_qemu usermode tests # run: cd libafl_qemu && cargo test # - name: Run libafl_qemu systemmode tests # run: cd libafl_qemu && cargo test --no-default-features --features x86_64,systemmode - name: Build examples - run: cargo build --examples --verbose + run: just examples cargo build --examples --verbose ubuntu-clippy: runs-on: ubuntu-24.04 @@ -143,7 +129,7 @@ jobs: - uses: Swatinem/rust-cache@v2 with: { shared-key: "ubuntu" } - name: Run clippy - run: LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} ./scripts/clippy.sh + run: LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} just clippy # --- test embedding the libafl_libfuzzer_runtime library # Fix me plz # - name: Test Build libafl_libfuzzer with embed @@ -180,7 +166,7 @@ jobs: - name: Install smoke test deps run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh - name: Run smoke test - run: ./libafl_concolic/test/smoke_test.sh + run: just concolic-smoke-test python-bindings: runs-on: ubuntu-24.04 @@ -194,9 +180,9 @@ jobs: - uses: Swatinem/rust-cache@v2 with: { shared-key: "ubuntu" } - name: Run a maturin build - run: export LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} && cd ./bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh + run: export LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} && just build-python - name: Run python test - run: . ./bindings/pylibafl/.env/bin/activate # && cd ./fuzzers/binary_only/python_qemu/ && python3 fuzzer.py 2>&1 | grep "Bye" + run: just test-python-fuzzer cargo-fmt: runs-on: ubuntu-24.04 @@ -212,8 +198,10 @@ jobs: with: { shared-key: "ubuntu" } - name: Installing black run: python3 -m pip install black + - name: Install taplo + run: curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - name: Format Check - run: ./scripts/fmt_all.sh check + run: just check-fmt check-md-links: # fixme: use ubuntu-latest once this gets fixed https://github.com/UmbrellaDocs/action-linkspector/issues/32 @@ -233,14 +221,14 @@ jobs: - uses: taiki-e/install-action@cargo-hack - run: rustup upgrade # Note: We currently only specify minimum rust versions for the default workspace members - - run: cargo hack check --rust-version -p libafl -p libafl_bolts -p libafl_derive -p libafl_cc -p libafl_targets + - run: just msrv fuzzers-preflight: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Fuzzer in CI Check - run: ./scripts/check_tested_fuzzers.sh + run: just fuzzers-preflight fuzzers: needs: @@ -331,7 +319,7 @@ jobs: - name: Build and run example fuzzers (Linux) if: runner.os == 'Linux' shell: bash - run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} ./scripts/test_fuzzer.sh ${{ matrix.fuzzer }} + run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} just test-fuzzer ${{ matrix.fuzzer }} changes: runs-on: ubuntu-24.04 @@ -372,7 +360,7 @@ jobs: - name: Build and run example fuzzers (Linux) if: runner.os == 'Linux' shell: bash - run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} ./scripts/test_fuzzer.sh ${{ matrix.fuzzer }} + run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} just test-fuzzer ${{ matrix.fuzzer }} fuzzers-qemu-user: needs: @@ -402,7 +390,7 @@ jobs: - name: Build and run example QEMU fuzzers (Linux) if: runner.os == 'Linux' shell: bash - run: ARCH=${{ matrix.arch }} RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} ./scripts/test_fuzzer.sh ${{ matrix.fuzzer }} + run: ARCH=${{ matrix.arch }} RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} just test-fuzzer ${{ matrix.fuzzer }} librasan-build: runs-on: ubuntu-24.04 @@ -418,10 +406,7 @@ jobs: run: | RUN_ON_CI=1 \ LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \ - just \ - -f ./libafl_qemu/librasan/Justfile \ - build_everything_dev \ - build_x86_64_release + just build-librasan librasan-test: runs-on: ubuntu-24.04 @@ -437,9 +422,7 @@ jobs: run: | RUN_ON_CI=1 \ LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} \ - just \ - -f ./libafl_qemu/librasan/Justfile \ - test_everything + just test-librasan fuzzers-qemu-system: needs: @@ -462,7 +445,7 @@ jobs: - name: Build and run example QEMU fuzzers (Linux) if: runner.os == 'Linux' shell: bash - run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} ./scripts/test_fuzzer.sh ${{ matrix.fuzzer }} + run: RUN_ON_CI=1 LLVM_CONFIG=llvm-config-${{env.MAIN_LLVM_VERSION}} just test-fuzzer ${{ matrix.fuzzer }} nostd-build: runs-on: ubuntu-24.04 @@ -471,15 +454,13 @@ jobs: with: components: rust-src - name: Add targets - run: rustup target add arm-linux-androideabi && rustup target add thumbv6m-none-eabi + run: rustup target add arm-linux-androideabi && rustup target add aarch64-unknown-none - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Build aarch64-unknown-none - run: cd ./fuzzers/fuzz_anything/baby_no_std && cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release && cd ../.. + run: just build-aarch64-unknown-none - name: run x86_64 until panic! - run: cd ./fuzzers/fuzz_anything/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1 - - name: no_std tests - run: cd ./libafl && cargo test --no-default-features + run: just test-no-std nostd-clippy: runs-on: ubuntu-24.04 @@ -492,25 +473,14 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: libafl armv6m-none-eabi (32 bit no_std) clippy - run: cd ./libafl && cargo clippy --target thumbv6m-none-eabi --no-default-features - - name: Build no_std no_alloc bolts - run: cd ./libafl_bolts && cargo +nightly build -Zbuild-std=core --target aarch64-unknown-none --no-default-features -v --release && cd ../ - - format-toml: - runs-on: ubuntu-24.04 - steps: - - name: Install taplo - run: curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo - - uses: actions/checkout@v4 - - name: Run taplo - run: taplo format --check + run: just clippy-thumbv6m-none-eabi build-docker: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - name: Build docker - run: docker build -t libafl . + run: just docker windows-frida-libpng: runs-on: windows-latest @@ -520,7 +490,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/workflows/windows-tester-prepare - name: Build fuzzers/binary_only/frida_libpng - run: cd fuzzers/binary_only/frida_libpng/ && just test + run: just test-fuzzer ./fuzzers/binary_only/frida_libpng/ windows-libfuzzer-stb-image: runs-on: windows-latest @@ -530,7 +500,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/workflows/windows-tester-prepare - name: Build fuzzers/inprocess/libfuzzer_stb_image - run: cd fuzzers/inprocess/libfuzzer_stb_image && cargo build --release + run: just test-fuzzer ./fuzzers/inprocess/libfuzzer_stb_image # windows-libfuzzer-asan: # runs-on: windows-latest @@ -540,7 +510,7 @@ jobs: # - uses: actions/checkout@v4 # - uses: ./.github/workflows/windows-tester-prepare # - name: Build fuzzers/inprocess/libfuzzer_windows_asan - # run: cd fuzzers/inprocess/libfuzzer_windows_asan && just test + # run: just test-fuzzer ./fuzzers/inprocess/libfuzzer_windows_asan windows-frida-gdiplus: runs-on: windows-latest @@ -550,7 +520,11 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/workflows/windows-tester-prepare - name: Build fuzzers/binary_only/frida_windows_gdiplus - run: cd fuzzers/binary_only/frida_windows_gdiplus/ && just test && just test_cmplog + run: just test-fuzzer ./fuzzers/binary_only/frida_windows_gdiplus/ + - name: Build fuzzers/binary_only/frida_windows_gdiplus + run: just test-fuzzer ./fuzzers/binary_only/frida_windows_gdiplus/ + - name: Cmplog test + run: just test-fuzzers-gdiplus-cmplog windows-tinyinst-simple: runs-on: windows-latest @@ -562,7 +536,7 @@ jobs: - uses: actions/checkout@v4 - uses: ./.github/workflows/windows-tester-prepare - name: Build fuzzers/binary_only/tinyinst_simple - run: cd fuzzers/binary_only/tinyinst_simple/ && just test + run: just test-fuzzer ./fuzzers/binary_only/tinyinst_simple/ windows-clippy: runs-on: windows-latest @@ -574,8 +548,7 @@ jobs: - uses: ./.github/workflows/windows-tester-prepare - uses: Swatinem/rust-cache@v2 - name: Run real clippy, not the fake one - shell: pwsh - run: .\scripts\clippy.ps1 + run: just clippy macos: runs-on: macOS-latest @@ -590,11 +563,11 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: MacOS Build - run: cargo build --verbose + run: just build - name: Increase map sizes - run: ./scripts/shmem_limits_macos.sh + run: just increase-mem-limits - name: Clippy - run: cargo +nightly clippy --tests --all --exclude libafl_nyx --exclude symcc_runtime --exclude runtime_test + run: just clippy ios: runs-on: macOS-latest @@ -605,7 +578,7 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Build iOS - run: PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo build --target aarch64-apple-ios && cd libafl_frida && cargo build --target aarch64-apple-ios && cd .. + run: just build-ios android: runs-on: ubuntu-24.04 @@ -623,7 +596,7 @@ jobs: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 - name: Build Android - run: cd libafl && PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo ndk -t arm64-v8a build --release + run: just build-android #run: cargo build --target aarch64-linux-android # TODO: Figure out how to properly build stuff with clang diff --git a/justfile b/justfile new file mode 100644 index 00000000000..04cdb898b54 --- /dev/null +++ b/justfile @@ -0,0 +1,293 @@ +export ROOT_DIR := justfile_directory() +export SCRIPTS_DIR := join(justfile_directory(), "scripts") +export FUZZERS_DIR := join(justfile_directory(), "fuzzers") +export TARGET_DIR := join(justfile_directory(), "target") +export DOCS_DIR := join(justfile_directory(), "docs") +export LIBAFL_DIR := join(justfile_directory(), "libafl") +export LIBAFL_BOLTS_DIR := join(justfile_directory(), "libafl_bolts") +export LIBAFL_TARGETS_DIR := join(justfile_directory(), "libafl_targets") + +MSRV := env_var_or_default('MSRV', "") + +# Check, build, and test all crates with default features enabled +default feature='' ignore='': (check feature ignore) (build feature ignore) (test feature ignore) + +# Check, build, and test all crates with all-features enabled +all-features: (default "--all-features") + +# Build examples +examples: (default "--examples") + +# Check, build, and test all crates with no-default-features +no-default-features: (default "--no-default-features") + +# Run check on all projects in the workspace +check feature='' ignore='': + cargo ws exec {{ignore}} cargo {{MSRV}} check --locked --all-targets {{feature}} + cargo {{MSRV}} check --manifest-path fuzz/Cargo.toml --locked --all-targets + +# Run build on all projects in the workspace +build feature='' ignore='': + cargo ws exec {{ignore}} cargo {{MSRV}} build --locked --all-targets {{feature}} + +# Run tests on all projects in the workspace +test feature='' ignore='': + cargo ws exec {{ignore}} cargo {{MSRV}} test --locked --all-targets {{feature}} + +# Runs tests without default features (for no_std) +test-no-std: + cd {{LIBAFL_DIR}} && cargo test --no-default-features + cd {{LIBAFL_BOLTS_DIR}} && cargo test --no-default-features + cd {{LIBAFL_TARGETS_DIR}} && cargo test --no-default-features + cd {{FUZZERS_DIR}}/fuzz_anything/baby_no_std && cargo +nightly run || test $? -ne 0 || exit 1 + +# Build the fuzzer on aarch64 none +build-aarch64-unknown-none: + cd {{LIBAFL_BOLTS_DIR}} && cargo +nightly build -Zbuild-std=core --target aarch64-unknown-none --no-default-features -v --release + cd {{FUZZERS_DIR}}/fuzz_anything/baby_no_std && cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release + +clippy-thumbv6m-none-eabi: + cd {{LIBAFL_DIR}} && cargo clippy --target thumbv6m-none-eabi --no-default-features + +# Builds the docs +doc feature='': + cargo ws exec cargo {{MSRV}} test --locked --doc {{feature}} --test-threads 1 + RUSTFLAGS="--cfg docsrs" cargo +nightly doc --all-features --no-deps + +# Tests the code using miri +test-miri: + RUST_BACKTRACE=1 MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test + +# Tests all code in docs (macos version) +[private] +[macos] +test-docs-internal: all-features + cd {{DOCS_DIR}} && mdbook test -L ../target/debug/deps $(python3-config --ldflags | cut -d ' ' -f1) + +# Tests all code in docs (linux version) +[private] +[linux] +test-docs-internal: all-features + RUSTFLAGS="--cfg docsrs" cargo +nightly test --doc --all-features + cd {{DOCS_DIR}} && mdbook test -L ../target/debug/deps + +# Tests all code in docs +test-docs: test-docs-internal + RUSTDOCFLAGS="-Dwarnings" cargo ws exec cargo doc --locked --all-features --no-deps --document-private-items + +# Runs clippy on all crates +[private] +clippy-inner feature='': + cargo ws exec cargo {{MSRV}} clippy --locked --all-targets {{feature}} -- -D warnings + +# Run clippy on all targets and all sources +[linux] +clippy: + just clippy-inner --no-default-features + just clippy-inner + just clippy-inner --all-features + +# Run clippy on.. some things? +[macos] +clippy: + cargo +nightly clippy --tests --all --exclude libafl_nyx --exclude symcc_runtime --exclude runtime_test + +# Run clippy powershell script +[windows] +clippy: + pwsh {{SCRIPTS_DIR}}/clippy.ps1 + +# Check the format of all code +check-fmt: (fmt "check") + +# Format everything +fmt params="": + {{SCRIPTS_DIR}}/fmt_all.sh {{params}} + +#: We currently only specify minimum rust versions for the default workspace members +msrv: + cargo hack check --rust-version -p libafl -p libafl_bolts -p libafl_derive -p libafl_cc -p libafl_targets + +# Check that all fuzzers are listed below in the justfile +fuzzers-preflight: + ./scripts/check_tested_fuzzers.sh + +# Do nothing (to comment things (out)) +nop comment1="" comment2="" comment3="": + +test-fuzzer fuzzer_dir: + {{SCRIPTS_DIR}}/test_fuzzer.sh {{fuzzer_dir}} + +test-fuzzers: fuzzers-preflight \ + test-os-specific-fuzzers \ + \ + (nop "Baby" ) \ + (test-fuzzer "./fuzzers/baby/baby_fuzzer_swap_differential") \ + (test-fuzzer "./fuzzers/baby/tutorial") \ + (test-fuzzer "./fuzzers/baby/baby_fuzzer") \ + (nop "./fuzzers/baby/backtrace_baby_fuzzers") \ + (test-fuzzer "./fuzzers/baby/baby_fuzzer_unicode") \ + (test-fuzzer "./fuzzers/baby/baby_fuzzer_minimizing") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/c_code_with_fork_executor") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/c_code_with_inprocess_executor") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_fork_executor") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/rust_code_with_inprocess_executor") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/command_executor") \ + (test-fuzzer "./fuzzers/baby/backtrace_baby_fuzzers/forkserver_executor") \ + (test-fuzzer "./fuzzers/baby/baby_fuzzer_custom_executor") \ + \ + (nop "Binary-only") \ + (test-fuzzer "./fuzzers/binary_only/frida_executable_libpng") \ + (test-fuzzer "./fuzzers/binary_only/frida_libpng") \ + (test-fuzzer "./fuzzers/binary_only/intel_pt_baby_fuzzer") \ + (test-fuzzer "./fuzzers/binary_only/intel_pt_command_executor") \ + (test-fuzzer "./fuzzers/binary_only/tinyinst_simple") \ + \ + (nop "Forkserver") \ + (test-fuzzer "./fuzzers/forkserver/forkserver_simple") \ + (test-fuzzer "./fuzzers/forkserver/forkserver_libafl_cc") \ + (test-fuzzer "./fuzzers/forkserver/fuzzbench_forkserver") \ + (test-fuzzer "./fuzzers/forkserver/fuzzbench_forkserver_cmplog") \ + (test-fuzzer "./fuzzers/forkserver/fuzzbench_forkserver_sand") \ + (test-fuzzer "./fuzzers/forkserver/libafl-fuzz") \ + (test-fuzzer "./fuzzers/forkserver/baby_fuzzer_with_forkexecutor") \ + \ + (nop "Full-system") \ + (test-fuzzer "./fuzzers/full_system/nyx_launcher") \ + (test-fuzzer "./fuzzers/full_system/nyx_libxml2_standalone") \ + (test-fuzzer "./fuzzers/full_system/nyx_libxml2_parallel") \ + \ + (test-fuzzer "./fuzzers/full_system/unicorn") \ + \ + (nop "Structure-aware") \ + (test-fuzzer "./fuzzers/structure_aware/nautilus_sync") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_grimoire") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_gramatron") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_tokens") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_multi") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_custom_input") \ + (test-fuzzer "./fuzzers/structure_aware/baby_fuzzer_nautilus") \ + (test-fuzzer "./fuzzers/structure_aware/forkserver_simple_nautilus") \ + \ + (nop "In-process") \ + (test-fuzzer "./fuzzers/fuzz_anything/cargo_fuzz") \ + (test-fuzzer "./fuzzers/inprocess/fuzzbench") \ + (test-fuzzer "./fuzzers/inprocess/fuzzbench_text") \ + (test-fuzzer "./fuzzers/inprocess/fuzzbench_ctx") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libmozjpeg") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng_launcher") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng_accounting") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng_centralized") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng_cmin") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_libpng_norestart") \ + (nop "./fuzzers/inprocess/libfuzzer_libpng_tcp_manager") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_stb_image_sugar") \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_stb_image") \ + (nop "./fuzzers/structure_aware/libfuzzer_stb_image_concolic") \ + (nop "./fuzzers/inprocess/sqlite_centralized_multi_machine") \ + \ + (nop "Fuzz Anything") \ + (test-fuzzer "./fuzzers/fuzz_anything/push_harness") \ + (test-fuzzer "./fuzzers/fuzz_anything/push_stage_harness") \ + (test-fuzzer "./fuzzers/fuzz_anything/libafl_atheris") \ + (test-fuzzer "./fuzzers/fuzz_anything/baby_no_std") \ + (test-fuzzer "./fuzzers/fuzz_anything/baby_fuzzer_wasm") \ + +# Windows-specific cmplog test +[windows] +test-fuzzers-gdiplus-cmplog: + cd {{FUZZERS_DIR}}/binary_only/frida_windows_gdiplus/ && just test_cmplog + + +# Fuzzers specific to linux +[linux] +test-os-specific-fuzzers: test-python-fuzzer \ + (nop "Binary-only") \ + (test-fuzzer "./fuzzers/binary_only/fuzzbench_fork_qemu") \ + (test-fuzzer "./fuzzers/binary_only/fuzzbench_qemu") \ + \ + (nop "Full-system") \ + (test-fuzzer "./fuzzers/full_system/qemu_baremetal") \ + (test-fuzzer "./fuzzers/full_system/qemu_linux_kernel") \ + (test-fuzzer "./fuzzers/full_system/qemu_linux_process") \ + \ + (nop "Binary only") \ + (test-fuzzer "./fuzzers/binary_only/qemu_cmin") \ + (test-fuzzer "./fuzzers/binary_only/qemu_coverage") \ + (test-fuzzer "./fuzzers/binary_only/qemu_launcher") \ + +# Fuzzers specific to MacOS +[macos] +test-os-specific-fuzzers: + +# Fuzzers specific to Windows +[windows] +test-os-specific-fuzzers: \ + (test-fuzzer "./fuzzers/inprocess/libfuzzer_windows_asan") \ + (test-fuzzer "./fuzzers/binary_only/frida_windows_gdiplus") \ + (test-fuzzer "fuzzers/binary_only/frida_libpng/") \ + (test-fuzzer "fuzzers/binary_only/tinyinst_simple/") \ + test-fuzzers-gdiplus-cmplog + +# Tests the python fuzzer +[linux] +test-python-fuzzer: + sh -c ". {{ROOT_DIR}}/bindings/pylibafl/.env/bin/activate && cd {{FUZZERS_DIR}}/binary_only/python_qemu/ && python3 fuzzer.py 2>&1 | grepy 'Bye'" + +# Builds the python bindings +build-python: + sh -C "cd {{ROOT_DIR}}/bindings/pylibafl && python3 -m venv .env && . .env/bin/activate && pip install --upgrade --force-reinstall . && ./test.sh" + +# Task to run clippy, rustfmt, and audit on all crates +cleanliness: clippy check-fmt + +build-librasan: + just \ + -f {{FUZZERS_DIR}}/libafl_qemu/librasan/Justfile \ + build_everything_dev \ + build_x86_64_release + +test-librasan: + just \ + -f {{FUZZERS_DIR}}/libafl_qemu/librasan/Justfile \ + test_everything + +# Publish all crates +[unix] +publish: + cd {{ROOT_DIR}} && cargo ws publish --publish-as-is --no-remove-dev-deps --token $CRATES_IO_TOKEN + +[unix] +autofix: + {{SCRIPTS_DIR}}/autofix.sh + +clean: + cargo clean + find {{FUZZERS_DIR}} -d -name 'target' -exec rm -r {} \; + +docker: + docker build -t libafl {{ROOT_DIR}} + +# Runs hellcheck on the scripts folder +[unix] +shellcheck: + shellcheck {{SCRIPTS_DIR}}/*.sh + +# Builds libafl for Android +build-android: + cd {{LIBAFL_DIR}} && PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo ndk -t arm64-v8a build --release + +# Builds libafl for iOS +build-ios: + PYO3_CROSS_PYTHON_VERSION=$(python3 -c "print('{}.{}'.format(__import__('sys').version_info.major, __import__('sys').version_info.minor))") cargo build --target aarch64-apple-ios && cd {{ROOT_DIR}}/libafl_frida && cargo build --target aarch64-apple-ios + +# Increase mem limit for macos +[macos] +increase-mem-limits: + {{SCRIPTS_DIR}}/shmem_limits_macos.sh + +# Run Smoketest for the libafl concolic executor +[linux] +concolic-smoke-test: + {{ROOT_DIR}}/libafl_concolic/test/smoke_test.sh diff --git a/libafl_targets/src/windows_asan.rs b/libafl_targets/src/windows_asan.rs index 767fec87cff..f93f40f0991 100644 --- a/libafl_targets/src/windows_asan.rs +++ b/libafl_targets/src/windows_asan.rs @@ -29,11 +29,8 @@ unsafe extern "C" { /// /// # Safety /// Calls the unsafe `__sanitizer_set_death_callback` symbol, but should be safe to call otherwise. -pub unsafe fn setup_asan_callback( - _executor: &E, - _event_mgr: &EM, - _fuzzer: &Z, -) where +pub unsafe fn setup_asan_callback(_executor: &E, _event_mgr: &EM, _fuzzer: &Z) +where E: Executor + HasObservers, E::Observers: ObserversTuple, EM: EventFirer + EventRestarter, diff --git a/scripts/check_tested_fuzzers.sh b/scripts/check_tested_fuzzers.sh index a191f01d9f3..81ff194e309 100755 --- a/scripts/check_tested_fuzzers.sh +++ b/scripts/check_tested_fuzzers.sh @@ -15,4 +15,17 @@ done < <( find ./fuzzers/baby/backtrace_baby_fuzzers -mindepth 1 -maxdepth 1 -type d ) -exit $ret \ No newline at end of file +while read -r fuzzdir; do + if ! grep -qa "$fuzzdir" justfile; then + ret=1 + echo "Missing fuzzer ${fuzzdir} in justfile!" + fi + if grep -qa "nop \"$fuzzdir" justfile; then + echo "Fuzzer ${fuzzdir} is explicitly ignored in justfile" + fi +done < <( + find ./fuzzers -mindepth 2 -maxdepth 2 -type d + find ./fuzzers/baby/backtrace_baby_fuzzers -mindepth 1 -maxdepth 1 -type d + ) + +exit $ret diff --git a/scripts/fmt_all.sh b/scripts/fmt_all.sh index 9bfe9865c1b..71781356dea 100755 --- a/scripts/fmt_all.sh +++ b/scripts/fmt_all.sh @@ -38,6 +38,8 @@ if [ "$1" != "check" ]; then echo "[*] Formatting TOML files" taplo format fi +else + run: taplo format --check || exit 1 fi echo "[*] Done :)" From a3f7a1b6ebbfede37a37036065b1ba828aee74bb Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Sat, 22 Mar 2025 08:51:26 -0700 Subject: [PATCH 2/2] more? --- .github/workflows/build_and_test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index bd3873c48e1..387d0134f98 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -533,6 +533,8 @@ jobs: steps: - name: install cxx bridge run: cargo install cxxbridge-cmd + - name: Install just, ws + run: cargo install just cargo-workspaces - uses: actions/checkout@v4 - uses: ./.github/workflows/windows-tester-prepare - name: Build fuzzers/binary_only/tinyinst_simple @@ -545,6 +547,8 @@ jobs: steps: - uses: dtolnay/rust-toolchain@stable - uses: actions/checkout@v4 + - name: Install just, ws + run: cargo install just cargo-workspaces - uses: ./.github/workflows/windows-tester-prepare - uses: Swatinem/rust-cache@v2 - name: Run real clippy, not the fake one @@ -556,6 +560,8 @@ jobs: - uses: dtolnay/rust-toolchain@stable - name: Add nightly clippy run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly + - name: Install just, ws + run: cargo install just cargo-workspaces - name: Install deps run: brew install z3 gtk+3 python - name: Install cxxbridge