diff --git a/src/agent/coverage/src/allowlist.rs b/src/agent/coverage/src/allowlist.rs index 2a0e807d17..3a46688243 100644 --- a/src/agent/coverage/src/allowlist.rs +++ b/src/agent/coverage/src/allowlist.rs @@ -140,6 +140,11 @@ impl AllowListLine { #[allow(clippy::single_char_pattern)] fn glob_to_regex(expr: &str) -> Result { + // 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"\\"); diff --git a/src/agent/coverage/src/allowlist/test-data/allow-all-glob-extension.txt b/src/agent/coverage/src/allowlist/test-data/allow-all-glob-extension.txt new file mode 100644 index 0000000000..314b1969ad --- /dev/null +++ b/src/agent/coverage/src/allowlist/test-data/allow-all-glob-extension.txt @@ -0,0 +1 @@ +a.* diff --git a/src/agent/coverage/src/allowlist/tests.rs b/src/agent/coverage/src/allowlist/tests.rs index 7c189aae88..be1d40312d 100644 --- a/src/agent/coverage/src/allowlist/tests.rs +++ b/src/agent/coverage/src/allowlist/tests.rs @@ -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(()) +}