Skip to content

Commit

Permalink
Integrate initial OSS-Fuzz support (#5850)
Browse files Browse the repository at this point in the history
  • Loading branch information
initializedd committed Dec 21, 2024
1 parent cff27db commit 7e7058e
Show file tree
Hide file tree
Showing 3 changed files with 317 additions and 0 deletions.
278 changes: 278 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "fuzz"
version = "0.0.0"
edition = "2021"
publish = false

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4.8"
clap = { path = "../", version = "4.5.20", features = ["derive"] }

# Prevent this from interfering with workspaces
[workspace]

[[bin]]
name = "parse_fuzzer"
path = "fuzz_targets/parse_fuzzer.rs"
test = false
doc = false

17 changes: 17 additions & 0 deletions fuzz/fuzz_targets/parse_fuzzer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use clap::Parser;

#[derive(Parser)]
struct Args {
#[arg(short, long)]
test: String
}

fuzz_target!(|data: &[u8]| {
if let Ok(s) = String::from_utf8(data.to_vec()) {
let _ = Args::try_parse_from(vec![s]);
}
});

0 comments on commit 7e7058e

Please sign in to comment.