diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 665f50fb4..6962a8f7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,6 +126,7 @@ jobs: item: - { name: record_ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 } - { name: record_matcher, fuzz-dir: crates/pica-matcher/fuzz, target: fuzz-record-matcher, max-total-time: 300 } + - { name: path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 } # - { name: select_query, fuzz-dir: crates/pica-select/fuzz, target: fuzz_query, max-total-time: 300 } steps: - uses: actions/checkout@v4 diff --git a/crates/pica-path/fuzz/.gitignore b/crates/pica-path/fuzz/.gitignore new file mode 100644 index 000000000..1a45eee77 --- /dev/null +++ b/crates/pica-path/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +coverage diff --git a/crates/pica-path/fuzz/Cargo.toml b/crates/pica-path/fuzz/Cargo.toml new file mode 100644 index 000000000..a2facf4a4 --- /dev/null +++ b/crates/pica-path/fuzz/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "pica-path-fuzz" +version = "0.0.0" +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.pica-path] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[profile.release] +debug = 1 + +[[bin]] +name = "fuzz-path" +path = "fuzz_targets/fuzz_path.rs" +test = false +doc = false diff --git a/crates/pica-path/fuzz/fuzz_targets/fuzz_path.rs b/crates/pica-path/fuzz/fuzz_targets/fuzz_path.rs new file mode 100644 index 000000000..056aa41d9 --- /dev/null +++ b/crates/pica-path/fuzz/fuzz_targets/fuzz_path.rs @@ -0,0 +1,10 @@ +#![no_main] + +extern crate libfuzzer_sys; + +use libfuzzer_sys::fuzz_target; +use pica_path::Path; + +fuzz_target!(|data: &[u8]| { + let _path = Path::try_from(data); +}); diff --git a/crates/pica-path/src/lib.rs b/crates/pica-path/src/lib.rs index e72416ab5..cf0b17a72 100644 --- a/crates/pica-path/src/lib.rs +++ b/crates/pica-path/src/lib.rs @@ -87,6 +87,7 @@ impl TryFrom<&[u8]> for Path { }) } } + impl FromStr for Path { type Err = ParsePathError;