<commit_before><IfModule mod_security2.c>
    # ModSecurity Core Rules Set configuration
<%- if scope.function_versioncmp([scope.lookupvar('::apache::apache_version'), '2.4']) >= 0 -%>
    IncludeOptional <%= @modsec_dir %>/*.conf
    IncludeOptional <%= @modsec_dir %>/activated_rules/*.conf
<%- else -%>
    Include <%= @modsec_dir %>/*.conf
    Include <%= @modsec_dir %>/activated_rules/*.conf
<%- end -%>

    # Default recommended configuration
    SecRuleEngine <%= @modsec_secruleengine %>
    SecRequestBodyAccess On
    SecRule REQUEST_HEADERS:Content-Type "text/xml" \
      "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
    SecRequestBodyLimit 13107200
    SecRequestBodyNoFilesLimit 131072
    SecRequestBodyInMemoryLimit 131072
    SecRequestBodyLimitAction Reject
    SecRule REQBODY_ERROR "!@eq 0" \
      "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
    SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
      "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body failed strict validation: \
      PE %{REQBODY_PROCESSOR_ERROR}, \
      BQ %{MULTIPART_BOUNDARY_QUOTED}, \
      BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
      DB %{MULTIPART_DATA_BEFORE}, \
      DA %{MULTIPART_DATA_AFTER}, \
      HF %{MULTIPART_HEADER_FOLDING}, \
      LF %{MULTIPART_LF_LINE}, \
      SM %{MULTIPART_MISSING_SEMICOLON}, \
      IQ %{MULTIPART_INVALID_QUOTING}, \
      IP %{MULTIPART_INVALID_PART}, \
      IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
      FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"

    SecRule &REQUEST_HEADERS:Proxy "@gt 0" "id:1000005,log,deny,msg:'httpoxy denied'"


    SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
      "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"

    SecPcreMatchLimit <%= @secpcrematchlimit %>
    SecPcreMatchLimitRecursion <%= @secpcrematchlimitrecursion %>

    SecRule TX:/^MSC_/ "!@streq 0" \
      "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"

    SecResponseBodyAccess Off
    SecResponseBodyMimeType text/plain text/html text/xml
    SecResponseBodyLimit 524288
    SecResponseBodyLimitAction ProcessPartial
    SecDebugLogLevel 0
    SecAuditEngine RelevantOnly
    SecAuditLogRelevantStatus "<%= @audit_log_relevant_status %>"
    SecAuditLogParts <%= @audit_log_parts %>
    SecAuditLogType Serial
    SecArgumentSeparator &
    SecCookieFormat 0
<%- if scope.lookupvar('::osfamily') == 'Debian' -%>
    SecDebugLog /var/log/apache2/modsec_debug.log
    SecAuditLog /var/log/apache2/modsec_audit.log
    SecTmpDir /var/cache/modsecurity
    SecDataDir /var/cache/modsecurity
    SecUploadDir /var/cache/modsecurity
<% else -%>
    SecDebugLog /var/log/httpd/modsec_debug.log
    SecAuditLog /var/log/httpd/modsec_audit.log
    SecTmpDir /var/lib/mod_security
    SecDataDir /var/lib/mod_security
    SecUploadDir /var/lib/mod_security
<% end -%>
    SecUploadKeepFiles Off
</IfModule><commit_msg>move IncludeOptional to bottom of configuration<commit_after><IfModule mod_security2.c>
    # Default recommended configuration
    SecRuleEngine <%= @modsec_secruleengine %>
    SecRequestBodyAccess On
    SecRule REQUEST_HEADERS:Content-Type "text/xml" \
      "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
    SecRequestBodyLimit 13107200
    SecRequestBodyNoFilesLimit 131072
    SecRequestBodyInMemoryLimit 131072
    SecRequestBodyLimitAction Reject
    SecRule REQBODY_ERROR "!@eq 0" \
      "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
    SecRule MULTIPART_STRICT_ERROR "!@eq 0" \
      "id:'200002',phase:2,t:none,log,deny,status:44,msg:'Multipart request body failed strict validation: \
      PE %{REQBODY_PROCESSOR_ERROR}, \
      BQ %{MULTIPART_BOUNDARY_QUOTED}, \
      BW %{MULTIPART_BOUNDARY_WHITESPACE}, \
      DB %{MULTIPART_DATA_BEFORE}, \
      DA %{MULTIPART_DATA_AFTER}, \
      HF %{MULTIPART_HEADER_FOLDING}, \
      LF %{MULTIPART_LF_LINE}, \
      SM %{MULTIPART_MISSING_SEMICOLON}, \
      IQ %{MULTIPART_INVALID_QUOTING}, \
      IP %{MULTIPART_INVALID_PART}, \
      IH %{MULTIPART_INVALID_HEADER_FOLDING}, \
      FL %{MULTIPART_FILE_LIMIT_EXCEEDED}'"

    SecRule &REQUEST_HEADERS:Proxy "@gt 0" "id:1000005,log,deny,msg:'httpoxy denied'"


    SecRule MULTIPART_UNMATCHED_BOUNDARY "!@eq 0" \
      "id:'200003',phase:2,t:none,log,deny,status:44,msg:'Multipart parser detected a possible unmatched boundary.'"

    SecPcreMatchLimit <%= @secpcrematchlimit %>
    SecPcreMatchLimitRecursion <%= @secpcrematchlimitrecursion %>

    SecRule TX:/^MSC_/ "!@streq 0" \
      "id:'200004',phase:2,t:none,deny,msg:'ModSecurity internal error flagged: %{MATCHED_VAR_NAME}'"

    SecResponseBodyAccess Off
    SecResponseBodyMimeType text/plain text/html text/xml
    SecResponseBodyLimit 524288
    SecResponseBodyLimitAction ProcessPartial
    SecDebugLogLevel 0
    SecAuditEngine RelevantOnly
    SecAuditLogRelevantStatus "<%= @audit_log_relevant_status %>"
    SecAuditLogParts <%= @audit_log_parts %>
    SecAuditLogType Serial
    SecArgumentSeparator &
    SecCookieFormat 0
<%- if scope.lookupvar('::osfamily') == 'Debian' -%>
    SecDebugLog /var/log/apache2/modsec_debug.log
    SecAuditLog /var/log/apache2/modsec_audit.log
    SecTmpDir /var/cache/modsecurity
    SecDataDir /var/cache/modsecurity
    SecUploadDir /var/cache/modsecurity
<% else -%>
    SecDebugLog /var/log/httpd/modsec_debug.log
    SecAuditLog /var/log/httpd/modsec_audit.log
    SecTmpDir /var/lib/mod_security
    SecDataDir /var/lib/mod_security
    SecUploadDir /var/lib/mod_security
<% end -%>
    SecUploadKeepFiles Off

    # ModSecurity Core Rules Set configuration
<%- if scope.function_versioncmp([scope.lookupvar('::apache::apache_version'), '2.4']) >= 0 -%>
    IncludeOptional <%= @modsec_dir %>/*.conf
    IncludeOptional <%= @modsec_dir %>/activated_rules/*.conf
<%- else -%>
    Include <%= @modsec_dir %>/*.conf
    Include <%= @modsec_dir %>/activated_rules/*.conf
<%- end -%>
</IfModule>
{'fraction_non_alphanumeric': 0.12463861227112111, 'fraction_numerical': 0.028589784773530358, 'mean_word_length': 4.313139931740614, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7297405', 'n_tokens_mistral': 2421, 'n_tokens_neox': 2145, 'n_words': 342}