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.
This commit is contained in:
parent
281e676ad1
commit
0a25ca7692
@ -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());
|
||||
|
||||
@ -75,7 +75,9 @@ 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")
|
||||
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(),
|
||||
),
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user