Skip to content

Commit d6e792c

Browse files
echobtfactorydroid
andauthored
fix(cortex-cli): fix failing tests in glob_match and test_redact_sensitive_value (#473)
- Fix glob_match to correctly handle **/*.rs pattern by treating the suffix part starting with * as a wildcard extension match (e.g., *.rs matches .rs) - Fix test_redact_sensitive_value test assertion: for 'sk-abc123xyz789' the last 4 chars are 'z789' not '9789' (added clarifying comment) Co-authored-by: Droid Agent <droid@factory.ai>
1 parent 7c6d932 commit d6e792c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

cortex-cli/src/debug_cmd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,8 @@ mod tests {
28122812
assert_eq!(redact_sensitive_value("12345678"), "[REDACTED]");
28132813

28142814
// Longer value shows first/last 4 chars
2815-
assert_eq!(redact_sensitive_value("sk-abc123xyz789"), "sk-a...9789");
2815+
// "sk-abc123xyz789" has 15 chars: first 4 = "sk-a", last 4 = "z789"
2816+
assert_eq!(redact_sensitive_value("sk-abc123xyz789"), "sk-a...z789");
28162817
assert_eq!(redact_sensitive_value("supersecretpassword"), "supe...word");
28172818
}
28182819
}

cortex-cli/src/exec_cmd.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,17 @@ fn glob_match(pattern: &str, text: &str) -> bool {
15501550
if parts.len() == 2 {
15511551
let prefix = parts[0].trim_end_matches('/');
15521552
let suffix = parts[1].trim_start_matches('/');
1553-
return (prefix.is_empty() || text.starts_with(prefix))
1554-
&& (suffix.is_empty() || text.ends_with(suffix));
1553+
let prefix_ok = prefix.is_empty() || text.starts_with(prefix);
1554+
let suffix_ok = if suffix.is_empty() {
1555+
true
1556+
} else if suffix.starts_with('*') {
1557+
// Handle patterns like **/*.rs - suffix is "*.rs"
1558+
let ext = &suffix[1..];
1559+
text.ends_with(ext)
1560+
} else {
1561+
text.ends_with(suffix)
1562+
};
1563+
return prefix_ok && suffix_ok;
15551564
}
15561565
}
15571566

0 commit comments

Comments
 (0)