pub struct DlpScanner { /* private fields */ }Expand description
Thread-safe DLP scanner
Implementations§
Source§impl DlpScanner
impl DlpScanner
Sourcepub fn new(config: DlpConfig) -> Self
pub fn new(config: DlpConfig) -> Self
Create a new DLP scanner with the given configuration.
§Panics
Panics if configuration validation fails (e.g., Hash mode without salt).
Use try_new for fallible construction.
Sourcepub fn try_new(config: DlpConfig) -> Result<Self, DlpConfigError>
pub fn try_new(config: DlpConfig) -> Result<Self, DlpConfigError>
Create a new DLP scanner with validation. Returns error if configuration is invalid.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if scanner is enabled
Sourcepub fn record_violations(
&self,
result: &ScanResult,
client_ip: Option<&str>,
path: &str,
)
pub fn record_violations( &self, result: &ScanResult, client_ip: Option<&str>, path: &str, )
Record violations from a scan result
Sourcepub async fn get_recent_violations(&self) -> Vec<DlpViolation>
pub async fn get_recent_violations(&self) -> Vec<DlpViolation>
Get recent violations
Sourcepub fn scan(&self, content: &str) -> ScanResult
pub fn scan(&self, content: &str) -> ScanResult
Scan content for sensitive data with optimizations:
- Inspection depth cap (truncation for large payloads)
- Aho-Corasick prefiltering for patterns with literal prefixes
Sourcepub fn scan_bytes(&self, data: &[u8]) -> ScanResult
pub fn scan_bytes(&self, data: &[u8]) -> ScanResult
Scan bytes as UTF-8 text
Sourcepub fn is_scannable_content_type(&self, content_type: &str) -> bool
pub fn is_scannable_content_type(&self, content_type: &str) -> bool
Check if content type should be scanned. Returns false for binary types (images, audio, video, archives, etc.) Returns true for text-based types that may contain sensitive data.
Sourcepub fn should_skip_content_type(&self, content_type: &str) -> bool
pub fn should_skip_content_type(&self, content_type: &str) -> bool
Quick check if content type should skip DLP entirely (binary content)
Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Get pattern count
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DlpScanner
impl !RefUnwindSafe for DlpScanner
impl Send for DlpScanner
impl Sync for DlpScanner
impl Unpin for DlpScanner
impl UnsafeUnpin for DlpScanner
impl !UnwindSafe for DlpScanner
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more