vtcode_commons/
exclusions.rs1pub const DEFAULT_EXCLUDED_DIRS: &[&str] = &[
12 ".git",
13 "node_modules",
14 "target",
15 "dist",
16 ".next",
17 "vendor",
18 ".cursor",
19 ".vtcode",
20 ".vscode",
21 ".idea",
22];
23
24pub const SENSITIVE_FILES: &[&str] = &[
28 ".env",
29 ".env.local",
30 ".env.production",
31 ".env.development",
32 ".env.test",
33 ".DS_Store",
34 ".git-credentials",
35 ".netrc",
36 ".npmrc",
37 ".pypirc",
38 "credentials",
39 "credentials.json",
40 "id_dsa",
41 "id_ecdsa",
42 "id_ed25519",
43 "id_rsa",
44];
45
46pub const DEFAULT_IGNORE_GLOBS: &[&str] = &[
49 "**/.git/**",
50 "**/node_modules/**",
51 "**/target/**",
52 "**/.cursor/**",
53 "**/dist/**",
54 "**/.next/**",
55 "**/vendor/**",
56 "**/.vtcode/**",
57 "**/.vscode/**",
58 "**/.idea/**",
59];
60
61pub fn is_sensitive_file(name: &str) -> bool {
66 SENSITIVE_FILES.iter().any(|sensitive| name.eq_ignore_ascii_case(sensitive))
67 || name.get(..5).is_some_and(|prefix| prefix.eq_ignore_ascii_case(".env."))
68}
69
70#[cfg(test)]
71mod tests {
72 use super::is_sensitive_file;
73
74 #[test]
75 fn sensitive_file_matching_is_case_insensitive() {
76 assert!(is_sensitive_file(".ENV"));
77 assert!(is_sensitive_file(".Env.Local"));
78 assert!(is_sensitive_file(".NPMRC"));
79 assert!(!is_sensitive_file(".environment"));
80 }
81
82 #[test]
83 fn ssh_private_key_basenames_are_sensitive() {
84 assert!(is_sensitive_file("id_dsa"));
85 assert!(is_sensitive_file("id_ecdsa"));
86 assert!(is_sensitive_file("ID_ECDSA"));
87 assert!(!is_sensitive_file("id_ecdsa.pub"));
88 }
89}