Skip to content

Commit 1f4dd89

Browse files
Merge pull request #156 from microsoft/main
Fork Sync: Update from parent repository
2 parents 2883579 + 0d6a0d7 commit 1f4dd89

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/agent/coverage/src/allowlist.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ impl AllowListLine {
140140

141141
#[allow(clippy::single_char_pattern)]
142142
fn glob_to_regex(expr: &str) -> Result<Regex> {
143+
// Treat `.` as literal, not match-any.
144+
//
145+
// Use character class syntax to avoid double-escaping.
146+
let expr = expr.replace(".", r"[.]");
147+
143148
// Don't make users escape Windows path separators.
144149
let expr = expr.replace(r"\", r"\\");
145150

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a.*

src/agent/coverage/src/allowlist/tests.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,20 @@ fn test_allow_glob_except_commented() -> Result<()> {
9999

100100
Ok(())
101101
}
102+
103+
#[test]
104+
fn test_allow_glob_extension() -> Result<()> {
105+
let text = include_str!("test-data/allow-all-glob-extension.txt");
106+
let allowlist = AllowList::parse(text)?;
107+
108+
assert!(allowlist.is_allowed("a.c"));
109+
assert!(allowlist.is_allowed("a.h"));
110+
111+
assert!(!allowlist.is_allowed("ac"));
112+
assert!(!allowlist.is_allowed("ah"));
113+
114+
assert!(!allowlist.is_allowed("axc"));
115+
assert!(!allowlist.is_allowed("axh"));
116+
117+
Ok(())
118+
}

0 commit comments

Comments
 (0)