Skip to content

Commit fc46598

Browse files
committed
Parametrize the SecDebugLogLevel
1 parent 9f159df commit fc46598

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

manifests/mod/security.pp

+41-35
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,119 @@
11
# @summary
22
# Installs and configures `mod_security`.
3-
#
3+
#
44
# @param version
55
# Manage mod_security or mod_security2
66
#
77
# @param logroot
88
# Configures the location of audit and debug logs.
9-
#
9+
#
1010
# @param crs_package
1111
# Name of package that installs CRS rules.
12-
#
12+
#
1313
# @param activated_rules
1414
# An array of rules from the modsec_crs_path or absolute to activate via symlinks.
1515
#
1616
# @param custom_rules
17-
#
17+
#
1818
# @param custom_rules_set
1919
#
2020
# @param modsec_dir
2121
# Defines the path where Puppet installs the modsec configuration and activated rules links.
22-
#
22+
#
2323
# @param modsec_secruleengine
2424
# Configures the rules engine.
25-
#
25+
#
2626
# @param audit_log_relevant_status
2727
# Configures which response status code is to be considered relevant for the purpose of audit logging.
28-
#
28+
#
2929
# @param audit_log_parts
3030
# Defines which parts of each transaction are going to be recorded in the audit log. Each part is assigned a single letter; when a
3131
# letter appears in the list then the equivalent part will be recorded.
32-
#
32+
#
3333
# @param audit_log_type
3434
# Defines the type of audit logging mechanism to be used.
35-
#
35+
#
3636
# @param audit_log_storage_dir
3737
# Defines the directory where concurrent audit log entries are to be stored. This directive is only needed when concurrent audit logging is used.
38-
#
38+
#
39+
# @param debug_log_level
40+
# Defines the level of debug logging mechanism to be used. Values can be set from 0 to 9, with 9 being the maximum version of information logged.
41+
#
3942
# @param secpcrematchlimit
4043
# Sets the match limit in the PCRE library.
41-
#
44+
#
4245
# @param secpcrematchlimitrecursion
4346
# Sets the match limit recursion in the PCRE library.
44-
#
47+
#
4548
# @param allowed_methods
4649
# A space-separated list of allowed HTTP methods.
47-
#
50+
#
4851
# @param content_types
4952
# A list of one or more allowed MIME types.
50-
#
53+
#
5154
# @param restricted_extensions
5255
# A space-sparated list of prohibited file extensions.
53-
#
56+
#
5457
# @param restricted_headers
5558
# A list of restricted headers separated by slashes and spaces.
56-
#
59+
#
5760
# @param secdefaultaction
5861
# Defines the default list of actions, which will be inherited by the rules in the same configuration context.
59-
#
62+
#
6063
# @param inbound_anomaly_threshold
6164
# Sets the scoring threshold level of the inbound blocking rules for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule Set.
62-
#
65+
#
6366
# @param outbound_anomaly_threshold
6467
# Sets the scoring threshold level of the outbound blocking rules for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule Set.
65-
#
68+
#
6669
# @param critical_anomaly_score
6770
# Sets the Anomaly Score for rules assigned with a critical severity.
68-
#
71+
#
6972
# @param error_anomaly_score
7073
# Sets the Anomaly Score for rules assigned with a error severity.
71-
#
74+
#
7275
# @param warning_anomaly_score
7376
# Sets the Anomaly Score for rules assigned with a warning severity.
74-
#
77+
#
7578
# @param notice_anomaly_score
7679
# Sets the Anomaly Score for rules assigned with a notice severity.
77-
#
80+
#
7881
# @param paranoia_level
7982
# Sets the paranoia level in the OWASP ModSecurity Core Rule Set.
80-
#
83+
#
8184
# @param executing_paranoia_level
8285
# Sets the executing paranoia level in the OWASP ModSecurity Core Rule Set.
8386
# The default is equal to, and cannot be lower than, $paranoia_level.
84-
#
87+
#
8588
# @param secrequestmaxnumargs
8689
# Sets the maximum number of arguments in the request.
87-
#
90+
#
8891
# @param secrequestbodylimit
8992
# Sets the maximum request body size ModSecurity will accept for buffering.
90-
#
93+
#
9194
# @param secrequestbodynofileslimit
92-
# Configures the maximum request body size ModSecurity will accept for buffering, excluding the size of any files being transported
95+
# Configures the maximum request body size ModSecurity will accept for buffering, excluding the size of any files being transported
9396
# in the request.
94-
#
97+
#
9598
# @param secrequestbodyinmemorylimit
9699
# Configures the maximum request body size that ModSecurity will store in memory.
97-
#
100+
#
98101
# @param secrequestbodyaccess
99102
# Toggle SecRequestBodyAccess On or Off
100-
#
103+
#
101104
# @param secrequestbodylimitaction
102105
# Controls what happens once a request body limit, configured with
103106
# SecRequestBodyLimit, is encountered
104-
#
107+
#
105108
# @param secresponsebodyaccess
106109
# Toggle SecResponseBodyAccess On or Off
107110
#
108111
# @param secresponsebodylimitaction
109112
# Controls what happens once a response body limit, configured with
110-
# SecResponseBodyLimitAction, is encountered.
111-
#
113+
# SecResponseBodyLimitAction, is encountered.
114+
#
112115
# @param manage_security_crs
113-
# Toggles whether to manage ModSecurity Core Rule Set
116+
# Toggles whether to manage ModSecurity Core Rule Set
114117
#
115118
# @param enable_dos_protection
116119
# Toggles the optional OWASP ModSecurity Core Rule Set DOS protection rule
@@ -144,6 +147,7 @@
144147
String $audit_log_parts = $apache::params::modsec_audit_log_parts,
145148
String $audit_log_type = $apache::params::modsec_audit_log_type,
146149
Optional[Stdlib::Absolutepath] $audit_log_storage_dir = undef,
150+
Integer[0,9] $debug_log_level = 0,
147151
Integer $secpcrematchlimit = $apache::params::secpcrematchlimit,
148152
Integer $secpcrematchlimitrecursion = $apache::params::secpcrematchlimitrecursion,
149153
String $allowed_methods = 'GET HEAD POST OPTIONS',
@@ -231,6 +235,7 @@
231235
# - $audit_log_parts
232236
# - $audit_log_type
233237
# - $audit_log_storage_dir
238+
# - $debug_log_level
234239
# - secpcrematchlimit
235240
# - secpcrematchlimitrecursion
236241
# - secrequestbodylimit
@@ -257,6 +262,7 @@
257262
'audit_log_parts' => $audit_log_parts,
258263
'audit_log_type' => $audit_log_type,
259264
'audit_log_storage_dir' => $audit_log_storage_dir,
265+
'debug_log_level' => $debug_log_level,
260266
'logroot' => $logroot,
261267
}
262268

spec/classes/mod/security_spec.rb

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
audit_log_parts: 'ABCDZ',
104104
audit_log_type: 'Concurrent',
105105
audit_log_storage_dir: '/var/log/httpd/audit',
106+
debug_log_level: 3,
106107
secdefaultaction: 'deny,status:406,nolog,auditlog',
107108
secrequestbodyaccess: 'Off',
108109
secresponsebodyaccess: 'On',
@@ -117,6 +118,7 @@
117118
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecAuditLogStorageDir /var/log/httpd/audit$} }
118119
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecRequestBodyAccess Off$} }
119120
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecResponseBodyAccess On$} }
121+
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecDebugLogLevel 3$} }
120122
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecRequestBodyLimitAction ProcessPartial$} }
121123
it { is_expected.to contain_file('security.conf').with_content %r{^\s+SecResponseBodyLimitAction Reject$} }
122124
it { is_expected.to contain_file('/etc/httpd/modsecurity.d/security_crs.conf').with_content %r{^\s*SecDefaultAction "phase:2,deny,status:406,nolog,auditlog"$} }

templates/mod/security.conf.epp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
SecResponseBodyMimeType text/plain text/html text/xml
4545
SecResponseBodyLimit 524288
4646
SecResponseBodyLimitAction <%= $secresponsebodylimitaction %>
47-
SecDebugLogLevel 0
47+
SecDebugLogLevel <%= $debug_log_level %>
4848
SecAuditEngine RelevantOnly
4949
SecAuditLogRelevantStatus "<%= $audit_log_relevant_status %>"
5050
SecAuditLogParts <%= $audit_log_parts %>

0 commit comments

Comments
 (0)