2019-10-17 05:54:13 +02:00
|
|
|
# frozen_string_literal: true
|
2016-05-11 03:48:26 +02:00
|
|
|
|
2020-07-18 18:23:58 +02:00
|
|
|
control 'apache mod_security configuration' do
|
2019-10-17 05:54:13 +02:00
|
|
|
title 'should match desired lines'
|
|
|
|
|
2021-02-12 11:33:32 +01:00
|
|
|
only_if('Disabled on Arch Linux') do
|
|
|
|
!%w[arch].include?(platform[:name])
|
|
|
|
end
|
|
|
|
|
2019-10-17 05:54:13 +02:00
|
|
|
modspec_file =
|
2021-04-03 23:39:56 +02:00
|
|
|
case system.platform[:family]
|
2019-10-17 05:54:13 +02:00
|
|
|
when 'redhat', 'fedora'
|
|
|
|
'/etc/httpd/conf.d/mod_security.conf'
|
|
|
|
when 'debian'
|
|
|
|
'/etc/modsecurity/modsecurity.conf-recommended'
|
2020-07-18 18:26:39 +02:00
|
|
|
when 'suse'
|
|
|
|
'/etc/apache2/conf.d/mod_security2.conf'
|
2021-04-03 23:39:56 +02:00
|
|
|
when 'bsd'
|
|
|
|
'/usr/local/etc/modsecurity/modsecurity.conf'
|
|
|
|
end
|
|
|
|
|
|
|
|
modspec_file_group =
|
|
|
|
case system.platform[:family]
|
|
|
|
when 'bsd'
|
|
|
|
'wheel'
|
|
|
|
else
|
|
|
|
'root'
|
2019-10-17 05:54:13 +02:00
|
|
|
end
|
2016-05-11 03:48:26 +02:00
|
|
|
|
|
|
|
describe file(modspec_file) do
|
2019-10-17 05:54:13 +02:00
|
|
|
it { should be_file }
|
|
|
|
its('mode') { should cmp '0644' }
|
|
|
|
its('owner') { should eq 'root' }
|
2021-04-03 23:39:56 +02:00
|
|
|
its('group') { should eq modspec_file_group }
|
2019-10-17 05:54:13 +02:00
|
|
|
its('content') { should match(/SecRuleEngine On/) }
|
|
|
|
its('content') { should match(/SecRequestBodyAccess On/) }
|
|
|
|
its('content') { should match(/SecRequestBodyLimit 14000000/) }
|
|
|
|
its('content') { should match(/SecRequestBodyNoFilesLimit 114002/) }
|
|
|
|
its('content') { should match(/SecRequestBodyInMemoryLimit 114002/) }
|
|
|
|
its('content') { should match(/SecRequestBodyLimitAction Reject/) }
|
|
|
|
its('content') { should match(/SecPcreMatchLimit 15000/) }
|
|
|
|
its('content') { should match(/SecPcreMatchLimitRecursion 15000/) }
|
|
|
|
its('content') { should match(/SecDebugLogLevel 3/) }
|
2016-05-11 03:48:26 +02:00
|
|
|
end
|
|
|
|
end
|