feat: mask local part of email addresses in used_transport_settings

Also remove redundant all_self_addrs from the info,
each address corresponds to the transport.
This commit is contained in:
link2xt
2026-05-21 21:36:01 +02:00
committed by l
parent 03b10ea83a
commit 602922c1d5
3 changed files with 22 additions and 7 deletions

View File

@@ -91,7 +91,15 @@ def test_lowercase_address(acfactory) -> None:
assert account.list_transports()[0]["addr"] == addr
param = account.get_info()["used_transport_settings"]
assert addr in param
domain = addr.rsplit("@")[-1]
domain_upper = addr_upper.rsplit("@")[-1]
assert domain in param
assert domain_upper not in param
# Whole address should not appear in the info,
# does not matter if uppercase or lowercase.
assert addr not in param
assert addr_upper not in param

View File

@@ -21,7 +21,6 @@ use crate::contact::{Contact, ContactId};
use crate::debug_logging::DebugLogging;
use crate::events::{Event, EventEmitter, EventType, Events};
use crate::imap::{Imap, ServerMetadata};
use crate::key::self_fingerprint;
use crate::log::warn;
use crate::logged_debug_assert;
use crate::message::{self, MessageState, MsgId};
@@ -843,7 +842,6 @@ impl Context {
/// Returns information about the context as key-value pairs.
pub async fn get_info(&self) -> Result<BTreeMap<&'static str, String>> {
let all_self_addrs = self.get_all_self_addrs().await?.join(", ");
let all_transports: Vec<String> = ConfiguredLoginParam::load_all(self)
.await?
.into_iter()
@@ -941,7 +939,6 @@ impl Context {
}
}
res.insert("all_self_addrs", all_self_addrs);
res.insert(
"who_can_call_me",
self.get_config_int(Config::WhoCanCallMe).await?.to_string(),

View File

@@ -131,7 +131,9 @@ pub(crate) struct ConfiguredServerLoginParam {
impl fmt::Display for ConfiguredServerLoginParam {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}:{}", self.connection, self.user)?;
// Do not print the username,
// we do not want it to end up in the logs.
write!(f, "{}", self.connection)?;
Ok(())
}
}
@@ -227,13 +229,21 @@ pub(crate) struct ConfiguredLoginParamJson {
impl fmt::Display for ConfiguredLoginParam {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let addr = &self.addr;
let provider_id = match self.provider {
Some(provider) => provider.id,
None => "none",
};
let certificate_checks = self.certificate_checks;
write!(f, "{addr} imap:[")?;
if let Ok(parsed_addr) = EmailAddress::new(&self.addr) {
// Only include the domain.
write!(f, "***@{}", parsed_addr.domain)?;
} else {
// Should not happen, but if the address
// does not have a distinct domain part,
// print it as is.
write!(f, "{}", self.addr)?;
};
write!(f, " imap:[")?;
let mut first = true;
for imap in &self.imap {
if !first {