Skip to content

Commit 3809439

Browse files
committed
merge unicornafl v3
2 parents a8f96da + de2f8d9 commit 3809439

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2881
-5113
lines changed

.github/workflows/ci.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Crate 📦 Distribution
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.config.os }}
10+
name: Test on ${{ matrix.config.os}}
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
config:
15+
- {
16+
os: 'ubuntu-latest'
17+
}
18+
19+
- {
20+
os: 'macos-latest'
21+
}
22+
- {
23+
os: 'macos-13'
24+
}
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: '🛠️ Set up Rust'
29+
uses: dtolnay/rust-toolchain@stable
30+
31+
- name: '🛠️ Set up dependency of AFL++ on Linux'
32+
if: ${{ contains(matrix.config.os, 'ubuntu') }}
33+
run: |
34+
sudo apt update && sudo apt install -y llvm-16-dev clang-16 build-essential \
35+
libtool libtool-bin libglib2.0-dev python3 make cmake automake meson ninja-build bison flex &&\
36+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 0 && \
37+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 0
38+
39+
- name: '🛠️ Set up dependency of AFL++ on macOS'
40+
if: ${{ contains(matrix.config.os, 'macos') }}
41+
run: |
42+
brew install wget git make cmake llvm gdb coreutils
43+
44+
- name: '🚧 Cargo test'
45+
run: |
46+
cargo test
47+
48+
- name: '🚧 Build sample'
49+
run: |
50+
cargo build --release --example sample --features env_logger
51+
52+
- name: '🚧 AFLplusplus Checkout'
53+
uses: actions/checkout@v4
54+
with:
55+
repository: 'AFLplusplus/AFLplusplus'
56+
ref: 'dev'
57+
path: 'AFLplusplus'
58+
59+
- name: '🛠️ macOS quirks for AFL++'
60+
if: contains(matrix.config.os, 'macos')
61+
run: |
62+
cd AFLplusplus && sudo sh ./afl-system-config
63+
64+
- name: '🚧 AFLplusplus Setup'
65+
run: |
66+
cd AFLplusplus &&\
67+
make -j4 afl-fuzz
68+
69+
- name: '🚧 Prepare fuzz resources'
70+
run: |
71+
mkdir ./input && echo 'a' > ./input/a
72+
73+
- name: '🚧 Fuzz 4-byte cmplog for 60 seconds'
74+
run: |
75+
./AFLplusplus/afl-fuzz -i ./input -o ./output-4 -b 1 -g 4 -G 4 -V 60 -c 0 -- ./target/release/examples/sample @@
76+
env:
77+
AFL_BENCH_UNTIL_CRASH: 1
78+
AFL_NO_CRASH_README: 1
79+
AFL_NO_UI: 1
80+
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
81+
AFL_SKIP_CPUFREQ: 1
82+
UNICORN_AFL_CMPCOV: 1
83+
84+
- name: "🚧 Check if we find the crash"
85+
run: |
86+
ls ./output-4/default/crashes/
87+
if [ "$(find ./output-4/default/crashes/ -type f | wc -l)" -eq 0 ]; then
88+
cat ./output-4/default/fuzzer_stats
89+
exit 1;
90+
else
91+
if ! [ "$(grep "stab" ./output-4/default/fuzzer_stats | awk '{print $3}')" = '100.00%' ]; then
92+
cat ./output-4/default/fuzzer_stats
93+
exit 2;
94+
fi
95+
fi
96+
97+
- name: '🚧 Fuzz 8-byte cmplog for 180 seconds'
98+
run: |
99+
./AFLplusplus/afl-fuzz -i ./input -o ./output-8 -b 1 -g 8 -G 8 -V 180 -c 0 -- ./target/release/examples/sample @@ true
100+
env:
101+
AFL_BENCH_UNTIL_CRASH: 1
102+
AFL_NO_CRASH_README: 1
103+
AFL_NO_UI: 1
104+
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
105+
AFL_SKIP_CPUFREQ: 1
106+
UNICORN_AFL_CMPCOV: 1
107+
108+
- name: "🚧 Check if we find the crash"
109+
run: |
110+
ls ./output-8/default/crashes/
111+
if [ "$(find ./output-8/default/crashes/ -type f | wc -l)" -eq 0 ]; then
112+
cat ./output-8/default/fuzzer_stats
113+
exit 1;
114+
else
115+
if ! [ "$(grep "stab" ./output-8/default/fuzzer_stats | awk '{print $3}')" = '100.00%' ]; then
116+
cat ./output-8/default/fuzzer_stats
117+
exit 2;
118+
fi
119+
fi
120+
121+
- name: '📦 Cargo Publish'
122+
if: ${{ startsWith(github.ref, 'refs/tags') && contains(matrix.config.os, 'ubuntu') }}
123+
env:
124+
TOKEN: ${{ secrets.CRATES_IO_KEY }}
125+
run: |
126+
cargo login $TOKEN && cargo test && cargo publish
127+
128+
fmt-check:
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v4
132+
- name: Cargo fmt
133+
run: cargo fmt --check
134+
135+
fmt-toml-check:
136+
runs-on: ubuntu-latest
137+
steps:
138+
- name: Install taplo
139+
run: cargo install taplo-cli --locked
140+
- uses: actions/checkout@v4
141+
- name: Run taplo
142+
run: taplo format --check

.github/workflows/py.yaml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: PyPI 📦 Distribution
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
# https://github.com/Cryptex-github/ril-py/blob/main/.github/workflows/py-binding.yml
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.config.os }}
11+
name: ${{ matrix.config.name }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
config:
16+
- {
17+
os: ubuntu-latest,
18+
arch: x64,
19+
python-version: 'cp38',
20+
name: 'manylinux_x86_64',
21+
alt_arch_name: x86_64
22+
}
23+
24+
# - {
25+
# os: macos-latest,
26+
# arch: x64,
27+
# python-ver: '3.8',
28+
# name: 'macos_x86_64'
29+
# }
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: set up python
34+
uses: actions/setup-python@v4
35+
with:
36+
python-version: '3.9'
37+
38+
- name: set up rust
39+
uses: dtolnay/rust-toolchain@stable
40+
with:
41+
toolchain: stable
42+
43+
- name: Setup Rust cache
44+
uses: Swatinem/rust-cache@v2
45+
with:
46+
key: ${{ matrix.config.alt_arch_name }}
47+
48+
- name: Get pip cache dir
49+
id: pip-cache
50+
if: matrix.config.os != 'windows-latest'
51+
run: |
52+
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
53+
54+
- name: Cache python dependencies
55+
uses: actions/cache@v3
56+
with:
57+
path: ${{ steps.pip-cache.outputs.dir || steps.pip-cache-win.outputs.dir }}
58+
key: ${{ runner.os }}-pip-${{ matrix.config.python-version }}
59+
60+
- name: install python dependencies
61+
run: pip install -U setuptools wheel twine cibuildwheel platformdirs
62+
63+
- name: Display cibuildwheel cache dir
64+
id: cibuildwheel-cache
65+
run: |
66+
from platformdirs import user_cache_path
67+
import os
68+
69+
with open(os.getenv('GITHUB_OUTPUT'), 'w') as f:
70+
f.write(f"dir={str(user_cache_path(appname='cibuildwheel', appauthor='pypa'))}")
71+
shell: python
72+
73+
- name: Cache cibuildwheel tools
74+
uses: actions/cache@v3
75+
with:
76+
path: ${{ steps.cibuildwheel-cache.outputs.dir }}
77+
key: ${{ runner.os }}-cibuildwheel-${{ matrix.config.python-version }}
78+
79+
- name: build sdist
80+
if: matrix.config.os == 'ubuntu-latest' && matrix.config.python-version == 'cp38'
81+
run: |
82+
pip install maturin build
83+
python -m build --sdist -o wheelhouse
84+
85+
- name: build ${{ matrix.config.platform || matrix.config.os }} binaries
86+
run: cibuildwheel --output-dir wheelhouse
87+
env:
88+
CIBW_BUILD_FRONTEND: build
89+
CIBW_BUILD: '${{ matrix.config.python-version }}-${{ matrix.config.name }}'
90+
# rust doesn't seem to be available for musl linux on i686
91+
CIBW_SKIP: '*-musllinux_i686'
92+
# we build for "alt_arch_name" if it exists, else 'auto'
93+
CIBW_ARCHS: ${{ matrix.config.alt_arch_name || 'auto' }}
94+
CIBW_ENVIRONMENT: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always"'
95+
CIBW_ENVIRONMENT_WINDOWS: 'PATH="$UserProfile\.cargo\bin;$PATH"'
96+
CIBW_ENVIRONMENT_LINUX: 'PATH="$HOME/.cargo/bin:$PATH" CARGO_TERM_COLOR="always" MATURIN_PEP517_ARGS="--compatibility manylinux_2_28"'
97+
# These are needed for Unicorn and cbindgen
98+
CIBW_BEFORE_ALL: >
99+
yum update -y && yum install -y clang clang-devel
100+
CIBW_BEFORE_BUILD: rustup show
101+
CIBW_BEFORE_BUILD_LINUX: >
102+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain=stable --profile=minimal -y &&
103+
rustup show
104+
# CIBW_TEST_COMMAND: 'pytest {project}/test'
105+
# CIBW_TEST_REQUIRES: pytest requests
106+
# CIBW_TEST_SKIP: '*-macosx_arm64 *-macosx_universal2:arm64'
107+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
108+
CIBW_BUILD_VERBOSITY: 1
109+
110+
- run: ${{ matrix.config.ls || 'ls -lh' }} wheelhouse/
111+
112+
- name: '📤 Upload artifact'
113+
uses: actions/upload-artifact@v4
114+
with:
115+
name: wheels
116+
path: wheelhouse/
117+
118+
publish:
119+
needs: [build]
120+
runs-on: ubuntu-latest
121+
if: startsWith(github.ref, 'refs/tags')
122+
steps:
123+
- uses: actions/download-artifact@v2
124+
with:
125+
name: artifact
126+
path: dist
127+
128+
- name: '📦 Publish distribution to PyPI'
129+
uses: pypa/gh-action-pypi-publish@master
130+
with:
131+
user: __token__
132+
password: ${{ secrets.pypi_pass }}

.github/workflows/py_test.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Python Example Testing
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
name: Build
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: '🛠️ Set up Rust'
15+
uses: dtolnay/rust-toolchain@stable
16+
17+
- name: '🛠️ Set up Python'
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: '🛠️ Have a venv'
23+
run: python3 -m venv venv
24+
25+
- name: '🛠️ Install the latest Unicorn dev'
26+
run: source venv/bin/activate && python3 -m pip install "git+https://github.com/unicorn-engine/unicorn@dev#subdirectory=bindings/python/"
27+
28+
- name: '🛠️ Set up dependency of AFL++'
29+
run: |
30+
sudo apt update && sudo apt install -y llvm-16-dev clang-16 build-essential \
31+
libtool libtool-bin libglib2.0-dev python3 make cmake automake meson ninja-build bison flex &&\
32+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 0 && \
33+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 0
34+
35+
- name: '🚧 Install Maturin'
36+
run: |
37+
source venv/bin/activate && python3 -m pip install maturin
38+
39+
- name: '🚧 Build Maturin Develop'
40+
run: |
41+
source venv/bin/activate && maturin develop --release
42+
43+
- name: '🚧 AFLplusplus Checkout'
44+
uses: actions/checkout@v4
45+
with:
46+
repository: 'wtdcode/AFLplusplus' # Until merged into main
47+
ref: 'uc-mode'
48+
path: 'AFLplusplus'
49+
50+
- name: '🚧 AFLplusplus Setup'
51+
run: |
52+
cd AFLplusplus &&\
53+
make -j4 afl-fuzz
54+
55+
- name: '🚧 Prepare fuzz resources'
56+
run: |
57+
mkdir ./input && echo 'a' > ./input/a
58+
59+
- name: '🚧 Fuzz 4-byte cmplog for 60 seconds'
60+
run: |
61+
source venv/bin/activate && ./AFLplusplus/afl-fuzz -i ./input -o ./output-4 -b 1 -g 4 -G 4 -V 60 -c 0 -U -- python3 examples/sample.py @@
62+
env:
63+
AFL_BENCH_UNTIL_CRASH: 1
64+
AFL_NO_CRASH_README: 1
65+
AFL_NO_UI: 1
66+
AFL_DEBUG: 1
67+
AFL_DEBUG_CHILD: 1
68+
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
69+
AFL_SKIP_CPUFREQ: 1
70+
UNICORN_AFL_CMPCOV: 1
71+
72+
- name: "🚧 Check if we find the crash"
73+
run: |
74+
ls ./output-4/default/crashes/
75+
if [ "$(find ./output-4/default/crashes/ -type f | wc -l)" -eq 0 ]; then
76+
cat ./output-4/default/fuzzer_stats
77+
exit 1;
78+
else
79+
if ! [ "$(grep "stab" ./output-4/default/fuzzer_stats | awk '{print $3}')" = '100.00%' ]; then
80+
cat ./output-4/default/fuzzer_stats
81+
exit 2;
82+
fi
83+
fi
84+
85+
- name: '🚧 Fuzz 8-byte cmplog for 180 seconds'
86+
run: |
87+
source venv/bin/activate && ./AFLplusplus/afl-fuzz -i ./input -o ./output-8 -b 1 -g 8 -G 8 -V 180 -c 0 -U -- python3 examples/sample.py @@ true
88+
env:
89+
AFL_BENCH_UNTIL_CRASH: 1
90+
AFL_NO_CRASH_README: 1
91+
AFL_NO_UI: 1
92+
AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES: 1
93+
AFL_SKIP_CPUFREQ: 1
94+
UNICORN_AFL_CMPCOV: 1
95+
96+
- name: "🚧 Check if we find the crash"
97+
run: |
98+
ls ./output-8/default/crashes/
99+
if [ "$(find ./output-8/default/crashes/ -type f | wc -l)" -eq 0 ]; then
100+
cat ./output-8/default/fuzzer_stats
101+
exit 1;
102+
else
103+
if ! [ "$(grep "stab" ./output-8/default/fuzzer_stats | awk '{print $3}')" = '100.00%' ]; then
104+
cat ./output-8/default/fuzzer_stats
105+
exit 2;
106+
fi
107+
fi

0 commit comments

Comments
 (0)