From 699c8d8722e5e18a02d70843134622bc7085aa20 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Fri, 20 Dec 2024 15:39:29 -0500 Subject: [PATCH] Fixes regex to match beginnig of IP address (#2900) The BadBotConfigLine class spits out sample apache configuration based to block certain IP address blocks based on their frequency in the apache log. The regex in the script was erroneously matching octet pairs to any part of the clients IP to flag it as a bad bot. This PR fixes the regex to only match the beginning Fixes #2899 --- scripts/lib/apache_log_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/apache_log_parser.rb b/scripts/lib/apache_log_parser.rb index 0e658c69ad..a40bf71e9e 100644 --- a/scripts/lib/apache_log_parser.rb +++ b/scripts/lib/apache_log_parser.rb @@ -120,7 +120,7 @@ def to_s indent + ips.map do |ip| ip += '.' if ip.count('.') < 3 ip.gsub!('.', '\.') - "SetEnvIfNoCase Remote_Addr \"#{ip}\" bad_bot" + "SetEnvIfNoCase Remote_Addr \"^#{ip}\" bad_bot" end.join("\n#{indent}") end end