Add fuzzing (#15)

This commit is contained in:
jneem 2024-10-19 08:22:23 +07:00 committed by GitHub
parent 3cade858fa
commit 42c84079c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 0 deletions

View file

@ -8,6 +8,7 @@ members = [
"bench", "bench",
"bench/tools/gen_large_yaml", "bench/tools/gen_large_yaml",
"bench/tools/bench_compare", "bench/tools/bench_compare",
"fuzz",
] ]
resolver = "2" resolver = "2"

19
fuzz/Cargo.toml Normal file
View file

@ -0,0 +1,19 @@
[package]
name = "saphyr-fuzz"
version = "0.0.0"
publish = false
edition = "2021"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.4"
saphyr.workspace = true
[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"
test = false
doc = false
bench = false

View file

@ -0,0 +1,9 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _ = saphyr::Yaml::load_from_str(s);
}
});