Puppet Class: apache::mod::security

Inherits:
apache::params
Defined in:
manifests/mod/security.pp

Summary

Installs and configures `mod_security`.

Overview

Note:

On RHEL/EL 10 the ModSecurity engine is provided by EPEL (enable EPEL yourself; this module does not manage it). The OWASP CRS package (‘mod_security_crs`) is not available on EL10, so `crs_source` defaults to `none` (engine only). CRS v4 can be opted into there via `crs_source => ’archive’‘ (downloaded from `crs_archive_source`, e.g. an internal mirror) or `crs_source => ’path’‘ (a pre-staged directory). EL7/8/9 keep the package-based default unchanged.

Parameters:

  • version (Integer) (defaults to: $apache::params::modsec_version)

    Manage mod_security or mod_security2

  • logroot (Stdlib::Absolutepath) (defaults to: $apache::params::logroot)

    Configures the location of audit and debug logs.

  • crs_package (Optional[String]) (defaults to: $apache::params::modsec_crs_package)

    Name of package that installs CRS rules. Only used when ‘crs_source` is `package`.

  • crs_source (Enum['package', 'archive', 'path', 'none']) (defaults to: $apache::params::modsec_crs_source)

    How the OWASP Core Rule Set is obtained:

    • ‘package` - install `crs_package` and activate rules via per-rule symlinks (v2/v3 layout). Default on EL7/8/9.

    • ‘archive` - download the CRS v4 tarball via `puppet/archive` from `crs_archive_source` (e.g. an internal mirror) and wire the v4 includes.

    • ‘path` - use a pre-staged CRS v4 directory given by `crs_path` (no download); only wires the v4 includes.

    • ‘none` - engine only, no CRS managed. Default on EL10.

  • crs_archive_source (Optional[String[1]]) (defaults to: $apache::params::modsec_crs_archive_source)

    Source URL or path for the CRS v4 tarball when ‘crs_source` is `archive`. No module default (user-pinned, e.g. an internal mirror) to avoid a version/CVE maintenance treadmill. Required for `archive`.

  • crs_archive_checksum (Optional[String[1]]) (defaults to: $apache::params::modsec_crs_archive_checksum)

    Checksum of the CRS v4 tarball for verification when ‘crs_source` is `archive`.

  • crs_archive_checksum_type (String[1]) (defaults to: $apache::params::modsec_crs_archive_checksum_type)

    Checksum algorithm for ‘crs_archive_checksum` (e.g. `sha256`).

  • crs_version (Optional[String[1]]) (defaults to: undef)

    The pinned CRS version (e.g. ‘4.27.0`), required for `crs_source => archive`. It fixes the extracted `coreruleset-<version>` directory name so the include paths are deterministic.

  • crs_path (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    For ‘crs_source => path`: absolute path to the pre-staged CRS v4 directory (contains `crs-setup.conf` and `rules/`). For `crs_source => archive`: overrides the extraction base directory (default `/usr/share`); the ruleset then lives at `<crs_path>/coreruleset-<crs_version>`.

  • activated_rules (Array[String]) (defaults to: $apache::params::modsec_default_rules)

    An array of rules from the modsec_crs_path or absolute to activate via symlinks.

  • custom_rules (Boolean) (defaults to: $apache::params::modsec_custom_rules)
  • custom_rules_set (Optional[Array[String]]) (defaults to: $apache::params::modsec_custom_rules_set)
  • modsec_dir (Stdlib::Absolutepath) (defaults to: $apache::params::modsec_dir)

    Defines the path where Puppet installs the modsec configuration and activated rules links.

  • modsec_secruleengine (String) (defaults to: $apache::params::modsec_secruleengine)

    Configures the rules engine.

  • debug_log_level (Integer[0, 9]) (defaults to: 0)

    Configures the debug log level.

  • audit_log_relevant_status (String) (defaults to: '^(?:5|4(?!04))')

    Configures which response status code is to be considered relevant for the purpose of audit logging.

  • audit_log_parts (String) (defaults to: $apache::params::modsec_audit_log_parts)

    Defines which parts of each transaction are going to be recorded in the audit log. Each part is assigned a single letter; when a letter appears in the list then the equivalent part will be recorded.

  • audit_log_type (String) (defaults to: $apache::params::modsec_audit_log_type)

    Defines the type of audit logging mechanism to be used.

  • audit_log_format (Enum['Native', 'JSON']) (defaults to: 'Native')

    Defines what format the logs should be written in.

  • audit_log_storage_dir (Optional[Stdlib::Absolutepath]) (defaults to: undef)

    Defines the directory where concurrent audit log entries are to be stored. This directive is only needed when concurrent audit logging is used.

  • secpcrematchlimit (Integer) (defaults to: $apache::params::secpcrematchlimit)

    Sets the match limit in the PCRE library.

  • secpcrematchlimitrecursion (Integer) (defaults to: $apache::params::secpcrematchlimitrecursion)

    Sets the match limit recursion in the PCRE library.

  • allowed_methods (String) (defaults to: 'GET HEAD POST OPTIONS')

    A space-separated list of allowed HTTP methods.

  • content_types (String) (defaults to: 'application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf')

    A list of one or more allowed MIME types.

  • restricted_extensions (String) (defaults to: '.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/')

    A space-sparated list of prohibited file extensions.

  • restricted_headers (String) (defaults to: '/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/')

    A list of restricted headers separated by slashes and spaces.

  • secdefaultaction (String) (defaults to: 'deny')

    Defines the default list of actions, which will be inherited by the rules in the same configuration context.

  • inbound_anomaly_threshold (Integer) (defaults to: 5)

    Sets the scoring threshold level of the inbound blocking rules for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule Set.

  • outbound_anomaly_threshold (Integer) (defaults to: 4)

    Sets the scoring threshold level of the outbound blocking rules for the Collaborative Detection Mode in the OWASP ModSecurity Core Rule Set.

  • critical_anomaly_score (Integer) (defaults to: 5)

    Sets the Anomaly Score for rules assigned with a critical severity.

  • error_anomaly_score (Integer) (defaults to: 4)

    Sets the Anomaly Score for rules assigned with a error severity.

  • warning_anomaly_score (Integer) (defaults to: 3)

    Sets the Anomaly Score for rules assigned with a warning severity.

  • notice_anomaly_score (Integer) (defaults to: 2)

    Sets the Anomaly Score for rules assigned with a notice severity.

  • paranoia_level (Integer[1,4]) (defaults to: 1)

    Sets the paranoia level in the OWASP ModSecurity Core Rule Set.

  • executing_paranoia_level (Integer[1,4]) (defaults to: $paranoia_level)

    Sets the executing paranoia level in the OWASP ModSecurity Core Rule Set. The default is equal to, and cannot be lower than, $paranoia_level.

  • secrequestmaxnumargs (Integer) (defaults to: 255)

    Sets the maximum number of arguments in the request.

  • secrequestbodylimit (Integer) (defaults to: 13107200)

    Sets the maximum request body size ModSecurity will accept for buffering.

  • secrequestbodynofileslimit (Integer) (defaults to: 131072)

    Configures the maximum request body size ModSecurity will accept for buffering, excluding the size of any files being transported in the request.

  • secrequestbodyinmemorylimit (Integer) (defaults to: 131072)

    Configures the maximum request body size that ModSecurity will store in memory.

  • secrequestbodyaccess (Apache::OnOff) (defaults to: 'On')

    Toggle SecRequestBodyAccess On or Off

  • secrequestbodylimitaction (Enum['Reject', 'ProcessPartial']) (defaults to: 'Reject')

    Controls what happens once a request body limit, configured with SecRequestBodyLimit, is encountered

  • secresponsebodyaccess (Apache::OnOff) (defaults to: 'Off')

    Toggle SecResponseBodyAccess On or Off

  • secresponsebodylimitaction (Enum['Reject', 'ProcessPartial']) (defaults to: 'ProcessPartial')

    Controls what happens once a response body limit, configured with SecResponseBodyLimitAction, is encountered.

  • manage_security_crs (Boolean) (defaults to: true)

    Toggles whether to manage ModSecurity Core Rule Set

  • enable_dos_protection (Boolean) (defaults to: true)

    Toggles the optional OWASP ModSecurity Core Rule Set DOS protection rule (rule id 900700)

  • dos_burst_time_slice (Integer[1, default]) (defaults to: 60)

    Configures time in which a burst is measured for the OWASP ModSecurity Core Rule Set DOS protection rule (rule id 900700)

  • dos_counter_threshold (Integer[1, default]) (defaults to: 100)

    Configures the amount of requests that can be made within dos_burst_time_slice before it is considered a burst in the OWASP ModSecurity Core Rule Set DOS protection rule (rule id 900700)

  • dos_block_timeout (Integer[1, default]) (defaults to: 600)

    Configures how long the client should be blocked when the dos_counter_threshold is exceeded in the OWASP ModSecurity Core Rule Set DOS protection rule (rule id 900700)

See Also:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'manifests/mod/security.pp', line 173

class apache::mod::security (
  Stdlib::Absolutepath $logroot                                = $apache::params::logroot,
  Integer $version                                             = $apache::params::modsec_version,
  Optional[String] $crs_package                                = $apache::params::modsec_crs_package,
  Enum['package', 'archive', 'path', 'none'] $crs_source       = $apache::params::modsec_crs_source,
  Optional[String[1]] $crs_archive_source                      = $apache::params::modsec_crs_archive_source,
  Optional[String[1]] $crs_archive_checksum                    = $apache::params::modsec_crs_archive_checksum,
  String[1] $crs_archive_checksum_type                         = $apache::params::modsec_crs_archive_checksum_type,
  Optional[String[1]] $crs_version                             = undef,
  Optional[Stdlib::Absolutepath] $crs_path                     = undef,
  Array[String] $activated_rules                               = $apache::params::modsec_default_rules,
  Boolean $custom_rules                                        = $apache::params::modsec_custom_rules,
  Optional[Array[String]] $custom_rules_set                    = $apache::params::modsec_custom_rules_set,
  Stdlib::Absolutepath $modsec_dir                             = $apache::params::modsec_dir,
  String $modsec_secruleengine                                 = $apache::params::modsec_secruleengine,
  Integer[0, 9] $debug_log_level                              = 0,
  String $audit_log_relevant_status                            = '^(?:5|4(?!04))',
  String $audit_log_parts                                      = $apache::params::modsec_audit_log_parts,
  String $audit_log_type                                       = $apache::params::modsec_audit_log_type,
  Enum['Native', 'JSON'] $audit_log_format                     = 'Native',
  Optional[Stdlib::Absolutepath] $audit_log_storage_dir        = undef,
  Integer $secpcrematchlimit                                   = $apache::params::secpcrematchlimit,
  Integer $secpcrematchlimitrecursion                          = $apache::params::secpcrematchlimitrecursion,
  String $allowed_methods                                      = 'GET HEAD POST OPTIONS',
  String $content_types                                        = 'application/x-www-form-urlencoded|multipart/form-data|text/xml|application/xml|application/x-amf',
  String $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/',
  String $restricted_headers                                   = '/Proxy-Connection/ /Lock-Token/ /Content-Range/ /Translate/ /via/ /if/',
  String $secdefaultaction                                     = 'deny',
  Integer $inbound_anomaly_threshold                           = 5,
  Integer $outbound_anomaly_threshold                          = 4,
  Integer $critical_anomaly_score                              = 5,
  Integer $error_anomaly_score                                 = 4,
  Integer $warning_anomaly_score                               = 3,
  Integer $notice_anomaly_score                                = 2,
  Integer $secrequestmaxnumargs                                = 255,
  Integer $secrequestbodylimit                                 = 13107200,
  Integer $secrequestbodynofileslimit                          = 131072,
  Integer $secrequestbodyinmemorylimit                         = 131072,
  Integer[1,4] $paranoia_level                                 = 1,
  Integer[1,4] $executing_paranoia_level                       = $paranoia_level,
  Apache::OnOff $secrequestbodyaccess                          = 'On',
  Apache::OnOff $secresponsebodyaccess                         = 'Off',
  Enum['Reject', 'ProcessPartial'] $secrequestbodylimitaction  = 'Reject',
  Enum['Reject', 'ProcessPartial'] $secresponsebodylimitaction = 'ProcessPartial',
  Boolean $manage_security_crs                                 = true,
  Boolean $enable_dos_protection                               = true,
  Integer[1, default] $dos_burst_time_slice                    = 60,
  Integer[1, default] $dos_counter_threshold                   = 100,
  Integer[1, default] $dos_block_timeout                       = 600,
) inherits apache::params {
  include apache

  $_secdefaultaction = $secdefaultaction ? {
    /log/   => $secdefaultaction, # it has log or nolog,auditlog or log,noauditlog
    default => "${secdefaultaction},log",
  }

  if $facts['os']['family'] == 'FreeBSD' {
    fail('FreeBSD is not currently supported')
  }

  if ($facts['os']['family'] == 'Suse' and versioncmp($facts['os']['release']['major'], '11') < 0) {
    fail('SLES 10 is not currently supported.')
  }

  if ($executing_paranoia_level < $paranoia_level) {
    fail('Executing paranoia level cannot be lower than paranoia level')
  }

  case $version {
    1: {
      $mod_name = 'security'
      $mod_conf_name = 'security.conf'
    }
    2: {
      $mod_name = 'security2'
      $mod_conf_name = 'security2.conf'
    }
    default: {
      fail('Unsuported version for mod security')
    }
  }
  ::apache::mod { $mod_name:
    id  => 'security2_module',
    lib => 'mod_security2.so',
  }

  ::apache::mod { 'unique_id':
    id  => 'unique_id_module',
    lib => 'mod_unique_id.so',
  }

  # Effective on-disk CRS v4 directory used in the include wiring. Kept outside
  # $modsec_dir, which is managed with purge => true and would otherwise remove
  # the extracted rule tree.
  # - path:    $crs_path is the ready CRS directory (contains crs-setup.conf + rules/).
  # - archive: CRS tarballs unpack to a versioned dir, so the ruleset lives at
  #            <base>/coreruleset-<crs_version> under the extraction base.
  $_crs_extract_base = $crs_path ? {
    undef   => '/usr/share',
    default => $crs_path,
  }
  $_crs_dir = $crs_source ? {
    'archive' => "${_crs_extract_base}/coreruleset-${crs_version}",
    default   => $crs_path,
  }

  # CRS acquisition. The activation wiring is selected later by the same
  # $crs_source: `package` keeps the legacy per-rule symlinks (v2/v3 layout),
  # while `archive`/`path` use the v4 include layout.
  case $crs_source {
    'package': {
      if $crs_package {
        package { $crs_package:
          ensure => 'installed',
          before => [
            File[$apache::confd_dir],
            File[$modsec_dir],
          ],
        }
      }
    }
    'archive': {
      if ! $crs_archive_source {
        fail('apache::mod::security: crs_source => "archive" requires crs_archive_source (URL/path to the CRS v4 tarball, e.g. an internal mirror).')
      }
      if ! $crs_version {
        fail('apache::mod::security: crs_source => "archive" requires crs_version (the pinned CRS version, e.g. "4.27.0"); it fixes the extracted coreruleset-<version> directory name.')
      }

      file { $_crs_extract_base:
        ensure => directory,
      }

      # Both the release "-minimal" asset and the source archive unpack to a
      # versioned top-level dir, coreruleset-<crs_version>/. Checksum
      # verification is only enabled when a checksum is supplied (a trusted
      # internal mirror may legitimately be used without one).
      archive { 'coreruleset.tar.gz':
        ensure          => present,
        path            => '/var/cache/coreruleset.tar.gz',
        source          => $crs_archive_source,
        checksum        => $crs_archive_checksum,
        checksum_type   => $crs_archive_checksum_type,
        checksum_verify => $crs_archive_checksum =~ NotUndef,
        extract         => true,
        extract_path    => $_crs_extract_base,
        creates         => "${_crs_dir}/crs-setup.conf.example",
        cleanup         => true,
        require         => File[$_crs_extract_base],
      }

      # CRS ships crs-setup.conf.example; create the active crs-setup.conf from
      # it once. The creates guard prevents clobbering later user edits.
      exec { 'apache-crs-setup-conf':
        command => ['/bin/cp', "${_crs_dir}/crs-setup.conf.example", "${_crs_dir}/crs-setup.conf"],
        creates => "${_crs_dir}/crs-setup.conf",
        require => Archive['coreruleset.tar.gz'],
        notify  => Class['apache::service'],
      }
    }
    'path': {
      if ! $crs_path {
        fail('apache::mod::security: crs_source => "path" requires crs_path (absolute path to a pre-staged CRS v4 directory).')
      }
    }
    'none': {}
    default: {}
  }

  # Template uses:
  # - logroot
  # - $modsec_dir
  # - $audit_log_parts
  # - $audit_log_type
  # - $audit_log_storage_dir
  # - secpcrematchlimit
  # - secpcrematchlimitrecursion
  # - secrequestbodylimit
  # - secrequestbodynofileslimit
  # - secrequestbodyinmemorylimit
  # - secrequestbodyaccess
  # - secresponsebodyaccess
  # - secrequestbodylimitaction
  # - secresponsebodylimitaction
  $security_conf_parameters = {
    'modsec_secruleengine'        => $modsec_secruleengine,
    'secrequestbodyaccess'        => $secrequestbodyaccess,
    'custom_rules'                => $custom_rules,
    'modsec_dir'                  => $modsec_dir,
    'secrequestbodylimit'         => $secrequestbodylimit,
    'secrequestbodynofileslimit'  => $secrequestbodynofileslimit,
    'secrequestbodyinmemorylimit' => $secrequestbodyinmemorylimit,
    'secrequestbodylimitaction'   => $secrequestbodylimitaction,
    'secpcrematchlimit'           => $secpcrematchlimit,
    'secpcrematchlimitrecursion'  => $secpcrematchlimitrecursion,
    'secresponsebodyaccess'       => $secresponsebodyaccess,
    'secresponsebodylimitaction'  => $secresponsebodylimitaction,
    'audit_log_relevant_status'   => $audit_log_relevant_status,
    'audit_log_parts'             => $audit_log_parts,
    'audit_log_type'              => $audit_log_type,
    'audit_log_format'            => $audit_log_format,
    'audit_log_storage_dir'       => $audit_log_storage_dir,
    'debug_log_level'             => $debug_log_level,
    'logroot'                     => $logroot,
  }

  file { 'security.conf':
    ensure  => file,
    content => epp('apache/mod/security.conf.epp', $security_conf_parameters),
    mode    => $apache::file_mode,
    path    => "${apache::mod_dir}/${mod_conf_name}",
    owner   => $apache::params::user,
    group   => $apache::params::group,
    require => Exec["mkdir ${apache::mod_dir}"],
    before  => File[$apache::mod_dir],
    notify  => Class['apache::service'],
  }

  file { $modsec_dir:
    ensure  => directory,
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    purge   => true,
    force   => true,
    recurse => true,
    require => Package['httpd'],
  }

  file { "${modsec_dir}/activated_rules":
    ensure  => directory,
    owner   => $apache::params::user,
    group   => $apache::params::group,
    mode    => '0555',
    purge   => true,
    force   => true,
    recurse => true,
    notify  => Class['apache::service'],
  }

  if $custom_rules {
    # Template to add custom rule and included in security configuration
    file { "${modsec_dir}/custom_rules":
      ensure  => directory,
      owner   => $apache::params::user,
      group   => $apache::params::group,
      mode    => $apache::file_mode,
      require => File[$modsec_dir],
    }

    file { "${modsec_dir}/custom_rules/custom_01_rules.conf":
      ensure  => file,
      owner   => $apache::params::user,
      group   => $apache::params::group,
      mode    => $apache::file_mode,
      content => epp('apache/mod/security_custom.conf.epp', { 'custom_rules_set'  => $custom_rules_set, }),
      require => File["${modsec_dir}/custom_rules"],
      notify  => Class['apache::service'],
    }
  }

  if $manage_security_crs and $crs_source == 'package' {
    # Legacy CRS v2/v3 layout: a tuning conf plus per-rule symlinks under
    # activated_rules/. Unchanged behaviour for EL7/8/9 package installs.
    # Template uses:
    # - $_secdefaultaction
    # - $critical_anomaly_score
    # - $error_anomaly_score
    # - $warning_anomaly_score
    # - $notice_anomaly_score
    # - $inbound_anomaly_threshold
    # - $outbound_anomaly_threshold
    # - $paranoia_level
    # - $executing_paranoia_level
    # - $allowed_methods
    # - $content_types
    # - $restricted_extensions
    # - $restricted_headers
    # - $secrequestmaxnumargs
    # - $enable_dos_protection
    # - $dos_burst_time_slice
    # - $dos_counter_threshold
    # - $dos_block_timeout
    $security_crs_parameters = {
      '_secdefaultaction'           => $_secdefaultaction,
      'critical_anomaly_score'      => $critical_anomaly_score,
      'error_anomaly_score'         => $error_anomaly_score,
      'warning_anomaly_score'       => $warning_anomaly_score,
      'notice_anomaly_score'        => $notice_anomaly_score,
      'inbound_anomaly_threshold'   => $inbound_anomaly_threshold,
      'outbound_anomaly_threshold'  => $outbound_anomaly_threshold,
      'secrequestmaxnumargs'        => $secrequestmaxnumargs,
      'allowed_methods'             => $allowed_methods,
      'content_types'               => $content_types,
      'restricted_extensions'       => $restricted_extensions,
      'restricted_headers'          => $restricted_headers,
      'paranoia_level'              => $paranoia_level,
      'executing_paranoia_level'    => $executing_paranoia_level,
      'enable_dos_protection'       => $enable_dos_protection,
      'dos_burst_time_slice'        => $dos_burst_time_slice,
      'dos_counter_threshold'       => $dos_counter_threshold,
      'dos_block_timeout'           => $dos_block_timeout,
    }

    file { "${modsec_dir}/security_crs.conf":
      ensure  => file,
      content => template('apache/mod/security_crs.conf.erb'),
      require => File[$modsec_dir],
      notify  => Class['apache::service'],
    }

    unless $facts['os']['name'] == 'SLES' or $facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Ubuntu' {
      apache::security::rule_link { $activated_rules: }
    }
  }

  if $manage_security_crs and $crs_source in ['archive', 'path'] {
    # CRS v4 layout: load crs-setup.conf then rules/*.conf from the CRS
    # directory. Dropped into $modsec_dir so the existing
    # `IncludeOptional ${modsec_dir}/*.conf` in security.conf picks it up.
    file { "${modsec_dir}/security_crs_v4.conf":
      ensure  => file,
      content => epp('apache/mod/security_crs_v4.conf.epp', { 'crs_dir' => $_crs_dir }),
      require => File[$modsec_dir],
      notify  => Class['apache::service'],
    }
  }
}