Skip to content

Commit c582f70

Browse files
committed
Allow overriding CRS allowed HTTP methods per vhost
1 parent 1d436fd commit c582f70

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

manifests/vhost.pp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,9 @@
562562
# for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule
563563
# Set.
564564
#
565+
# @param modsec_allowed_methods
566+
# Override global allowed methods. A space-separated list of allowed HTTP methods.
567+
#
565568
# @param no_proxy_uris
566569
# Specifies URLs you do not want to proxy. This parameter is meant to be used in combination
567570
# with [`proxy_dest`](#proxy_dest).
@@ -1913,6 +1916,7 @@
19131916
Optional[String] $modsec_body_limit = undef,
19141917
Optional[Integer[1, default]] $modsec_inbound_anomaly_threshold = undef,
19151918
Optional[Integer[1, default]] $modsec_outbound_anomaly_threshold = undef,
1919+
Optional[String] $modsec_allowed_methods = undef,
19161920
Array[Hash] $jk_mounts = [],
19171921
Boolean $auth_kerb = false,
19181922
Enum['on', 'off'] $krb_method_negotiate = 'on',
@@ -2800,7 +2804,8 @@
28002804
# - $modsec_audit_log_destination
28012805
# - $modsec_inbound_anomaly_threshold
28022806
# - $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) {
2807+
# - $modsec_allowed_methods
2808+
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) or $modsec_allowed_methods {
28042809
concat::fragment { "${name}-security":
28052810
target => "${priority_real}${filename}.conf",
28062811
order => 320,

templates/vhost/_security.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,13 @@
4949
setvar:tx.inbound_anomaly_score_threshold=<%= @modsec_inbound_anomaly_threshold -%>, \
5050
setvar:tx.outbound_anomaly_score_threshold=<%= @modsec_outbound_anomaly_threshold -%>"
5151
<% end -%>
52+
<% if @modsec_allowed_methods -%>
53+
SecAction \
54+
"id:900200,\
55+
phase:1,\
56+
nolog,\
57+
pass,\
58+
t:none,\
59+
setvar:'tx.allowed_methods=<%= @modsec_allowed_methods -%>'"
60+
<% end -%>
5261
</IfModule>

0 commit comments

Comments
 (0)