pub struct SecretPattern {
pub name: String,
pub pattern: Regex,
pub secret_type: SecretType,
pub confidence: f64,
pub validate: bool,
pub context_keywords: Vec<String>,
pub ignore_keywords: Vec<String>,
}Expand description
A secret detection pattern
Fields§
§name: StringPattern name
pattern: RegexRegex pattern
secret_type: SecretTypeType of secret this pattern detects
confidence: f64Base confidence score for matches (0.0-1.0)
validate: boolWhether to validate the matched content
context_keywords: Vec<String>Context words that increase confidence
ignore_keywords: Vec<String>Context words that decrease confidence
Implementations§
Source§impl SecretPattern
impl SecretPattern
Sourcepub fn new(
name: &str,
pattern: &str,
secret_type: SecretType,
confidence: f64,
) -> Result<Self, Error>
pub fn new( name: &str, pattern: &str, secret_type: SecretType, confidence: f64, ) -> Result<Self, Error>
Create a new pattern
Sourcepub fn with_context_keywords(self, keywords: Vec<String>) -> Self
pub fn with_context_keywords(self, keywords: Vec<String>) -> Self
Add context keywords that increase confidence
Sourcepub fn with_ignore_keywords(self, keywords: Vec<String>) -> Self
pub fn with_ignore_keywords(self, keywords: Vec<String>) -> Self
Add ignore keywords that decrease confidence
Sourcepub fn with_validation(self) -> Self
pub fn with_validation(self) -> Self
Enable validation for this pattern
Sourcepub fn find_matches(&self, text: &str) -> Vec<PatternMatch>
pub fn find_matches(&self, text: &str) -> Vec<PatternMatch>
Find all matches in the given text
Sourcepub fn adjust_confidence(&self, matched_text: &str, context: &str) -> f64
pub fn adjust_confidence(&self, matched_text: &str, context: &str) -> f64
Adjust confidence based on context
Trait Implementations§
Source§impl Clone for SecretPattern
impl Clone for SecretPattern
Source§fn clone(&self) -> SecretPattern
fn clone(&self) -> SecretPattern
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SecretPattern
impl RefUnwindSafe for SecretPattern
impl Send for SecretPattern
impl Sync for SecretPattern
impl Unpin for SecretPattern
impl UnsafeUnpin for SecretPattern
impl UnwindSafe for SecretPattern
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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