Skip to content

Commit 8eafd5d

Browse files
committed
Allow overriding CRS anomaly threshold per vhost
1 parent 922c95e commit 8eafd5d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

manifests/vhost.pp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,16 @@
552552
# If none of those parameters are set, the global audit log is used
553553
# (`/var/log/httpd/modsec\_audit.log`; Debian and derivatives: `/var/log/apache2/modsec\_audit.log`; others: ).
554554
#
555+
# @param modsec_inbound_anomaly_threshold
556+
# Override the global scoring threshold level of the inbound blocking rules
557+
# for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule
558+
# Set.
559+
#
560+
# @param modsec_outbound_anomaly_threshold
561+
# Override the global scoring threshold level of the outbound blocking rules
562+
# for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule
563+
# Set.
564+
#
555565
# @param no_proxy_uris
556566
# Specifies URLs you do not want to proxy. This parameter is meant to be used in combination
557567
# with [`proxy_dest`](#proxy_dest).
@@ -1901,6 +1911,8 @@
19011911
Optional[Variant[Hash, Array]] $modsec_disable_msgs = undef,
19021912
Optional[Variant[Hash, Array]] $modsec_disable_tags = undef,
19031913
Optional[String] $modsec_body_limit = undef,
1914+
Optional[Integer[1, default]] $modsec_inbound_anomaly_threshold = undef,
1915+
Optional[Integer[1, default]] $modsec_outbound_anomaly_threshold = undef,
19041916
Array[Hash] $jk_mounts = [],
19051917
Boolean $auth_kerb = false,
19061918
Enum['on', 'off'] $krb_method_negotiate = 'on',
@@ -2786,7 +2798,9 @@
27862798
# - $modsec_disable_tags
27872799
# - $modsec_body_limit
27882800
# - $modsec_audit_log_destination
2789-
if $modsec_disable_vhost or $modsec_disable_ids or !empty($modsec_disable_ips) or $modsec_disable_msgs or $modsec_disable_tags or $modsec_audit_log_destination {
2801+
# - $modsec_inbound_anomaly_threshold
2802+
# - $modsec_outbound_anomaly_threshold
2803+
if $modsec_disable_vhost or $modsec_disable_ids or !empty($modsec_disable_ips) or $modsec_disable_msgs or $modsec_disable_tags or $modsec_audit_log_destination or ($modsec_inbound_anomaly_threshold and $modsec_outbound_anomaly_threshold) {
27902804
concat::fragment { "${name}-security":
27912805
target => "${priority_real}${filename}.conf",
27922806
order => 320,

templates/vhost/_security.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,14 @@
3939
<% if @modsec_body_limit -%>
4040
SecRequestBodyLimit <%= @modsec_body_limit %>
4141
<% end -%>
42+
<% if @modsec_inbound_anomaly_threshold and @modsec_outbound_anomaly_threshold -%>
43+
SecAction \
44+
"id:900110,\
45+
phase:1,\
46+
nolog,\
47+
pass,\
48+
t:none,\
49+
setvar:tx.inbound_anomaly_score_threshold=<%= @modsec_inbound_anomaly_threshold -%>, \
50+
setvar:tx.outbound_anomaly_score_threshold=<%= @modsec_outbound_anomaly_threshold -%>"
51+
<% end -%>
4252
</IfModule>

0 commit comments

Comments
 (0)