Skip to content

Commit 3c58ec6

Browse files
committed
Adding ModSecurity parameter for audit log format.
1 parent 925cd89 commit 3c58ec6

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

manifests/mod/security.pp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#
3333
# @param audit_log_type
3434
# Defines the type of audit logging mechanism to be used.
35+
#
36+
# @param audit_log_format
37+
# Defines what format the logs should be written in. Accepts `Native` and `JSON`.
38+
# Default value: Native
3539
#
3640
# @param audit_log_storage_dir
3741
# Defines the directory where concurrent audit log entries are to be stored. This directive is only needed when concurrent audit logging is used.
@@ -143,6 +147,7 @@
143147
String $audit_log_relevant_status = '^(?:5|4(?!04))',
144148
String $audit_log_parts = $apache::params::modsec_audit_log_parts,
145149
String $audit_log_type = $apache::params::modsec_audit_log_type,
150+
Enum['Native', 'JSON'] $audit_log_format = $apache::params::modsec_audit_log_format,
146151
Optional[Stdlib::Absolutepath] $audit_log_storage_dir = undef,
147152
Integer $secpcrematchlimit = $apache::params::secpcrematchlimit,
148153
Integer $secpcrematchlimitrecursion = $apache::params::secpcrematchlimitrecursion,
@@ -256,6 +261,7 @@
256261
'audit_log_relevant_status' => $audit_log_relevant_status,
257262
'audit_log_parts' => $audit_log_parts,
258263
'audit_log_type' => $audit_log_type,
264+
'audit_log_format' => $audit_log_format,
259265
'audit_log_storage_dir' => $audit_log_storage_dir,
260266
'logroot' => $logroot,
261267
}

manifests/params.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
$modsec_audit_log_parts = 'ABIJDEFHZ'
3838
$modsec_audit_log_type = 'Serial'
39+
$modsec_audit_log_format = 'Native'
3940
$modsec_custom_rules = false
4041
$modsec_custom_rules_set = undef
4142

spec/classes/mod/security_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
audit_log_relevant_status: '^(?:5|4(?!01|04))',
103103
audit_log_parts: 'ABCDZ',
104104
audit_log_type: 'Concurrent',
105+
audit_log_format: 'JSON',
105106
audit_log_storage_dir: '/var/log/httpd/audit',
106107
secdefaultaction: 'deny,status:406,nolog,auditlog',
107108
secrequestbodyaccess: 'Off',
@@ -114,6 +115,7 @@
114115
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogRelevantStatus "\^\(\?:5\|4\(\?!01\|04\)\)"$} }
115116
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogParts ABCDZ$} }
116117
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogType Concurrent$} }
118+
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogFormat JSON$} }
117119
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogStorageDir /var/log/httpd/audit$} }
118120
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecRequestBodyAccess Off$} }
119121
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecResponseBodyAccess On$} }

templates/mod/security.conf.epp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
SecAuditLogRelevantStatus "<%= $audit_log_relevant_status %>"
5050
SecAuditLogParts <%= $audit_log_parts %>
5151
SecAuditLogType <%= $audit_log_type %>
52+
<%- if $audit_log_format == 'JSON' { -%>
53+
SecAuditLogFormat JSON
54+
<%- } -%>
5255
<%- if $audit_log_storage_dir { -%>
5356
SecAuditLogStorageDir <%= $audit_log_storage_dir %>
5457
<%- } -%>

0 commit comments

Comments
 (0)