From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A221867351 for ; Mon, 9 Nov 2020 15:18:51 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 96600172A4 for ; Mon, 9 Nov 2020 15:18:51 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 9396C1729B for ; Mon, 9 Nov 2020 15:18:50 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 56B9E45F02 for ; Mon, 9 Nov 2020 15:18:50 +0100 (CET) From: Mira Limbeck To: pmg-devel@lists.proxmox.com Date: Mon, 9 Nov 2020 15:18:46 +0100 Message-Id: <20201109141846.24669-1-m.limbeck@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.239 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.379 Envelope sender has no MX or A DNS records RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pmg-devel] [PATCH pmg-log-tracker] change case sensitive string match to case insensitive X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2020 14:18:51 -0000 With the rewrite from C to Rust the search string match was changed to be case sensitive by accident. Fix this by comparing the lowercase values of both the input and the search string. Signed-off-by: Mira Limbeck --- src/main.rs | 2 +- tests/tests_after_queue.rs | 23 +++++++++++++++++++++++ tests/tests_before_queue.rs | 23 +++++++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ce09f14..3495269 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1842,7 +1842,7 @@ impl Parser { self.string_match = false; if !self.options.string_match.is_empty() - && find(complete_line, self.options.string_match.as_bytes()).is_some() + && find_lowercase(complete_line, self.options.string_match.as_bytes()).is_some() { self.string_match = true; } diff --git a/tests/tests_after_queue.rs b/tests/tests_after_queue.rs index 42d0f6b..f6441fa 100644 --- a/tests/tests_after_queue.rs +++ b/tests/tests_after_queue.rs @@ -114,3 +114,26 @@ fn after_queue_search_string() { let output_reader = BufReader::new(&output.stdout[..]); utils::compare_output(output_reader, expected_output); } + +#[test] +fn after_queue_search_string_case_insensitive() { + let output = Command::new(utils::log_tracker_path()) + .arg("-vv") + .arg("-s") + .arg("1608302400") + .arg("-e") + .arg("1608303600") + .arg("-i") + .arg("tests/test_input_mixed") + .arg("-x") + .arg("reJECT") + .output() + .expect("failed to execute pmg-log-tracker"); + + let expected_file = File::open("tests/test_output_after_queue_search_string") + .expect("failed to open test_output"); + + let expected_output = BufReader::new(&expected_file); + let output_reader = BufReader::new(&output.stdout[..]); + utils::compare_output(output_reader, expected_output); +} diff --git a/tests/tests_before_queue.rs b/tests/tests_before_queue.rs index bd46e53..fb7a149 100644 --- a/tests/tests_before_queue.rs +++ b/tests/tests_before_queue.rs @@ -114,6 +114,29 @@ fn before_queue_search_string() { utils::compare_output(output_reader, expected_output); } +#[test] +fn before_queue_search_string_case_insensitive() { + let output = Command::new(utils::log_tracker_path()) + .arg("-vv") + .arg("-s") + .arg("1608300000") + .arg("-e") + .arg("1608302400") + .arg("-i") + .arg("tests/test_input_mixed") + .arg("-x") + .arg("reJECT") + .output() + .expect("failed to execute pmg-log-tracker"); + + let expected_file = File::open("tests/test_output_before_queue_search_string") + .expect("failed to open test_output"); + + let expected_output = BufReader::new(&expected_file); + let output_reader = BufReader::new(&output.stdout[..]); + utils::compare_output(output_reader, expected_output); +} + #[test] fn before_queue_exclude_greylist_ndr() { let output = Command::new(utils::log_tracker_path()) -- 2.20.1