vtcode_commons/
exclusions.rs1pub const VTCODE_IGNORE_FILE: &str = ".vtcodegitignore";
12
13pub const DEFAULT_EXCLUDED_DIRS: &[&str] = &[
19 ".git",
20 "node_modules",
21 "target",
22 "dist",
23 ".next",
24 "vendor",
25 ".cursor",
26 ".vtcode",
27 ".vscode",
28 ".idea",
29];
30
31pub const SENSITIVE_FILES: &[&str] = &[
35 ".env",
36 ".env.local",
37 ".env.production",
38 ".env.development",
39 ".env.test",
40 ".DS_Store",
41 ".git-credentials",
42 ".netrc",
43 ".npmrc",
44 ".pypirc",
45 "credentials",
46 "credentials.json",
47 "id_dsa",
48 "id_ecdsa",
49 "id_ecdsa_sk",
50 "id_ed25519",
51 "id_ed25519_sk",
52 "id_mldsa44_ed25519",
53 "id_rsa",
54];
55
56pub const DEFAULT_IGNORE_GLOBS: &[&str] = &[
59 "**/.git/**",
60 "**/node_modules/**",
61 "**/target/**",
62 "**/.cursor/**",
63 "**/dist/**",
64 "**/.next/**",
65 "**/vendor/**",
66 "**/.vtcode/**",
67 "**/.vscode/**",
68 "**/.idea/**",
69];
70
71pub fn is_sensitive_file(name: &str) -> bool {
76 SENSITIVE_FILES.iter().any(|sensitive| name.eq_ignore_ascii_case(sensitive))
77 || name.get(..5).is_some_and(|prefix| prefix.eq_ignore_ascii_case(".env."))
78}
79
80#[cfg(test)]
81mod tests {
82 use super::is_sensitive_file;
83
84 #[test]
85 fn sensitive_file_matching_is_case_insensitive() {
86 assert!(is_sensitive_file(".ENV"));
87 assert!(is_sensitive_file(".Env.Local"));
88 assert!(is_sensitive_file(".NPMRC"));
89 assert!(!is_sensitive_file(".environment"));
90 }
91
92 #[test]
93 fn ssh_private_key_basenames_are_sensitive() {
94 assert!(is_sensitive_file("id_dsa"));
95 assert!(is_sensitive_file("id_ecdsa"));
96 assert!(is_sensitive_file("ID_ECDSA"));
97 assert!(!is_sensitive_file("id_ecdsa.pub"));
98 }
99
100 #[test]
101 fn post_quantum_and_fido_ssh_private_keys_are_sensitive() {
102 assert!(is_sensitive_file("id_mldsa44_ed25519"));
103 assert!(is_sensitive_file("ID_MLDSA44_ED25519"));
104 assert!(is_sensitive_file("id_ecdsa_sk"));
105 assert!(is_sensitive_file("id_ed25519_sk"));
106 assert!(!is_sensitive_file("id_mldsa44_ed25519.pub"));
107 }
108}