pub struct FieldRule {
pub pattern: String,
pub category: Option<Category>,
pub label: Option<String>,
pub min_length: Option<usize>,
pub sub_processor: Option<String>,
pub sub_fields: Vec<FieldRule>,
}Expand description
A rule describing a single field/key to sanitize.
§Pattern Syntax
- Exact key:
"password","db_host". - Dotted path:
"database.password","smtp.user". - Glob suffix:
"*.password"— matches any key ending in.password. - Glob prefix:
"db.*"— matches any key starting withdb.. - Wildcard:
"*"— matches every field.
§Sub-processor
When a field’s value is itself a structured document (e.g. YAML embedded
in a Ruby heredoc), set sub_processor to the processor name and provide
sub_fields with rules for the nested content. The parent processor
extracts the value and delegates it to the named sub-processor.
- pattern: "*['ldap_servers']"
sub_processor: yaml
sub_fields:
- pattern: "*.password"
category: custom:password
- pattern: "*.bind_dn"
category: custom:dnFields§
§pattern: StringKey pattern to match (see Pattern Syntax above).
category: Option<Category>Category for replacement generation. Defaults to Custom("field")
if not specified. Ignored when sub_processor is set.
label: Option<String>Optional human-readable label for reporting.
min_length: Option<usize>Minimum byte length a value must reach before it is replaced.
Values shorter than this threshold pass through unchanged. Use this
to avoid redacting obviously non-secret values matched by broad glob
patterns (e.g. "false", "0", "nil" matched by *secret*).
A value of 8 is a reasonable default for token/password fields.
Omit (or set to 0) to replace all matching values regardless of length.
sub_processor: Option<String>Name of the processor to use for the field’s value when it contains
an embedded structured document (e.g. "yaml", "json", "toml").
sub_fields: Vec<FieldRule>Field rules applied by sub_processor to the nested content.
Ignored when sub_processor is None.
Implementations§
Source§impl FieldRule
impl FieldRule
Sourcepub fn with_min_length(self, min: usize) -> Self
pub fn with_min_length(self, min: usize) -> Self
Set the minimum value length required for replacement.
Sourcepub fn with_category(self, category: Category) -> Self
pub fn with_category(self, category: Category) -> Self
Set the category for this rule.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Set the label for this rule.
Sourcepub fn with_sub_processor(self, name: impl Into<String>) -> Self
pub fn with_sub_processor(self, name: impl Into<String>) -> Self
Set the sub-processor name for embedded structured content.
Sourcepub fn with_sub_fields(self, fields: Vec<FieldRule>) -> Self
pub fn with_sub_fields(self, fields: Vec<FieldRule>) -> Self
Set the field rules applied by the sub-processor.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FieldRule
impl<'de> Deserialize<'de> for FieldRule
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for FieldRule
impl RefUnwindSafe for FieldRule
impl Send for FieldRule
impl Sync for FieldRule
impl Unpin for FieldRule
impl UnsafeUnpin for FieldRule
impl UnwindSafe for FieldRule
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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