├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report-for-version-2-x.md │ └── bug-report-for-version-3-x.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── ci.yml ├── .gitignore ├── .gitmodules ├── AUTHORS ├── CHANGES ├── LICENSE ├── Makefile.am ├── README.md ├── SECURITY.md ├── build.sh ├── build ├── .empty ├── ax_cxx_compile_stdcxx.m4 ├── ax_prog_doxygen.m4 ├── ax_valgrind_check.m4 ├── curl.m4 ├── libgeoip.m4 ├── libmaxmind.m4 ├── libxml.m4 ├── lmdb.m4 ├── lua.m4 ├── pcre.m4 ├── pcre2.m4 ├── release.sh ├── ssdeep.m4 ├── win32 │ ├── CMakeLists.txt │ ├── ConfigureChecks.cmake │ ├── README.md │ ├── conanfile.txt │ ├── config.h.cmake │ └── docker │ │ ├── Dockerfile │ │ ├── InstallBuildTools.cmd │ │ └── git.inf └── yajl.m4 ├── configure.ac ├── doc ├── .empty ├── Makefile.am ├── doxygen.cfg └── ms-doxygen-logo.png ├── examples ├── Makefile.am ├── multiprocess_c │ ├── Makefile.am │ ├── basic_rules.conf │ └── multi.c ├── multithread │ ├── Makefile.am │ ├── basic_rules.conf │ └── multithread.cc ├── reading_logs_via_rule_message │ ├── Makefile.am │ ├── blocked_request.conf │ ├── blocked_request_engine_on.conf │ ├── match.conf │ ├── no_match.conf │ ├── reading_logs_via_rule_message.h │ └── simple_request.cc ├── reading_logs_with_offset │ ├── Makefile.am │ └── read.cc ├── simple_example_using_c │ ├── Makefile.am │ ├── basic_rules.conf │ ├── test-valgrind.sh │ └── test.c └── using_bodies_in_chunks │ ├── Makefile.am │ ├── example.conf │ └── simple_request.cc ├── headers └── modsecurity │ ├── actions │ └── action.h │ ├── anchored_set_variable.h │ ├── anchored_set_variable_translation_proxy.h │ ├── anchored_variable.h │ ├── audit_log.h │ ├── collection │ ├── collection.h │ └── collections.h │ ├── debug_log.h │ ├── intervention.h │ ├── modsecurity.h │ ├── rule.h │ ├── rule_marker.h │ ├── rule_message.h │ ├── rule_unconditional.h │ ├── rule_with_actions.h │ ├── rule_with_operator.h │ ├── rules.h │ ├── rules_exceptions.h │ ├── rules_properties.h │ ├── rules_set.h │ ├── rules_set_phases.h │ ├── rules_set_properties.h │ ├── transaction.h │ ├── variable_origin.h │ └── variable_value.h ├── modsecurity.conf-recommended ├── modsecurity.pc.in ├── others ├── Makefile.am ├── modsec.png └── modsec_white_bg.png ├── src ├── Makefile.am ├── actions │ ├── accuracy.cc │ ├── accuracy.h │ ├── action.cc │ ├── audit_log.cc │ ├── audit_log.h │ ├── block.cc │ ├── block.h │ ├── capture.cc │ ├── capture.h │ ├── chain.cc │ ├── chain.h │ ├── ctl │ │ ├── audit_engine.cc │ │ ├── audit_engine.h │ │ ├── audit_log_parts.cc │ │ ├── audit_log_parts.h │ │ ├── parse_xml_into_args.cc │ │ ├── parse_xml_into_args.h │ │ ├── request_body_access.cc │ │ ├── request_body_access.h │ │ ├── request_body_processor_json.cc │ │ ├── request_body_processor_json.h │ │ ├── request_body_processor_urlencoded.cc │ │ ├── request_body_processor_urlencoded.h │ │ ├── request_body_processor_xml.cc │ │ ├── request_body_processor_xml.h │ │ ├── rule_engine.cc │ │ ├── rule_engine.h │ │ ├── rule_remove_by_id.cc │ │ ├── rule_remove_by_id.h │ │ ├── rule_remove_by_tag.cc │ │ ├── rule_remove_by_tag.h │ │ ├── rule_remove_target_by_id.cc │ │ ├── rule_remove_target_by_id.h │ │ ├── rule_remove_target_by_tag.cc │ │ └── rule_remove_target_by_tag.h │ ├── data │ │ ├── status.cc │ │ └── status.h │ ├── disruptive │ │ ├── allow.cc │ │ ├── allow.h │ │ ├── deny.cc │ │ ├── deny.h │ │ ├── drop.cc │ │ ├── drop.h │ │ ├── pass.cc │ │ ├── pass.h │ │ ├── redirect.cc │ │ └── redirect.h │ ├── exec.cc │ ├── exec.h │ ├── expire_var.cc │ ├── expire_var.h │ ├── init_col.cc │ ├── init_col.h │ ├── log.cc │ ├── log.h │ ├── log_data.cc │ ├── log_data.h │ ├── maturity.cc │ ├── maturity.h │ ├── msg.cc │ ├── msg.h │ ├── multi_match.cc │ ├── multi_match.h │ ├── no_audit_log.cc │ ├── no_audit_log.h │ ├── no_log.cc │ ├── no_log.h │ ├── phase.cc │ ├── phase.h │ ├── rev.cc │ ├── rev.h │ ├── rule_id.cc │ ├── rule_id.h │ ├── set_env.cc │ ├── set_env.h │ ├── set_rsc.cc │ ├── set_rsc.h │ ├── set_sid.cc │ ├── set_sid.h │ ├── set_uid.cc │ ├── set_uid.h │ ├── set_var.cc │ ├── set_var.h │ ├── severity.cc │ ├── severity.h │ ├── skip.cc │ ├── skip.h │ ├── skip_after.cc │ ├── skip_after.h │ ├── tag.cc │ ├── tag.h │ ├── transformations │ │ ├── base64_decode.cc │ │ ├── base64_decode.h │ │ ├── base64_decode_ext.cc │ │ ├── base64_decode_ext.h │ │ ├── base64_encode.cc │ │ ├── base64_encode.h │ │ ├── cmd_line.cc │ │ ├── cmd_line.h │ │ ├── compress_whitespace.cc │ │ ├── compress_whitespace.h │ │ ├── css_decode.cc │ │ ├── css_decode.h │ │ ├── escape_seq_decode.cc │ │ ├── escape_seq_decode.h │ │ ├── hex_decode.cc │ │ ├── hex_decode.h │ │ ├── hex_encode.cc │ │ ├── hex_encode.h │ │ ├── html_entity_decode.cc │ │ ├── html_entity_decode.h │ │ ├── js_decode.cc │ │ ├── js_decode.h │ │ ├── length.cc │ │ ├── length.h │ │ ├── lower_case.cc │ │ ├── lower_case.h │ │ ├── md5.cc │ │ ├── md5.h │ │ ├── none.cc │ │ ├── none.h │ │ ├── normalise_path.cc │ │ ├── normalise_path.h │ │ ├── normalise_path_win.cc │ │ ├── normalise_path_win.h │ │ ├── parity_even_7bit.cc │ │ ├── parity_even_7bit.h │ │ ├── parity_odd_7bit.cc │ │ ├── parity_odd_7bit.h │ │ ├── parity_zero_7bit.cc │ │ ├── parity_zero_7bit.h │ │ ├── remove_comments.cc │ │ ├── remove_comments.h │ │ ├── remove_comments_char.cc │ │ ├── remove_comments_char.h │ │ ├── remove_nulls.cc │ │ ├── remove_nulls.h │ │ ├── remove_whitespace.cc │ │ ├── remove_whitespace.h │ │ ├── replace_comments.cc │ │ ├── replace_comments.h │ │ ├── replace_nulls.cc │ │ ├── replace_nulls.h │ │ ├── sha1.cc │ │ ├── sha1.h │ │ ├── sql_hex_decode.cc │ │ ├── sql_hex_decode.h │ │ ├── transformation.cc │ │ ├── transformation.h │ │ ├── trim.cc │ │ ├── trim.h │ │ ├── trim_left.cc │ │ ├── trim_left.h │ │ ├── trim_right.cc │ │ ├── trim_right.h │ │ ├── upper_case.cc │ │ ├── upper_case.h │ │ ├── url_decode.cc │ │ ├── url_decode.h │ │ ├── url_decode_uni.cc │ │ ├── url_decode_uni.h │ │ ├── url_encode.cc │ │ ├── url_encode.h │ │ ├── utf8_to_unicode.cc │ │ └── utf8_to_unicode.h │ ├── ver.cc │ ├── ver.h │ ├── xmlns.cc │ └── xmlns.h ├── anchored_set_variable.cc ├── anchored_variable.cc ├── audit_log │ ├── audit_log.cc │ └── writer │ │ ├── https.cc │ │ ├── https.h │ │ ├── parallel.cc │ │ ├── parallel.h │ │ ├── serial.cc │ │ ├── serial.h │ │ ├── writer.cc │ │ └── writer.h ├── collection │ ├── backend │ │ ├── collection_data.cc │ │ ├── collection_data.h │ │ ├── in_memory-per_process.cc │ │ ├── in_memory-per_process.h │ │ ├── lmdb.cc │ │ └── lmdb.h │ └── collections.cc ├── compat │ └── msvc.h ├── debug_log │ ├── debug_log.cc │ ├── debug_log_writer.cc │ └── debug_log_writer.h ├── debug_log_writer_agent.h ├── engine │ ├── lua.cc │ └── lua.h ├── modsecurity.cc ├── operators │ ├── .directory │ ├── begins_with.cc │ ├── begins_with.h │ ├── contains.cc │ ├── contains.h │ ├── contains_word.cc │ ├── contains_word.h │ ├── detect_sqli.cc │ ├── detect_sqli.h │ ├── detect_xss.cc │ ├── detect_xss.h │ ├── ends_with.cc │ ├── ends_with.h │ ├── eq.cc │ ├── eq.h │ ├── fuzzy_hash.cc │ ├── fuzzy_hash.h │ ├── ge.cc │ ├── ge.h │ ├── geo_lookup.cc │ ├── geo_lookup.h │ ├── gsblookup.cc │ ├── gsblookup.h │ ├── gt.cc │ ├── gt.h │ ├── inspect_file.cc │ ├── inspect_file.h │ ├── ip_match.cc │ ├── ip_match.h │ ├── ip_match_f.cc │ ├── ip_match_f.h │ ├── ip_match_from_file.cc │ ├── ip_match_from_file.h │ ├── le.cc │ ├── le.h │ ├── lt.cc │ ├── lt.h │ ├── no_match.cc │ ├── no_match.h │ ├── operator.cc │ ├── operator.h │ ├── pm.cc │ ├── pm.h │ ├── pm_f.h │ ├── pm_from_file.cc │ ├── pm_from_file.h │ ├── rbl.cc │ ├── rbl.h │ ├── rsub.cc │ ├── rsub.h │ ├── rx.cc │ ├── rx.h │ ├── rx_global.cc │ ├── rx_global.h │ ├── str_eq.cc │ ├── str_eq.h │ ├── str_match.cc │ ├── str_match.h │ ├── unconditional_match.cc │ ├── unconditional_match.h │ ├── validate_byte_range.cc │ ├── validate_byte_range.h │ ├── validate_dtd.cc │ ├── validate_dtd.h │ ├── validate_hash.cc │ ├── validate_hash.h │ ├── validate_schema.cc │ ├── validate_schema.h │ ├── validate_url_encoding.cc │ ├── validate_url_encoding.h │ ├── validate_utf8_encoding.cc │ ├── validate_utf8_encoding.h │ ├── verify_cc.cc │ ├── verify_cc.h │ ├── verify_cpf.cc │ ├── verify_cpf.h │ ├── verify_ssn.cc │ ├── verify_ssn.h │ ├── verify_svnr.cc │ ├── verify_svnr.h │ ├── within.cc │ └── within.h ├── parser │ ├── Makefile.am │ ├── driver.cc │ ├── driver.h │ ├── location.hh │ ├── position.hh │ ├── seclang-parser.cc │ ├── seclang-parser.hh │ ├── seclang-parser.yy │ ├── seclang-scanner.cc │ ├── seclang-scanner.ll │ └── stack.hh ├── request_body_processor │ ├── json.cc │ ├── json.h │ ├── multipart.cc │ ├── multipart.h │ ├── xml.cc │ └── xml.h ├── rule.cc ├── rule_message.cc ├── rule_script.cc ├── rule_script.h ├── rule_unconditional.cc ├── rule_with_actions.cc ├── rule_with_operator.cc ├── rules_exceptions.cc ├── rules_set.cc ├── rules_set_phases.cc ├── rules_set_properties.cc ├── run_time_string.cc ├── run_time_string.h ├── transaction.cc ├── unique_id.cc ├── unique_id.h ├── utils │ ├── acmp.cc │ ├── acmp.h │ ├── base64.cc │ ├── base64.h │ ├── decode.cc │ ├── decode.h │ ├── geo_lookup.cc │ ├── geo_lookup.h │ ├── https_client.cc │ ├── https_client.h │ ├── ip_tree.cc │ ├── ip_tree.h │ ├── md5.h │ ├── msc_tree.cc │ ├── msc_tree.h │ ├── phase.h │ ├── random.cc │ ├── random.h │ ├── regex.cc │ ├── regex.h │ ├── sha1.h │ ├── shared_files.cc │ ├── shared_files.h │ ├── string.h │ ├── system.cc │ └── system.h └── variables │ ├── args.h │ ├── args_combined_size.h │ ├── args_get.h │ ├── args_get_names.h │ ├── args_names.h │ ├── args_post.h │ ├── args_post_names.h │ ├── auth_type.h │ ├── duration.cc │ ├── duration.h │ ├── env.cc │ ├── env.h │ ├── files.h │ ├── files_combined_size.h │ ├── files_names.h │ ├── files_sizes.h │ ├── files_tmp_content.h │ ├── files_tmp_names.h │ ├── full_request.h │ ├── full_request_length.h │ ├── geo.h │ ├── global.h │ ├── highest_severity.cc │ ├── highest_severity.h │ ├── inbound_data_error.h │ ├── ip.h │ ├── matched_var.h │ ├── matched_var_name.h │ ├── matched_vars.h │ ├── matched_vars_names.h │ ├── modsec_build.cc │ ├── modsec_build.h │ ├── msc_pcre_error.h │ ├── msc_pcre_limits_exceeded.h │ ├── multipart_boundary_quoted.h │ ├── multipart_boundary_whitespace.h │ ├── multipart_crlf_lf_lines.h │ ├── multipart_data_after.h │ ├── multipart_data_before.h │ ├── multipart_file_limit_exceeded.h │ ├── multipart_file_name.h │ ├── multipart_header_folding.h │ ├── multipart_invalid_header_folding.h │ ├── multipart_invalid_part.h │ ├── multipart_invalid_quoting.h │ ├── multipart_lf_line.h │ ├── multipart_missing_semicolon.h │ ├── multipart_name.h │ ├── multipart_part_headers.h │ ├── multipart_strict_error.h │ ├── multipart_unmatched_boundary.h │ ├── outbound_data_error.h │ ├── path_info.h │ ├── query_string.h │ ├── remote_addr.h │ ├── remote_host.h │ ├── remote_port.h │ ├── remote_user.cc │ ├── remote_user.h │ ├── reqbody_error.h │ ├── reqbody_error_msg.h │ ├── reqbody_processor.h │ ├── reqbody_processor_error.h │ ├── reqbody_processor_error_msg.h │ ├── request_base_name.h │ ├── request_body.h │ ├── request_body_length.h │ ├── request_cookies.h │ ├── request_cookies_names.h │ ├── request_file_name.h │ ├── request_headers.h │ ├── request_headers_names.h │ ├── request_line.h │ ├── request_method.h │ ├── request_protocol.h │ ├── request_uri.h │ ├── request_uri_raw.h │ ├── resource.h │ ├── response_body.h │ ├── response_content_length.h │ ├── response_content_type.h │ ├── response_headers.h │ ├── response_headers_names.h │ ├── response_protocol.h │ ├── response_status.h │ ├── rule.cc │ ├── rule.h │ ├── server_addr.h │ ├── server_name.h │ ├── server_port.h │ ├── session.h │ ├── session_id.h │ ├── status.h │ ├── time.cc │ ├── time.h │ ├── time_day.cc │ ├── time_day.h │ ├── time_epoch.cc │ ├── time_epoch.h │ ├── time_hour.cc │ ├── time_hour.h │ ├── time_min.cc │ ├── time_min.h │ ├── time_mon.cc │ ├── time_mon.h │ ├── time_sec.cc │ ├── time_sec.h │ ├── time_wday.cc │ ├── time_wday.h │ ├── time_year.cc │ ├── time_year.h │ ├── tx.cc │ ├── tx.h │ ├── unique_id.h │ ├── url_encoded_error.h │ ├── user.h │ ├── user_id.h │ ├── variable.cc │ ├── variable.h │ ├── web_app_id.h │ ├── xml.cc │ └── xml.h ├── test ├── .empty ├── Makefile.am ├── benchmark │ ├── Makefile.am │ ├── basic_rules.conf │ ├── benchmark.cc │ ├── download-owasp-v3-rules.sh │ └── download-owasp-v4-rules.sh ├── coding_style_suppressions.txt ├── common │ ├── colors.h │ ├── custom_debug_log.cc │ ├── custom_debug_log.h │ ├── modsecurity_test.cc │ ├── modsecurity_test.h │ ├── modsecurity_test_context.h │ └── modsecurity_test_results.h ├── cppcheck_suppressions.txt ├── custom-test-driver ├── fuzzer │ ├── Makefile.am │ └── afl_fuzzer.cc ├── modsecurity-regression-ip-list.txt ├── modsecurity-regression-rules.txt ├── optimization │ └── optimization.cc ├── regression-tests-valgrind.sh ├── regression │ ├── regression.cc │ ├── regression_test.cc │ └── regression_test.h ├── test-cases │ ├── data │ │ ├── GeoIP2-City-Test-source.json │ │ ├── GeoIP2-City-Test.mmdb │ │ ├── SoapEnvelope-bad.dtd │ │ ├── SoapEnvelope-bad.xsd │ │ ├── SoapEnvelope.dtd │ │ ├── SoapEnvelope.xsd │ │ ├── SoapEnvelope2.xsd │ │ ├── big-file.conf │ │ ├── config_example-bad-op-include.txt │ │ ├── config_example-ops-include.txt │ │ ├── config_example.txt │ │ ├── config_example2.txt │ │ ├── config_example3.txt │ │ ├── geo │ │ │ ├── GeoIPCity.dat │ │ │ └── README.txt │ │ ├── inspectFile-abcdef.lua │ │ ├── ipMatchFromFile.txt │ │ ├── match-getvar-multi-transformations.lua │ │ ├── match-getvar-transformation.lua │ │ ├── match-getvar-withTnfs.lua │ │ ├── match-getvar.lua │ │ ├── match-getvars-args.lua │ │ ├── match-getvars.lua │ │ ├── match-log.lua │ │ ├── match-set.lua │ │ ├── match.lua │ │ ├── not-so-big-file.conf │ │ ├── script.lua │ │ ├── setvar.lua │ │ ├── ssdeep.txt │ │ ├── test.lua │ │ └── unicode.mapping-reduced │ └── regression │ │ ├── action-allow.json │ │ ├── action-block.json │ │ ├── action-ctl_audit_engine.json │ │ ├── action-ctl_request_body_access.json │ │ ├── action-ctl_request_body_processor.json │ │ ├── action-ctl_request_body_processor_urlencoded.json │ │ ├── action-ctl_rule_engine.json │ │ ├── action-ctl_rule_remove_by_id.json │ │ ├── action-ctl_rule_remove_by_tag.json │ │ ├── action-ctl_rule_remove_target_by_id.json │ │ ├── action-ctl_rule_remove_target_by_tag.json │ │ ├── action-disruptive.json │ │ ├── action-exec.json │ │ ├── action-expirevar.json │ │ ├── action-id.json │ │ ├── action-initcol.json │ │ ├── action-msg.json │ │ ├── action-setenv.json │ │ ├── action-setrsc.json │ │ ├── action-setsid.json │ │ ├── action-setuid.json │ │ ├── action-skip.json │ │ ├── action-tag.json │ │ ├── action-tnf-base64.json │ │ ├── action-xmlns.json │ │ ├── actions.json │ │ ├── auditlog.json │ │ ├── collection-case-insensitive.json │ │ ├── collection-lua.json │ │ ├── collection-regular_expression_selection.json │ │ ├── collection-resource.json │ │ ├── collection-tx-with-macro.json │ │ ├── collection-tx.json │ │ ├── config-body_limits.json │ │ ├── config-calling_phases_by_name.json │ │ ├── config-include-bad.json │ │ ├── config-include.json │ │ ├── config-remove_by_id.json │ │ ├── config-remove_by_msg.json │ │ ├── config-remove_by_tag.json │ │ ├── config-response_type.json │ │ ├── config-secdefaultaction.json │ │ ├── config-secremoterules.json │ │ ├── config-update-action-by-id.json │ │ ├── config-update-target-by-id.json │ │ ├── config-update-target-by-msg.json │ │ ├── config-update-target-by-tag.json │ │ ├── config-xml_external_entity.json │ │ ├── debug_log.json │ │ ├── directive-sec_rule_script.json │ │ ├── fn-setHostname.json │ │ ├── issue-1152.json │ │ ├── issue-1528.json │ │ ├── issue-1565.json │ │ ├── issue-1576.json │ │ ├── issue-1591.json │ │ ├── issue-1725.json │ │ ├── issue-1743.json │ │ ├── issue-1785.json │ │ ├── issue-1812.json │ │ ├── issue-1825.json │ │ ├── issue-1831.json │ │ ├── issue-1844.json │ │ ├── issue-1850.json │ │ ├── issue-1941.json │ │ ├── issue-1943.json │ │ ├── issue-1956.json │ │ ├── issue-1960.json │ │ ├── issue-2000.json │ │ ├── issue-2099.json │ │ ├── issue-2111.json │ │ ├── issue-2196.json │ │ ├── issue-2296.json │ │ ├── issue-2423-msg-in-chain.json │ │ ├── issue-2427.json │ │ ├── issue-3340.json │ │ ├── issue-394.json │ │ ├── issue-849.json │ │ ├── issue-960.json │ │ ├── misc-variable-under-quotes.json │ │ ├── misc.json │ │ ├── offset-variable.json │ │ ├── operator-UnconditionalMatch.json │ │ ├── operator-detectsqli.json │ │ ├── operator-detectxss.json │ │ ├── operator-fuzzyhash.json │ │ ├── operator-inpectFile.json │ │ ├── operator-ipMatchFromFile.json │ │ ├── operator-pm.json │ │ ├── operator-rx.json │ │ ├── operator-rxGlobal.json │ │ ├── operator-validate-byte-range.json │ │ ├── operator-verifycc.json │ │ ├── operator-verifycpf.json │ │ ├── operator-verifyssn.json │ │ ├── operator-verifysvnr.json │ │ ├── request-body-parser-json.json │ │ ├── request-body-parser-multipart-crlf.json │ │ ├── request-body-parser-multipart.json │ │ ├── request-body-parser-xml-validade-dtd.json │ │ ├── request-body-parser-xml.json │ │ ├── rule-920120.json │ │ ├── rule-920200.json │ │ ├── rule-920274.json │ │ ├── sec_component_signature.json │ │ ├── secaction.json │ │ ├── secargumentslimit.json │ │ ├── secmarker.json │ │ ├── secruleengine.json │ │ ├── transformation-none.json │ │ ├── transformations.json │ │ ├── variable-ARGS.json │ │ ├── variable-ARGS_COMBINED_SIZE.json │ │ ├── variable-ARGS_GET.json │ │ ├── variable-ARGS_GET_NAMES.json │ │ ├── variable-ARGS_NAMES.json │ │ ├── variable-ARGS_POST.json │ │ ├── variable-ARGS_POST_NAMES.json │ │ ├── variable-AUTH_TYPE.json │ │ ├── variable-DURATION.json │ │ ├── variable-ENV.json │ │ ├── variable-FILES.json │ │ ├── variable-FILES_COMBINED_SIZE.json │ │ ├── variable-FILES_NAMES.json │ │ ├── variable-FILES_SIZES.json │ │ ├── variable-FULL_REQUEST.json │ │ ├── variable-FULL_REQUEST_LENGTH.json │ │ ├── variable-GEO.json │ │ ├── variable-HIGHEST_SEVERITY.json │ │ ├── variable-INBOUND_DATA_ERROR.json │ │ ├── variable-MATCHED_VAR.json │ │ ├── variable-MATCHED_VARS.json │ │ ├── variable-MATCHED_VARS_NAMES.json │ │ ├── variable-MATCHED_VAR_NAME.json │ │ ├── variable-MODSEC_BUILD.json │ │ ├── variable-MULTIPART_CRLF_LF_LINES.json │ │ ├── variable-MULTIPART_FILENAME.json │ │ ├── variable-MULTIPART_INVALID_HEADER_FOLDING.json │ │ ├── variable-MULTIPART_NAME.json │ │ ├── variable-MULTIPART_PART_HEADERS.json │ │ ├── variable-MULTIPART_STRICT_ERROR.json │ │ ├── variable-MULTIPART_UNMATCHED_BOUNDARY.json │ │ ├── variable-OUTBOUND_DATA_ERROR.json │ │ ├── variable-PATH_INFO.json │ │ ├── variable-QUERY_STRING.json │ │ ├── variable-REMOTE_ADDR.json │ │ ├── variable-REMOTE_HOST.json │ │ ├── variable-REMOTE_PORT.json │ │ ├── variable-REMOTE_USER.json │ │ ├── variable-REQBODY_PROCESSOR.json │ │ ├── variable-REQBODY_PROCESSOR_ERROR.json │ │ ├── variable-REQUEST_BASENAME.json │ │ ├── variable-REQUEST_BODY.json │ │ ├── variable-REQUEST_BODY_LENGTH.json │ │ ├── variable-REQUEST_COOKIES.json │ │ ├── variable-REQUEST_COOKIES_NAMES.json │ │ ├── variable-REQUEST_FILENAME.json │ │ ├── variable-REQUEST_HEADERS.json │ │ ├── variable-REQUEST_HEADERS_NAMES.json │ │ ├── variable-REQUEST_LINE.json │ │ ├── variable-REQUEST_METHOD.json │ │ ├── variable-REQUEST_PROTOCOL.json │ │ ├── variable-REQUEST_URI.json │ │ ├── variable-REQUEST_URI_RAW.json │ │ ├── variable-RESPONSE_BODY.json │ │ ├── variable-RESPONSE_CONTENT_LENGTH.json │ │ ├── variable-RESPONSE_CONTENT_TYPE.json │ │ ├── variable-RESPONSE_HEADERS.json │ │ ├── variable-RESPONSE_HEADERS_NAMES.json │ │ ├── variable-RESPONSE_PROTOCOL.json │ │ ├── variable-RULE.json │ │ ├── variable-SERVER_ADDR.json │ │ ├── variable-SERVER_NAME.json │ │ ├── variable-SERVER_PORT.json │ │ ├── variable-SESSIONID.json │ │ ├── variable-STATUS.json │ │ ├── variable-TIME.json │ │ ├── variable-TIME_DAY.json │ │ ├── variable-TIME_EPOCH.json │ │ ├── variable-TIME_HOUR.json │ │ ├── variable-TIME_MIN.json │ │ ├── variable-TIME_MON.json │ │ ├── variable-TIME_SEC.json │ │ ├── variable-TIME_WDAY.json │ │ ├── variable-TIME_YEAR.json │ │ ├── variable-TX.json │ │ ├── variable-UNIQUE_ID.json │ │ ├── variable-URLENCODED_ERROR.json │ │ ├── variable-USERID.json │ │ ├── variable-WEBAPPID.json │ │ ├── variable-WEBSERVER_ERROR_LOG.json │ │ ├── variable-XML.json │ │ ├── variable-variation-count.json │ │ └── variable-variation-exclusion.json ├── test-suite.in ├── test-suite.sh ├── unit-tests-valgrind.sh ├── unit │ ├── unit.cc │ ├── unit_test.cc │ └── unit_test.h └── valgrind_suppressions.txt ├── tools ├── Makefile.am └── rules-check │ ├── Makefile.am │ └── rules-check.cc ├── unicode.mapping └── vcbuild.bat /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | # Unix-style newlines with a newline ending every file 5 | [*] 6 | end_of_line = lf 7 | indent_style = space 8 | # Scripts without suffixes in the project root tend to indent by two spaces 9 | indent_size = 2 10 | 11 | # Most of the project files indent by four spaces 12 | [*/**] 13 | indent_size = 4 14 | 15 | # Test files indent by two spaces 16 | [test/**] 17 | indent_size = 2 18 | 19 | # The config parser file indents by both two and four spaces, 20 | # so we choose to indent by two spaces as a common denominator. 21 | [*.yy] 22 | indent_size = 2 23 | 24 | [{Makefile,Makefile.am}] 25 | indent_style = tab 26 | 27 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ## what 5 | 6 | 10 | 11 | ## why 12 | 13 | 18 | 19 | ## references 20 | 21 | 25 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "test/test-cases/secrules-language-tests"] 2 | path = test/test-cases/secrules-language-tests 3 | url = https://github.com/owasp-modsecurity/secrules-language-tests 4 | [submodule "others/libinjection"] 5 | path = others/libinjection 6 | url = https://github.com/libinjection/libinjection.git 7 | [submodule "bindings/python"] 8 | path = bindings/python 9 | url = https://github.com/owasp-modsecurity/ModSecurity-Python-bindings.git 10 | [submodule "others/mbedtls"] 11 | path = others/mbedtls 12 | url = https://github.com/Mbed-TLS/mbedtls.git 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | zimmerle = Felipe Zimmerle 2 | rbarnett = Ryan C. Barnett 3 | csanders-git = Chaim Sanders 4 | victorhora = Victor Hora 5 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | The latest versions of both v2.9.x and v3.0.x are supported. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | For information on how to report a security issue, please see https://github.com/owasp-modsecurity/ModSecurity#security-issue 10 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | rm -rf autom4te.cache 4 | rm -f aclocal.m4 5 | case `uname` in Darwin*) glibtoolize --force --copy ;; 6 | *) libtoolize --force --copy ;; esac 7 | autoreconf --install 8 | autoheader 9 | automake --add-missing --foreign --copy --force-missing 10 | autoconf --force 11 | rm -rf autom4te.cache 12 | 13 | 14 | -------------------------------------------------------------------------------- /build/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/build/.empty -------------------------------------------------------------------------------- /build/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clean -xfdi 4 | git submodule foreach --recursive git clean -xfdi 5 | 6 | VERSION=`git describe --tags` 7 | DIR_NAME="modsecurity-$VERSION" 8 | TAR_NAME="modsecurity-$VERSION.tar.gz" 9 | 10 | MY_DIR=${PWD##*/} 11 | ./build.sh 12 | 13 | cd .. 14 | tar --transform "s/^$MY_DIR/$DIR_NAME/" -cvzf $TAR_NAME --exclude .git $MY_DIR 15 | 16 | sha256sum $TAR_NAME > $TAR_NAME.sha256 17 | gpg --detach-sign -a $TAR_NAME 18 | 19 | cd - 20 | echo $TAR_NAME ": done." 21 | 22 | -------------------------------------------------------------------------------- /build/win32/ConfigureChecks.cmake: -------------------------------------------------------------------------------- 1 | include(CheckIncludeFile) 2 | include(CheckIncludeFiles) 3 | 4 | check_include_file("dlfcn.h" HAVE_DLFCN_H) 5 | check_include_file("inttypes.h" HAVE_INTTYPES_H) 6 | check_include_file("stdint.h" HAVE_STDINT_H) 7 | check_include_file("stdio.h" HAVE_STDIO_H) 8 | check_include_file("stdlib.h" HAVE_STDLIB_H) 9 | check_include_file("string" HAVE_STRING) 10 | check_include_file("strings.h" HAVE_STRINGS_H) 11 | check_include_file("string.h" HAVE_STRING_H) 12 | check_include_file("sys/stat.h" HAVE_SYS_STAT_H) 13 | check_include_file("sys/types.h" HAVE_SYS_TYPES_H) 14 | check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H) 15 | check_include_file("unistd.h" HAVE_UNISTD_H) 16 | 17 | #/* Define to 1 if you have the ANSI C header files. */ 18 | check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) 19 | -------------------------------------------------------------------------------- /build/win32/conanfile.txt: -------------------------------------------------------------------------------- 1 | [requires] 2 | yajl/2.1.0 3 | pcre2/10.42 4 | libxml2/2.12.6 5 | lua/5.4.6 6 | libcurl/8.6.0 7 | lmdb/0.9.31 8 | libmaxminddb/1.9.1 9 | dirent/1.24 10 | poco/1.13.3 11 | 12 | [generators] 13 | CMakeDeps 14 | CMakeToolchain 15 | -------------------------------------------------------------------------------- /build/win32/docker/InstallBuildTools.cmd: -------------------------------------------------------------------------------- 1 | @rem Copyright (C) Microsoft Corporation. All rights reserved. 2 | @rem Licensed under the MIT license. See LICENSE.txt in the project root for license information. 3 | 4 | @if not defined _echo echo off 5 | setlocal enabledelayedexpansion 6 | 7 | call %* 8 | if "%ERRORLEVEL%"=="3010" ( 9 | exit /b 0 10 | ) else ( 11 | if not "%ERRORLEVEL%"=="0" ( 12 | set ERR=%ERRORLEVEL% 13 | call C:\TEMP\collect.exe -zip:C:\vslogs.zip 14 | 15 | exit /b !ERR! 16 | ) 17 | ) 18 | -------------------------------------------------------------------------------- /build/win32/docker/git.inf: -------------------------------------------------------------------------------- 1 | [Setup] 2 | Lang=default 3 | Dir=C:\Program Files\Git 4 | Group=Git 5 | NoIcons=0 6 | SetupType=default 7 | Components=ext,ext\shellhere,ext\guihere,gitlfs,assoc,autoupdate 8 | Tasks= 9 | EditorOption=VIM 10 | CustomEditorPath= 11 | PathOption=Cmd 12 | SSHOption=OpenSSH 13 | TortoiseOption=false 14 | CURLOption=WinSSL 15 | CRLFOption=LFOnly 16 | BashTerminalOption=ConHost 17 | PerformanceTweaksFSCache=Enabled 18 | UseCredentialManager=Enabled 19 | EnableSymlinks=Disabled 20 | EnableBuiltinInteractiveAdd=Disabled -------------------------------------------------------------------------------- /doc/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/doc/.empty -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I build 3 | 4 | # Doxygen support 5 | # include $(top_srcdir)/build/ax_prog_doxygen.m4 6 | 7 | # distribution of the Doxygen configuration file 8 | EXTRA_DIST = \ 9 | doxygen.cfg 10 | 11 | 12 | MAINTAINERCLEANFILES = \ 13 | Makefile.in \ 14 | doxygen_sqlite3.db \ 15 | html \ 16 | latex 17 | 18 | -------------------------------------------------------------------------------- /doc/ms-doxygen-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/doc/ms-doxygen-logo.png -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I build 3 | 4 | 5 | SUBDIRS = \ 6 | multiprocess_c \ 7 | multithread \ 8 | reading_logs_with_offset \ 9 | reading_logs_via_rule_message \ 10 | simple_example_using_c \ 11 | using_bodies_in_chunks 12 | 13 | pkginclude_HEADERS = \ 14 | reading_logs_via_rule_message/reading_logs_via_rule_message.h 15 | 16 | # make clean 17 | CLEANFILES = 18 | 19 | # make maintainer-clean 20 | MAINTAINERCLEANFILES = \ 21 | Makefile.in 22 | 23 | -------------------------------------------------------------------------------- /examples/multiprocess_c/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = multi 4 | 5 | multi_SOURCES = \ 6 | multi.c 7 | 8 | multi_LDADD = \ 9 | $(SSDEEP_LDADD) \ 10 | $(LUA_LDADD) \ 11 | $(MAXMIND_LDADD) \ 12 | $(GLOBAL_LDADD) 13 | 14 | multi_LDFLAGS = \ 15 | -L$(top_builddir)/src/.libs/ \ 16 | $(GEOIP_LDFLAGS) \ 17 | -lmodsecurity \ 18 | -lm \ 19 | -lstdc++ \ 20 | $(LUA_LDFLAGS) \ 21 | $(SSDEEP_LDFLAGS) \ 22 | $(MAXMIND_LDFLAGS) \ 23 | $(YAJL_LDFLAGS) 24 | 25 | multi_CFLAGS = \ 26 | -I$(top_builddir)/headers \ 27 | -I$(top_builddir) \ 28 | $(GLOBAL_CFLAGS) 29 | 30 | MAINTAINERCLEANFILES = \ 31 | Makefile.in 32 | 33 | 34 | -------------------------------------------------------------------------------- /examples/multiprocess_c/basic_rules.conf: -------------------------------------------------------------------------------- 1 | SecDebugLog /dev/stdout 2 | SecDebugLogLevel 9 3 | 4 | 5 | SecRule REQUEST_HEADERS:User-Agent ".*" "id:1,phase:1,t:sha1,t:hexEncode,setvar:tx.ua_hash=%{MATCHED_VAR}" 6 | 7 | SecAction "phase:2,initcol:ip=%{REMOTE_ADDR}_%{tx.ua_hash}" 8 | 9 | SecRule REQUEST_HEADERS:User-Agent ".*" "id:2,phase:2,setvar:ip.auth_attempt=+1" 10 | 11 | SecRule ARGS:foo "herewego" "id:3,phase:2,setvar:ip.foo=bar" 12 | SecRule IP "bar" "id:4,phase:2" 13 | SecRule IP:auth_attempt "bar" "id:5,phase:2" 14 | 15 | -------------------------------------------------------------------------------- /examples/multithread/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = multithread 4 | 5 | multithread_SOURCES = \ 6 | multithread.cc 7 | 8 | multithread_LDADD = \ 9 | $(CURL_LDADD) \ 10 | $(GEOIP_LDADD) \ 11 | $(GLOBAL_LDADD) \ 12 | $(LIBXML2_LDADD) \ 13 | $(LMDB_LDADD) \ 14 | $(MAXMIND_LDADD) \ 15 | $(LUA_LDADD) \ 16 | $(PCRE_LDADD) \ 17 | $(PCRE2_LDADD) \ 18 | $(SSDEEP_LDADD) \ 19 | $(YAJL_LDADD) 20 | 21 | multithread_LDFLAGS = \ 22 | -L$(top_builddir)/src/.libs/ \ 23 | $(GEOIP_LDFLAGS) \ 24 | -lmodsecurity \ 25 | -lpthread \ 26 | -lm \ 27 | -lstdc++ \ 28 | $(LMDB_LDFLAGS) \ 29 | $(LUA_LDFLAGS) \ 30 | $(MAXMIND_LDFLAGS) \ 31 | $(SSDEEP_LDFLAGS) \ 32 | $(YAJL_LDFLAGS) 33 | 34 | multithread_CPPFLAGS = \ 35 | $(GLOBAL_CFLAGS) \ 36 | -I$(top_builddir)/headers \ 37 | -I$(top_builddir) \ 38 | -g \ 39 | -I../others \ 40 | -fPIC \ 41 | -O3 \ 42 | $(CURL_CFLAGS) \ 43 | $(GEOIP_CFLAGS) \ 44 | $(GLOBAL_CPPFLAGS) \ 45 | $(MODSEC_NO_LOGS) \ 46 | $(YAJL_CFLAGS) \ 47 | $(LMDB_CFLAGS) \ 48 | $(LUA_CFLAGS) \ 49 | $(PCRE_CFLAGS) \ 50 | $(PCRE2_CFLAGS) \ 51 | $(LIBXML2_CFLAGS) 52 | 53 | 54 | MAINTAINERCLEANFILES = \ 55 | Makefile.in 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/multithread/basic_rules.conf: -------------------------------------------------------------------------------- 1 | SecDebugLog debug.log 2 | SecDebugLogLevel 9 3 | 4 | 5 | SecRule REQUEST_HEADERS:User-Agent ".*" "id:1,phase:1,t:sha1,t:hexEncode,setvar:tx.ua_hash=%{MATCHED_VAR}" 6 | 7 | SecAction "id:2,phase:2,initcol:ip=%{REMOTE_ADDR}_%{tx.ua_hash}" 8 | 9 | SecRule REQUEST_HEADERS:User-Agent "@rx .*" "id:3,phase:2,setvar:ip.auth_attempt=+1" 10 | 11 | SecRule ARGS:foo "@rx herewego" "id:4,phase:2,setvar:ip.foo=bar,expirevar:ip.foo=2" 12 | #SecRule ARGS:foo "@rx herewego" "id:4,phase:2,setvar:ip.foo=bar" 13 | SecRule IP "@rx bar" "id:5,phase:2,pass" 14 | SecRule IP:auth_attempt "@rx bar" "id:6,phase:2,pass" 15 | -------------------------------------------------------------------------------- /examples/reading_logs_via_rule_message/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = simple_request 4 | 5 | simple_request_SOURCES = \ 6 | simple_request.cc 7 | 8 | simple_request_LDADD = \ 9 | $(CURL_LDADD) \ 10 | $(GEOIP_LDADD) \ 11 | $(GLOBAL_LDADD) \ 12 | $(LIBXML2_LDADD) \ 13 | $(LMDB_LDADD) \ 14 | $(MAXMIND_LDADD) \ 15 | $(LUA_LDADD) \ 16 | $(PCRE_LDADD) \ 17 | $(PCRE2_LDADD) \ 18 | $(SSDEEP_LDADD) \ 19 | $(YAJL_LDADD) 20 | 21 | simple_request_LDFLAGS = \ 22 | -L$(top_builddir)/src/.libs/ \ 23 | $(GEOIP_LDFLAGS) \ 24 | -lmodsecurity \ 25 | -lpthread \ 26 | -lm \ 27 | -lstdc++ \ 28 | $(LMDB_LDFLAGS) \ 29 | $(LUA_LDFLAGS) \ 30 | $(MAXMIND_LDFLAGS) \ 31 | $(SSDEEP_LDFLAGS) \ 32 | $(YAJL_LDFLAGS) 33 | 34 | simple_request_CPPFLAGS = \ 35 | $(GLOBAL_CFLAGS) \ 36 | -I$(top_builddir)/headers \ 37 | -I$(top_builddir) \ 38 | -g \ 39 | -I../others \ 40 | -fPIC \ 41 | -O3 \ 42 | $(CURL_CFLAGS) \ 43 | $(GEOIP_CFLAGS) \ 44 | $(GLOBAL_CPPFLAGS) \ 45 | $(MODSEC_NO_LOGS) \ 46 | $(YAJL_CFLAGS) \ 47 | $(LMDB_CFLAGS) \ 48 | $(LUA_CFLAGS) \ 49 | $(PCRE_CFLAGS) \ 50 | $(PCRE2_CFLAGS) \ 51 | $(LIBXML2_CFLAGS) 52 | 53 | 54 | MAINTAINERCLEANFILES = \ 55 | Makefile.in 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/reading_logs_via_rule_message/blocked_request.conf: -------------------------------------------------------------------------------- 1 | SecRule ARGS:param1 "test" "id:1,deny,phase:2,chain,msg:'test'" 2 | SecRule ARGS:param1 "test" "log" 3 | 4 | -------------------------------------------------------------------------------- /examples/reading_logs_via_rule_message/blocked_request_engine_on.conf: -------------------------------------------------------------------------------- 1 | SecRuleEngine On 2 | SecRule ARGS:param1 "test" "id:1,deny" 3 | -------------------------------------------------------------------------------- /examples/reading_logs_via_rule_message/match.conf: -------------------------------------------------------------------------------- 1 | SecRule ARGS:param1 "test" "id:1,deny,msg:'this',msg:'is',msg:'a',msg:'test'" 2 | -------------------------------------------------------------------------------- /examples/reading_logs_via_rule_message/no_match.conf: -------------------------------------------------------------------------------- 1 | SecRule ARGS:param1 "WHEEE" "id:1,phase:2,deny,msg:'this',msg:'is',msg:'a',msg:'test'" 2 | -------------------------------------------------------------------------------- /examples/reading_logs_with_offset/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = read 4 | 5 | read_SOURCES = \ 6 | read.cc 7 | 8 | read_LDADD = \ 9 | $(CURL_LDADD) \ 10 | $(GEOIP_LDADD) \ 11 | $(MAXMIND_LDADD) \ 12 | $(GLOBAL_LDADD) \ 13 | $(LIBXML2_LDADD) \ 14 | $(LMDB_LDADD) \ 15 | $(LUA_LDADD) \ 16 | $(PCRE_LDADD) \ 17 | $(PCRE2_LDADD) \ 18 | $(SSDEEP_LDADD) \ 19 | $(YAJL_LDADD) 20 | 21 | read_LDFLAGS = \ 22 | -L$(top_builddir)/src/.libs/ \ 23 | $(GEOIP_LDFLAGS) \ 24 | -lmodsecurity \ 25 | -lm \ 26 | -lstdc++ \ 27 | $(LMDB_LDFLAGS) \ 28 | $(LUA_LDFLAGS) \ 29 | $(SSDEEP_LDFLAGS) \ 30 | $(MAXMIND_LDFLAGS) \ 31 | $(YAJL_LDFLAGS) 32 | 33 | read_CPPFLAGS = \ 34 | $(GLOBAL_CFLAGS) \ 35 | -I$(top_builddir)/headers \ 36 | -I$(top_builddir) \ 37 | -g \ 38 | -I../others \ 39 | -fPIC \ 40 | -O3 \ 41 | $(CURL_CFLAGS) \ 42 | $(GEOIP_CFLAGS) \ 43 | $(MAXMIND_CFLAGS) \ 44 | $(GLOBAL_CPPFLAGS) \ 45 | $(MODSEC_NO_LOGS) \ 46 | $(YAJL_CFLAGS) \ 47 | $(LMDB_CFLAGS) \ 48 | $(LUA_CFLAGS) \ 49 | $(PCRE_CFLAGS) \ 50 | $(PCRE2_CFLAGS) \ 51 | $(LIBXML2_CFLAGS) 52 | 53 | 54 | MAINTAINERCLEANFILES = \ 55 | Makefile.in 56 | 57 | 58 | -------------------------------------------------------------------------------- /examples/reading_logs_with_offset/read.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | 8 | // Variable offset - REQUEST_HEADERS_NAMES 9 | 10 | const char *request = "" \ 11 | "GET /index.html?param1=value1¶m2=value1¶m3=value1 HTTP/\n" \ 12 | "AuThOrIzAtIoN: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n" \ 13 | "Host: localhost\n" \ 14 | "Content-Length: 27\n" \ 15 | "Content-Type: application/x-www-form-urlencoded\n"; 16 | 17 | 18 | int main() { 19 | modsecurity::ModSecurity msc; 20 | std::string json(""); 21 | const char *err = NULL; 22 | int ret = 0; 23 | 24 | ret = msc.processContentOffset(request, strlen(request), 25 | "o0,4v64,13v114,4v130,14v149,12t:lowercase", &json, &err); 26 | 27 | if (ret >= 0) { 28 | std::cout << json << std::endl; 29 | } else { 30 | std::cout << err << std::endl; 31 | } 32 | 33 | return ret; 34 | } 35 | -------------------------------------------------------------------------------- /examples/simple_example_using_c/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = test 4 | 5 | test_SOURCES = \ 6 | test.c 7 | 8 | test_LDADD = \ 9 | $(GLOBAL_LDADD) \ 10 | $(LUA_LDADD) \ 11 | $(SSDEEP_LDADD) 12 | 13 | test_LDFLAGS = \ 14 | -L$(top_builddir)/src/.libs/ \ 15 | $(GEOIP_LDFLAGS) \ 16 | -lmodsecurity \ 17 | -lm \ 18 | -lstdc++ \ 19 | $(LUA_LDFLAGS) \ 20 | $(SSDEEP_LDFLAGS) \ 21 | $(YAJL_LDFLAGS) 22 | 23 | test_CFLAGS = \ 24 | -I$(top_builddir)/headers \ 25 | -I$(top_builddir) \ 26 | $(GLOBAL_CFLAGS) 27 | 28 | MAINTAINERCLEANFILES = \ 29 | Makefile.in 30 | 31 | 32 | -------------------------------------------------------------------------------- /examples/simple_example_using_c/test-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | valgrind --tool=massif 4 | valgrind --show-leak-kinds=all --leak-check=full ./test 5 | -------------------------------------------------------------------------------- /examples/using_bodies_in_chunks/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = simple_request 4 | 5 | simple_request_SOURCES = \ 6 | simple_request.cc 7 | 8 | simple_request_LDADD = \ 9 | $(CURL_LDADD) \ 10 | $(GEOIP_LDADD) \ 11 | $(MAXMIND_LDADD) \ 12 | $(GLOBAL_LDADD) \ 13 | $(LIBXML2_LDADD) \ 14 | $(LMDB_LDADD) \ 15 | $(LUA_LDADD) \ 16 | $(PCRE_LDADD) \ 17 | $(PCRE2_LDADD) \ 18 | $(SSDEEP_LDADD) \ 19 | $(YAJL_LDADD) 20 | 21 | simple_request_LDFLAGS = \ 22 | -L$(top_builddir)/src/.libs/ \ 23 | $(GEOIP_LDFLAGS) \ 24 | -lmodsecurity \ 25 | -lm \ 26 | -lstdc++ \ 27 | $(MAXMIND_LDFLAGS) \ 28 | $(LMDB_LDFLAGS) \ 29 | $(LUA_LDFLAGS) \ 30 | $(SSDEEP_LDFLAGS) \ 31 | $(YAJL_LDFLAGS) 32 | 33 | simple_request_CPPFLAGS = \ 34 | $(GLOBAL_CFLAGS) \ 35 | -I$(top_builddir)/headers \ 36 | -I$(top_builddir) \ 37 | -g \ 38 | -I../others \ 39 | -fPIC \ 40 | -O3 \ 41 | $(GEOIP_CFLAGS) \ 42 | $(CURL_CFLAGS) \ 43 | $(MAXMIND_CFLAGS) \ 44 | $(GLOBAL_CPPFLAGS) \ 45 | $(MODSEC_NO_LOGS) \ 46 | $(YAJL_CFLAGS) \ 47 | $(LMDB_CFLAGS) \ 48 | $(LUA_CFLAGS) \ 49 | $(PCRE_CFLAGS) \ 50 | $(PCRE2_CFLAGS) \ 51 | $(LIBXML2_CFLAGS) 52 | 53 | MAINTAINERCLEANFILES = \ 54 | Makefile.in 55 | 56 | 57 | -------------------------------------------------------------------------------- /examples/using_bodies_in_chunks/example.conf: -------------------------------------------------------------------------------- 1 | SecDebugLog /dev/stdout 2 | SecDebugLogLevel 9 3 | SecRule RESPONSE_BODY "/soap:Body" "id:1,phase:5,deny" 4 | -------------------------------------------------------------------------------- /headers/modsecurity/rules_properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | 18 | 19 | -------------------------------------------------------------------------------- /modsecurity.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: ModSecurity 7 | Description: ModSecurity API 8 | Version: @MSC_VERSION_WITH_PATCHLEVEL@ 9 | Cflags: -I@includedir@ 10 | Libs: -L@libdir@ -lmodsecurity 11 | Libs.private: @CURL_LDADD@ @GEOIP_LDADD@ @MAXMIND_LDADD@ @GLOBAL_LDADD@ @LIBXML2_LDADD@ @LMDB_LDADD@ @LUA_LDADD@ @PCRE_LDADD@ @SSDEEP_LDADD@ @YAJL_LDADD@ 12 | -------------------------------------------------------------------------------- /others/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LTLIBRARIES = libinjection.la libmbedtls.la 3 | 4 | libinjection_la_SOURCES = \ 5 | libinjection/src/libinjection_html5.c \ 6 | libinjection/src/libinjection_sqli.c \ 7 | libinjection/src/libinjection_xss.c 8 | 9 | libinjection_la_CFLAGS = -D LIBINJECTION_VERSION=\"${LIBINJECTION_VERSION}\" 10 | libinjection_la_LIBADD = 11 | 12 | noinst_HEADERS = \ 13 | libinjection/src/libinjection.h \ 14 | libinjection/src/libinjection_html5.h \ 15 | libinjection/src/libinjection_sqli.h \ 16 | libinjection/src/libinjection_sqli_data.h \ 17 | libinjection/src/libinjection_xss.h \ 18 | mbedtls/include/mbedtls/base64.h \ 19 | mbedtls/include/mbedtls/check_config.h \ 20 | mbedtls/include/mbedtls/mbedtls_config.h \ 21 | mbedtls/include/mbedtls/md5.h \ 22 | mbedtls/include/mbedtls/platform.h \ 23 | mbedtls/include/mbedtls/sha1.h 24 | 25 | libmbedtls_la_SOURCES = \ 26 | mbedtls/library/base64.c \ 27 | mbedtls/library/md5.c \ 28 | mbedtls/library/sha1.c \ 29 | mbedtls/library/platform_util.c 30 | 31 | libmbedtls_la_CFLAGS = -DMBEDTLS_CONFIG_FILE=\"mbedtls/mbedtls_config.h\" -I$(top_srcdir)/others/mbedtls/include 32 | libmbedtls_la_CPPFLAGS = 33 | libmbedtls_la_LIBADD = 34 | -------------------------------------------------------------------------------- /others/modsec.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/others/modsec.png -------------------------------------------------------------------------------- /others/modsec_white_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/others/modsec_white_bg.png -------------------------------------------------------------------------------- /src/actions/capture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | 18 | #include "modsecurity/actions/action.h" 19 | 20 | #ifndef SRC_ACTIONS_CAPTURE_H_ 21 | #define SRC_ACTIONS_CAPTURE_H_ 22 | 23 | 24 | namespace modsecurity { 25 | class RuleWithOperator; 26 | namespace actions { 27 | 28 | 29 | class Capture : public Action { 30 | public: 31 | explicit Capture(const std::string &action) 32 | : Action(action) { } 33 | 34 | bool evaluate(RuleWithActions *rule, Transaction *transaction) override; 35 | }; 36 | 37 | 38 | } // namespace actions 39 | } // namespace modsecurity 40 | 41 | #endif // SRC_ACTIONS_CAPTURE_H_ 42 | -------------------------------------------------------------------------------- /src/actions/chain.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/chain.h" 17 | 18 | #include "modsecurity/rule_with_actions.h" 19 | 20 | namespace modsecurity::actions { 21 | 22 | 23 | bool Chain::evaluate(RuleWithActions *rule, Transaction *transaction) { 24 | rule->setChained(true); 25 | return true; 26 | } 27 | 28 | 29 | } // namespace modsecurity::actions 30 | -------------------------------------------------------------------------------- /src/actions/multi_match.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/multi_match.h" 17 | 18 | #include 19 | #include 20 | 21 | #include "modsecurity/transaction.h" 22 | #include "modsecurity/rule.h" 23 | 24 | namespace modsecurity { 25 | namespace actions { 26 | 27 | 28 | bool MultiMatch::evaluate(RuleWithActions *rule, Transaction *transaction) { 29 | return true; 30 | } 31 | 32 | 33 | } // namespace actions 34 | } // namespace modsecurity 35 | -------------------------------------------------------------------------------- /src/actions/no_audit_log.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/no_audit_log.h" 17 | 18 | #include 19 | #include 20 | 21 | #include "modsecurity/transaction.h" 22 | #include "modsecurity/rule.h" 23 | #include "modsecurity/rule_message.h" 24 | 25 | namespace modsecurity { 26 | namespace actions { 27 | 28 | 29 | bool NoAuditLog::evaluate(RuleWithActions *rule, Transaction *transaction, RuleMessage &ruleMessage) { 30 | ruleMessage.m_noAuditLog = true; 31 | ruleMessage.m_saveMessage = false; 32 | 33 | return true; 34 | } 35 | 36 | 37 | } // namespace actions 38 | } // namespace modsecurity 39 | -------------------------------------------------------------------------------- /src/actions/no_log.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/no_log.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "modsecurity/actions/action.h" 23 | #include "modsecurity/transaction.h" 24 | #include "src/operators/operator.h" 25 | #include "modsecurity/rule_message.h" 26 | 27 | 28 | namespace modsecurity { 29 | namespace actions { 30 | 31 | 32 | bool NoLog::evaluate(RuleWithActions *rule, Transaction *transaction, RuleMessage &ruleMessage) { 33 | ruleMessage.m_saveMessage = false; 34 | return true; 35 | } 36 | 37 | 38 | } // namespace actions 39 | } // namespace modsecurity 40 | -------------------------------------------------------------------------------- /src/actions/rev.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/rev.h" 17 | 18 | #include "modsecurity/rule_with_actions.h" 19 | 20 | 21 | namespace modsecurity::actions { 22 | 23 | 24 | bool Rev::init(std::string *error) { 25 | m_rev = m_parser_payload; 26 | return true; 27 | } 28 | 29 | 30 | bool Rev::evaluate(RuleWithActions *rule, Transaction *transaction) { 31 | rule->m_rev = m_rev; 32 | return true; 33 | } 34 | 35 | 36 | } // namespace modsecurity::actions 37 | -------------------------------------------------------------------------------- /src/actions/skip_after.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/skip_after.h" 17 | 18 | #include 19 | #include 20 | 21 | #include "modsecurity/rules_set.h" 22 | #include "modsecurity/actions/action.h" 23 | #include "modsecurity/transaction.h" 24 | 25 | 26 | namespace modsecurity { 27 | namespace actions { 28 | 29 | 30 | bool SkipAfter::evaluate(RuleWithActions *rule, Transaction *transaction) { 31 | ms_dbg_a(transaction, 5, "Setting skipAfter for: " + *m_skipName); 32 | transaction->addMarker(m_skipName); 33 | return true; 34 | } 35 | 36 | 37 | } // namespace actions 38 | } // namespace modsecurity 39 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_decode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "base64_decode.h" 17 | 18 | #include "src/utils/base64.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool Base64Decode::transform(std::string &value, const Transaction *trans) const { 25 | if (value.empty()) return false; 26 | value = Utils::Base64::decode(value); 27 | return true; 28 | } 29 | 30 | 31 | } // namespace modsecurity::actions::transformations 32 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Base64Decode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_decode_ext.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "base64_decode_ext.h" 17 | 18 | #include "src/utils/base64.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool Base64DecodeExt::transform(std::string &value, const Transaction *trans) const { 25 | if (value.empty()) return false; 26 | value = Utils::Base64::decode_forgiven(value); 27 | return true; 28 | } 29 | 30 | 31 | } // namespace modsecurity::actions::transformations 32 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_decode_ext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_EXT_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_EXT_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Base64DecodeExt : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_BASE64_DECODE_EXT_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_encode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "base64_encode.h" 17 | 18 | #include "src/utils/base64.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool Base64Encode::transform(std::string &value, const Transaction *trans) const { 25 | if (value.empty()) return false; 26 | value = Utils::Base64::encode(value); 27 | return true; 28 | } 29 | 30 | 31 | } // namespace modsecurity::actions::transformations 32 | -------------------------------------------------------------------------------- /src/actions/transformations/base64_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Base64Encode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_BASE64_ENCODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/cmd_line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_CMD_LINE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_CMD_LINE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class CmdLine : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // modsecurity::namespace actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_CMD_LINE_H_ 33 | 34 | -------------------------------------------------------------------------------- /src/actions/transformations/compress_whitespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_COMPRESS_WHITESPACE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_COMPRESS_WHITESPACE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class CompressWhitespace : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_COMPRESS_WHITESPACE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/css_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_CSS_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_CSS_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class CssDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_CSS_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/escape_seq_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_ESCAPE_SEQ_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_ESCAPE_SEQ_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class EscapeSeqDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_ESCAPE_SEQ_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/hex_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_HEX_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_HEX_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class HexDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_HEX_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/hex_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_HEX_ENCODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_HEX_ENCODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class HexEncode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_HEX_ENCODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/html_entity_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_HTML_ENTITY_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_HTML_ENTITY_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class HtmlEntityDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_HTML_ENTITY_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/js_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_JS_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_JS_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class JsDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_JS_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/length.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "length.h" 17 | 18 | 19 | namespace modsecurity::actions::transformations { 20 | 21 | 22 | bool Length::transform(std::string &value, const Transaction *trans) const { 23 | value = std::to_string(value.size()); 24 | return true; 25 | } 26 | 27 | 28 | } // namespace modsecurity::actions::transformations 29 | -------------------------------------------------------------------------------- /src/actions/transformations/length.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_LENGTH_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_LENGTH_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Length : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_LENGTH_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/lower_case.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | 17 | #include "lower_case.h" 18 | 19 | #include 20 | 21 | 22 | namespace modsecurity::actions::transformations { 23 | 24 | 25 | bool LowerCase::transform(std::string &value, const Transaction *trans) const { 26 | return convert(value, [](auto c) { 27 | return std::tolower(c); }); 28 | } 29 | 30 | 31 | } // namespace modsecurity::actions::transformations 32 | -------------------------------------------------------------------------------- /src/actions/transformations/md5.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "md5.h" 17 | 18 | #include "src/utils/md5.h" 19 | 20 | namespace modsecurity::actions::transformations { 21 | 22 | 23 | bool Md5::transform(std::string &value, const Transaction *trans) const { 24 | value = Utils::Md5::digest(value); 25 | return true; 26 | } 27 | 28 | 29 | } // namespace modsecurity::actions::transformations 30 | -------------------------------------------------------------------------------- /src/actions/transformations/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_MD5_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_MD5_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Md5 : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_MD5_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/none.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "none.h" 17 | 18 | 19 | namespace modsecurity::actions::transformations { 20 | 21 | 22 | bool None::transform(std::string &value, const Transaction *trans) const { 23 | return false; 24 | } 25 | 26 | 27 | } // namespace modsecurity::actions::transformations 28 | -------------------------------------------------------------------------------- /src/actions/transformations/none.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_NONE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_NONE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class None : public Transformation { 24 | public: 25 | explicit None(const std::string &action) 26 | : Transformation(action) 27 | { m_isNone = true; } 28 | 29 | bool transform(std::string &value, const Transaction *trans) const override; 30 | }; 31 | 32 | } // namespace modsecurity::actions::transformations 33 | 34 | #endif // SRC_ACTIONS_TRANSFORMATIONS_NONE_H_ 35 | -------------------------------------------------------------------------------- /src/actions/transformations/normalise_path_win.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "normalise_path_win.h" 17 | 18 | #include "normalise_path.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool NormalisePathWin::transform(std::string &value, const Transaction *trans) const { 25 | return NormalisePath::normalize_path_inplace(value, true); 26 | } 27 | 28 | 29 | } // namespace modsecurity::actions::transformations 30 | -------------------------------------------------------------------------------- /src/actions/transformations/normalise_path_win.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_NORMALISE_PATH_WIN_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_NORMALISE_PATH_WIN_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class NormalisePathWin : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_NORMALISE_PATH_WIN_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/parity_even_7bit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "parity_even_7bit.h" 17 | 18 | 19 | namespace modsecurity::actions::transformations { 20 | 21 | 22 | bool ParityEven7bit::transform(std::string &value, const Transaction *trans) const { 23 | return ParityEven7bit::inplace(value); 24 | } 25 | 26 | 27 | } // namespace modsecurity::actions::transformations 28 | -------------------------------------------------------------------------------- /src/actions/transformations/parity_odd_7bit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "parity_odd_7bit.h" 17 | #include "parity_even_7bit.h" 18 | 19 | 20 | namespace modsecurity::actions::transformations { 21 | 22 | 23 | bool ParityOdd7bit::transform(std::string &value, const Transaction *trans) const { 24 | return ParityEven7bit::inplace(value); 25 | } 26 | 27 | 28 | } // namespace modsecurity::actions::transformations 29 | -------------------------------------------------------------------------------- /src/actions/transformations/parity_odd_7bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_PARITY_ODD_7BIT_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_PARITY_ODD_7BIT_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class ParityOdd7bit : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_PARITY_ODD_7BIT_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/parity_zero_7bit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_PARITY_ZERO_7BIT_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_PARITY_ZERO_7BIT_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class ParityZero7bit : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_PARITY_ZERO_7BIT_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/remove_comments.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class RemoveComments : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/remove_comments_char.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_CHAR_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_CHAR_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class RemoveCommentsChar : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_REMOVE_COMMENTS_CHAR_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/remove_nulls.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2023 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "remove_nulls.h" 17 | 18 | 19 | namespace modsecurity::actions::transformations { 20 | 21 | 22 | bool RemoveNulls::transform(std::string &value, const Transaction *trans) const { 23 | return remove_if(value, [](const auto c) { return c == '\0'; }); 24 | } 25 | 26 | 27 | } // namespace modsecurity::actions::transformations 28 | -------------------------------------------------------------------------------- /src/actions/transformations/remove_whitespace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_REMOVE_WHITESPACE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_REMOVE_WHITESPACE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class RemoveWhitespace : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_REMOVE_WHITESPACE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/replace_comments.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_REPLACE_COMMENTS_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_REPLACE_COMMENTS_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class ReplaceComments : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_REPLACE_COMMENTS_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/replace_nulls.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2023 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "replace_nulls.h" 17 | 18 | 19 | namespace modsecurity::actions::transformations { 20 | 21 | 22 | bool ReplaceNulls::transform(std::string &value, const Transaction *trans) const { 23 | bool changed = false; 24 | 25 | for(auto &c : value) { 26 | if (c == '\0') { 27 | c = ' '; 28 | changed = true; 29 | } 30 | } 31 | 32 | return changed; 33 | } 34 | 35 | } // namespace modsecurity::actions::transformations 36 | -------------------------------------------------------------------------------- /src/actions/transformations/replace_nulls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_REPLACE_NULLS_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_REPLACE_NULLS_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class ReplaceNulls : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_REPLACE_NULLS_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/sha1.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "sha1.h" 17 | 18 | #include "src/utils/sha1.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool Sha1::transform(std::string &value, const Transaction *trans) const { 25 | value = Utils::Sha1::digest(value); 26 | return true; 27 | } 28 | 29 | 30 | } // namespace modsecurity::actions::transformations 31 | -------------------------------------------------------------------------------- /src/actions/transformations/sha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_SHA1_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_SHA1_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Sha1 : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_SHA1_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/sql_hex_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_SQL_HEX_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_SQL_HEX_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class SqlHexDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_SQL_HEX_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/trim_left.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "trim_left.h" 17 | #include "trim.h" 18 | 19 | 20 | namespace modsecurity::actions::transformations { 21 | 22 | 23 | bool TrimLeft::transform(std::string &value, const Transaction *trans) const { 24 | return Trim::ltrim(value); 25 | } 26 | 27 | 28 | } // namespace modsecurity::actions::transformations 29 | -------------------------------------------------------------------------------- /src/actions/transformations/trim_left.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_TRIM_LEFT_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_TRIM_LEFT_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class TrimLeft : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_TRIM_LEFT_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/trim_right.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "trim_right.h" 17 | #include "trim.h" 18 | 19 | 20 | namespace modsecurity::actions::transformations { 21 | 22 | 23 | bool TrimRight::transform(std::string &value, const Transaction *trans) const { 24 | return Trim::rtrim(value); 25 | } 26 | 27 | 28 | } // namespace modsecurity::actions::transformations 29 | -------------------------------------------------------------------------------- /src/actions/transformations/trim_right.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_TRIM_RIGHT_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_TRIM_RIGHT_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class TrimRight : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_TRIM_RIGHT_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/upper_case.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | 17 | #include "upper_case.h" 18 | 19 | #include 20 | 21 | #include "lower_case.h" 22 | 23 | 24 | namespace modsecurity::actions::transformations { 25 | 26 | 27 | bool UpperCase::transform(std::string &value, const Transaction *trans) const { 28 | return LowerCase::convert(value, [](auto c) 29 | { return std::toupper(c); }); 30 | } 31 | 32 | 33 | } // namespace modsecurity::actions::transformations 34 | -------------------------------------------------------------------------------- /src/actions/transformations/upper_case.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_UPPER_CASE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_UPPER_CASE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class UpperCase : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_UPPER_CASE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/url_decode.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "url_decode.h" 17 | 18 | #include "src/utils/decode.h" 19 | 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | 24 | bool UrlDecode::transform(std::string &value, const Transaction *trans) const { 25 | int invalid_count; 26 | return utils::urldecode_nonstrict_inplace(value, invalid_count); 27 | } 28 | 29 | 30 | } // namespace modsecurity::actions::transformations 31 | -------------------------------------------------------------------------------- /src/actions/transformations/url_decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class UrlDecode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/url_decode_uni.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_UNI_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_UNI_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class UrlDecodeUni : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_URL_DECODE_UNI_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/url_encode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_URL_ENCODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_URL_ENCODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class UrlEncode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_URL_ENCODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/transformations/utf8_to_unicode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_ 17 | #define SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_ 18 | 19 | #include "transformation.h" 20 | 21 | namespace modsecurity::actions::transformations { 22 | 23 | class Utf8ToUnicode : public Transformation { 24 | public: 25 | using Transformation::Transformation; 26 | 27 | bool transform(std::string &value, const Transaction *trans) const override; 28 | }; 29 | 30 | } // namespace modsecurity::actions::transformations 31 | 32 | #endif // SRC_ACTIONS_TRANSFORMATIONS_UTF8_TO_UNICODE_H_ 33 | -------------------------------------------------------------------------------- /src/actions/ver.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/actions/ver.h" 17 | 18 | #include "modsecurity/rule_with_actions.h" 19 | 20 | 21 | namespace modsecurity::actions { 22 | 23 | 24 | bool Ver::evaluate(RuleWithActions *rule, Transaction *transaction) { 25 | rule->m_ver = m_parser_payload; 26 | return true; 27 | } 28 | 29 | 30 | } // namespace modsecurity::actions 31 | -------------------------------------------------------------------------------- /src/compat/msvc.h: -------------------------------------------------------------------------------- 1 | #ifndef __COMPAT_MSVC 2 | #define __COMPAT_MSVC 3 | 4 | #include 5 | 6 | #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) 7 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 8 | #endif 9 | 10 | #define strcasecmp _stricmp 11 | #define strncasecmp _strnicmp 12 | #define strtok_r strtok_s 13 | #define popen _popen 14 | #define pclose _pclose 15 | 16 | inline tm* localtime_r(const time_t* tin, tm* tout) { 17 | // cppcheck-suppress[uninitvar, ctuuninitvar] 18 | if (!localtime_s(tout, tin)) return tout; 19 | 20 | return nullptr; 21 | } 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/operators/.directory: -------------------------------------------------------------------------------- 1 | [Dolphin] 2 | SortRole=type 3 | Timestamp=2015,6,11,13,57,39 4 | Version=3 5 | ViewMode=1 6 | VisibleRoles=Details_text,Details_size,Details_date,Details_type,CustomizedDetails 7 | -------------------------------------------------------------------------------- /src/operators/ge.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/ge.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | 23 | namespace modsecurity { 24 | namespace operators { 25 | 26 | bool Ge::evaluate(Transaction *transaction, const std::string &input) { 27 | std::string p(m_string->evaluate(transaction)); 28 | std::string i = input; 29 | 30 | bool ge = atoll(i.c_str()) >= atoll(p.c_str()); 31 | 32 | return ge; 33 | } 34 | 35 | 36 | } // namespace operators 37 | } // namespace modsecurity 38 | -------------------------------------------------------------------------------- /src/operators/geo_lookup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_OPERATORS_GEO_LOOKUP_H_ 17 | #define SRC_OPERATORS_GEO_LOOKUP_H_ 18 | 19 | #include 20 | 21 | #include "src/operators/operator.h" 22 | 23 | 24 | namespace modsecurity::operators { 25 | 26 | 27 | class GeoLookup : public Operator { 28 | public: 29 | /** @ingroup ModSecurity_Operator */ 30 | GeoLookup() 31 | : Operator("GeoLookup") { } 32 | bool evaluate(Transaction *transaction, const std::string &exp) override; 33 | }; 34 | 35 | 36 | } // namespace modsecurity::operators 37 | 38 | 39 | #endif // SRC_OPERATORS_GEO_LOOKUP_H_ 40 | -------------------------------------------------------------------------------- /src/operators/gsblookup.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/gsblookup.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | namespace modsecurity { 23 | namespace operators { 24 | 25 | 26 | bool GsbLookup::evaluate(Transaction *transaction, const std::string &str) { 27 | /** 28 | * @todo Implement the operator GeoLookup. 29 | * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#gsblookup 30 | */ 31 | return true; 32 | } 33 | 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/operators/gt.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/gt.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | 23 | namespace modsecurity { 24 | namespace operators { 25 | 26 | bool Gt::evaluate(Transaction *transaction, const std::string &input) { 27 | std::string p(m_string->evaluate(transaction)); 28 | 29 | bool gt = atoll(input.c_str()) > atoll(p.c_str()); 30 | 31 | return gt; 32 | } 33 | 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/operators/ip_match_f.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/ip_match_f.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | namespace modsecurity { 23 | namespace operators { 24 | 25 | 26 | } // namespace operators 27 | } // namespace modsecurity 28 | -------------------------------------------------------------------------------- /src/operators/ip_match_f.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_OPERATORS_IP_MATCH_F_H_ 17 | #define SRC_OPERATORS_IP_MATCH_F_H_ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "src/operators/ip_match_from_file.h" 24 | 25 | 26 | namespace modsecurity { 27 | namespace operators { 28 | 29 | class IpMatchF : public IpMatchFromFile { 30 | public: 31 | explicit IpMatchF(std::unique_ptr param) 32 | : IpMatchFromFile(std::move(param)) { } 33 | }; 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | 38 | 39 | #endif // SRC_OPERATORS_IP_MATCH_F_H_ 40 | -------------------------------------------------------------------------------- /src/operators/le.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/le.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | 23 | namespace modsecurity { 24 | namespace operators { 25 | 26 | bool Le::evaluate(Transaction *transaction, const std::string &input) { 27 | std::string p(m_string->evaluate(transaction)); 28 | 29 | bool le = atoll(input.c_str()) <= atoll(p.c_str()); 30 | 31 | return le; 32 | } 33 | 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/operators/lt.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/lt.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | namespace modsecurity { 23 | namespace operators { 24 | 25 | bool Lt::evaluate(Transaction *transaction, const std::string &input) { 26 | std::string p(m_string->evaluate(transaction)); 27 | 28 | bool lt = atoll(input.c_str()) < atoll(p.c_str()); 29 | 30 | return lt; 31 | } 32 | 33 | 34 | } // namespace operators 35 | } // namespace modsecurity 36 | -------------------------------------------------------------------------------- /src/operators/no_match.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/no_match.h" 17 | 18 | #include 19 | 20 | namespace modsecurity { 21 | namespace operators { 22 | 23 | bool NoMatch::evaluate(Transaction *transaction, const std::string &str) { 24 | return false; 25 | } 26 | 27 | 28 | } // namespace operators 29 | } // namespace modsecurity 30 | -------------------------------------------------------------------------------- /src/operators/pm_f.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_OPERATORS_PM_F_H_ 17 | #define SRC_OPERATORS_PM_F_H_ 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "src/operators/pm_from_file.h" 24 | 25 | 26 | namespace modsecurity { 27 | namespace operators { 28 | 29 | 30 | class PmF : public PmFromFile { 31 | public: 32 | /** @ingroup ModSecurity_Operator */ 33 | explicit PmF(std::unique_ptr param) 34 | : PmFromFile("PmFromF", std::move(param)) { } 35 | }; 36 | 37 | 38 | } // namespace operators 39 | } // namespace modsecurity 40 | 41 | 42 | #endif // SRC_OPERATORS_PM_F_H_ 43 | -------------------------------------------------------------------------------- /src/operators/rsub.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/rsub.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | namespace modsecurity { 23 | namespace operators { 24 | 25 | 26 | bool Rsub::evaluate(Transaction *transaction, const std::string &str) { 27 | /** 28 | * @todo Implement the operator Rsub. 29 | * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#rsub 30 | */ 31 | return true; 32 | } 33 | 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/operators/str_eq.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/str_eq.h" 17 | 18 | #include 19 | 20 | namespace modsecurity { 21 | namespace operators { 22 | 23 | bool StrEq::evaluate(Transaction *transaction, const std::string &str) { 24 | std::string pt(m_string->evaluate(transaction)); 25 | return !pt.compare(str); 26 | } 27 | 28 | 29 | } // namespace operators 30 | } // namespace modsecurity 31 | -------------------------------------------------------------------------------- /src/operators/str_match.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/str_match.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | 23 | namespace modsecurity { 24 | namespace operators { 25 | 26 | 27 | bool StrMatch::evaluate(Transaction *transaction, const std::string &input) { 28 | std::string p(m_string->evaluate(transaction)); 29 | bool ret = input.find(p) != std::string::npos; 30 | 31 | return ret; 32 | } 33 | 34 | 35 | } // namespace operators 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/operators/unconditional_match.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/unconditional_match.h" 17 | 18 | namespace modsecurity { 19 | namespace operators { 20 | 21 | bool UnconditionalMatch::evaluate(Transaction *transaction, 22 | const std::string &input) { 23 | return true; 24 | } 25 | 26 | } // namespace operators 27 | } // namespace modsecurity 28 | -------------------------------------------------------------------------------- /src/operators/validate_hash.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/operators/validate_hash.h" 17 | 18 | #include 19 | 20 | #include "src/operators/operator.h" 21 | 22 | namespace modsecurity { 23 | namespace operators { 24 | 25 | bool ValidateHash::evaluate(Transaction *transaction, const std::string &str) { 26 | /** 27 | * @todo Implement the operator ValidateHash. 28 | * Reference: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#validateHash 29 | */ 30 | return true; 31 | } 32 | 33 | 34 | } // namespace operators 35 | } // namespace modsecurity 36 | -------------------------------------------------------------------------------- /src/parser/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LTLIBRARIES = libmodsec_parser.la 3 | 4 | BUILT_SOURCES = \ 5 | seclang-parser.cc \ 6 | test.cc 7 | 8 | libmodsec_parser_la_SOURCES = \ 9 | seclang-parser.yy \ 10 | seclang-scanner.ll \ 11 | test.cc 12 | 13 | libmodsec_parser_la_CPPFLAGS = \ 14 | -I../.. \ 15 | -I../../headers \ 16 | -I../../others \ 17 | -I.. \ 18 | -g \ 19 | -fPIC \ 20 | -O3 \ 21 | $(CURL_CFLAGS) \ 22 | $(GEOIP_CFLAGS) \ 23 | $(GLOBAL_CPPFLAGS) \ 24 | $(MODSEC_NO_LOGS) \ 25 | $(YAJL_CFLAGS) \ 26 | $(LMDB_CFLAGS) \ 27 | $(PCRE_CFLAGS) \ 28 | $(PCRE2_CFLAGS) \ 29 | $(LIBXML2_CFLAGS) 30 | 31 | test.cc: seclang-parser.hh 32 | cat seclang-parser.hh | sed "s/return \*new (yyas_ ()) T (t)/return *new (yyas_ ()) T (std::move((T\&)t))/g" > seclang-parser.hh.fix && mv seclang-parser.hh.fix seclang-parser.hh 33 | touch test.cc 34 | 35 | CLEANFILES = test.cc \ 36 | seclang-scanner.cc \ 37 | seclang-parser.cc \ 38 | seclang-parser.hh \ 39 | location.hh \ 40 | position.hh \ 41 | stack.hh 42 | 43 | EXTRA_DIST = $(CLEANFILES) 44 | 45 | DISTCLAEN = 46 | -------------------------------------------------------------------------------- /src/parser/position.hh: -------------------------------------------------------------------------------- 1 | // A Bison parser, made by GNU Bison 3.8.2. 2 | 3 | // Starting with Bison 3.2, this file is useless: the structure it 4 | // used to define is now defined in "location.hh". 5 | // 6 | // To get rid of this file: 7 | // 1. add '%require "3.2"' (or newer) to your grammar file 8 | // 2. remove references to this file from your build system 9 | // 3. if you used to include it, include "location.hh" instead. 10 | 11 | #include "location.hh" 12 | -------------------------------------------------------------------------------- /src/parser/stack.hh: -------------------------------------------------------------------------------- 1 | // A Bison parser, made by GNU Bison 3.8.2. 2 | 3 | // Starting with Bison 3.2, this file is useless: the structure it 4 | // used to define is now defined with the parser itself. 5 | // 6 | // To get rid of this file: 7 | // 1. add '%require "3.2"' (or newer) to your grammar file 8 | // 2. remove references to this file from your build system. 9 | -------------------------------------------------------------------------------- /src/utils/decode.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "modsecurity/modsecurity.h" 22 | #include "src/utils/string.h" 23 | 24 | #ifndef SRC_UTILS_DECODE_H_ 25 | #define SRC_UTILS_DECODE_H_ 26 | 27 | 28 | namespace modsecurity { 29 | namespace utils { 30 | 31 | 32 | bool urldecode_nonstrict_inplace(std::string &val, 33 | int &invalid_count); 34 | std::string uri_decode(const std::string & sSrc); 35 | 36 | 37 | } // namespace utils 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_UTILS_DECODE_H_ 41 | -------------------------------------------------------------------------------- /src/utils/md5.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef SRC_UTILS_MD5_H_ 17 | #define SRC_UTILS_MD5_H_ 18 | 19 | #include "src/utils/sha1.h" 20 | #include "mbedtls/md5.h" 21 | #include 22 | 23 | namespace modsecurity::Utils { 24 | 25 | 26 | class Md5 : public DigestImpl<&mbedtls_md5, 16> { 27 | }; 28 | 29 | 30 | } // namespace modsecurity::Utils 31 | 32 | #endif // SRC_UTILS_MD5_H_ -------------------------------------------------------------------------------- /src/utils/random.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "modsecurity/modsecurity.h" 22 | 23 | #ifndef SRC_UTILS_RANDOM_H_ 24 | #define SRC_UTILS_RANDOM_H_ 25 | 26 | 27 | namespace modsecurity { 28 | namespace utils { 29 | 30 | 31 | double random_number(const double from, const double to); 32 | double generate_transaction_unique_id(); 33 | 34 | 35 | } // namespace utils 36 | } // namespace modsecurity 37 | 38 | 39 | #endif // SRC_UTILS_RANDOM_H_ 40 | -------------------------------------------------------------------------------- /src/variables/args.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_H_ 23 | #define SRC_VARIABLES_ARGS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | DEFINE_VARIABLE_DICT(Args, ARGS, m_variableArgs) 33 | 34 | 35 | } // namespace variables 36 | } // namespace modsecurity 37 | 38 | #endif // SRC_VARIABLES_ARGS_H_ 39 | 40 | -------------------------------------------------------------------------------- /src/variables/args_combined_size.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_COMBINED_SIZE_H_ 23 | #define SRC_VARIABLES_ARGS_COMBINED_SIZE_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ArgsCombinedSize, ARGS_COMBINED_SIZE, 34 | m_variableARGScombinedSize) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_ARGS_COMBINED_SIZE_H_ 41 | -------------------------------------------------------------------------------- /src/variables/args_get.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_GET_H_ 23 | #define SRC_VARIABLES_ARGS_GET_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ArgsGet, ARGS_GET, m_variableArgsGet) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_ARGS_GET_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/args_get_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_GET_NAMES_H_ 23 | #define SRC_VARIABLES_ARGS_GET_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ArgsGetNames, ARGS_GET_NAMES, m_variableArgsGetNames) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_ARGS_GET_NAMES_H_ 40 | -------------------------------------------------------------------------------- /src/variables/args_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_NAMES_H_ 23 | #define SRC_VARIABLES_ARGS_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ArgsNames, ARGS_NAMES, m_variableArgsNames) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_ARGS_NAMES_H_ 40 | -------------------------------------------------------------------------------- /src/variables/args_post.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_POST_H_ 23 | #define SRC_VARIABLES_ARGS_POST_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ArgsPost, ARGS_POST, m_variableArgsPost) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_ARGS_POST_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/args_post_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_ARGS_POST_NAMES_H_ 23 | #define SRC_VARIABLES_ARGS_POST_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ArgsPostNames, ARGS_POST_NAMES, m_variableArgsPostNames) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_ARGS_POST_NAMES_H_ 40 | -------------------------------------------------------------------------------- /src/variables/auth_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_AUTH_TYPE_H_ 23 | #define SRC_VARIABLES_AUTH_TYPE_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(AuthType, AUTH_TYPE, m_variableAuthType) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_AUTH_TYPE_H_ 40 | -------------------------------------------------------------------------------- /src/variables/files.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_H_ 23 | #define SRC_VARIABLES_FILES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(Files, FILES, m_variableFiles) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_FILES_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/files_combined_size.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_COMBINED_SIZE_H_ 23 | #define SRC_VARIABLES_FILES_COMBINED_SIZE_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(FilesCombinedSize, FILES_COMBINED_SIZE, 34 | m_variableFilesCombinedSize) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_FILES_COMBINED_SIZE_H_ 41 | -------------------------------------------------------------------------------- /src/variables/files_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_NAMES_H_ 23 | #define SRC_VARIABLES_FILES_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(FilesNames, FILES_NAMES, m_variableFilesNames) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_FILES_NAMES_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/files_sizes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_SIZES_H_ 23 | #define SRC_VARIABLES_FILES_SIZES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(FilesSizes, FILES_SIZES, m_variableFilesSizes) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_FILES_SIZES_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/files_tmp_content.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_TMP_CONTENT_H_ 23 | #define SRC_VARIABLES_FILES_TMP_CONTENT_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(FilesTmpContent, FILES_TMP_CONTENT, 34 | m_variableFilesTmpContent) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_FILES_TMP_CONTENT_H_ 41 | 42 | -------------------------------------------------------------------------------- /src/variables/files_tmp_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FILES_TMP_NAMES_H_ 23 | #define SRC_VARIABLES_FILES_TMP_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(FilesTmpNames, FILES_TMPNAMES, m_variableFilesTmpNames) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_FILES_TMP_NAMES_H_ 40 | -------------------------------------------------------------------------------- /src/variables/full_request.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FULL_REQUEST_H_ 23 | #define SRC_VARIABLES_FULL_REQUEST_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(FullRequest, FULL_REQUEST, m_variableFullRequest) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_FULL_REQUEST_H_ 40 | -------------------------------------------------------------------------------- /src/variables/full_request_length.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_FULL_REQUEST_LENGTH_H_ 23 | #define SRC_VARIABLES_FULL_REQUEST_LENGTH_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(FullRequestLength, FULL_REQUEST_LENGTH, 34 | m_variableFullRequestLength) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_FULL_REQUEST_LENGTH_H_ 41 | -------------------------------------------------------------------------------- /src/variables/geo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_GEO_H_ 23 | #define SRC_VARIABLES_GEO_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(Geo, GEO, m_variableGeo) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_GEO_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/inbound_data_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_INBOUND_DATA_ERROR_H_ 23 | #define SRC_VARIABLES_INBOUND_DATA_ERROR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(InboundDataError, INBOUND_DATA_ERROR, 34 | m_variableInboundDataError) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_INBOUND_DATA_ERROR_H_ 41 | -------------------------------------------------------------------------------- /src/variables/matched_var.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MATCHED_VAR_H_ 23 | #define SRC_VARIABLES_MATCHED_VAR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(MatchedVar, MATCHED_VAR, m_variableMatchedVar) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MATCHED_VAR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/matched_var_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MATCHED_VAR_NAME_H_ 23 | #define SRC_VARIABLES_MATCHED_VAR_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(MatchedVarName, MATCHED_VAR_NAME, m_variableMatchedVarName) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MATCHED_VAR_NAME_H_ 40 | -------------------------------------------------------------------------------- /src/variables/matched_vars.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MATCHED_VARS_H_ 23 | #define SRC_VARIABLES_MATCHED_VARS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(MatchedVars, MATCHED_VARS, m_variableMatchedVars) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MATCHED_VARS_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/matched_vars_names.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MATCHED_VARS_NAMES_H_ 23 | #define SRC_VARIABLES_MATCHED_VARS_NAMES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(MatchedVarsNames, MATCHED_VARS_NAMES, 34 | m_variableMatchedVarsNames) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_MATCHED_VARS_NAMES_H_ 41 | 42 | -------------------------------------------------------------------------------- /src/variables/modsec_build.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/variables/modsec_build.h" 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "modsecurity/transaction.h" 23 | 24 | namespace modsecurity { 25 | namespace variables { 26 | 27 | void ModsecBuild::evaluate(Transaction *transaction, 28 | RuleWithActions *rule, 29 | std::vector *l) { 30 | 31 | l->push_back(new VariableValue(&m_retName, &m_build)); 32 | } 33 | 34 | 35 | } // namespace variables 36 | } // namespace modsecurity 37 | -------------------------------------------------------------------------------- /src/variables/msc_pcre_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2022 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MSC_PCRE_ERROR_H_ 23 | #define SRC_VARIABLES_MSC_PCRE_ERROR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(MscPcreError, MSC_PCRE_ERROR, m_variableMscPcreError) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MSC_PCRE_ERROR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/multipart_data_after.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MULTIPART_DATA_AFTER_H_ 23 | #define SRC_VARIABLES_MULTIPART_DATA_AFTER_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(MultipartDateAfter, MULTIPART_DATA_AFTER, 34 | m_variableMultipartDataAfter) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_MULTIPART_DATA_AFTER_H_ 41 | -------------------------------------------------------------------------------- /src/variables/multipart_file_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MULTIPART_FILE_NAME_H_ 23 | #define SRC_VARIABLES_MULTIPART_FILE_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(MultiPartFileName, MULTIPART_FILENAME, 34 | m_variableMultipartFileName) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_MULTIPART_FILE_NAME_H_ 41 | 42 | -------------------------------------------------------------------------------- /src/variables/multipart_lf_line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MULTIPART_LF_LINE_H_ 23 | #define SRC_VARIABLES_MULTIPART_LF_LINE_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(MultipartLFLine, MULTIPART_LF_LINE, m_variableMultipartLFLine) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MULTIPART_LF_LINE_H_ 40 | -------------------------------------------------------------------------------- /src/variables/multipart_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_MULTIPART_NAME_H_ 23 | #define SRC_VARIABLES_MULTIPART_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(MultiPartName, MULTIPART_NAME, m_variableMultipartName) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_MULTIPART_NAME_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/outbound_data_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_OUTBOUND_DATA_ERROR_H_ 23 | #define SRC_VARIABLES_OUTBOUND_DATA_ERROR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(OutboundDataError, OUTBOUND_DATA_ERROR, 34 | m_variableOutboundDataError) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_OUTBOUND_DATA_ERROR_H_ 41 | -------------------------------------------------------------------------------- /src/variables/path_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_PATH_INFO_H_ 23 | #define SRC_VARIABLES_PATH_INFO_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(PathInfo, PATH_INFO, m_variablePathInfo) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_PATH_INFO_H_ 40 | -------------------------------------------------------------------------------- /src/variables/query_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_QUERY_STRING_H_ 23 | #define SRC_VARIABLES_QUERY_STRING_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(QueryString, QUERY_STRING, m_variableQueryString) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_QUERY_STRING_H_ 40 | -------------------------------------------------------------------------------- /src/variables/remote_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REMOTE_ADDR_H_ 23 | #define SRC_VARIABLES_REMOTE_ADDR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RemoteAddr, REMOTE_ADDR, m_variableRemoteAddr) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REMOTE_ADDR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/remote_host.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REMOTE_HOST_H_ 23 | #define SRC_VARIABLES_REMOTE_HOST_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RemoteHost, REMOTE_HOST, m_variableRemoteHost) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REMOTE_HOST_H_ 40 | -------------------------------------------------------------------------------- /src/variables/remote_port.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REMOTE_PORT_H_ 23 | #define SRC_VARIABLES_REMOTE_PORT_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RemotePort, REMOTE_PORT, m_variableRemotePort) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REMOTE_PORT_H_ 40 | -------------------------------------------------------------------------------- /src/variables/reqbody_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQBODY_ERROR_H_ 23 | #define SRC_VARIABLES_REQBODY_ERROR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ReqbodyError, REQBODY_ERROR, m_variableReqbodyError) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQBODY_ERROR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/reqbody_error_msg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQBODY_ERROR_MSG_H_ 23 | #define SRC_VARIABLES_REQBODY_ERROR_MSG_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ReqbodyErrorMsg, REQBODY_ERROR_MSG, m_variableReqbodyErrorMsg) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQBODY_ERROR_MSG_H_ 40 | -------------------------------------------------------------------------------- /src/variables/reqbody_processor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQBODY_PROCESSOR_H_ 23 | #define SRC_VARIABLES_REQBODY_PROCESSOR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ReqbodyProcessor, REQBODY_PROCESSOR, m_variableReqbodyProcessor) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQBODY_PROCESSOR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_base_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_BASE_NAME_H_ 23 | #define SRC_VARIABLES_REQUEST_BASE_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestBasename, REQUEST_BASENAME, m_variableRequestBasename) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_BASE_NAME_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_body.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_BODY_H_ 23 | #define SRC_VARIABLES_REQUEST_BODY_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestBody, REQUEST_BODY, m_variableRequestBody) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_BODY_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_body_length.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_BODY_LENGTH_H_ 23 | #define SRC_VARIABLES_REQUEST_BODY_LENGTH_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestBodyLength, REQUEST_BODY_LENGTH, 34 | m_variableRequestBodyLength) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_REQUEST_BODY_LENGTH_H_ 41 | -------------------------------------------------------------------------------- /src/variables/request_cookies.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_COOKIES_H_ 23 | #define SRC_VARIABLES_REQUEST_COOKIES_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(RequestCookies, REQUEST_COOKIES, m_variableRequestCookies) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_COOKIES_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/request_file_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_FILE_NAME_H_ 23 | #define SRC_VARIABLES_REQUEST_FILE_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestFilename, REQUEST_FILENAME, m_variableRequestFilename) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_FILE_NAME_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_headers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_HEADERS_H_ 23 | #define SRC_VARIABLES_REQUEST_HEADERS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(RequestHeaders, REQUEST_HEADERS, m_variableRequestHeaders) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_HEADERS_H_ 40 | 41 | -------------------------------------------------------------------------------- /src/variables/request_line.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_LINE_H_ 23 | #define SRC_VARIABLES_REQUEST_LINE_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestLine, REQUEST_LINE, m_variableRequestLine) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_LINE_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_method.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_METHOD_H_ 23 | #define SRC_VARIABLES_REQUEST_METHOD_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestMethod, REQUEST_METHOD, m_variableRequestMethod) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_METHOD_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_PROTOCOL_H_ 23 | #define SRC_VARIABLES_REQUEST_PROTOCOL_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestProtocol, REQUEST_PROTOCOL, m_variableRequestProtocol) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_PROTOCOL_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_uri.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_URI_H_ 23 | #define SRC_VARIABLES_REQUEST_URI_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestURI, REQUEST_URI, m_variableRequestURI) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_URI_H_ 40 | -------------------------------------------------------------------------------- /src/variables/request_uri_raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_REQUEST_URI_RAW_H_ 23 | #define SRC_VARIABLES_REQUEST_URI_RAW_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(RequestURIRaw, REQUEST_URI_RAW, m_variableRequestURIRaw) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_REQUEST_URI_RAW_H_ 40 | -------------------------------------------------------------------------------- /src/variables/response_body.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_RESPONSE_BODY_H_ 23 | #define SRC_VARIABLES_RESPONSE_BODY_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ResponseBody, RESPONSE_BODY, m_variableResponseBody) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_RESPONSE_BODY_H_ 40 | -------------------------------------------------------------------------------- /src/variables/response_headers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_RESPONSE_HEADERS_H_ 23 | #define SRC_VARIABLES_RESPONSE_HEADERS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE_DICT(ResponseHeaders, RESPONSE_HEADERS, 34 | m_variableResponseHeaders) 35 | 36 | 37 | } // namespace variables 38 | } // namespace modsecurity 39 | 40 | #endif // SRC_VARIABLES_RESPONSE_HEADERS_H_ 41 | 42 | -------------------------------------------------------------------------------- /src/variables/response_protocol.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_RESPONSE_PROTOCOL_H_ 23 | #define SRC_VARIABLES_RESPONSE_PROTOCOL_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ResponseProtocol, RESPONSE_PROTOCOL, m_variableResponseProtocol) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_RESPONSE_PROTOCOL_H_ 40 | -------------------------------------------------------------------------------- /src/variables/response_status.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_RESPONSE_STATUS_H_ 23 | #define SRC_VARIABLES_RESPONSE_STATUS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ResponseStatus, RESPONSE_STATUS, m_variableResponseStatus) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_RESPONSE_STATUS_H_ 40 | -------------------------------------------------------------------------------- /src/variables/rule.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/variables/rule.h" 17 | 18 | 19 | namespace modsecurity { 20 | namespace variables { 21 | 22 | 23 | const std::string Rule_DictElement::m_rule("RULE"); 24 | const std::string Rule_DictElement::m_rule_id("id"); 25 | const std::string Rule_DictElement::m_rule_rev("rev"); 26 | const std::string Rule_DictElement::m_rule_severity("severity"); 27 | const std::string Rule_DictElement::m_rule_logdata("logdata"); 28 | const std::string Rule_DictElement::m_rule_msg("msg"); 29 | 30 | 31 | } // namespace variables 32 | } // namespace modsecurity 33 | -------------------------------------------------------------------------------- /src/variables/server_addr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_SERVER_ADDR_H_ 23 | #define SRC_VARIABLES_SERVER_ADDR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ServerAddr, SERVER_ADDR, m_variableServerAddr) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_SERVER_ADDR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/server_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_SERVER_NAME_H_ 23 | #define SRC_VARIABLES_SERVER_NAME_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ServerName, SERVER_NAME, m_variableServerName) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_SERVER_NAME_H_ 40 | -------------------------------------------------------------------------------- /src/variables/server_port.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_SERVER_PORT_H_ 23 | #define SRC_VARIABLES_SERVER_PORT_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(ServerPort, SERVER_PORT, m_variableServerPort) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_SERVER_PORT_H_ 40 | -------------------------------------------------------------------------------- /src/variables/session_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_SESSION_ID_H_ 23 | #define SRC_VARIABLES_SESSION_ID_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | DEFINE_VARIABLE(SessionID, SESSIONID, m_variableSessionID) 33 | 34 | 35 | } // namespace variables 36 | } // namespace modsecurity 37 | 38 | #endif // SRC_VARIABLES_SESSION_ID_H_ 39 | -------------------------------------------------------------------------------- /src/variables/status.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_STATUS_H_ 23 | #define SRC_VARIABLES_STATUS_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(Status, STATUS, m_variableResponseStatus) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_STATUS_H_ 40 | -------------------------------------------------------------------------------- /src/variables/tx.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include "src/variables/tx.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "modsecurity/transaction.h" 32 | 33 | namespace modsecurity { 34 | namespace variables { 35 | 36 | 37 | 38 | } // namespace variables 39 | } // namespace modsecurity 40 | -------------------------------------------------------------------------------- /src/variables/unique_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_UNIQUE_ID_H_ 23 | #define SRC_VARIABLES_UNIQUE_ID_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(UniqueID, UNIQUEID, m_variableUniqueID) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_UNIQUE_ID_H_ 40 | -------------------------------------------------------------------------------- /src/variables/url_encoded_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_URL_ENCODED_ERROR_H_ 23 | #define SRC_VARIABLES_URL_ENCODED_ERROR_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(UrlEncodedError, URLENCODED_ERROR, m_variableUrlEncodedError) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_URL_ENCODED_ERROR_H_ 40 | -------------------------------------------------------------------------------- /src/variables/user_id.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #ifndef SRC_VARIABLES_USER_ID_H_ 23 | #define SRC_VARIABLES_USER_ID_H_ 24 | 25 | #include "src/variables/variable.h" 26 | 27 | namespace modsecurity { 28 | 29 | class Transaction; 30 | namespace variables { 31 | 32 | 33 | DEFINE_VARIABLE(UserID, USERID, m_variableUserID) 34 | 35 | 36 | } // namespace variables 37 | } // namespace modsecurity 38 | 39 | #endif // SRC_VARIABLES_USER_ID_H_ 40 | -------------------------------------------------------------------------------- /test/.empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/test/.empty -------------------------------------------------------------------------------- /test/benchmark/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_PROGRAMS = benchmark 4 | 5 | benchmark_SOURCES = \ 6 | benchmark.cc 7 | 8 | benchmark_LDADD = \ 9 | $(CURL_LDADD) \ 10 | $(GEOIP_LDADD) \ 11 | $(MAXMIND_LDADD) \ 12 | $(PCRE_LDADD) \ 13 | $(PCRE2_LDADD) \ 14 | $(YAJL_LDADD) \ 15 | $(LMDB_LDADD) \ 16 | $(SSDEEP_LDADD) \ 17 | $(LUA_LDADD) \ 18 | $(LIBXML2_LDADD) \ 19 | $(GLOBAL_LDADD) 20 | 21 | benchmark_LDFLAGS = \ 22 | -L$(top_builddir)/src/.libs/ \ 23 | $(GEOIP_LDFLAGS) \ 24 | -lmodsecurity \ 25 | -lpthread \ 26 | -lm \ 27 | -lstdc++ \ 28 | $(GEOIP_LDFLAGS) \ 29 | $(MAXMIND_LDFLAGS) \ 30 | $(YAJL_LDFLAGS) \ 31 | $(LMDB_LDFLAGS) \ 32 | $(SSDEEP_LDFLAGS) \ 33 | $(LUA_LDFLAGS) 34 | 35 | benchmark_CPPFLAGS = \ 36 | -I$(top_builddir)/headers \ 37 | $(GLOBAL_CPPFLAGS) \ 38 | $(PCRE_CFLAGS) \ 39 | $(PCRE2_CFLAGS) \ 40 | $(LMDB_CFLAGS) \ 41 | $(LIBXML2_CFLAGS) 42 | 43 | MAINTAINERCLEANFILES = \ 44 | Makefile.in 45 | 46 | -------------------------------------------------------------------------------- /test/benchmark/basic_rules.conf: -------------------------------------------------------------------------------- 1 | 2 | Include "../../modsecurity.conf-recommended" 3 | 4 | -------------------------------------------------------------------------------- /test/benchmark/download-owasp-v3-rules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone -c advice.detachedHead=false --depth 1 --branch v3.0.2 https://github.com/coreruleset/coreruleset.git owasp-v3 4 | 5 | echo 'Include "owasp-v3/crs-setup.conf.example"' >> basic_rules.conf 6 | echo 'Include "owasp-v3/rules/*.conf"' >> basic_rules.conf 7 | 8 | echo "Done." 9 | 10 | -------------------------------------------------------------------------------- /test/benchmark/download-owasp-v4-rules.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone -c advice.detachedHead=false --depth 1 --branch v4.3.0 https://github.com/coreruleset/coreruleset.git owasp-v4 4 | 5 | echo 'Include "owasp-v4/crs-setup.conf.example"' >> basic_rules.conf 6 | echo 'Include "owasp-v4/rules/*.conf"' >> basic_rules.conf 7 | 8 | echo "Done." 9 | 10 | -------------------------------------------------------------------------------- /test/common/colors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #ifndef TEST_COMMON_COLORS_H_ 17 | #define TEST_COMMON_COLORS_H_ 18 | 19 | 20 | #define KNRM "\x1B[0m" 21 | #define KRED "\x1B[31m" 22 | #define KGRN "\x1B[32m" 23 | #define KYEL "\x1B[33m" 24 | #define KBLU "\x1B[34m" 25 | #define KMAG "\x1B[35m" 26 | #define KCYN "\x1B[36m" 27 | #define KWHT "\x1B[97m" 28 | #define RESET "\033[0m" 29 | 30 | 31 | #endif // TEST_COMMON_COLORS_H_ 32 | -------------------------------------------------------------------------------- /test/common/modsecurity_test_results.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ModSecurity, http://www.modsecurity.org/ 3 | * Copyright (c) 2015 - 2021 Trustwave Holdings, Inc. (http://www.trustwave.com/) 4 | * 5 | * You may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * If any of the files related to licensing are missing or if you have any 11 | * other questions related to licensing please contact Trustwave Holdings, Inc. 12 | * directly using the email address security@modsecurity.org. 13 | * 14 | */ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #ifndef TEST_COMMON_MODSECURITY_TEST_RESULTS_H_ 22 | #define TEST_COMMON_MODSECURITY_TEST_RESULTS_H_ 23 | 24 | namespace modsecurity_test { 25 | 26 | template class ModSecurityTestResults : public std::vector { 27 | public: 28 | std::string log_raw_debug_log; 29 | int status; 30 | std::string location; 31 | }; 32 | 33 | } // namespace modsecurity_test 34 | 35 | #endif // TEST_COMMON_MODSECURITY_TEST_RESULTS_H_ 36 | -------------------------------------------------------------------------------- /test/fuzzer/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | # make clean 4 | CLEANFILES = 5 | 6 | # make maintainer-clean 7 | MAINTAINERCLEANFILES = \ 8 | Makefile.in 9 | 10 | 11 | noinst_PROGRAMS = afl_fuzzer 12 | 13 | afl_fuzzer_SOURCES = \ 14 | afl_fuzzer.cc 15 | 16 | afl_fuzzer_LDADD = \ 17 | $(GLOBAL_LDADD) \ 18 | $(CURL_LDADD) \ 19 | $(GEOIP_LDFLAGS) $(GEOIP_LDADD) \ 20 | $(PCRE_LDADD) \ 21 | $(PCRE2_LDADD) \ 22 | $(YAJL_LDFLAGS) $(YAJL_LDADD) \ 23 | $(LMDB_LDFLAGS) $(LMDB_LDADD) \ 24 | $(MAXMIND_LDFLAGS) $(MAXMIND_LDADD) \ 25 | $(SSDEEP_LDFLAGS) $(SSDEEP_LDADD) \ 26 | $(LUA_LDFLAGS) $(LUA_LDADD) \ 27 | $(LIBXML2_LDADD) \ 28 | $(top_builddir)/src/.libs/libmodsecurity.a \ 29 | $(top_builddir)/others/libinjection.la \ 30 | $(top_builddir)/others/libmbedtls.la 31 | 32 | 33 | afl_fuzzer_CPPFLAGS = \ 34 | -Icommon \ 35 | -I../ \ 36 | -I../../ \ 37 | -O0 \ 38 | -g \ 39 | -I$(top_builddir)/headers \ 40 | $(CURL_CFLAGS) \ 41 | $(GEOIP_CFLAGS) \ 42 | $(MAXMIND_CFLAGS) \ 43 | $(GLOBAL_CPPFLAGS) \ 44 | $(MODSEC_NO_LOGS) \ 45 | $(YAJL_CFLAGS) \ 46 | $(LMDB_CFLAGS) \ 47 | $(PCRE_CFLAGS) \ 48 | $(PCRE2_CFLAGS) \ 49 | $(LIBXML2_CFLAGS) 50 | -------------------------------------------------------------------------------- /test/modsecurity-regression-ip-list.txt: -------------------------------------------------------------------------------- 1 | 127.0.0.1 2 | 8.8.4.4 3 | -------------------------------------------------------------------------------- /test/modsecurity-regression-rules.txt: -------------------------------------------------------------------------------- 1 | SecRule REQUEST_FILENAME "@pmFromFile https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/refs/heads/v3/master/test/modsecurity-regression-ip-list.txt" "id:'123',phase:2,log,pass,t:none" 2 | -------------------------------------------------------------------------------- /test/regression-tests-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | valgrind --tool=massif ./regression_tests $* 4 | valgrind --leak-check=full --suppressions=./valgrind_suppressions.txt ./regression_tests $* 5 | -------------------------------------------------------------------------------- /test/test-cases/data/GeoIP2-City-Test.mmdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/test/test-cases/data/GeoIP2-City-Test.mmdb -------------------------------------------------------------------------------- /test/test-cases/data/SoapEnvelope-bad.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/test-cases/data/SoapEnvelope.dtd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/test-cases/data/config_example-bad-op-include.txt: -------------------------------------------------------------------------------- 1 | SecRule ARGS "@contains config_example" "id:10,pass,t:trim" 2 | SecRule ARGS 123 "@missingOperator config_example" "id:11,pass,t:trim" 3 | -------------------------------------------------------------------------------- /test/test-cases/data/config_example-ops-include.txt: -------------------------------------------------------------------------------- 1 | Include test-cases/data/config_example-not-exist.txt -------------------------------------------------------------------------------- /test/test-cases/data/config_example.txt: -------------------------------------------------------------------------------- 1 | Include test-cases/data/config_example2.txt 2 | SecRule ARGS "@contains config_example" "id:101,pass,t:trim" -------------------------------------------------------------------------------- /test/test-cases/data/config_example2.txt: -------------------------------------------------------------------------------- 1 | SecRule ARGS "@contains config_example2" "id:40,pass,t:trim" -------------------------------------------------------------------------------- /test/test-cases/data/config_example3.txt: -------------------------------------------------------------------------------- 1 | Include test-cases/data/config_example2.txt 2 | SecRule ARGS "@contains config_example" ops "id:1000,pass,t:trim" -------------------------------------------------------------------------------- /test/test-cases/data/geo/GeoIPCity.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/test/test-cases/data/geo/GeoIPCity.dat -------------------------------------------------------------------------------- /test/test-cases/data/geo/README.txt: -------------------------------------------------------------------------------- 1 | This data was download from: 2 | 3 | https://github.com/maxmind/geoip-api-php/tree/master/tests 4 | 5 | -------------------------------------------------------------------------------- /test/test-cases/data/inspectFile-abcdef.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/lua 2 | 3 | function main(filename) 4 | local file = io.open(filename, 'r') 5 | local chunk = file:read(1024) 6 | local ret = string.match(chunk, 'abcdef') 7 | io.close(file) 8 | 9 | return ret 10 | end 11 | -------------------------------------------------------------------------------- /test/test-cases/data/ipMatchFromFile.txt: -------------------------------------------------------------------------------- 1 | 127.0.0.1 2 | 3 | # Comment line 4 | 10.10.10.1 5 | ::1 6 | 200.249.12.31 7 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvar-multi-transformations.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | ret = nil 3 | m.log(9, "Lets rock."); 4 | 5 | var = m.getvar("tx.test" , { "lowercase", "uppercase" }); 6 | if var == nil then 7 | m.log(9, "Don't know what to say..."); 8 | return ret; 9 | end 10 | 11 | if var == "FELIPE" then 12 | m.log(9, "Whee. Working like a charm. That is what we have: " .. var); 13 | elseif var == "felipe" then 14 | m.log(9, "Oh boy. Got: " .. var); 15 | ret ="ok"; 16 | else 17 | m.log(9, "Really?"); 18 | end 19 | 20 | return "whee" 21 | end 22 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvar-transformation.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | ret = nil 3 | m.log(9, "Lets rock."); 4 | 5 | var = m.getvar("tx.test" , "lowercase"); 6 | if var == nil then 7 | m.log(9, "Don't know what to say..."); 8 | return ret; 9 | end 10 | 11 | if var == "FELIPE" then 12 | m.log(9, "Ops."); 13 | elseif var == "felipe" then 14 | m.log(9, "Just fine."); 15 | ret ="ok"; 16 | else 17 | m.log(9, "Really?"); 18 | end 19 | 20 | return "whee" 21 | end 22 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvar-withTnfs.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | ret = nil 3 | 4 | var = m.getvar("tx.test", "lowercase"); 5 | 6 | return ret 7 | end 8 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvar.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | ret = nil 3 | 4 | num = m.getvar("tx.test"); 5 | if num == nil then 6 | m.log(9, "Don't know what to say about this so called number."); 7 | return ret 8 | end 9 | num = tonumber(num) 10 | 11 | if num > 1 then 12 | m.log(9, "Number is bigger than one."); 13 | ret = "Whee :)" 14 | else 15 | m.log(9, "Really?"); 16 | end 17 | 18 | return ret 19 | end 20 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvars-args.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | local d = m.getvars("ARGS"); 3 | local size = #d; 4 | m.log(9,"ARGS count read =" .. tostring(size)); 5 | 6 | ret = nil 7 | 8 | if ( #d == 2 ) then 9 | return nil 10 | end 11 | 12 | return "Unexpected result" 13 | end 14 | -------------------------------------------------------------------------------- /test/test-cases/data/match-getvars.lua: -------------------------------------------------------------------------------- 1 | function dump(o) 2 | if type(o) == 'table' then 3 | local s = '{ ' 4 | for k,v in pairs(o) do 5 | if type(k) ~= 'number' then k = '"'..k..'"' end 6 | s = s .. '['..k..'] = ' .. dump(v) .. ',' 7 | end 8 | return s .. '} ' 9 | else 10 | return tostring(o) 11 | end 12 | end 13 | 14 | function main() 15 | ret = nil 16 | m.log(9, "Here I am"); 17 | z = m.getvars("QUERY_STRING"); 18 | m.log(9, "Z: " .. dump(z)) 19 | 20 | return ret 21 | end 22 | -------------------------------------------------------------------------------- /test/test-cases/data/match-log.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | m.log(9, "echo 123"); 3 | return "Lua script matched."; 4 | end 5 | -------------------------------------------------------------------------------- /test/test-cases/data/match-set.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | m.log(9, "echo 123"); 3 | m.setvar("tx.test", "whee"); 4 | return "Lua script matched."; 5 | end 6 | -------------------------------------------------------------------------------- /test/test-cases/data/match.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | return "Lua script matched."; 3 | end 4 | -------------------------------------------------------------------------------- /test/test-cases/data/not-so-big-file.conf: -------------------------------------------------------------------------------- 1 | # 1 2 | # 2 3 | # 3 4 | # 4 5 | # 5 6 | # 6 7 | # 7 8 | # 8 9 | 10 | # 10 11 | # 11 12 | # 12 13 | 14 | Include "big-file.conf" 15 | 16 | # 18 17 | # 19 18 | # 20 19 | 20 | # 22 21 | # 23 22 | # 24 23 | # 25 24 | # 26 25 | # 27 26 | # 28 27 | -------------------------------------------------------------------------------- /test/test-cases/data/setvar.lua: -------------------------------------------------------------------------------- 1 | function main() 2 | var = 2; 3 | m.setvar("TX.lua_set_var", var); 4 | m.setvar("IP.lua_set_var", var); 5 | m.setvar("GLOBAL.lua_set_var", var); 6 | m.setvar("RESOURCE.lua_set_var", var); 7 | m.setvar("SESSION.lua_set_var", var); 8 | m.setvar("USER.lua_set_var", var); 9 | return nil; 10 | end 11 | -------------------------------------------------------------------------------- /test/test-cases/data/ssdeep.txt: -------------------------------------------------------------------------------- 1 | ssdeep,1.1--blocksize:hash:hash,filename 2 | 96:MbQ1L0LDX8GPI8ov3D2D9zd6/gz2wZhFvV0O598La8Kqvfi0znNa8Xi5SM7XRWCK:KvL8Gg8rWIz2ZKqvfjzQ55RpRHjftQ++,"modsecurity.conf-recommended" 3 | 192:b8B5UQvywcMIJuavpde/Yyz/U/vF+vGCoCvrQr/dw:afcnrvp8zqUvGrzr6,"README_WINDOWS.TXT" 4 | 96:+qK8Z4gA165/hquKNMi68zuEyMM9qNB26x:+RG4z6c1LyZOB26x,"README.TXT" 5 | -------------------------------------------------------------------------------- /test/test-cases/data/test.lua: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owasp-modsecurity/ModSecurity/31507404e6a6c0da46a85b478301fc73b8c202d4/test/test-cases/data/test.lua -------------------------------------------------------------------------------- /test/test-cases/data/unicode.mapping-reduced: -------------------------------------------------------------------------------- 1 | 1251 0434:64 043e:6f 0440:70 2 | -------------------------------------------------------------------------------- /test/test-cases/regression/config-update-target-by-msg.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"SecRuleUpdateTargetByTag", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host":"localhost", 17 | "User-Agent":"curl/7.38.0", 18 | "Accept":"*/*" 19 | }, 20 | "uri":"/?key=value&key=other_value", 21 | "method":"GET" 22 | }, 23 | "response":{ 24 | "headers":{ 25 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 26 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 27 | "Content-Type":"text/html" 28 | }, 29 | "body":[ 30 | "no need." 31 | ] 32 | }, 33 | "expected":{ 34 | "http_code": 200 35 | }, 36 | "rules":[ 37 | "SecRuleEngine On", 38 | "SecRuleUpdateTargetByMsg test !ARGS", 39 | "SecRule ARGS \"@contains value\" \"id:1,pass,t:trim,msg:'test',deny\"" 40 | ] 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /test/test-cases/regression/fn-setHostname.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing function :: setRequestHostName", 6 | "client": { 7 | "ip":"200.249.12.31" 8 | }, 9 | "server":{ 10 | "ip":"200.249.12.31", 11 | "port":80, 12 | "hostname":"modsecurity.org" 13 | }, 14 | "request": { 15 | "headers": { 16 | "Host":"www.modsecurity.org" 17 | }, 18 | "uri":"/foo?q=attack", 19 | "http_version": 1.1 20 | }, 21 | "response":{ 22 | "headers":{ 23 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 24 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 25 | "Content-Type":"text/plain" 26 | }, 27 | "body":[ 28 | "denystring" 29 | ] 30 | }, 31 | "expected":{ 32 | "http_code": 403, 33 | "debug_log": "[hostname: \"modsecurity.org\"]" 34 | }, 35 | "rules":[ 36 | "SecRuleEngine On", 37 | "SecResponseBodyAccess On", 38 | "SecRule ARGS_GET \"@contains attack\" \"id:1,phase:2,deny\"" 39 | ] 40 | } 41 | ] 42 | -------------------------------------------------------------------------------- /test/test-cases/regression/issue-1528.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled": 1, 4 | "version_min": 209000, 5 | "version_max": -1, 6 | "title": "Macro expansion inside regex does not work", 7 | "url": "https:\/\/github.com\/SpiderLabs\/ModSecurity\/issues\/1528", 8 | "gihub_issue": 1528, 9 | "client": { 10 | "ip": "200.249.12.31", 11 | "port": 2313 12 | }, 13 | "server": { 14 | "ip": "200.249.12.31", 15 | "port": 80 16 | }, 17 | "request": { 18 | "uri":"/?param=attack", 19 | "headers": "", 20 | "body": "", 21 | "method": "GET", 22 | "http_version": 1.1 23 | }, 24 | "response": { 25 | "headers": "", 26 | "body": "" 27 | }, 28 | "expected": { 29 | "debug_log": "Rule returned 1", 30 | "error_log": "Matched \"Operator `Rx' with parameter `\\^attack\\$'" 31 | }, 32 | "rules": [ 33 | "SecRuleEngine On", 34 | "SecAction \"id:1, nolog, setvar:tx.bad_value=attack\"", 35 | "SecRule ARGS:param \"@rx ^%{tx.bad_value}$\" \"id:2,block\"" 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /test/test-cases/regression/issue-1960.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"SecRuleEngine DetectionOnly with disruptive SecDefaultAction", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host": "localhost" 17 | }, 18 | "uri":"?a=a", 19 | "method":"GET" 20 | }, 21 | "response":{ 22 | "headers":{ 23 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 24 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 25 | "Content-Type":"text/html" 26 | }, 27 | "body":[ 28 | "no need." 29 | ] 30 | }, 31 | "expected":{ 32 | "http_code":200 33 | }, 34 | "rules":[ 35 | "SecRuleEngine DetectionOnly", 36 | "SecDefaultAction \"phase:1,deny,status:403\"", 37 | "SecRule ARGS \"@rx a\" \"id:1,phase:1,block" 38 | ] 39 | } 40 | ] 41 | -------------------------------------------------------------------------------- /test/test-cases/regression/issue-2111.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing ctl:ruleRemoveById with range - issue 1444", 6 | "expected":{ 7 | "http_code":200 8 | }, 9 | "client":{ 10 | "ip":"127.0.0.1", 11 | "port":123 12 | }, 13 | "request":{ 14 | "headers":{ 15 | "Host":"localhost", 16 | "User-Agent":"curl/7.38.0", 17 | "Accept":"*/*" 18 | }, 19 | "uri":"index.php?foo=bar&z=xxx", 20 | "method":"GET", 21 | "body": "" 22 | }, 23 | "server":{ 24 | "ip":"127.0.0.1", 25 | "port":80 26 | }, 27 | "rules":[ 28 | "SecRuleEngine On", 29 | "SecRule ARGS:foo \"@rx ^bar$\" \"id:100,phase:1,ctl:ruleRemoveById=200-1999\"", 30 | "SecRule ARGS:z \"@rx ^xxx$\" \"id:1010,phase:1,deny,status:403\"" 31 | ] 32 | } 33 | ] 34 | -------------------------------------------------------------------------------- /test/test-cases/regression/issue-394.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled": 1, 4 | "version_min": 209000, 5 | "version_max": -1, 6 | "title": "Segmentation fault when uploading file with SecStreamInBodyInspection enabled", 7 | "url": "https:\/\/github.com\/SpiderLabs\/ModSecurity\/issues\/394", 8 | "gihub_issue": 394, 9 | "client": { 10 | "ip": "200.249.12.31", 11 | "port": 2313 12 | }, 13 | "server": { 14 | "ip": "200.249.12.31", 15 | "port": 80 16 | }, 17 | "request": { 18 | "headers": "", 19 | "body": "", 20 | "method": "GET", 21 | "http_version": 1.1 22 | }, 23 | "response": { 24 | "headers": "", 25 | "body": "" 26 | }, 27 | "expected": { 28 | "audit_logs": "", 29 | "debug_logs": "", 30 | "error_logs": "" 31 | }, 32 | "rules": [ 33 | "SecRuleEngine On", 34 | "SecRequestBodyAccess On", 35 | "SecResponseBodyAccess On" 36 | ] 37 | } 38 | ] 39 | -------------------------------------------------------------------------------- /test/test-cases/regression/misc.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "version_max":0, 6 | "title":"Testing action :: SecRule directives should be case insensitive", 7 | "expected":{ 8 | "audit_log":"", 9 | "debug_log":"Executing operator \"Contains\" with param \"PHPSESSID\" against REQUEST_HEADERS.", 10 | "error_log":"" 11 | }, 12 | "rules":[ 13 | "secruleengine On", 14 | "secrule REQUEST_HEADERS \"@contains PHPSESSID\" \"id:1,t:lowercase,t:none,msg:'This is a test, %{REQUEST_HEADERS:Accept}%'\"", 15 | "secrule TX \"@contains to_test\" \"id:2,t:lowercase,t:none\"" 16 | ] 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/test-cases/regression/operator-validate-byte-range.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing Operator :: @validateByteRange with bytes > 127", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host":"localhost", 17 | "User-Agent":"curl/7.38.0", 18 | "Accept":"*/*", 19 | "Content-Length": "27", 20 | "Content-Type": "application/x-www-form-urlencoded" 21 | }, 22 | "uri":"/%D0%A2%D0%B0%D1%80%D0%B0%D0%B1%D0%B0%D0%BD", 23 | "method":"GET", 24 | "body": [ ] 25 | }, 26 | "response":{ 27 | "headers":{}, 28 | "body":[ 29 | "no need." 30 | ] 31 | }, 32 | "expected":{ 33 | "debug_log":"Rule returned 0." 34 | }, 35 | "rules":[ 36 | "SecRuleEngine On", 37 | "SecRule REQUEST_URI \"@validateByteRange 37-102, 127-255\" \"id:1,phase:2,pass,t:trim\"" 38 | ] 39 | } 40 | ] 41 | -------------------------------------------------------------------------------- /test/test-cases/regression/variable-REQUEST_METHOD.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing Variables :: REQUEST_METHOD", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host":"localhost", 17 | "User-Agent":"curl/7.38.0", 18 | "Accept":"*/*" 19 | }, 20 | "uri":"/?key=value&key=other_value", 21 | "method":"GET", 22 | "http_version":1.1 23 | }, 24 | "response":{ 25 | "headers":{ 26 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 27 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 28 | "Content-Type":"text/html" 29 | }, 30 | "body":[ 31 | "no need." 32 | ] 33 | }, 34 | "expected":{ 35 | "debug_log":"Target value: \"GET\" \\(Variable: REQUEST_METHOD\\)" 36 | }, 37 | "rules":[ 38 | "SecRuleEngine On", 39 | "SecRule REQUEST_METHOD \"@contains test \" \"id:1,pass,t:trim\"" 40 | ] 41 | } 42 | ] 43 | 44 | -------------------------------------------------------------------------------- /test/test-cases/regression/variable-REQUEST_PROTOCOL.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing Variables :: REQUEST_PROTOCOL", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host":"localhost", 17 | "User-Agent":"curl/7.38.0", 18 | "Accept":"*/*" 19 | }, 20 | "uri":"/?key=value&key=other_value", 21 | "method":"GET", 22 | "http_version":1.1 23 | }, 24 | "response":{ 25 | "headers":{ 26 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 27 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 28 | "Content-Type":"text/html" 29 | }, 30 | "body":[ 31 | "no need." 32 | ] 33 | }, 34 | "expected":{ 35 | "debug_log":"Target value: \"HTTP/1.1\" \\(Variable: REQUEST_PROTOCOL\\)" 36 | }, 37 | "rules":[ 38 | "SecRuleEngine On", 39 | "SecRule REQUEST_PROTOCOL \"@contains test \" \"id:1,pass,t:trim\"" 40 | ] 41 | } 42 | ] 43 | 44 | -------------------------------------------------------------------------------- /test/test-cases/regression/variable-RESPONSE_BODY.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing Variables :: RESPONSE_BODY", 6 | "client": { 7 | "ip":"200.249.12.31" 8 | }, 9 | "request": { 10 | "headers": { 11 | "Host":"localhost" 12 | }, 13 | "uri":"/foo", 14 | "http_version":1.1 15 | }, 16 | "response":{ 17 | "headers":{ 18 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 19 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 20 | "Content-Type":"text/plain" 21 | }, 22 | "body":[ 23 | "denystring" 24 | ] 25 | }, 26 | "expected":{ 27 | "http_code": 403 28 | }, 29 | "rules":[ 30 | "SecRuleEngine On", 31 | "SecResponseBodyAccess On", 32 | "SecRule RESPONSE_BODY \"@contains denystring\" \"id:1,phase:4,deny\"" 33 | ] 34 | } 35 | ] 36 | -------------------------------------------------------------------------------- /test/test-cases/regression/variable-RESPONSE_CONTENT_TYPE.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "title":"Testing Variables :: RESPONSE_CONTENT_TYPE", 6 | "client":{ 7 | "ip":"200.249.12.31", 8 | "port":123 9 | }, 10 | "server":{ 11 | "ip":"200.249.12.31", 12 | "port":80 13 | }, 14 | "request":{ 15 | "headers":{ 16 | "Host":"localhost", 17 | "User-Agent":"curl/7.38.0", 18 | "Accept":"*/*" 19 | }, 20 | "uri":"/?key=value&key=other_value", 21 | "method":"GET", 22 | "http_version":1.1 23 | }, 24 | "response":{ 25 | "headers":{ 26 | "Date":"Mon, 13 Jul 2015 20:02:41 GMT", 27 | "Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT", 28 | "Content-Type":"text/html" 29 | }, 30 | "body":[ 31 | "no need." 32 | ] 33 | }, 34 | "expected":{ 35 | "debug_log":"Target value: \"text/html\" \\(Variable: RESPONSE_CONTENT_TYPE\\)" 36 | }, 37 | "rules":[ 38 | "SecRuleEngine On", 39 | "SecRule RESPONSE_CONTENT_TYPE \"@contains test \" \"id:1,phase:3,pass,t:trim\"" 40 | ] 41 | } 42 | ] 43 | 44 | -------------------------------------------------------------------------------- /test/test-cases/regression/variable-WEBSERVER_ERROR_LOG.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "enabled":1, 4 | "version_min":300000, 5 | "version_max":0, 6 | "title":"Testing Variables :: WEBSERVER_ERROR_LOG (1/1)", 7 | "expected":{ 8 | "parser_error":"Line: 1. Column: 27. Variable VARIABLE_WEBSERVER_ERROR_LOG is not supported by libModSecurity" 9 | }, 10 | "rules":[ 11 | "secrule WEBSERVER_ERROR_LOG \"@contains test\" \"id:1,t:lowercase,t:none,msg:'This is a test, %{REQUEST_HEADERS:Accept}%'\"" 12 | ] 13 | } 14 | ] 15 | -------------------------------------------------------------------------------- /test/test-suite.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | cd test 1> /dev/null 4 | 5 | length=$(($#-1)) 6 | array=${@:1:$length} 7 | 8 | PARAM=$array 9 | FILE=${@: -1} 10 | 11 | if [[ $FILE == *"test-cases/regression/"* ]] 12 | then 13 | AMOUNT=$(./regression_tests countall ../$FILE) 14 | RET=$? 15 | if [ $RET -ne 0 ]; then 16 | echo ":test-result: SKIP: json is not enabled. (regression/$RET) ../$FILE" 17 | exit 0 18 | fi 19 | 20 | for i in `seq 1 $AMOUNT`; do 21 | $VALGRIND $PARAM ./regression_tests ../$FILE:$i 22 | RET=$? 23 | if [ $RET -ne 0 ]; then 24 | echo ":test-result: FAIL possible segfault/$RET: ../$FILE:$i" 25 | fi 26 | echo $VALGRIND $PARAM ./regression_tests ../$FILE:$i 27 | done; 28 | else 29 | $VALGRIND $PARAM ./unit_tests ../$FILE 30 | RET=$? 31 | if [ $RET -eq 127 ] 32 | then 33 | echo ":test-result: SKIP: json is not enabled. (unit/$RET) ../$FILE" 34 | elif [ $RET -ne 0 ] 35 | then 36 | echo ":test-result: FAIL possible segfault: (unit/$RET) ../$FILE" 37 | fi 38 | fi 39 | 40 | cd - 1> /dev/null 41 | -------------------------------------------------------------------------------- /test/unit-tests-valgrind.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | valgrind --tool=massif ./unit-tests $* 4 | valgrind --leak-check=full --suppressions=./valgrind_suppressions.txt ./unit-tests $* 5 | -------------------------------------------------------------------------------- /tools/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I build 3 | 4 | 5 | SUBDIRS = \ 6 | rules-check 7 | 8 | # make clean 9 | CLEANFILES = 10 | 11 | # make maintainer-clean 12 | MAINTAINERCLEANFILES = \ 13 | Makefile.in 14 | 15 | -------------------------------------------------------------------------------- /tools/rules-check/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | bin_PROGRAMS = modsec-rules-check 4 | 5 | modsec_rules_check_SOURCES = \ 6 | rules-check.cc 7 | 8 | modsec_rules_check_LDADD = \ 9 | $(top_builddir)/src/.libs/libmodsecurity.la \ 10 | $(CURL_LDADD) \ 11 | $(GEOIP_LDADD) \ 12 | $(MAXMIND_LDADD) \ 13 | $(GLOBAL_LDADD) \ 14 | $(LIBXML2_LDADD) \ 15 | $(LMDB_LDADD) \ 16 | $(LUA_LDADD) \ 17 | $(PCRE_LDADD) \ 18 | $(PCRE2_LDADD) \ 19 | $(SSDEEP_LDADD) \ 20 | $(YAJL_LDADD) 21 | 22 | modsec_rules_check_LDFLAGS = \ 23 | $(GEOIP_LDFLAGS) \ 24 | $(MAXMIND_LDFLAGS) \ 25 | $(LDFLAGS) \ 26 | $(LMDB_LDFLAGS) \ 27 | $(LUA_LDFLAGS) \ 28 | $(SSDEEP_LDFLAGS) \ 29 | $(YAJL_LDFLAGS) \ 30 | $(LIBXML2_LDFLAGS) 31 | 32 | modsec_rules_check_CPPFLAGS = \ 33 | -I$(top_builddir)/headers \ 34 | $(GLOBAL_CPPFLAGS) \ 35 | $(PCRE_CFLAGS) \ 36 | $(PCRE2_CFLAGS) \ 37 | $(LMDB_CFLAGS) \ 38 | $(MAXMIND_CFLAGS) \ 39 | $(LIBXML2_CFLAGS) 40 | 41 | MAINTAINERCLEANFILES = \ 42 | Makefile.in 43 | 44 | -------------------------------------------------------------------------------- /vcbuild.bat: -------------------------------------------------------------------------------- 1 | @rem For Windows build information, see build\win32\README.md 2 | 3 | @echo off 4 | pushd %CD% 5 | 6 | if not "%1"=="" (set build_type=%1) else (set build_type=Release) 7 | echo Build type: %build_type% 8 | 9 | if not "%2"=="" (set arch=%2) else (set arch=x86_64) 10 | echo Arch: %arch% 11 | 12 | if "%3"=="USE_ASAN" ( 13 | echo Address Sanitizer: Enabled 14 | set CI_ASAN=-c tools.build:cxxflags="[""/fsanitize=address""]" 15 | set ASAN_FLAG=ON 16 | ) else ( 17 | echo Address Sanitizer: Disabled 18 | set CI_ASAN= 19 | set ASAN_FLAG=OFF 20 | ) 21 | 22 | cd build\win32 23 | conan install . -s compiler.cppstd=17 %CI_ASAN% --output-folder=build --build=missing --settings=build_type=%build_type% --settings=arch=%arch% 24 | cd build 25 | cmake --fresh .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DUSE_ASAN=%ASAN_FLAG% %4 %5 %6 %7 %8 %9 26 | cmake --build . --config %build_type% 27 | 28 | popd 29 | --------------------------------------------------------------------------------