|
475 | 475 | # Configures the maximum request body size (in bytes) ModSecurity accepts for buffering. |
476 | 476 | # |
477 | 477 | # @param modsec_disable_vhost |
478 | | -# Disables `mod_security` on a virtual host. Only valid if `apache::mod::security` is included. |
| 478 | +# Deprecated. Disables `mod_security` on a virtual host. Use `modsec_rule_engine => 'Off'` instead. |
| 479 | +# Only valid if `apache::mod::security` is included. |
479 | 480 | # |
480 | 481 | # @param modsec_disable_ids |
481 | 482 | # Removes `mod_security` IDs from the virtual host.<br /> |
|
1710 | 1711 | # |
1711 | 1712 | # @param proxy_protocol_exceptions |
1712 | 1713 | # Disable processing of PROXY header for certain hosts or networks |
| 1714 | +# |
| 1715 | +# @param modsec_rule_engine |
| 1716 | +# Configures the ModSecurity rules engine for this virtual host. When unset, the virtual host |
| 1717 | +# inherits the global `apache::mod::security::modsec_secruleengine` setting. |
| 1718 | +# |
1713 | 1719 | define apache::vhost ( |
1714 | 1720 | Variant[Stdlib::Absolutepath, Boolean] $docroot, |
1715 | 1721 | Boolean $manage_docroot = true, |
|
1973 | 1979 | Optional[Variant[String[1], Array[String[1]]]] $userdir = undef, |
1974 | 1980 | Optional[Boolean] $proxy_protocol = undef, |
1975 | 1981 | Array[Stdlib::Host] $proxy_protocol_exceptions = [], |
| 1982 | + Optional[Enum['On', 'Off', 'DetectionOnly']] $modsec_rule_engine = undef, |
1976 | 1983 | ) { |
1977 | 1984 | # The base class must be included first because it is used by parameter defaults |
1978 | 1985 | if ! defined(Class['apache']) { |
|
2181 | 2188 | } |
2182 | 2189 |
|
2183 | 2190 | ## Create a global LocationMatch if locations aren't defined |
2184 | | - if $modsec_disable_ids { |
2185 | | - if $modsec_disable_ids =~ Array { |
2186 | | - $_modsec_disable_ids = { '.*' => $modsec_disable_ids } |
2187 | | - } else { |
2188 | | - $_modsec_disable_ids = $modsec_disable_ids |
2189 | | - } |
| 2191 | + $_modsec_disable_ids = $modsec_disable_ids ? { |
| 2192 | + Array => { '.*' => $modsec_disable_ids }, |
| 2193 | + default => $modsec_disable_ids, |
2190 | 2194 | } |
2191 | 2195 |
|
2192 | | - if $modsec_disable_msgs { |
2193 | | - if $modsec_disable_msgs =~ Array { |
2194 | | - $_modsec_disable_msgs = { '.*' => $modsec_disable_msgs } |
2195 | | - } else { |
2196 | | - $_modsec_disable_msgs = $modsec_disable_msgs |
2197 | | - } |
| 2196 | + $_modsec_disable_msgs = $modsec_disable_msgs ? { |
| 2197 | + Array => { '.*' => $modsec_disable_msgs }, |
| 2198 | + default => $modsec_disable_msgs, |
2198 | 2199 | } |
2199 | 2200 |
|
2200 | | - if $modsec_disable_tags { |
2201 | | - if $modsec_disable_tags =~ Array { |
2202 | | - $_modsec_disable_tags = { '.*' => $modsec_disable_tags } |
2203 | | - } else { |
2204 | | - $_modsec_disable_tags = $modsec_disable_tags |
2205 | | - } |
| 2201 | + $_modsec_disable_tags = $modsec_disable_tags ? { |
| 2202 | + Array => { '.*' => $modsec_disable_tags }, |
| 2203 | + default => $modsec_disable_tags, |
2206 | 2204 | } |
2207 | 2205 |
|
2208 | 2206 | concat { "${priority_real}${filename}.conf": |
|
2840 | 2838 | } |
2841 | 2839 | } |
2842 | 2840 |
|
2843 | | - 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 { |
2844 | | - $security_params = { |
2845 | | - 'modsec_disable_vhost' => $modsec_disable_vhost, |
2846 | | - 'modsec_audit_log_destination' => $modsec_audit_log_destination, |
2847 | | - '_modsec_disable_ids' => $modsec_disable_ids, |
2848 | | - 'modsec_disable_ips' => $modsec_disable_ips, |
2849 | | - '_modsec_disable_msgs' => $modsec_disable_msgs, |
2850 | | - '_modsec_disable_tags' => $modsec_disable_tags, |
2851 | | - 'modsec_body_limit' => $modsec_body_limit, |
2852 | | - 'modsec_inbound_anomaly_threshold' => $modsec_inbound_anomaly_threshold, |
2853 | | - 'modsec_outbound_anomaly_threshold' => $modsec_outbound_anomaly_threshold, |
2854 | | - 'modsec_allowed_methods' => $modsec_allowed_methods, |
2855 | | - } |
| 2841 | + if $modsec_disable_vhost { |
| 2842 | + deprecation('apache::vhost::modsec_disable_vhost', 'This parameter is deprecated. Set `modsec_rule_engine` to `Off` instead.') |
| 2843 | + } |
| 2844 | + |
| 2845 | + $_modsec_rule_engine = $modsec_rule_engine ? { |
| 2846 | + undef => $modsec_disable_vhost ? { |
| 2847 | + true => 'Off', |
| 2848 | + default => undef, |
| 2849 | + }, |
| 2850 | + default => $modsec_rule_engine, |
| 2851 | + } |
| 2852 | + |
| 2853 | + $modsec_enabled = ($modsec_rule_engine != undef or $modsec_disable_vhost or $modsec_audit_log_destination != undef or $modsec_disable_ids != undef or !empty($modsec_disable_ips) or $modsec_disable_msgs != undef or $modsec_disable_tags != undef or $modsec_body_limit != undef or $modsec_inbound_anomaly_threshold != undef or $modsec_outbound_anomaly_threshold != undef or $modsec_allowed_methods != undef) |
| 2854 | + |
| 2855 | + $security_params = { |
| 2856 | + '_modsec_rule_engine' => $_modsec_rule_engine, |
| 2857 | + 'modsec_audit_log_destination' => $modsec_audit_log_destination, |
| 2858 | + '_modsec_disable_ids' => $_modsec_disable_ids, |
| 2859 | + 'modsec_disable_ips' => $modsec_disable_ips, |
| 2860 | + '_modsec_disable_msgs' => $_modsec_disable_msgs, |
| 2861 | + '_modsec_disable_tags' => $_modsec_disable_tags, |
| 2862 | + 'modsec_body_limit' => $modsec_body_limit, |
| 2863 | + 'modsec_inbound_anomaly_threshold' => $modsec_inbound_anomaly_threshold, |
| 2864 | + 'modsec_outbound_anomaly_threshold' => $modsec_outbound_anomaly_threshold, |
| 2865 | + 'modsec_allowed_methods' => $modsec_allowed_methods, |
| 2866 | + } |
| 2867 | + if $modsec_enabled { |
2856 | 2868 | concat::fragment { "${name}-security": |
2857 | 2869 | target => "${priority_real}${filename}.conf", |
2858 | 2870 | order => 320, |
|
0 commit comments