pub mod detector;
pub mod patterns;
pub mod entropy;
pub mod rules;
pub mod scanner;
pub mod findings;
pub use detector::{SecretDetector, ScanOptions, DetectionConfig};
pub use patterns::{SecretPattern, SecretType, PatternMatch};
pub use entropy::{EntropyAnalyzer, EntropyResult};
pub use rules::{CustomRule, RuleEngine, RuleType};
pub use scanner::{FileScanner, ScanResult};
pub use findings::{Finding, ConfidenceLevel, FoundSecret};
use crate::error::{CargoCryptError, CryptoResult};
use std::path::Path;
pub async fn scan_file<P: AsRef<Path>>(path: P) -> CryptoResult<Vec<Finding>> {
let detector = SecretDetector::new();
let options = ScanOptions::default();
detector.scan_file(path, &options).await
}
pub async fn scan_directory<P: AsRef<Path>>(path: P) -> CryptoResult<Vec<Finding>> {
let detector = SecretDetector::new();
let options = ScanOptions::default();
detector.scan_directory(path, &options).await
}
pub fn is_likely_secret(text: &str) -> bool {
let analyzer = EntropyAnalyzer::new();
let result = analyzer.analyze(text);
result.is_likely_secret()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_entropy_detection() {
assert!(is_likely_secret("AKIAIOSFODNN7EXAMPLE"));
assert!(is_likely_secret("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"));
assert!(is_likely_secret("sk_test_FAKE1234567890ABCDEF"));
assert!(!is_likely_secret("hello_world"));
assert!(!is_likely_secret("my_variable_name"));
assert!(!is_likely_secret("configuration"));
assert!(!is_likely_secret("123456789"));
}
#[tokio::test]
async fn test_quick_scan_functions() {
let detector = SecretDetector::new();
assert_eq!(detector.name(), "SecretDetector");
}
}