From f74f90cac6c72981a8b9ba1e4fae056b6417bc63 Mon Sep 17 00:00:00 2001 From: Xi Chen Date: Mon, 30 Mar 2026 11:32:19 -0400 Subject: [PATCH] fix: remove double-escaped backslashes in DLP regex patterns The onboard config generator used raw strings (r#"..."#) but wrote regex backslashes as \\b instead of \b. In a raw string, backslashes are literal, so \\b produces \\b in the output TOML. TOML literal strings (single-quoted) also do not interpret escapes, so the regex engine received \\b (literal backslash + b) instead of \b (word boundary). This caused all DLP patterns (SSN, credit cards) to silently fail to match any input. Fixes #90 --- src/onboard/config_render.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/onboard/config_render.rs b/src/onboard/config_render.rs index eb4c65f..0dacdbf 100644 --- a/src/onboard/config_render.rs +++ b/src/onboard/config_render.rs @@ -70,11 +70,11 @@ minimax_base_url = "https://api.minimax.io" {key_section}[dlp] scan_responses = true patterns = [ - {{ name = "ssn", regex = '\\b\\d{{3}}-\\d{{2}}-\\d{{4}}\\b', action = "redact" }}, - {{ name = "visa_card", regex = '\\b4[0-9]{{12}}(?:[0-9]{{3}})?\\b', action = "redact" }}, - {{ name = "visa_mastercard", regex = '\\b(?:4[0-9]{{12}}(?:[0-9]{{3}})?|5[1-5][0-9]{{14}})\\b', action = "redact" }}, - {{ name = "mastercard", regex = '\\b5[1-5][0-9]{{14}}\\b', action = "redact" }}, - {{ name = "amex_card", regex = '\\b3[47][0-9]{{13}}\\b', action = "redact" }}, + {{ name = "ssn", regex = '\b\d{{3}}-\d{{2}}-\d{{4}}\b', action = "redact" }}, + {{ name = "visa_card", regex = '\b4[0-9]{{12}}(?:[0-9]{{3}})?\b', action = "redact" }}, + {{ name = "visa_mastercard", regex = '\b(?:4[0-9]{{12}}(?:[0-9]{{3}})?|5[1-5][0-9]{{14}})\b', action = "redact" }}, + {{ name = "mastercard", regex = '\b5[1-5][0-9]{{14}}\b', action = "redact" }}, + {{ name = "amex_card", regex = '\b3[47][0-9]{{13}}\b', action = "redact" }}, ] {oauth_providers_section}"#, version = env!("CARGO_PKG_VERSION"),