Skip to content

Commit af8b92d

Browse files
committed
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.
1 parent 6fa86ab commit af8b92d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/worker/jobs/typosquat.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ async fn check(
5757
if !squats.is_empty() {
5858
// Well, well, well. For now, the only action we'll take is to e-mail people who
5959
// hopefully care to check into things more closely.
60-
info!(?squats, "Found potential typosquatting");
60+
61+
let squats_formatted = squats
62+
.iter()
63+
.map(ToString::to_string)
64+
.collect::<Vec<_>>()
65+
.join(", ");
66+
67+
info!("Found potential typosquatting by new crate `{name}`: {squats_formatted}");
6168

6269
let squats_data: Vec<_> = squats
6370
.iter()
@@ -114,6 +121,8 @@ mod tests {
114121

115122
#[tokio::test]
116123
async fn integration() -> anyhow::Result<()> {
124+
crate::util::tracing::init_for_test();
125+
117126
let emails = Emails::new_in_memory();
118127
let test_db = TestDatabase::new();
119128
let mut conn = test_db.async_connect().await;

0 commit comments

Comments
 (0)