pub struct Redactor {
level: RedactionLevel,
re_aws_key_id: Regex,
re_secret: Regex,
re_session: Regex,
re_presigned: Regex,
re_account_id: Regex,
re_bearer: Regex,
home_dir: Option<String>,
}Expand description
Compiled redaction patterns.
Construct once with Redactor::new() and reuse across many calls.
Fields§
§level: RedactionLevel§re_aws_key_id: Regex(AKIA|ASIA|AROA)[A-Z0-9]{16} — AWS access key IDs.
re_secret: Regex(?i)(aws_secret_access_key|secret_access_key|secret)\s*=\s*['"]?([A-Za-z0-9/+=]{40})['"]?
re_session: Regex(?i)(aws_session_token|session_token)\s*=\s*['"]?([A-Za-z0-9/+=]{100,})['"]?
re_presigned: RegexPresigned URLs — everything after ? when X-Amz-Signature is present.
re_account_id: Regex12-digit AWS account IDs (only applied at RedactionLevel::Full).
re_bearer: RegexBearer token values.
home_dir: Option<String>Actual home-dir prefix at runtime (e.g. /Users/alice).
Implementations§
Source§impl Redactor
impl Redactor
Sourcepub fn with_level(level: RedactionLevel) -> Self
pub fn with_level(level: RedactionLevel) -> Self
Build a Redactor with the given RedactionLevel.
Sourcepub fn redact_text(&self, text: &str) -> String
pub fn redact_text(&self, text: &str) -> String
Apply all active patterns to text and return the redacted string.
Patterns are applied in this order so that more-specific matches are replaced before generic ones (e.g. presigned URLs before account IDs):
- Presigned URLs (full querystring)
- AWS session tokens (longest values first, before secrets)
- AWS secret access keys
- Bearer tokens
- AWS access key IDs
- AWS account IDs (Full level only)
Sourcepub fn redact_path(&self, path: &str) -> String
pub fn redact_path(&self, path: &str) -> String
Replace $HOME/ and the literal home-dir path prefix with ~/.
If the home directory cannot be determined at runtime, the input is returned unchanged.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Redactor
impl RefUnwindSafe for Redactor
impl Send for Redactor
impl Sync for Redactor
impl Unpin for Redactor
impl UnsafeUnpin for Redactor
impl UnwindSafe for Redactor
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
§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>
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