From 86f5bcc007faf2c7bb84b877e83670a1b800d1e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 19 Oct 2026 13:50:10 +0500 Subject: [PATCH] Keep shutdown diagnostics readable without exposing portable PINs --- .../20261019-portable-stop-diagnostics.md | 7 +++++++ crates/coa-core/src/diag.rs | 20 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20261019-portable-stop-diagnostics.md diff --git a/changelog.d/20261019-portable-stop-diagnostics.md b/changelog.d/20261019-portable-stop-diagnostics.md new file mode 100644 index 0000000..ba36efe --- /dev/null +++ b/changelog.d/20261019-portable-stop-diagnostics.md @@ -0,0 +1,7 @@ +--- +area: manager +type: fixed +audience: admins +title: Server stop errors remain readable while private connection codes stay hidden +--- +The Manager keeps useful MySQL shutdown messages in diagnostics without exposing portable character connection codes. diff --git a/crates/coa-core/src/diag.rs b/crates/coa-core/src/diag.rs index b83e0e5..8aca557 100644 --- a/crates/coa-core/src/diag.rs +++ b/crates/coa-core/src/diag.rs @@ -392,7 +392,14 @@ pub fn redact(text: &str) -> String { let mut out = Vec::new(); for line in text.lines() { let l = line.to_lowercase(); - let sensitive = SENSITIVE.iter().any(|k| l.contains(k)); + let sensitive = SENSITIVE.iter().any(|k| { + if *k == "pin" { + l.match_indices("pin") + .any(|(at, _)| at == 0 || !l.as_bytes()[at - 1].is_ascii_alphanumeric()) + } else { + l.contains(k) + } + }); out.push(if sensitive { "[line removed: may contain a secret]".to_string() } else { @@ -1034,6 +1041,17 @@ real error assert!(!t.contains("PASS") && !t.contains("abc")); } + #[test] + fn stop_diagnostics_survive_while_portable_pins_remain_hidden() { + let ordinary = "MySQL is still stopping; wait before copying the repack."; + assert_eq!(redact(ordinary), ordinary); + for secret in ["PIN: 123456", "pin=123456", "transfer_pin=123456", "PIN123456"] { + let output = redact(&format!("{ordinary}\n{secret}")); + assert!(output.contains(ordinary)); + assert!(!output.contains("123456")); + } + } + #[test] fn json_redaction_keeps_the_file_valid_and_hides_the_secrets() { let t = redact_json(