diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..a092511 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,3 @@ +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..300c633 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,26 @@ + +[package] +authors = ["Automatically generated"] +edition = "2018" +name = "grass-fuzz" +publish = false +version = "0.0.0" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.3" + +[dependencies.grass] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +doc = false +name = "from_string_parsing" +path = "fuzz_targets/from_string_parsing.rs" +test = false diff --git a/fuzz/README.md b/fuzz/README.md new file mode 100644 index 0000000..380386f --- /dev/null +++ b/fuzz/README.md @@ -0,0 +1,28 @@ +# Fuzz +Fuzzing targets for the grass library. + +## Installing +You'll need `cargo-fuzz` for this to work, simply do: +``` +cargo install cargo-fuzz +``` + +## Running +Get a list of available targets with: +``` +cargo fuzz list +``` + +And run a available target simply with: +``` +cargo fuzz run +``` +You might have to use nightly: +``` +cargo +nightly fuzz run +``` + + + +## More info about fuzzing +Consult the [fuzzing book](https://rust-fuzz.github.io/book/introduction.html). \ No newline at end of file diff --git a/fuzz/fuzz_targets/from_string_parsing.rs b/fuzz/fuzz_targets/from_string_parsing.rs new file mode 100644 index 0000000..4b9da26 --- /dev/null +++ b/fuzz/fuzz_targets/from_string_parsing.rs @@ -0,0 +1,14 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; + + +fuzz_target!(|data: &[u8]| { + if let Ok(s) = std::str::from_utf8(data) { + let options = grass::Options::default(); + + let _ = grass::from_string( + s.to_owned(), + &options + ); + } +});