From 0b3df17920f9592de8d3774c3ecff4ac54ff282d Mon Sep 17 00:00:00 2001 From: maziggy Date: Sun, 1 Feb 2026 14:26:56 +0100 Subject: [PATCH] Sanitize printer serial numbers in support bundle logs (Issue #216) The support bundle states that printer serial numbers are NOT collected, but they were appearing in debug logs. Added regex to sanitize Bambu Lab serial numbers (00M/01D/01S/01P/03W prefix + alphanumeric) while keeping the prefix for debugging context. Example: [01D00A12345678] -> [01D[SERIAL]] Closes #216 --- backend/app/api/routes/support.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/app/api/routes/support.py b/backend/app/api/routes/support.py index 8cdc78c03..1a42dc05f 100644 --- a/backend/app/api/routes/support.py +++ b/backend/app/api/routes/support.py @@ -410,6 +410,10 @@ def _sanitize_log_content(content: str) -> str: # Replace email addresses content = re.sub(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b", "[EMAIL]", content) + # Replace Bambu Lab printer serial numbers (format: 00M/01D/01S/01P/03W + alphanumeric, 12-16 chars total) + # These appear in logs as [SERIAL] or in messages + content = re.sub(r"\b(0[0-3][A-Z0-9])[A-Z0-9]{9,13}\b", r"\1[SERIAL]", content) + # Replace paths with usernames content = re.sub(r"/home/[^/\s]+/", "/home/[user]/", content) content = re.sub(r"/Users/[^/\s]+/", "/Users/[user]/", content)