pub struct SecretDetector {
min_secret_length: usize,
}Expand description
Detector for secrets in content.
Fields§
§min_secret_length: usizeMinimum length for generic secret values.
Implementations§
Source§impl SecretDetector
impl SecretDetector
Sourcepub const fn with_min_length(self, length: usize) -> Self
pub const fn with_min_length(self, length: usize) -> Self
Sets the minimum secret length for generic patterns.
Sourcepub fn contains_secrets(&self, content: &str) -> bool
pub fn contains_secrets(&self, content: &str) -> bool
Checks if content contains any secrets.
Sourcepub fn detect(&self, content: &str) -> Vec<SecretMatch>
pub fn detect(&self, content: &str) -> Vec<SecretMatch>
Returns all detected secret matches.
Sourcefn collect_pattern_matches(
&self,
pattern: SecretPattern,
content: &str,
matches: &mut Vec<SecretMatch>,
)
fn collect_pattern_matches( &self, pattern: SecretPattern, content: &str, matches: &mut Vec<SecretMatch>, )
Collects matches for a single pattern into the result vector.
Sourcefn process_match(
&self,
pattern: &SecretPattern,
m: &Match<'_>,
) -> Option<SecretMatch>
fn process_match( &self, pattern: &SecretPattern, m: &Match<'_>, ) -> Option<SecretMatch>
Processes a single regex match and returns a SecretMatch if it should be included.
Sourcefn deduplicate_overlapping(sorted_matches: Vec<SecretMatch>) -> Vec<SecretMatch>
fn deduplicate_overlapping(sorted_matches: Vec<SecretMatch>) -> Vec<SecretMatch>
Removes overlapping matches, keeping the first occurrence.
Sourcepub fn detect_types(&self, content: &str) -> Vec<String>
pub fn detect_types(&self, content: &str) -> Vec<String>
Returns the types of secrets detected.
Sourcefn is_placeholder(value: &str) -> bool
fn is_placeholder(value: &str) -> bool
Checks if a matched value is a common placeholder (false positive).
This reduces false positives for generic API key and bearer token patterns.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SecretDetector
impl RefUnwindSafe for SecretDetector
impl Send for SecretDetector
impl Sync for SecretDetector
impl Unpin for SecretDetector
impl UnwindSafe for SecretDetector
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].