From 87d74c6b8e674de39f83b7c307826a7137335ef5 Mon Sep 17 00:00:00 2001 From: qpxdesign Date: Fri, 8 Mar 2024 10:25:55 -0500 Subject: [PATCH] fixed bugs --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/utils/read_folder_conserve_memory.rs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d8e4b1a..a1941e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -655,7 +655,7 @@ dependencies = [ [[package]] name = "ngxav" -version = "0.4.8" +version = "0.4.9" dependencies = [ "chrono", "clap", diff --git a/Cargo.toml b/Cargo.toml index db2a641..3987be8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ workspace = { members = [ "tests","tests/obfuscate_access_log_ips"] } [package] name = "ngxav" -version = "0.4.8" +version = "0.4.9" 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_conserve_memory.rs b/src/utils/read_folder_conserve_memory.rs index 23b6bf3..245fa15 100644 --- a/src/utils/read_folder_conserve_memory.rs +++ b/src/utils/read_folder_conserve_memory.rs @@ -8,7 +8,6 @@ use std::fs::File; use std::io::{BufRead, BufReader}; pub fn read_folder_conserve_memory(file_path: String, isUnique: Option) { - println!("{}", "step zero"); let mut paths: Vec<_> = fs::read_dir(file_path).unwrap().collect(); paths.sort_by_key(|x| { metadata(x.as_ref().unwrap().path().to_str().unwrap()) @@ -16,7 +15,6 @@ pub fn read_folder_conserve_memory(file_path: String, isUnique: Option) { .modified() .unwrap() }); - println!("{}", "step one"); let mut occurrences: HashMap = HashMap::new(); for path in paths { let p: String = path.unwrap().path().to_str().unwrap().to_string(); @@ -28,7 +26,11 @@ pub fn read_folder_conserve_memory(file_path: String, isUnique: Option) { Ok(line) => { let ip: String = line.clone().split(" ").collect::>()[0].to_string(); - if keep_line(&parse_line(&line), true) { + + if line.chars().filter(|c| *c == '"').count() > 4 + && line.len() > 20 + && keep_line(&parse_line(&line), true) + { if isUnique.is_some() && isUnique.unwrap() == true { if !occurrences.contains_key(&ip) { println!("{}", line.clone() + "\n");