Skip to content

Commit

Permalink
Increase privacy of masked config
Browse files Browse the repository at this point in the history
This changes the masking function to hide a bit more information from
the generated support string. It will still keep showing the `://` for
example, and `,`, but other characters will be hidden.

Also did some small changes on some key's which all showed up as
`Internal` on the Settings page.

Fixes #2929
  • Loading branch information
BlackDex committed Dec 8, 2022
1 parent b7c9a34 commit 0825b2a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,17 @@ macro_rules! make_config {
/// 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 {
value.chars().map(|c|
let mut n: u16 = 0;
let mut colon_match = false;
value.chars().map(|c| {
n += 1;
match c {
c if c.is_alphanumeric() => '*',
'_' => '*',
'-' => '*',
_ => c
':' if n <= 11 => { colon_match = true ; c },
'/' if n <= 13 && colon_match => c,
',' => c,
_ => '*'
}
}
).collect::<String>()
}

Expand Down Expand Up @@ -475,9 +479,9 @@ make_config! {
/// service is set, an icon request to Vaultwarden will return an HTTP redirect to the
/// corresponding icon at the external service.
icon_service: String, false, def, "internal".to_string();
/// Internal
/// _icon_service_url
_icon_service_url: String, false, gen, |c| generate_icon_service_url(&c.icon_service);
/// Internal
/// _icon_service_csp
_icon_service_csp: String, false, gen, |c| generate_icon_service_csp(&c.icon_service, &c._icon_service_url);
/// Icon redirect code |> The HTTP status code to use for redirects to an external icon service.
/// The supported codes are 301 (legacy permanent), 302 (legacy temporary), 307 (temporary), and 308 (permanent).
Expand Down Expand Up @@ -613,7 +617,7 @@ make_config! {
helo_name: String, true, option;
/// Embed images as email attachments.
smtp_embed_images: bool, true, def, true;
/// Internal
/// _smtp_img_src
_smtp_img_src: String, false, gen, |c| generate_smtp_img_src(c.smtp_embed_images, &c.domain);
/// Enable SMTP debugging (Know the risks!) |> DANGEROUS: Enabling this will output very detailed SMTP messages. This could contain sensitive information like passwords and usernames! Only enable this during troubleshooting!
smtp_debug: bool, false, def, false;
Expand Down

0 comments on commit 0825b2a

Please sign in to comment.