|
130 | 130 | } |
131 | 131 | it { is_expected.to contain_file('/etc/httpd/modsecurity.d/custom_rules/custom_01_rules.conf').with_content %r{^\s*.*"id:199999,phase:1,nolog,allow,ctl:ruleEngine=off"$} } |
132 | 132 | end |
| 133 | + |
| 134 | + describe 'with CRS parameters' do |
| 135 | + let :params do |
| 136 | + { |
| 137 | + paranoia_level: 1, |
| 138 | + executing_paranoia_level: 2, |
| 139 | + } |
| 140 | + end |
| 141 | + |
| 142 | + it { |
| 143 | + is_expected.to contain_file('/etc/httpd/modsecurity.d/security_crs.conf').with_content \ |
| 144 | + %r{^SecAction \\\n\s+\"id:900000,\\\n\s+phase:1,\\\n\s+nolog,\\\n\s+pass,\\\n\s+t:none,\\\n\s+setvar:tx.paranoia_level=1"$} |
| 145 | + is_expected.to contain_file('/etc/httpd/modsecurity.d/security_crs.conf').with_content \ |
| 146 | + %r{^SecAction \\\n\s+\"id:900001,\\\n\s+phase:1,\\\n\s+nolog,\\\n\s+pass,\\\n\s+t:none,\\\n\s+setvar:tx.executing_paranoia_level=2"$} |
| 147 | + } |
| 148 | + end |
| 149 | + |
| 150 | + describe 'with invalid CRS parameters' do |
| 151 | + let :params do |
| 152 | + { |
| 153 | + paranoia_level: 2, |
| 154 | + executing_paranoia_level: 1, |
| 155 | + } |
| 156 | + end |
| 157 | + |
| 158 | + it { |
| 159 | + is_expected.to compile.and_raise_error(%r{Executing paranoia level cannot be lower than paranoia level}) |
| 160 | + } |
| 161 | + end |
133 | 162 | end |
134 | 163 | when 'Debian' |
135 | 164 | context 'on Debian based systems' do |
|
259 | 288 | ) |
260 | 289 | } |
261 | 290 | end |
| 291 | + |
| 292 | + describe 'with CRS parameters' do |
| 293 | + let :params do |
| 294 | + { |
| 295 | + paranoia_level: 1, |
| 296 | + executing_paranoia_level: 1, |
| 297 | + } |
| 298 | + end |
| 299 | + |
| 300 | + it { |
| 301 | + is_expected.to contain_file('/etc/modsecurity/security_crs.conf').with_content \ |
| 302 | + %r{^SecAction \\\n\s+\"id:900000,\\\n\s+phase:1,\\\n\s+nolog,\\\n\s+pass,\\\n\s+t:none,\\\n\s+setvar:tx.paranoia_level=1"$} |
| 303 | + is_expected.to contain_file('/etc/modsecurity/security_crs.conf').with_content \ |
| 304 | + %r{^SecAction \\\n\s+\"id:900001,\\\n\s+phase:1,\\\n\s+nolog,\\\n\s+pass,\\\n\s+t:none,\\\n\s+setvar:tx.executing_paranoia_level=1"$} |
| 305 | + } |
| 306 | + end |
| 307 | + |
| 308 | + describe 'with invalid CRS parameters' do |
| 309 | + let :params do |
| 310 | + { |
| 311 | + paranoia_level: 2, |
| 312 | + executing_paranoia_level: 1, |
| 313 | + } |
| 314 | + end |
| 315 | + |
| 316 | + it { |
| 317 | + is_expected.to compile.and_raise_error(%r{Executing paranoia level cannot be lower than paranoia level}) |
| 318 | + } |
| 319 | + end |
262 | 320 | end |
263 | 321 | end |
264 | 322 | end |
|
0 commit comments