CI: A few updates and fixes (#2023)

* CI: Don't run cargo clean in order to preserve build caches

* CI: run yaml formatter >:)

* CI: try sharing build caches between similar jobs

* CI: it looks like the `ucd-generate` tool is not used anymore

* CI: Sneak in merge queue support :)

* CI: split out `cargo fmt --check` job

* libafl_qemu injections: be more resilient about mapping paths
This commit is contained in:
Mrmaxmeier 2024-04-09 12:55:07 +02:00 committed by GitHub
parent 2cc560e727
commit f252469d86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 336 additions and 334 deletions

View File

@ -2,10 +2,11 @@ name: build and test
on: on:
push: push:
branches: [ main, 'pr/**' ] branches: [main, "pr/**"]
pull_request: pull_request:
branches: [ main ] branches: [main]
workflow_dispatch: workflow_dispatch:
merge_group:
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
concurrency: concurrency:
@ -40,6 +41,10 @@ jobs:
crate: mdbook-linkcheck crate: mdbook-linkcheck
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
if: runner.os == 'Linux'
- uses: Swatinem/rust-cache@v2
if: runner.os != 'Linux'
- name: Check for binary blobs - name: Check for binary blobs
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: ./scripts/check_for_blobs.sh run: ./scripts/check_for_blobs.sh
@ -75,6 +80,7 @@ jobs:
toolchain: stable toolchain: stable
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "llvm-tester" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -82,7 +88,6 @@ jobs:
- name: Build and test with llvm-${{ matrix.llvm-version }} - name: Build and test with llvm-${{ matrix.llvm-version }}
run: pwd && ls & cd libafl_cc && cargo build --release run: pwd && ls & cd libafl_cc && cargo build --release
ubuntu-doc: ubuntu-doc:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
needs: ubuntu needs: ubuntu
@ -99,10 +104,9 @@ jobs:
run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
- name: Install ucd-generate
run: cargo install -f ucd-generate
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -130,10 +134,9 @@ jobs:
run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
- name: Install ucd-generate
run: cargo install -f ucd-generate
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -158,10 +161,9 @@ jobs:
run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev run: sudo apt update && sudo apt install ninja-build shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade run: rustup toolchain install nightly --component rustfmt --component clippy --component miri --allow-downgrade
- name: Install ucd-generate
run: cargo install -f ucd-generate
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -171,10 +173,6 @@ jobs:
# pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately # pcguard edges and pcguard hitcounts are not compatible and we need to build them seperately
- name: Check pcguard edges - name: Check pcguard edges
run: cargo check --features=sancov_pcguard_edges run: cargo check --features=sancov_pcguard_edges
- name: Format
run: cargo fmt -- --check
- name: Cleanup
run: cargo clean
- name: Run clang-format style check for C/C++ programs. - name: Run clang-format style check for C/C++ programs.
run: clang-format -n -Werror --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c' | grep -v 'QEMU-Nyx') run: clang-format -n -Werror --style=file $(find . -type f \( -name '*.cpp' -o -iname '*.hpp' -o -name '*.cc' -o -name '*.cxx' -o -name '*.cc' -o -name '*.h' \) | grep -v '/target/' | grep -v 'libpng-1\.6\.37' | grep -v 'stb_image\.h' | grep -v 'dlmalloc\.c' | grep -v 'QEMU-Nyx')
- name: run shellcheck - name: run shellcheck
@ -202,6 +200,7 @@ jobs:
run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly run: rustup toolchain install nightly --component clippy --allow-downgrade && rustup default nightly
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -210,10 +209,6 @@ jobs:
- name: Run clippy - name: Run clippy
run: ./scripts/clippy.sh run: ./scripts/clippy.sh
# Clean up files to save up disk space
- name: Cleanup
run: cargo clean
# --- test embedding the libafl_libfuzzer_runtime library # --- test embedding the libafl_libfuzzer_runtime library
# Fix me plz # Fix me plz
# - name: Test Build libafl_libfuzzer with embed # - name: Test Build libafl_libfuzzer with embed
@ -249,12 +244,11 @@ jobs:
run: sudo apt update && sudo apt install ninja-build clang-format shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev run: sudo apt update && sudo apt install ninja-build clang-format shellcheck libgtk-3-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libslirp-dev libz3-dev
- name: Install cargo-hack - name: Install cargo-hack
run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin run: curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: Install ucd-generate
run: cargo install -f ucd-generate
- name: Add nightly - name: Add nightly
run: rustup toolchain install nightly --allow-downgrade run: rustup toolchain install nightly --allow-downgrade
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install LLVM and Clang - name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1 uses: KyleMayes/install-llvm-action@v1
with: with:
@ -280,6 +274,7 @@ jobs:
toolchain: stable toolchain: stable
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: { shared-key: "ubuntu" }
- name: Install smoke test deps - name: Install smoke test deps
run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh run: sudo ./libafl_concolic/test/smoke_test_ubuntu_deps.sh
- name: Run smoke test - name: Run smoke test
@ -310,6 +305,19 @@ jobs:
- name: Run python test - name: Run python test
run: . ./bindings/pylibafl/.env/bin/activate # && cd ./fuzzers/python_qemu/ && python3 fuzzer.py 2>&1 | grep "Bye" run: . ./bindings/pylibafl/.env/bin/activate # && cd ./fuzzers/python_qemu/ && python3 fuzzer.py 2>&1 | grep "Bye"
cargo-fmt:
runs-on: ubuntu-latest
steps:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt
- uses: actions/checkout@v3
- name: Format Check
run: cargo fmt -- --check
fuzzers: fuzzers:
needs: ubuntu needs: ubuntu
strategy: strategy:
@ -482,8 +490,6 @@ jobs:
toolchain: stable toolchain: stable
- name: Add nightly rustfmt and clippy - name: Add nightly rustfmt and clippy
run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade && rustup default nightly run: rustup toolchain install nightly --component rustfmt --component clippy --allow-downgrade && rustup default nightly
- name: Install ucd-generate
run: cargo install -f ucd-generate
- name: Install deps - name: Install deps
run: brew install z3 gtk+3 run: brew install z3 gtk+3
- name: Install cxxbridge - name: Install cxxbridge
@ -551,7 +557,6 @@ jobs:
freebsd-version freebsd-version
. "$HOME/.cargo/env" . "$HOME/.cargo/env"
rustup toolchain install nightly rustup toolchain install nightly
cargo install -f ucd-generate
export LLVM_CONFIG=/usr/local/bin/llvm-config16 export LLVM_CONFIG=/usr/local/bin/llvm-config16
pwd pwd
ls -lah ls -lah

View File

@ -8,8 +8,7 @@ runs:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
with: with: { shared-key: "${{ runner.os }}-shared-fuzzer-cache" }
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/toolchain@v1 - uses: actions-rs/toolchain@v1
with: with:
profile: minimal profile: minimal
@ -23,9 +22,6 @@ runs:
- name: Add wasm target - name: Add wasm target
shell: bash shell: bash
run: rustup target add wasm32-unknown-unknown run: rustup target add wasm32-unknown-unknown
- name: Install ucd-generate
shell: bash
run: cargo install -f ucd-generate
- name: Remove obsolete llvm (Linux) - name: Remove obsolete llvm (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
shell: bash shell: bash

View File

@ -78,7 +78,7 @@ fn main() {
assert!( assert!(
command.status().map_or(false, |s| s.success()), command.status().map_or(false, |s| s.success()),
"Couldn't build runtime crate! Did you remember to use nightly? (`rustup default nightly` to install) Or, did you remember to install ucd-generate? (`cargo install ucd-generate` to install)" "Couldn't build runtime crate! Did you remember to use nightly? (`rustup default nightly` to install)"
); );
let mut archive_path = custom_lib_dir.join(std::env::var_os("TARGET").unwrap()); let mut archive_path = custom_lib_dir.join(std::env::var_os("TARGET").unwrap());

View File

@ -272,7 +272,8 @@ where
for region in qemu.mappings() { for region in qemu.mappings() {
if let Some(path) = region.path().map(ToOwned::to_owned) { if let Some(path) = region.path().map(ToOwned::to_owned) {
if !path.is_empty() { // skip [heap], [vdso] and friends
if !path.is_empty() && !path.starts_with('[') {
LibInfo::add_unique( LibInfo::add_unique(
&mut libs, &mut libs,
LibInfo { LibInfo {