Skip to content

Commit 2872d32

Browse files
authored
Add fuzz testing for router and OpenAPI (#166)
* added fuzz tests * fuzzing + gitignore polishing * made clippy happy * adjusted openapi fuzzing
1 parent a06be54 commit 2872d32

File tree

38 files changed

+457
-348
lines changed

38 files changed

+457
-348
lines changed

.github/workflows/fuzz.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Fuzz
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
schedule:
7+
- cron: "17 3 * * *"
8+
workflow_dispatch:
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
ASAN_OPTIONS: quarantine_size_mb=1:malloc_context_size=0
13+
14+
jobs:
15+
fuzz_build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@nightly
20+
- name: Install cargo-fuzz
21+
run: cargo install cargo-fuzz --locked
22+
- name: Build fuzz targets
23+
run: cargo +nightly fuzz build
24+
25+
fuzz_smoke:
26+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
27+
runs-on: ubuntu-latest
28+
needs: fuzz_build
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: dtolnay/rust-toolchain@nightly
32+
- name: Install cargo-fuzz
33+
run: cargo install cargo-fuzz --locked
34+
- name: Smoke run router
35+
run: cargo +nightly fuzz run fuzz_router_match -- -max_len=512 -max_total_time=45 -rss_limit_mb=512
36+
- name: Smoke run query
37+
run: cargo +nightly fuzz run fuzz_query_decode -- -max_len=1024 -max_total_time=45 -rss_limit_mb=512
38+
39+
fuzz_nightly:
40+
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
41+
runs-on: ubuntu-latest
42+
needs: fuzz_build
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- target: fuzz_router_match
48+
max_len: 512
49+
- target: fuzz_query_decode
50+
max_len: 1024
51+
- target: fuzz_extractor_typed
52+
max_len: 4096
53+
- target: fuzz_openapi_gen
54+
max_len: 256
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: dtolnay/rust-toolchain@nightly
58+
- name: Install cargo-fuzz
59+
run: cargo install cargo-fuzz --locked
60+
- name: Nightly fuzz run
61+
run: cargo +nightly fuzz run ${{ matrix.target }} -- -max_len=${{ matrix.max_len }} -max_total_time=300 -rss_limit_mb=512

0 commit comments

Comments
 (0)