Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/agent/coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ impl AllowListLine {

#[allow(clippy::single_char_pattern)]
fn glob_to_regex(expr: &str) -> Result<Regex> {
// Treat `.` as literal, not match-any.
//
// Use character class syntax to avoid double-escaping.
let expr = expr.replace(".", r"[.]");

// Don't make users escape Windows path separators.
let expr = expr.replace(r"\", r"\\");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a.*
17 changes: 17 additions & 0 deletions src/agent/coverage/src/allowlist/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,20 @@ fn test_allow_glob_except_commented() -> Result<()> {

Ok(())
}

#[test]
fn test_allow_glob_extension() -> Result<()> {
let text = include_str!("test-data/allow-all-glob-extension.txt");
let allowlist = AllowList::parse(text)?;

assert!(allowlist.is_allowed("a.c"));
assert!(allowlist.is_allowed("a.h"));

assert!(!allowlist.is_allowed("ac"));
assert!(!allowlist.is_allowed("ah"));

assert!(!allowlist.is_allowed("axc"));
assert!(!allowlist.is_allowed("axh"));

Ok(())
}