Skip to content

Commit

Permalink
Fixes regex to match beginnig of IP address (#2900)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
afred authored Dec 20, 2024
1 parent bfdff51 commit 699c8d8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/lib/apache_log_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 699c8d8

Please sign in to comment.