Skip to content

Commit 6ac89e5

Browse files
Fuzz more of pathspec patterns
- Fuzz more of the API - Add associated dictionary
1 parent 34e4a16 commit 6ac89e5

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

gix-pathspec/fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = "2021"
99
cargo-fuzz = true
1010

1111
[dependencies]
12+
anyhow = "1.0.77"
1213
libfuzzer-sys = "0.4"
1314

1415
[dependencies.gix-pathspec]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# ---- Magic signatures ----
2+
":(top)"
3+
"top"
4+
":/"
5+
6+
":(icase)"
7+
"icase"
8+
9+
":(literal)"
10+
"literal"
11+
12+
":(glob)"
13+
"glob"
14+
15+
# We can't close attr as they take arguments.
16+
":(attr:"
17+
":(attr:!"
18+
"attr"
19+
20+
":(exclude)"
21+
"exclude"
22+
":!"
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
#![no_main]
2+
use anyhow::Result;
23
use libfuzzer_sys::fuzz_target;
4+
use std::hint::black_box;
5+
6+
fn fuzz(data: &[u8]) -> Result<()> {
7+
let pattern = gix_pathspec::parse(data, Default::default())?;
8+
_ = black_box(pattern.is_nil());
9+
_ = black_box(pattern.prefix_directory());
10+
_ = black_box(pattern.path());
11+
// TODO: Fuzz normalize
12+
_ = black_box(pattern.is_excluded());
13+
_ = black_box(pattern.to_bstring());
14+
Ok(())
15+
}
316

417
fuzz_target!(|data: &[u8]| {
5-
let _a = gix_pathspec::parse(data, Default::default());
18+
_ = black_box(fuzz(data));
619
});

0 commit comments

Comments
 (0)