pub struct CredentialScanner { /* private fields */ }Expand description
Pre-compiled multi-pattern credential scanner.
Construct once with CredentialScanner::new (or CredentialScanner::with_config)
and call CredentialScanner::scan repeatedly. Pattern compilation happens at
construction time; each scan call is O(n) in the length of the input text.
Implementations§
Source§impl CredentialScanner
impl CredentialScanner
Sourcepub fn new() -> Self
pub fn new() -> Self
Build the scanner with all built-in patterns and scanning enabled.
§Panics
Panics only if the hard-coded AC patterns are somehow invalid — this cannot happen in practice.
Sourcepub fn with_config(config: ScannerConfig) -> Self
pub fn with_config(config: ScannerConfig) -> Self
Build the scanner from explicit configuration.
Custom patterns are appended after the built-in set and are tagged as
CredentialKind::Custom. If config.disabled is true the scanner
is inert — scan always returns an empty result.
Sourcepub fn scan(&self, text: &str) -> ScanResult
pub fn scan(&self, text: &str) -> ScanResult
Scan text for credential patterns and return a ScanResult.
Four passes are performed:
- Aho-Corasick literal prefix scan — O(n), 18 patterns covering API keys, auth tokens, cloud credentials, database URLs, and PEM private key headers.
- Credit card and SSN digit-sequence scan.
- Email address scan.
- High-entropy token scan (Shannon entropy > 4.5 bits/char, length 20–64).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CredentialScanner
impl RefUnwindSafe for CredentialScanner
impl Send for CredentialScanner
impl Sync for CredentialScanner
impl Unpin for CredentialScanner
impl UnsafeUnpin for CredentialScanner
impl UnwindSafe for CredentialScanner
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