Skip to main content

RedactPolicy

Trait RedactPolicy 

Source
pub trait RedactPolicy {
    // Provided methods
    fn redact_key(&self, _key: &str) -> bool { ... }
    fn redact_value(&self, _key: Option<&str>, value: &str) -> Option<String> { ... }
}
Expand description

Policy for redacting sensitive data from error output.

§Example

use orion_error::report::RedactPolicy;

struct HideTokens;

impl RedactPolicy for HideTokens {
    fn redact_key(&self, key: &str) -> bool {
        key.contains("token") || key.contains("secret")
    }

    fn redact_value(&self, key: Option<&str>, value: &str) -> Option<String> {
        match key {
            Some("detail") | Some("source.message") => {
                Some(value.replace("token=", "token=<redacted>"))
            }
            _ => Some(value.to_string()),
        }
    }
}
  • redact_key returns true to drop the entire entry.
  • redact_value transforms or replaces individual values. Return None to drop the entry, Some(...) to replace it.

Provided Methods§

Source

fn redact_key(&self, _key: &str) -> bool

Source

fn redact_value(&self, _key: Option<&str>, value: &str) -> Option<String>

Implementors§