From c99642312d4fb0fdc2564e0aabe39e3221b3e7a1 Mon Sep 17 00:00:00 2001 From: qpxdesign Date: Fri, 8 Mar 2024 12:06:07 -0500 Subject: [PATCH] bug fix --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/utils/read_folder.rs | 34 +++++++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4180261..19b0ab8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -655,7 +655,7 @@ dependencies = [ [[package]] name = "ngxav" -version = "0.5.4" +version = "0.5.5" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index ed509a8..3fa8667 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ workspace = { members = [ "tests","tests/obfuscate_access_log_ips"] } [package] name = "ngxav" -version = "0.5.4" +version = "0.5.5" edition = "2021" license = "MIT" description = "Search through NGINX logs with advanced filters and support for displaying analytics about your selected log entries" diff --git a/src/utils/read_folder.rs b/src/utils/read_folder.rs index 285736a..c092d5b 100644 --- a/src/utils/read_folder.rs +++ b/src/utils/read_folder.rs @@ -11,14 +11,42 @@ pub fn read_folder(file_path: String) -> Vec { let a = std::io::BufReader::new( fs::File::open(path.as_ref().unwrap().path().to_str().unwrap()).unwrap(), ); - if path.unwrap().path().to_str().unwrap().contains(".gz") { + if path + .as_ref() + .unwrap() + .path() + .to_str() + .unwrap() + .contains("error") + { + } else if path.unwrap().path().to_str().unwrap().contains(".gz") { let d = GzDecoder::new(a); for line in io::BufReader::new(d).lines() { - lines.push(line.unwrap().to_string()); + if line + .as_ref() + .expect("WOOP") + .chars() + .filter(|c| *c == '"') + .count() + > 6 + && line.as_ref().expect("WOOP").len() > 20 + { + lines.push(line.unwrap().to_string()); + } } } else { for line in io::BufReader::new(a).lines() { - lines.push(line.unwrap().to_string()); + if line + .as_ref() + .expect("WOOP") + .chars() + .filter(|c| *c == '"') + .count() + > 6 + && line.as_ref().expect("WOOP").len() > 20 + { + lines.push(line.unwrap().to_string()); + } } } }