Saltstack Official Apache Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 line
3.7KB

  1. {%- set apache = pillar.get('apache', {}) %}
  2. {%- set modsec = apache.get('mod_security', {}) %}
  3. {%- set sec_rule_engine = modsec.get('sec_rule_engine', 'DetectionOnly' ) -%}
  4. {%- set sec_request_body_access = modsec.get('sec_request_body_access', 'On' ) -%}
  5. {%- set sec_request_body_limit = modsec.get('sec_request_body_limit', 13107200 ) -%}
  6. {%- set sec_request_body_no_files_limit = modsec.get('sec_request_body_no_files_limit', 131072 ) -%}
  7. {%- set sec_request_body_in_memory_limit = modsec.get('sec_request_body_in_memory_limit', 131072 ) -%}
  8. {%- set sec_request_body_limit_action = modsec.get('sec_request_body_limit_action', 'Reject' ) -%}
  9. {%- set sec_pcre_match_limit = modsec.get('sec_pcre_match_limit', 1000 ) -%}
  10. {%- set sec_pcre_match_limit_recursion = modsec.get('sec_pcre_match_limit_recursion', 1000 ) -%}
  11. {%- set sec_debug_log_level = modsec.get('sec_debug_log_level', 0 ) -%}
  12. #
  13. # This file is managed by Salt! Do not edit by hand!
  14. # Modify the salt pillar that generates this file instead
  15. #
  16. LoadModule security2_module modules/mod_security2.so
  17. <IfModule !mod_unique_id.c>
  18. LoadModule unique_id_module modules/mod_unique_id.so
  19. </IfModule>
  20. <IfModule mod_security2.c>
  21. # ModSecurity Core Rules Set configuration
  22. {%- if 'osfinger' in grains and grains.osfinger in ('Red Hat Enterprise Linux Server-6', 'CentOS-6') %}
  23. Include modsecurity.d/*.conf
  24. Include modsecurity.d/activated_rules/*.conf
  25. {%- else %}
  26. IncludeOptional modsecurity.d/*.conf
  27. IncludeOptional modsecurity.d/activated_rules/*.conf
  28. {%- endif %}
  29. # Default recommended configuration
  30. SecRuleEngine {{ sec_rule_engine }}
  31. SecRequestBodyAccess {{ sec_request_body_access }}
  32. SecRule REQUEST_HEADERS:Content-Type "text/xml" \
  33. "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
  34. SecRequestBodyLimit {{ sec_request_body_limit }}
  35. SecRequestBodyNoFilesLimit {{ sec_request_body_no_files_limit }}
  36. SecRequestBodyInMemoryLimit {{ sec_request_body_in_memory_limit }}
  37. SecRequestBodyLimitAction {{ sec_request_body_limit_action }}
  38. SecRule REQBODY_ERROR "!@eq 0" \
  39. "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
  40. SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
  41. "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body \
  42. failed strict validation: \
  43. PE %{REQBODY_PROCESSOR_ERROR}, \
  44. BQ %{MULTIPART_BOUNDARY_QUOTED}, \
  45. BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
  46. DB %{MULTIPART_DATA_BEFORE}, \
  47. DA %{MULTIPART_DATA_AFTER}, \
  48. HF %{MULTIPART_HEADER_FOLDING}, \
  49. LF %{MULTIPART_LF_LINE}, \
  50. SM %{MULTIPART_MISSING_SEMICOLON}, \
  51. IQ %{MULTIPART_INVALID_QUOTING}, \
  52. IP %{MULTIPART_INVALID_PART}, \
  53. IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
  54. FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"
  55. SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
  56. "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"
  57. SecPcreMatchLimit {{ sec_pcre_match_limit }}
  58. SecPcreMatchLimitRecursion {{ sec_pcre_match_limit_recursion }}
  59. SecRule TX:/^MSC_/ "!@streq 0" \
  60. "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"
  61. SecResponseBodyAccess Off
  62. SecDebugLog /var/log/httpd/modsec_debug.log
  63. SecDebugLogLevel {{ sec_debug_log_level }}
  64. SecAuditEngine RelevantOnly
  65. SecAuditLogRelevantStatus "^(?:5|4(?!04))"
  66. SecAuditLogParts ABIJDEFHZ
  67. SecAuditLogType Serial
  68. SecAuditLog /var/log/httpd/modsec_audit.log
  69. SecArgumentSeparator &
  70. SecCookieFormat 0
  71. SecTmpDir /var/lib/mod_security
  72. SecDataDir /var/lib/mod_security
  73. </IfModule>