[tests] Fuzz: cargo-fuzz targets for route files, header rules, share tokens, path_within and the CA's PEM/CSR parsing (tests/fuzz), a bounded run script that saves any crash as a hex regression, and every seed and saved crash replayed in cargo test

This commit is contained in:
2026-11-10 21:17:29 +01:00
parent 1358649550
commit 08e24e5d40
30 changed files with 673 additions and 1 deletions
+58
View File
@@ -0,0 +1,58 @@
# cargo-fuzz project (libFuzzer). Its own workspace: libfuzzer-sys needs the fuzzer flags, which
# the main workspace must not get. The target bodies live in ../src/lib.rs (crate ianitor-fuzz).
# Run: tests/fuzz/run.sh (bounded; any crash fails and is saved as a regression).
[package]
name = "ianitor-fuzz-targets"
version = "0.0.0"
publish = false
edition = "2024"
license = "MPL-2.0"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
ianitor-fuzz = { path = ".." }
[workspace]
members = ["."]
[profile.release]
debug = 1
[[bin]]
name = "routes"
path = "fuzz_targets/routes.rs"
test = false
doc = false
bench = false
[[bin]]
name = "header_rules"
path = "fuzz_targets/header_rules.rs"
test = false
doc = false
bench = false
[[bin]]
name = "share_token"
path = "fuzz_targets/share_token.rs"
test = false
doc = false
bench = false
[[bin]]
name = "path_within"
path = "fuzz_targets/path_within.rs"
test = false
doc = false
bench = false
[[bin]]
name = "pki_pem"
path = "fuzz_targets/pki_pem.rs"
test = false
doc = false
bench = false
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| ianitor_fuzz::header_rules(data));
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| ianitor_fuzz::path_within(data));
+9
View File
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| ianitor_fuzz::pki_pem(data));
+9
View File
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| ianitor_fuzz::routes_toml(data));
@@ -0,0 +1,9 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| ianitor_fuzz::share_token(data));