sherlock_io/patterns/
general.rs1use regex::Regex;
2
3pub struct GeneralPatterns {
4 external_patterns: Vec<Regex>,
5 cache_patterns: Vec<Regex>,
6 extensions: Vec<String>,
7}
8
9impl GeneralPatterns {
10 pub fn new() -> Self {
11 let external_patterns = vec![
12 Regex::new(r"vendor/").unwrap(),
14 Regex::new(r"deps/").unwrap(),
15 Regex::new(r"packages/").unwrap(),
16 ];
17
18 let cache_patterns = vec![
19 Regex::new(r"(?i)/cache/").unwrap(),
21 Regex::new(r"(?i)/temp/").unwrap(),
22 Regex::new(r"(?i)/tmp/").unwrap(),
23
24 Regex::new(r"logs/").unwrap(),
26 ];
27
28 let extensions = vec![
29 "json".to_string(), "xml".to_string(), "yaml".to_string(),
31 "yml".to_string(), "toml".to_string(), "ini".to_string(),
32 "cfg".to_string(), "conf".to_string(), "config".to_string(),
33
34 "sh".to_string(), "bash".to_string(), "zsh".to_string(),
36 "fish".to_string(), "ps1".to_string(), "bat".to_string(),
37 "cmd".to_string(),
38
39 "md".to_string(), "rst".to_string(), "txt".to_string(),
41 "adoc".to_string(), "asciidoc".to_string(),
42 ];
43
44 Self {
45 external_patterns,
46 cache_patterns,
47 extensions,
48 }
49 }
50
51 pub fn get_external_patterns(&self) -> &[Regex] {
52 &self.external_patterns
53 }
54
55 pub fn get_cache_patterns(&self) -> &[Regex] {
56 &self.cache_patterns
57 }
58
59 pub fn get_extensions(&self) -> &[String] {
60 &self.extensions
61 }
62
63 pub fn get_script_names() -> Vec<&'static str> {
64 vec![
65 "Dockerfile", "docker-compose.yml", "docker-compose.yaml",
66 "Containerfile", "Vagrantfile", "Procfile", ".gitignore",
67 ".dockerignore", ".editorconfig", "LICENSE", "README.md",
68 "CHANGELOG.md", "CONTRIBUTING.md", "CODE_OF_CONDUCT.md",
69 ]
70 }
71}