From 0a25ca7692566e68435fb83d1d8a05f051661d76 Mon Sep 17 00:00:00 2001 From: Shaun Arman Date: Sun, 5 Apr 2026 09:59:19 -0500 Subject: [PATCH] fix(pii): remove lookahead from hostname regex, fix fmt in analysis test Rust's `regex` crate does not support lookaround assertions. The hostname pattern `(?=.{1,253}\b)` caused a panic on every `PiiDetector::new()` call, failing all four PII detector tests in CI (rust-fmt-check, rust-clippy, rust-tests). Removed the lookahead; the remaining pattern correctly matches valid FQDNs without the RFC 1035 length pre-check. Also reformatted analysis.rs:253 to satisfy `rustfmt` (line break after `=`). All 127 Rust tests pass and `cargo fmt --check` and `cargo clippy -- -D warnings` are clean. --- src-tauri/src/commands/analysis.rs | 6 ++---- src-tauri/src/pii/patterns.rs | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/commands/analysis.rs b/src-tauri/src/commands/analysis.rs index ea8bccb6..5005c2cb 100644 --- a/src-tauri/src/commands/analysis.rs +++ b/src-tauri/src/commands/analysis.rs @@ -250,10 +250,8 @@ mod tests { #[test] fn test_validate_log_file_path_accepts_small_file() { - let file_path = std::env::temp_dir().join(format!( - "tftsr-analysis-test-{}.log", - uuid::Uuid::now_v7() - )); + let file_path = + std::env::temp_dir().join(format!("tftsr-analysis-test-{}.log", uuid::Uuid::now_v7())); std::fs::write(&file_path, "hello").unwrap(); let result = validate_log_file_path(file_path.to_string_lossy().as_ref()); assert!(result.is_ok()); diff --git a/src-tauri/src/pii/patterns.rs b/src-tauri/src/pii/patterns.rs index eb21cabc..ab28f0c3 100644 --- a/src-tauri/src/pii/patterns.rs +++ b/src-tauri/src/pii/patterns.rs @@ -75,8 +75,10 @@ pub fn get_patterns() -> Vec<(PiiType, Regex)> { // Hostname / FQDN ( PiiType::Hostname, - Regex::new(r"\b(?=.{1,253}\b)(?:[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,63}\b") - .unwrap(), + Regex::new( + r"\b(?:[A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z]{2,63}\b", + ) + .unwrap(), ), ] }