Skip to content

Commit 59e59e8

Browse files
scottmullalybmjen
authored andcommitted
ModSec debug logs to use apache logroot parameter (puppetlabs#1560)
1 parent a844191 commit 59e59e8

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,7 @@ ${modsec\_dir}/activated\_rules.
19151915
- `secdefaultaction`: Configures the Mode of Operation, Self-Contained ('deny') vs. Collaborative Detection ('pass'), for the OWASP ModSecurity Core Rule Set. Default: 'deny'. Fuller values can be set too like "log,auditlog,deny,status:406,tag:'SLA 24/7'"
19161916
- `secpcrematchlimit`: Sets the number for the match limit in the PCRE library. Default: '1500'
19171917
- `secpcrematchlimitrecursion`: Sets the number for the match limit recursion in the PCRE library. Default: '1500'
1918+
- `logroot`: Configures the location of audit and debug logs. Defaults to apache log directory (Redhat: /var/log/httpd Debian: /var/log/apache2)
19181919
- `audit_log_releavant_status`: Configures which response status code is to be considered relevant for the purpose of audit logging. Defaults: '^(?:5|4(?!04))'.
19191920
- `audit_log_parts`: Sets the sections to be put in the [audit log][]. Default: 'ABIJDEFHZ'
19201921
- `anomaly_score_blocking`: De-/Activates the Collaborative Detection Blocking of the OWASP ModSecurity Core Rule Set. Default: off.

manifests/mod/security.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class apache::mod::security (
2+
$logroot = $::apache::params::logroot,
23
$crs_package = $::apache::params::modsec_crs_package,
34
$activated_rules = $::apache::params::modsec_default_rules,
45
$modsec_dir = $::apache::params::modsec_dir,
@@ -61,6 +62,7 @@
6162
}
6263

6364
# Template uses:
65+
# - logroot
6466
# - $modsec_dir
6567
# - $audit_log_parts
6668
# - secpcrematchlimit

spec/classes/mod/security_spec.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,12 @@
2828
it { should contain_file('security.conf').with(
2929
:path => '/etc/httpd/conf.modules.d/security.conf'
3030
) }
31-
it { should contain_file('security.conf').with_content %r{^\s+SecAuditLogRelevantStatus "\^\(\?:5\|4\(\?!04\)\)"$} }
32-
it { should contain_file('security.conf').with_content %r{^\s+SecAuditLogParts ABIJDEFHZ$} }
31+
it { should contain_file('security.conf')
32+
.with_content(%r{^\s+SecAuditLogRelevantStatus "\^\(\?:5\|4\(\?!04\)\)"$})
33+
.with_content(%r{^\s+SecAuditLogParts ABIJDEFHZ$})
34+
.with_content(%r{^\s+SecDebugLog /var/log/httpd/modsec_debug.log$})
35+
.with_content(%r{^\s+SecAuditLog /var/log/httpd/modsec_audit.log$})
36+
}
3337
it { should contain_file('/etc/httpd/modsecurity.d').with(
3438
:ensure => 'directory',
3539
:path => '/etc/httpd/modsecurity.d',
@@ -99,8 +103,12 @@
99103
it { should contain_file('security.conf').with(
100104
:path => '/etc/apache2/mods-available/security.conf'
101105
) }
102-
it { should contain_file('security.conf').with_content %r{^\s+SecAuditLogRelevantStatus "\^\(\?:5\|4\(\?!04\)\)"$} }
103-
it { should contain_file('security.conf').with_content %r{^\s+SecAuditLogParts ABIJDEFHZ$} }
106+
it { should contain_file('security.conf')
107+
.with_content(%r{^\s+SecAuditLogRelevantStatus "\^\(\?:5\|4\(\?!04\)\)"$})
108+
.with_content(%r{^\s+SecAuditLogParts ABIJDEFHZ$})
109+
.with_content(%r{^\s+SecDebugLog /var/log/apache2/modsec_debug.log$})
110+
.with_content(%r{^\s+SecAuditLog /var/log/apache2/modsec_audit.log$})
111+
}
104112
it { should contain_file('/etc/modsecurity').with(
105113
:ensure => 'directory',
106114
:path => '/etc/modsecurity',

templates/mod/security.conf.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
SecArgumentSeparator &
5050
SecCookieFormat 0
5151
<%- if scope.lookupvar('::osfamily') == 'Debian' -%>
52-
SecDebugLog /var/log/apache2/modsec_debug.log
53-
SecAuditLog /var/log/apache2/modsec_audit.log
52+
SecDebugLog <%= @logroot %>/modsec_debug.log
53+
SecAuditLog <%= @logroot %>/modsec_audit.log
5454
SecTmpDir /var/cache/modsecurity
5555
SecDataDir /var/cache/modsecurity
5656
SecUploadDir /var/cache/modsecurity
@@ -61,8 +61,8 @@
6161
SecDataDir /var/lib/mod_security
6262
SecUploadDir /var/lib/mod_security
6363
<% else -%>
64-
SecDebugLog /var/log/httpd/modsec_debug.log
65-
SecAuditLog /var/log/httpd/modsec_audit.log
64+
SecDebugLog <%= @logroot %>/modsec_debug.log
65+
SecAuditLog <%= @logroot %>/modsec_audit.log
6666
SecTmpDir /var/lib/mod_security
6767
SecDataDir /var/lib/mod_security
6868
SecUploadDir /var/lib/mod_security

0 commit comments

Comments
 (0)