Skip to content

Commit a723b56

Browse files
committed
add configuration options to mod_security
1 parent 08158d4 commit a723b56

4 files changed

Lines changed: 45 additions & 12 deletions

File tree

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,10 @@ vhosts.
907907
include '::apache::mod::security'
908908
```
909909

910+
#####`crs_package`
911+
912+
Name of package to install containing crs rules
913+
910914
#####`modsec_dir`
911915

912916
Directory to install the modsec configuration and activated rules links into
@@ -916,6 +920,23 @@ Directory to install the modsec configuration and activated rules links into
916920
Array of rules from the modsec_crs_path to activate by symlinking to
917921
${modsec_dir}/activated_rules.
918922

923+
#####`allowed_methods`
924+
925+
HTTP methods allowed by mod_security
926+
927+
#####`content_types`
928+
929+
Content-types allowed by mod_security
930+
931+
#####`restricted_extensions`
932+
933+
Extensions prohibited by mod_security
934+
935+
#####`restricted_headers`
936+
937+
Headers restricted by mod_security
938+
939+
919940
####Defined Type: `apache::vhost`
920941

921942
The Apache module allows a lot of flexibility in the setup and configuration of virtual hosts. This flexibility is due, in part, to `vhost` being a defined resource type, which allows it to be evaluated multiple times with different parameters.
@@ -1824,7 +1845,7 @@ Sets the value for the [PassengerEnabled](http://www.modrails.com/documentation/
18241845
```
18251846

18261847
*Note:* Be aware that there is an [issue](http://www.conandalton.net/2010/06/passengerenabled-off-not-working.html) using the PassengerEnabled directive with the PassengerHighPerformance directive.
1827-
1848+
18281849
######`php_value` and `php_flag`
18291850

18301851
`php_value` sets the value of the directory, and `php_flag` uses a boolean to configure the directory. Further information can be found [here](http://php.net/manual/en/configuration.changes.php).

manifests/mod/security.pp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
class apache::mod::security (
2-
$crs_package = $::apache::params::modsec_crs_package,
3-
$activated_rules = $::apache::params::modsec_default_rules,
4-
$modsec_dir = $::apache::params::modsec_dir,
2+
$crs_package = $::apache::params::modsec_crs_package,
3+
$activated_rules = $::apache::params::modsec_default_rules,
4+
$modsec_dir = $::apache::params::modsec_dir,
5+
$allowed_methods = 'GET HEAD POST OPTIONS',
6+
$content_types = 'application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf',
7+
$restricted_extensions = '.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/',
8+
$restricted_headers = '/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/',
59
){
610

711
if $::osfamily == 'FreeBSD' {
@@ -31,6 +35,8 @@
3135
ensure => file,
3236
content => template('apache/mod/security.conf.erb'),
3337
path => "${::apache::mod_dir}/security.conf",
38+
owner => $::apache::params::user,
39+
group => $::apache::params::group,
3440
require => Exec["mkdir ${::apache::mod_dir}"],
3541
before => File[$::apache::mod_dir],
3642
notify => Class['apache::service'],
@@ -42,14 +48,19 @@
4248
group => $::apache::params::group,
4349
mode => '0555',
4450
purge => true,
51+
force => true,
4552
recurse => true,
4653
}
4754

4855
file { "${modsec_dir}/activated_rules":
49-
ensure => directory,
50-
owner => $::apache::params::user,
51-
group => $::apache::params::group,
52-
mode => '0555',
56+
ensure => directory,
57+
owner => $::apache::params::user,
58+
group => $::apache::params::group,
59+
mode => '0555',
60+
purge => true,
61+
force => true,
62+
recurse => true,
63+
notify => Class['apache::service'],
5364
}
5465

5566
file { "${modsec_dir}/security_crs.conf":

manifests/security/rule_link.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
path => "${::apache::mod::security::modsec_dir}/activated_rules/${filename}",
99
target => "${::apache::params::modsec_crs_path}/${title}",
1010
require => File["${::apache::mod::security::modsec_dir}/activated_rules"],
11+
notify => Class['apache::service'],
1112
}
1213
}

templates/mod/security_crs.conf.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ SecAction \
269269
"id:'900012', \
270270
phase:1, \
271271
t:none, \
272-
setvar:'tx.allowed_methods=GET HEAD POST OPTIONS', \
273-
setvar:'tx.allowed_request_content_type=application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf', \
272+
setvar:'tx.allowed_methods=<%= @allowed_methods -%>', \
273+
setvar:'tx.allowed_request_content_type=<%= @content_types -%>', \
274274
setvar:'tx.allowed_http_versions=HTTP/0.9 HTTP/1.0 HTTP/1.1', \
275-
setvar:'tx.restricted_extensions=.asa/ .asax/ .ascx/ .axd/ .backup/ .bak/ .bat/ .cdx/ .cer/ .cfg/ .cmd/ .com/ .config/ .conf/ .cs/ .csproj/ .csr/ .dat/ .db/ .dbf/ .dll/ .dos/ .htr/ .htw/ .ida/ .idc/ .idq/ .inc/ .ini/ .key/ .licx/ .lnk/ .log/ .mdb/ .old/ .pass/ .pdb/ .pol/ .printer/ .pwd/ .resources/ .resx/ .sql/ .sys/ .vb/ .vbs/ .vbproj/ .vsdisco/ .webinfo/ .xsd/ .xsx/', \
276-
setvar:'tx.restricted_headers=/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/', \
275+
setvar:'tx.restricted_extensions=<%= @restricted_extensions -%>', \
276+
setvar:'tx.restricted_headers=<%= @restricted_headers -%>', \
277277
nolog, \
278278
pass"
279279

0 commit comments

Comments
 (0)