Created
October 22, 2013 14:50
-
-
Save aiwilliams/7102105 to your computer and use it in GitHub Desktop.
Generating suggested whitelists for Naxsi Web Application Firewall from multiple error logs. This assumes you want a distinct set for each log.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
nx_dir = 'naxsi-rules.d' | |
rules_dir = 'etc/nginx/naxsi' | |
FileUtils.mkdir_p nx_dir | |
Dir['var/log/nginx/*.error.log'].each do |log_path| | |
log_name = File.basename(log_path, '.error.log') | |
db_path = File.join nx_dir, "#{log_name}.naxsi.sqlite" | |
rules_path = File.join rules_dir, "#{log_name}-generated.rules" | |
`nx_util.py -l #{log_path}* -d #{db_path}` | |
`nx_util.py -o -d #{db_path} -c nx_util.conf > #{rules_path}` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[nx_util] | |
data_dir=/usr/local/nx_datas | |
database_dir= | |
naxsi_core_rules=etc/nginx/naxsi_core.rules |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment