pub struct SecretAnalyzer { /* private fields */ }Expand description
The main detection engine. Scans source code content for secrets, suspicious commands, high-entropy strings, and IOCs.
Create with SecretAnalyzer::new by providing regex rules,
then call analyze_content for each file.
Implementations§
Source§impl SecretAnalyzer
impl SecretAnalyzer
Sourcepub fn new(
rules: impl IntoIterator<Item = (String, String)>,
suspicious_rules: impl IntoIterator<Item = (String, String)>,
) -> Result<Self, AnalyzerError>
pub fn new( rules: impl IntoIterator<Item = (String, String)>, suspicious_rules: impl IntoIterator<Item = (String, String)>, ) -> Result<Self, AnalyzerError>
Creates a new analyzer with the given detection rules.
rules: Secret detection patterns (e.g. AWS keys, tokens). Each is(rule_id, regex).suspicious_rules: Command/behavior patterns (e.g. reverse shells). These are automatically skipped in safe contexts like import statements.
Returns AnalyzerError::InvalidPattern if any regex is invalid.
Sourcepub fn analyze_content(
&self,
content: &str,
file_path: &str,
file_name: &str,
) -> AnalysisResult
pub fn analyze_content( &self, content: &str, file_path: &str, file_name: &str, ) -> AnalysisResult
Analyzes the content of a single file for secrets, suspicious patterns, and IOCs.
content: The full text content of the file.file_path: Relative path (e.g."src/config.py"), used for file context classification.file_name: Just the filename (e.g."config.py"), used for extension-based logic.
Returns an AnalysisResult with all findings and extracted IOCs.
Auto Trait Implementations§
impl Freeze for SecretAnalyzer
impl RefUnwindSafe for SecretAnalyzer
impl Send for SecretAnalyzer
impl Sync for SecretAnalyzer
impl Unpin for SecretAnalyzer
impl UnsafeUnpin for SecretAnalyzer
impl UnwindSafe for SecretAnalyzer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more