fix(server): don't log usernames to log file, I guess

This commit is contained in:
perf3ct 2025-07-11 20:05:56 +00:00
parent 520c8f0dbf
commit 0b9b935334
3 changed files with 9 additions and 3 deletions

View File

@ -70,7 +70,9 @@ async fn main() -> Result<()> {
let ingester = BatchIngester::new(db, queue_service, file_service, config);
println!("Starting batch ingestion from: {}", directory);
println!("User ID: {}", user_id);
// Only show the first and last character of the user ID
let masked_user_id = format!("{}{}", &user_id.to_string()[..1], &user_id.to_string()[user_id.to_string().len() - 1..]);
println!("User ID: {}", masked_user_id);
// Start ingestion
if let Err(e) = ingester.ingest_directory(dir_path, user_id).await {

View File

@ -59,7 +59,9 @@ impl Config {
let credentials = &credentials_part[username_start + 3..];
if let Some(colon_pos) = credentials.find(':') {
let username = &credentials[..colon_pos];
format!("{}{}:***@{}", protocol, username, remaining_part)
// Show first and last character of the username
let masked_username = format!("{}{}", &username[..1], &username[username.len() - 1..]);
format!("{}{}:***@{}", protocol, masked_username, remaining_part)
} else {
format!("{}***@{}", protocol, remaining_part)
}

View File

@ -108,8 +108,10 @@ async fn main() -> anyhow::Result<()> {
} else {
"unknown"
};
// if we get the username, let's now mask it to get just the first and last character
let masked_username = format!("{}{}", &username[..1], &username[username.len() - 1..]);
format!("{}://{}:***@{}", protocol, username, host_part)
format!("{}://{}:***@{}", protocol, masked_username, host_part)
} else {
"Invalid database URL format".to_string()
};