1use std::path::Path;
2
3use glob::Pattern;
4
5mod config;
6mod io;
7mod metadata;
8mod paths;
9mod scan_cache;
10
11pub use config::{CACHE_DIR_ENV_VAR, CacheConfig, CacheKind, CacheKinds, DEFAULT_CACHE_DIR_NAME};
12pub use scan_cache::{CachedScanFindings, read_cached_findings, write_cached_findings};
13
14pub fn build_collection_exclude_patterns(scan_root: &Path, cache_root: &Path) -> Vec<Pattern> {
15 let mut patterns = Vec::new();
16
17 if let Ok(relative_cache_root) = cache_root.strip_prefix(scan_root)
18 && !relative_cache_root.as_os_str().is_empty()
19 {
20 for path in [cache_root.to_path_buf(), relative_cache_root.to_path_buf()] {
21 let normalized = path.to_string_lossy().replace('\\', "/");
22 let escaped = Pattern::escape(&normalized);
23 for pattern in [escaped.clone(), format!("{escaped}/**")] {
24 if let Ok(pattern) = Pattern::new(&pattern) {
25 patterns.push(pattern);
26 }
27 }
28 }
29 }
30
31 patterns
32}