mirror of
https://github.com/uuid-rs/uuid.git
synced 2025-09-26 20:41:01 +00:00
add a fuzzing target for the parser
This commit is contained in:
parent
9d06072aa5
commit
4b30c32ca8
@ -118,6 +118,10 @@ You can follow [this link][lrus] to look for issues like this.
|
||||
|
||||
[lrus]: https://github.com/uuid-rs/uuid/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-asc
|
||||
|
||||
# Fuzzing
|
||||
We use [`cargo fuzz`] to fuzz test various parts of `uuid`. See their guide
|
||||
for more details on what fuzzing is and how to run the tests yourself.
|
||||
|
||||
# Helpful Links
|
||||
[Helpful Links]: #helpful-links
|
||||
|
||||
@ -133,3 +137,4 @@ seasoned developers, some useful places to look for information are:
|
||||
[u-r-l-o]: https://users.rust-lang.org
|
||||
[Discussions]: https://github.com/uuid-rs/uuid/discussions
|
||||
[search existing issues]: https://github.com/uuid-rs/uuid/search?q=&type=Issues&utf8=%E2%9C%93
|
||||
[`cargo fuzz`]: https://rust-fuzz.github.io/book/cargo-fuzz.html
|
||||
|
3
fuzz/.gitignore
vendored
Normal file
3
fuzz/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
target
|
||||
corpus
|
||||
artifacts
|
25
fuzz/Cargo.toml
Normal file
25
fuzz/Cargo.toml
Normal file
@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "uuid-fuzz"
|
||||
version = "0.0.0"
|
||||
authors = ["Automatically generated"]
|
||||
publish = false
|
||||
edition = "2018"
|
||||
|
||||
[package.metadata]
|
||||
cargo-fuzz = true
|
||||
|
||||
[dependencies]
|
||||
libfuzzer-sys = "0.4"
|
||||
|
||||
[dependencies.uuid]
|
||||
path = ".."
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
[workspace]
|
||||
members = ["."]
|
||||
|
||||
[[bin]]
|
||||
name = "fuzz_target_parse"
|
||||
path = "fuzz_targets/fuzz_target_parse.rs"
|
||||
test = false
|
||||
doc = false
|
1
fuzz/corpus/fuzz_target_parse/guid
Normal file
1
fuzz/corpus/fuzz_target_parse/guid
Normal file
@ -0,0 +1 @@
|
||||
{6d93bade-bd9f-4e13-8914-9474e1e3567b}
|
1
fuzz/corpus/fuzz_target_parse/hyphenated
Normal file
1
fuzz/corpus/fuzz_target_parse/hyphenated
Normal file
@ -0,0 +1 @@
|
||||
67e55044-10b1-426f-9247-bb680e5fe0c8
|
1
fuzz/corpus/fuzz_target_parse/simple
Normal file
1
fuzz/corpus/fuzz_target_parse/simple
Normal file
@ -0,0 +1 @@
|
||||
67e5504410b1426f9247bb680e5fe0c8
|
1
fuzz/corpus/fuzz_target_parse/urn
Normal file
1
fuzz/corpus/fuzz_target_parse/urn
Normal file
@ -0,0 +1 @@
|
||||
urn:uuid:67e55044-10b1-426f-9247-bb680e5fe0c8
|
12
fuzz/fuzz_targets/fuzz_target_parse.rs
Normal file
12
fuzz/fuzz_targets/fuzz_target_parse.rs
Normal file
@ -0,0 +1,12 @@
|
||||
#![no_main]
|
||||
use libfuzzer_sys::fuzz_target;
|
||||
|
||||
use std::str;
|
||||
use uuid::Uuid;
|
||||
|
||||
fuzz_target!(|data: &[u8]| {
|
||||
if let Ok(uuid) = str::from_utf8(data) {
|
||||
// Ensure the parser doesn't panic
|
||||
let _ = Uuid::parse_str(uuid);
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user