From af8b92dce307ba91f5acec642f0a6bda58407066 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 12 Sep 2025 14:35:08 +0200 Subject: [PATCH] worker/typosquat: Improve typosquat logging Using structured debug logging for this isn't particularly useful when using Datadog. Instead, we format the squat info properly and print it as the message. --- src/worker/jobs/typosquat.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/worker/jobs/typosquat.rs b/src/worker/jobs/typosquat.rs index 8653f8ea87f..a0a29d5cf08 100644 --- a/src/worker/jobs/typosquat.rs +++ b/src/worker/jobs/typosquat.rs @@ -57,7 +57,14 @@ async fn check( if !squats.is_empty() { // Well, well, well. For now, the only action we'll take is to e-mail people who // hopefully care to check into things more closely. - info!(?squats, "Found potential typosquatting"); + + let squats_formatted = squats + .iter() + .map(ToString::to_string) + .collect::>() + .join(", "); + + info!("Found potential typosquatting by new crate `{name}`: {squats_formatted}"); let squats_data: Vec<_> = squats .iter() @@ -114,6 +121,8 @@ mod tests { #[tokio::test] async fn integration() -> anyhow::Result<()> { + crate::util::tracing::init_for_test(); + let emails = Emails::new_in_memory(); let test_db = TestDatabase::new(); let mut conn = test_db.async_connect().await;