diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bb9df39e9..bf58f721f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,10 +89,11 @@ jobs: strategy: matrix: item: - - { name: pica-record-ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 } + - { name: pica-format, fuzz-dir: crates/pica-format/fuzz, target: fuzz-format, max-total-time: 300 } + - { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 } - { name: pica-record-matcher, fuzz-dir: crates/pica-matcher/fuzz, target: fuzz-record-matcher, max-total-time: 300 } + - { name: pica-record-ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 } - { name: pica-select-query, fuzz-dir: crates/pica-select/fuzz, target: fuzz-query, max-total-time: 300 } - - { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 } steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly diff --git a/crates/pica-format/fuzz/.gitignore b/crates/pica-format/fuzz/.gitignore new file mode 100644 index 000000000..1a45eee77 --- /dev/null +++ b/crates/pica-format/fuzz/.gitignore @@ -0,0 +1,4 @@ +target +corpus +artifacts +coverage diff --git a/crates/pica-format/fuzz/Cargo.toml b/crates/pica-format/fuzz/Cargo.toml new file mode 100644 index 000000000..44ec0f247 --- /dev/null +++ b/crates/pica-format/fuzz/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "pica-format-fuzz" +version = "0.0.0" +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.pica-format] +path = ".." + +[workspace] +members = ["."] + +[[bin]] +name = "fuzz-format" +path = "fuzz_targets/fuzz_format.rs" +test = false +doc = false +bench = false diff --git a/crates/pica-format/fuzz/fuzz_targets/fuzz_format.rs b/crates/pica-format/fuzz/fuzz_targets/fuzz_format.rs new file mode 100644 index 000000000..4a5280cc9 --- /dev/null +++ b/crates/pica-format/fuzz/fuzz_targets/fuzz_format.rs @@ -0,0 +1,12 @@ +#![no_main] + +use std::str::FromStr; + +use libfuzzer_sys::fuzz_target; +use pica_format::Format; + +fuzz_target!(|data: &[u8]| { + if let Ok(s) = std::str::from_utf8(data) { + let _format = Format::from_str(s); + } +});