Skip to content

Commit 97449e4

Browse files
authored
Merge pull request #2583 from Tamerz/modsec_log_format
2 parents 00d529d + 8a10df5 commit 97449e4

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

REFERENCE.md

+9
Original file line numberDiff line numberDiff line change
@@ -6075,6 +6075,7 @@ The following parameters are available in the `apache::mod::security` class:
60756075
* [`audit_log_relevant_status`](#-apache--mod--security--audit_log_relevant_status)
60766076
* [`audit_log_parts`](#-apache--mod--security--audit_log_parts)
60776077
* [`audit_log_type`](#-apache--mod--security--audit_log_type)
6078+
* [`audit_log_format`](#-apache--mod--security--audit_log_format)
60786079
* [`audit_log_storage_dir`](#-apache--mod--security--audit_log_storage_dir)
60796080
* [`secpcrematchlimit`](#-apache--mod--security--secpcrematchlimit)
60806081
* [`secpcrematchlimitrecursion`](#-apache--mod--security--secpcrematchlimitrecursion)
@@ -6194,6 +6195,14 @@ Defines the type of audit logging mechanism to be used.
61946195

61956196
Default value: `$apache::params::modsec_audit_log_type`
61966197

6198+
##### <a name="-apache--mod--security--audit_log_format"></a>`audit_log_format`
6199+
6200+
Data type: `Enum['Native', 'JSON']`
6201+
6202+
Defines what format the logs should be written in.
6203+
6204+
Default value: `'Native'`
6205+
61976206
##### <a name="-apache--mod--security--audit_log_storage_dir"></a>`audit_log_storage_dir`
61986207

61996208
Data type: `Optional[Stdlib::Absolutepath]`

manifests/mod/security.pp

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
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.
3538
#
3639
# @param audit_log_storage_dir
3740
# 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 +146,7 @@
143146
String $audit_log_relevant_status = '^(?:5|4(?!04))',
144147
String $audit_log_parts = $apache::params::modsec_audit_log_parts,
145148
String $audit_log_type = $apache::params::modsec_audit_log_type,
149+
Enum['Native', 'JSON'] $audit_log_format = 'Native',
146150
Optional[Stdlib::Absolutepath] $audit_log_storage_dir = undef,
147151
Integer $secpcrematchlimit = $apache::params::secpcrematchlimit,
148152
Integer $secpcrematchlimitrecursion = $apache::params::secpcrematchlimitrecursion,
@@ -256,6 +260,7 @@
256260
'audit_log_relevant_status' => $audit_log_relevant_status,
257261
'audit_log_parts' => $audit_log_parts,
258262
'audit_log_type' => $audit_log_type,
263+
'audit_log_format' => $audit_log_format,
259264
'audit_log_storage_dir' => $audit_log_storage_dir,
260265
'logroot' => $logroot,
261266
}

spec/classes/mod/security_spec.rb

+2
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

+3
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)