Browse Source

make support string more secure

convert all characters to a `*`, except for `:` and `/`
additionally `:` and `/` will also be converted when occuring after the 12nd character
pull/2878/head
Helmut K. C. Tessarek 3 years ago
parent
commit
e5a607b5e9
No known key found for this signature in database GPG Key ID: BE0985349D44DD00
  1. 21
      src/config.rs

21
src/config.rs

@ -229,17 +229,18 @@ macro_rules! make_config {
inner.config.clone() inner.config.clone()
}; };
/// We map over the string and remove all alphanumeric, _ and - characters.
/// This is the fastest way (within micro-seconds) instead of using a regex (which takes mili-seconds)
fn _privacy_mask(value: &str) -> String { fn _privacy_mask(value: &str) -> String {
value.chars().map(|c| let mut masked: String = String::new();
match c { let mut n = 0;
c if c.is_alphanumeric() => '*', for c in value.chars() {
'_' => '*', if n <= 12 && [':', '/'].contains(&c) {
'-' => '*', masked += &c.to_string();
_ => c } else {
} masked += &'*'.to_string();
).collect::<String>() }
n += 1;
}
masked
} }
serde_json::Value::Object({ serde_json::Value::Object({

Loading…
Cancel
Save