Sanitize text by redacting sensitive data
(&self, text: &str)
| 214 | |
| 215 | /// Sanitize text by redacting sensitive data |
| 216 | fn sanitize_text(&self, text: &str) -> String { |
| 217 | let mut result = text.to_string(); |
| 218 | |
| 219 | for pattern in &self.patterns { |
| 220 | result = pattern |
| 221 | .regex |
| 222 | .replace_all(&result, format!("[{}]", pattern.redaction_label)) |
| 223 | .to_string(); |
| 224 | } |
| 225 | |
| 226 | result |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | impl Default for DefaultSecurityProvider { |