From bab7d6ccdf6431dab1997c817a4aafd69103b4b3 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Tue, 26 Feb 2019 21:59:08 -0300 Subject: [PATCH] Moves rule* headers to src/ --- headers/modsecurity/actions/action.h | 4 +- headers/modsecurity/rules.h | 21 ++- headers/modsecurity/rules_set_phases.h | 4 +- src/actions/accuracy.cc | 3 +- src/actions/block.cc | 3 +- src/actions/chain.cc | 2 +- src/actions/maturity.cc | 3 +- src/actions/phase.cc | 2 +- src/actions/rev.cc | 2 +- src/actions/rule_id.cc | 2 +- src/actions/set_env.cc | 2 +- src/actions/set_var.cc | 3 +- src/actions/ver.cc | 2 +- src/operators/detect_sqli.cc | 2 +- src/operators/detect_xss.cc | 2 +- src/operators/pm.cc | 2 +- src/operators/rbl.cc | 2 +- src/operators/rx.cc | 2 +- src/operators/rx_global.cc | 2 +- src/operators/verify_cc.cc | 2 +- src/operators/verify_cpf.cc | 2 +- src/operators/verify_ssn.cc | 2 +- src/operators/verify_svnr.cc | 2 +- src/parser/driver.cc | 2 +- src/parser/seclang-parser.cc | 172 ++++++++++++++++++ src/parser/seclang-parser.hh | 16 +- src/parser/seclang-parser.yy | 6 +- {headers/modsecurity => src}/rule_marker.h | 0 src/rule_message.cc | 2 +- src/rule_script.h | 2 +- src/rule_unconditional.cc | 2 +- .../modsecurity => src}/rule_unconditional.h | 8 +- src/rule_with_actions.cc | 14 +- .../modsecurity => src}/rule_with_actions.h | 9 +- src/rule_with_operator.cc | 14 +- .../modsecurity => src}/rule_with_operator.h | 10 +- src/rules.cc | 2 +- src/rules_set.cc | 2 +- src/rules_set_phases.cc | 25 +-- src/run_time_string.cc | 2 +- src/transaction.cc | 1 + src/variables/rule.h | 3 +- src/variables/xml.cc | 2 +- 43 files changed, 284 insertions(+), 83 deletions(-) rename {headers/modsecurity => src}/rule_marker.h (100%) rename {headers/modsecurity => src}/rule_unconditional.h (87%) rename {headers/modsecurity => src}/rule_with_actions.h (99%) rename {headers/modsecurity => src}/rule_with_operator.h (90%) diff --git a/headers/modsecurity/actions/action.h b/headers/modsecurity/actions/action.h index 72a95069..fd728f66 100644 --- a/headers/modsecurity/actions/action.h +++ b/headers/modsecurity/actions/action.h @@ -23,7 +23,6 @@ #include "modsecurity/intervention.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" #ifndef HEADERS_MODSECURITY_ACTIONS_ACTION_H_ #define HEADERS_MODSECURITY_ACTIONS_ACTION_H_ @@ -32,7 +31,8 @@ namespace modsecurity { class Transaction; -class RuleWithOperator; +class RuleWithActions; + namespace actions { diff --git a/headers/modsecurity/rules.h b/headers/modsecurity/rules.h index 43198b7c..7b3346dd 100644 --- a/headers/modsecurity/rules.h +++ b/headers/modsecurity/rules.h @@ -27,28 +27,35 @@ #endif #include "modsecurity/rule.h" -#include "modsecurity/rule_with_operator.h" -#include "modsecurity/rule_with_actions.h" + #ifndef HEADERS_MODSECURITY_RULES_H_ #define HEADERS_MODSECURITY_RULES_H_ - #ifdef __cplusplus namespace modsecurity { - +namespace actions { +namespace transformations { +class Transformation; +} +} class Rules { public: void dump() const; - int append(Rules *from, const std::vector &ids, std::ostringstream *err); + int append(Rules *from, + const std::vector &ids, + std::ostringstream *err); bool insert(const std::shared_ptr &rule); - bool insert(std::shared_ptr rule, const std::vector *ids, std::ostringstream *err); + bool insert(std::shared_ptr rule, + const std::vector *ids, + std::ostringstream *err); size_t size() const; + std::shared_ptr operator[](int index) const; std::shared_ptr at(int index) const; @@ -58,6 +65,8 @@ class Rules { std::vector > m_defaultTransformations; std::vector > m_rules; + void dump(); + }; diff --git a/headers/modsecurity/rules_set_phases.h b/headers/modsecurity/rules_set_phases.h index 59d3fdf3..17844ce0 100644 --- a/headers/modsecurity/rules_set_phases.h +++ b/headers/modsecurity/rules_set_phases.h @@ -48,8 +48,8 @@ class RulesSetPhases { int append(RulesSetPhases *from, std::ostringstream *err); void dump() const; - Rules *operator[](int index) { return &m_rulesAtPhase[index]; } - Rules *at(int index) { return &m_rulesAtPhase[index]; } + Rules *operator[](int index); + Rules *at(int index); private: Rules m_rulesAtPhase[8]; diff --git a/src/actions/accuracy.cc b/src/actions/accuracy.cc index 66cb913d..51514fb0 100644 --- a/src/actions/accuracy.cc +++ b/src/actions/accuracy.cc @@ -21,7 +21,8 @@ #include "modsecurity/actions/action.h" #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" + namespace modsecurity { namespace actions { diff --git a/src/actions/block.cc b/src/actions/block.cc index c20cf6ab..b929d228 100644 --- a/src/actions/block.cc +++ b/src/actions/block.cc @@ -24,7 +24,8 @@ #include "modsecurity/rule.h" #include "modsecurity/intervention.h" #include "src/actions/data/status.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" + namespace modsecurity { namespace actions { diff --git a/src/actions/chain.cc b/src/actions/chain.cc index b2ac0990..db9e6c68 100644 --- a/src/actions/chain.cc +++ b/src/actions/chain.cc @@ -20,7 +20,7 @@ #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/actions/maturity.cc b/src/actions/maturity.cc index 1d6ae4a0..b419d385 100644 --- a/src/actions/maturity.cc +++ b/src/actions/maturity.cc @@ -21,7 +21,8 @@ #include "modsecurity/actions/action.h" #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" + namespace modsecurity { namespace actions { diff --git a/src/actions/phase.cc b/src/actions/phase.cc index 4cba84c4..b6382a43 100644 --- a/src/actions/phase.cc +++ b/src/actions/phase.cc @@ -22,7 +22,7 @@ #include "modsecurity/rule.h" #include "modsecurity/modsecurity.h" #include "src/utils/string.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/actions/rev.cc b/src/actions/rev.cc index e2ec45e7..4e2d94e0 100644 --- a/src/actions/rev.cc +++ b/src/actions/rev.cc @@ -21,7 +21,7 @@ #include "modsecurity/actions/action.h" #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/actions/rule_id.cc b/src/actions/rule_id.cc index 40424933..7457e091 100644 --- a/src/actions/rule_id.cc +++ b/src/actions/rule_id.cc @@ -20,7 +20,7 @@ #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/actions/set_env.cc b/src/actions/set_env.cc index 2d92d48c..0079c68d 100644 --- a/src/actions/set_env.cc +++ b/src/actions/set_env.cc @@ -21,7 +21,7 @@ #include "modsecurity/transaction.h" #include "modsecurity/rule.h" #include "src/utils/string.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/actions/set_var.cc b/src/actions/set_var.cc index 2ae13606..5c289d98 100644 --- a/src/actions/set_var.cc +++ b/src/actions/set_var.cc @@ -30,7 +30,8 @@ #include "src/variables/tx.h" #include "src/variables/user.h" #include "src/variables/variable.h" -#include "modsecurity/rule_with_operator.h" +#include "src/rule_with_operator.h" + namespace modsecurity { namespace actions { diff --git a/src/actions/ver.cc b/src/actions/ver.cc index caf3d08b..a169bb23 100644 --- a/src/actions/ver.cc +++ b/src/actions/ver.cc @@ -21,7 +21,7 @@ #include "modsecurity/actions/action.h" #include "modsecurity/transaction.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/detect_sqli.cc b/src/operators/detect_sqli.cc index b79e0a0b..66a32a5d 100644 --- a/src/operators/detect_sqli.cc +++ b/src/operators/detect_sqli.cc @@ -20,7 +20,7 @@ #include "src/operators/operator.h" #include "others/libinjection/src/libinjection.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/detect_xss.cc b/src/operators/detect_xss.cc index af5e57ab..4819a11f 100644 --- a/src/operators/detect_xss.cc +++ b/src/operators/detect_xss.cc @@ -19,7 +19,7 @@ #include "src/operators/operator.h" #include "others/libinjection/src/libinjection.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/pm.cc b/src/operators/pm.cc index b673efac..6a125ce8 100644 --- a/src/operators/pm.cc +++ b/src/operators/pm.cc @@ -28,7 +28,7 @@ #include "src/operators/operator.h" #include "src/utils/acmp.h" #include "src/utils/string.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/rbl.cc b/src/operators/rbl.cc index 0628dc18..b1fc25a2 100644 --- a/src/operators/rbl.cc +++ b/src/operators/rbl.cc @@ -25,7 +25,7 @@ #include "modsecurity/rules_set.h" #include "src/operators/operator.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/rx.cc b/src/operators/rx.cc index bedf9ac1..4890db66 100644 --- a/src/operators/rx.cc +++ b/src/operators/rx.cc @@ -22,7 +22,7 @@ #include "src/operators/operator.h" #include "modsecurity/rule.h" #include "modsecurity/rule_message.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/rx_global.cc b/src/operators/rx_global.cc index 47e40bfa..dc5a9d8a 100644 --- a/src/operators/rx_global.cc +++ b/src/operators/rx_global.cc @@ -20,7 +20,7 @@ #include #include "src/operators/operator.h" -#include "modsecurity/rule.h" +#include "src/rule_with_actions.h" #include "modsecurity/rule_message.h" namespace modsecurity { diff --git a/src/operators/verify_cc.cc b/src/operators/verify_cc.cc index 2ca93199..1804d5f7 100644 --- a/src/operators/verify_cc.cc +++ b/src/operators/verify_cc.cc @@ -21,7 +21,7 @@ #include #include "src/operators/operator.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" #if PCRE_HAVE_JIT diff --git a/src/operators/verify_cpf.cc b/src/operators/verify_cpf.cc index edac33a9..1ad3bc43 100644 --- a/src/operators/verify_cpf.cc +++ b/src/operators/verify_cpf.cc @@ -19,7 +19,7 @@ #include #include "src/operators/operator.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/verify_ssn.cc b/src/operators/verify_ssn.cc index 3a5a69d9..706d76d1 100644 --- a/src/operators/verify_ssn.cc +++ b/src/operators/verify_ssn.cc @@ -20,7 +20,7 @@ #include #include "src/operators/operator.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/operators/verify_svnr.cc b/src/operators/verify_svnr.cc index 075c5989..8a444ac1 100644 --- a/src/operators/verify_svnr.cc +++ b/src/operators/verify_svnr.cc @@ -9,7 +9,7 @@ #include "modsecurity/rule_message.h" #include "modsecurity/rules_set_properties.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { namespace operators { diff --git a/src/parser/driver.cc b/src/parser/driver.cc index 0d4cd55a..66764cd7 100644 --- a/src/parser/driver.cc +++ b/src/parser/driver.cc @@ -18,7 +18,7 @@ #include "modsecurity/rules_set_properties.h" #include "src/parser/seclang-parser.hh" #include "modsecurity/audit_log.h" -#include "modsecurity/rule_marker.h" +#include "src/rule_marker.h" using modsecurity::audit_log::AuditLog; using modsecurity::RuleWithOperator; diff --git a/src/parser/seclang-parser.cc b/src/parser/seclang-parser.cc index 5f7a1771..83f713bf 100644 --- a/src/parser/seclang-parser.cc +++ b/src/parser/seclang-parser.cc @@ -42,7 +42,11 @@ // Unqualified %code blocks. +<<<<<<< HEAD #line 326 "seclang-parser.yy" +======= +#line 327 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) #include "src/parser/driver.h" @@ -1318,7 +1322,11 @@ namespace yy { // User initialization code. +<<<<<<< HEAD #line 319 "seclang-parser.yy" +======= +#line 320 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { // Initialize the initial location. yyla.location.begin.filename = yyla.location.end.filename = new std::string(driver.file); @@ -5399,6 +5407,7 @@ namespace yy { #line 5400 "seclang-parser.cc" break; +<<<<<<< HEAD case 410: // act: "ACTION_TRANSFORMATION_PHP_ARGS_NAMES" #line 2920 "seclang-parser.yy" { @@ -5409,222 +5418,361 @@ namespace yy { case 411: // act: "ACTION_TRANSFORMATION_UPPERCASE" #line 2924 "seclang-parser.yy" +======= + case 410: // act: "ACTION_TRANSFORMATION_UPPERCASE" +#line 2920 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::UpperCase(yystack_[0].value.as < std::string > ())); } #line 5416 "seclang-parser.cc" break; +<<<<<<< HEAD case 412: // act: "ACTION_TRANSFORMATION_URL_DECODE_UNI" #line 2928 "seclang-parser.yy" +======= + case 411: // act: "ACTION_TRANSFORMATION_URL_DECODE_UNI" +#line 2924 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::UrlDecodeUni(yystack_[0].value.as < std::string > ())); } #line 5424 "seclang-parser.cc" break; +<<<<<<< HEAD case 413: // act: "ACTION_TRANSFORMATION_URL_DECODE" #line 2932 "seclang-parser.yy" +======= + case 412: // act: "ACTION_TRANSFORMATION_URL_DECODE" +#line 2928 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::UrlDecode(yystack_[0].value.as < std::string > ())); } #line 5432 "seclang-parser.cc" break; +<<<<<<< HEAD case 414: // act: "ACTION_TRANSFORMATION_URL_ENCODE" #line 2936 "seclang-parser.yy" +======= + case 413: // act: "ACTION_TRANSFORMATION_URL_ENCODE" +#line 2932 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::UrlEncode(yystack_[0].value.as < std::string > ())); } #line 5440 "seclang-parser.cc" break; +<<<<<<< HEAD case 415: // act: "ACTION_TRANSFORMATION_NONE" #line 2940 "seclang-parser.yy" +======= + case 414: // act: "ACTION_TRANSFORMATION_NONE" +#line 2936 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::None(yystack_[0].value.as < std::string > ())); } #line 5448 "seclang-parser.cc" break; +<<<<<<< HEAD case 416: // act: "ACTION_TRANSFORMATION_COMPRESS_WHITESPACE" #line 2944 "seclang-parser.yy" +======= + case 415: // act: "ACTION_TRANSFORMATION_COMPRESS_WHITESPACE" +#line 2940 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::CompressWhitespace(yystack_[0].value.as < std::string > ())); } #line 5456 "seclang-parser.cc" break; +<<<<<<< HEAD case 417: // act: "ACTION_TRANSFORMATION_REMOVE_WHITESPACE" #line 2948 "seclang-parser.yy" +======= + case 416: // act: "ACTION_TRANSFORMATION_REMOVE_WHITESPACE" +#line 2944 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::RemoveWhitespace(yystack_[0].value.as < std::string > ())); } #line 5464 "seclang-parser.cc" break; +<<<<<<< HEAD case 418: // act: "ACTION_TRANSFORMATION_REPLACE_NULLS" #line 2952 "seclang-parser.yy" +======= + case 417: // act: "ACTION_TRANSFORMATION_REPLACE_NULLS" +#line 2948 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::ReplaceNulls(yystack_[0].value.as < std::string > ())); } #line 5472 "seclang-parser.cc" break; +<<<<<<< HEAD case 419: // act: "ACTION_TRANSFORMATION_REMOVE_NULLS" #line 2956 "seclang-parser.yy" +======= + case 418: // act: "ACTION_TRANSFORMATION_REMOVE_NULLS" +#line 2952 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::RemoveNulls(yystack_[0].value.as < std::string > ())); } #line 5480 "seclang-parser.cc" break; +<<<<<<< HEAD case 420: // act: "ACTION_TRANSFORMATION_HTML_ENTITY_DECODE" #line 2960 "seclang-parser.yy" +======= + case 419: // act: "ACTION_TRANSFORMATION_HTML_ENTITY_DECODE" +#line 2956 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::HtmlEntityDecode(yystack_[0].value.as < std::string > ())); } #line 5488 "seclang-parser.cc" break; +<<<<<<< HEAD case 421: // act: "ACTION_TRANSFORMATION_JS_DECODE" #line 2964 "seclang-parser.yy" +======= + case 420: // act: "ACTION_TRANSFORMATION_JS_DECODE" +#line 2960 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::JsDecode(yystack_[0].value.as < std::string > ())); } #line 5496 "seclang-parser.cc" break; +<<<<<<< HEAD case 422: // act: "ACTION_TRANSFORMATION_CSS_DECODE" #line 2968 "seclang-parser.yy" +======= + case 421: // act: "ACTION_TRANSFORMATION_CSS_DECODE" +#line 2964 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::CssDecode(yystack_[0].value.as < std::string > ())); } #line 5504 "seclang-parser.cc" break; +<<<<<<< HEAD case 423: // act: "ACTION_TRANSFORMATION_TRIM" #line 2972 "seclang-parser.yy" +======= + case 422: // act: "ACTION_TRANSFORMATION_TRIM" +#line 2968 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::Trim(yystack_[0].value.as < std::string > ())); } #line 5512 "seclang-parser.cc" break; +<<<<<<< HEAD case 424: // act: "ACTION_TRANSFORMATION_TRIM_LEFT" #line 2976 "seclang-parser.yy" +======= + case 423: // act: "ACTION_TRANSFORMATION_TRIM_LEFT" +#line 2972 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::TrimLeft(yystack_[0].value.as < std::string > ())); } #line 5520 "seclang-parser.cc" break; +<<<<<<< HEAD case 425: // act: "ACTION_TRANSFORMATION_TRIM_RIGHT" #line 2980 "seclang-parser.yy" +======= + case 424: // act: "ACTION_TRANSFORMATION_TRIM_RIGHT" +#line 2976 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::TrimRight(yystack_[0].value.as < std::string > ())); } #line 5528 "seclang-parser.cc" break; +<<<<<<< HEAD case 426: // act: "ACTION_TRANSFORMATION_NORMALISE_PATH_WIN" #line 2984 "seclang-parser.yy" +======= + case 425: // act: "ACTION_TRANSFORMATION_NORMALISE_PATH_WIN" +#line 2980 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::NormalisePathWin(yystack_[0].value.as < std::string > ())); } #line 5536 "seclang-parser.cc" break; +<<<<<<< HEAD case 427: // act: "ACTION_TRANSFORMATION_NORMALISE_PATH" #line 2988 "seclang-parser.yy" +======= + case 426: // act: "ACTION_TRANSFORMATION_NORMALISE_PATH" +#line 2984 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::NormalisePath(yystack_[0].value.as < std::string > ())); } #line 5544 "seclang-parser.cc" break; +<<<<<<< HEAD case 428: // act: "ACTION_TRANSFORMATION_LENGTH" #line 2992 "seclang-parser.yy" +======= + case 427: // act: "ACTION_TRANSFORMATION_LENGTH" +#line 2988 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::Length(yystack_[0].value.as < std::string > ())); } #line 5552 "seclang-parser.cc" break; +<<<<<<< HEAD case 429: // act: "ACTION_TRANSFORMATION_UTF8_TO_UNICODE" #line 2996 "seclang-parser.yy" +======= + case 428: // act: "ACTION_TRANSFORMATION_UTF8_TO_UNICODE" +#line 2992 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::Utf8ToUnicode(yystack_[0].value.as < std::string > ())); } #line 5560 "seclang-parser.cc" break; +<<<<<<< HEAD case 430: // act: "ACTION_TRANSFORMATION_REMOVE_COMMENTS_CHAR" #line 3000 "seclang-parser.yy" +======= + case 429: // act: "ACTION_TRANSFORMATION_REMOVE_COMMENTS_CHAR" +#line 2996 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::RemoveCommentsChar(yystack_[0].value.as < std::string > ())); } #line 5568 "seclang-parser.cc" break; +<<<<<<< HEAD case 431: // act: "ACTION_TRANSFORMATION_REMOVE_COMMENTS" #line 3004 "seclang-parser.yy" +======= + case 430: // act: "ACTION_TRANSFORMATION_REMOVE_COMMENTS" +#line 3000 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::RemoveComments(yystack_[0].value.as < std::string > ())); } #line 5576 "seclang-parser.cc" break; +<<<<<<< HEAD case 432: // act: "ACTION_TRANSFORMATION_REPLACE_COMMENTS" #line 3008 "seclang-parser.yy" +======= + case 431: // act: "ACTION_TRANSFORMATION_REPLACE_COMMENTS" +#line 3004 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::transformations::ReplaceComments(yystack_[0].value.as < std::string > ())); } #line 5584 "seclang-parser.cc" break; +<<<<<<< HEAD case 433: // setvar_action: "NOT" var #line 3015 "seclang-parser.yy" +======= + case 432: // setvar_action: "NOT" var +#line 3011 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::SetVar(actions::SetVarOperation::unsetOperation, std::move(yystack_[0].value.as < std::unique_ptr > ()))); } #line 5592 "seclang-parser.cc" break; +<<<<<<< HEAD case 434: // setvar_action: var #line 3019 "seclang-parser.yy" +======= + case 433: // setvar_action: var +#line 3015 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::SetVar(actions::SetVarOperation::setToOneOperation, std::move(yystack_[0].value.as < std::unique_ptr > ()))); } #line 5600 "seclang-parser.cc" break; +<<<<<<< HEAD case 435: // setvar_action: var SETVAR_OPERATION_EQUALS run_time_string #line 3023 "seclang-parser.yy" +======= + case 434: // setvar_action: var SETVAR_OPERATION_EQUALS run_time_string +#line 3019 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::SetVar(actions::SetVarOperation::setOperation, std::move(yystack_[2].value.as < std::unique_ptr > ()), std::move(yystack_[0].value.as < std::unique_ptr > ()))); } #line 5608 "seclang-parser.cc" break; +<<<<<<< HEAD case 436: // setvar_action: var SETVAR_OPERATION_EQUALS_PLUS run_time_string #line 3027 "seclang-parser.yy" +======= + case 435: // setvar_action: var SETVAR_OPERATION_EQUALS_PLUS run_time_string +#line 3023 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::SetVar(actions::SetVarOperation::sumAndSetOperation, std::move(yystack_[2].value.as < std::unique_ptr > ()), std::move(yystack_[0].value.as < std::unique_ptr > ()))); } #line 5616 "seclang-parser.cc" break; +<<<<<<< HEAD case 437: // setvar_action: var SETVAR_OPERATION_EQUALS_MINUS run_time_string #line 3031 "seclang-parser.yy" +======= + case 436: // setvar_action: var SETVAR_OPERATION_EQUALS_MINUS run_time_string +#line 3027 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { ACTION_CONTAINER(yylhs.value.as < std::unique_ptr > (), new actions::SetVar(actions::SetVarOperation::substractAndSetOperation, std::move(yystack_[2].value.as < std::unique_ptr > ()), std::move(yystack_[0].value.as < std::unique_ptr > ()))); } #line 5624 "seclang-parser.cc" break; +<<<<<<< HEAD case 438: // run_time_string: run_time_string "FREE_TEXT_QUOTE_MACRO_EXPANSION" #line 3038 "seclang-parser.yy" +======= + case 437: // run_time_string: run_time_string "FREE_TEXT_QUOTE_MACRO_EXPANSION" +#line 3034 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { yystack_[1].value.as < std::unique_ptr > ()->appendText(yystack_[0].value.as < std::string > ()); yylhs.value.as < std::unique_ptr > () = std::move(yystack_[1].value.as < std::unique_ptr > ()); @@ -5632,8 +5780,13 @@ namespace yy { #line 5633 "seclang-parser.cc" break; +<<<<<<< HEAD case 439: // run_time_string: run_time_string var #line 3043 "seclang-parser.yy" +======= + case 438: // run_time_string: run_time_string var +#line 3039 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { yystack_[1].value.as < std::unique_ptr > ()->appendVar(std::move(yystack_[0].value.as < std::unique_ptr > ())); yylhs.value.as < std::unique_ptr > () = std::move(yystack_[1].value.as < std::unique_ptr > ()); @@ -5641,8 +5794,13 @@ namespace yy { #line 5642 "seclang-parser.cc" break; +<<<<<<< HEAD case 440: // run_time_string: "FREE_TEXT_QUOTE_MACRO_EXPANSION" #line 3048 "seclang-parser.yy" +======= + case 439: // run_time_string: "FREE_TEXT_QUOTE_MACRO_EXPANSION" +#line 3044 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { std::unique_ptr r(new RunTimeString()); r->appendText(yystack_[0].value.as < std::string > ()); @@ -5651,8 +5809,13 @@ namespace yy { #line 5652 "seclang-parser.cc" break; +<<<<<<< HEAD case 441: // run_time_string: var #line 3054 "seclang-parser.yy" +======= + case 440: // run_time_string: var +#line 3050 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) { std::unique_ptr r(new RunTimeString()); r->appendVar(std::move(yystack_[0].value.as < std::unique_ptr > ())); @@ -7201,8 +7364,13 @@ namespace yy { 2879, 2883, 2887, 2891, 2895, 2899, 2903, 2907, 2911, 2915, 2919, 2923, 2927, 2931, 2935, 2939, 2943, 2947, 2951, 2955, 2959, 2963, 2967, 2971, 2975, 2979, 2983, 2987, 2991, 2995, +<<<<<<< HEAD 2999, 3003, 3007, 3014, 3018, 3022, 3026, 3030, 3037, 3042, 3047, 3053 +======= + 2999, 3003, 3010, 3014, 3018, 3022, 3026, 3033, 3038, 3043, + 3049 +>>>>>>> 3e285811 (Moves rule* headers to src/) }; void @@ -7236,7 +7404,11 @@ namespace yy { } // yy #line 7238 "seclang-parser.cc" +<<<<<<< HEAD #line 3060 "seclang-parser.yy" +======= +#line 3056 "seclang-parser.yy" +>>>>>>> 3e285811 (Moves rule* headers to src/) void yy::seclang_parser::error (const location_type& l, const std::string& m) { diff --git a/src/parser/seclang-parser.hh b/src/parser/seclang-parser.hh index 1db831f2..d7ebc961 100644 --- a/src/parser/seclang-parser.hh +++ b/src/parser/seclang-parser.hh @@ -56,7 +56,9 @@ class Driver; } } -#include "modsecurity/rule_unconditional.h" +#include "src/rule_unconditional.h" +#include "src/rule_with_operator.h" +#include "src/rule_with_actions.h" #include "src/rule_script.h" #include "src/actions/accuracy.h" @@ -351,7 +353,11 @@ using namespace modsecurity::operators; a = std::move(c); +<<<<<<< HEAD #line 355 "seclang-parser.hh" +======= +#line 356 "seclang-parser.hh" +>>>>>>> 3e285811 (Moves rule* headers to src/) # include # include // std::abort @@ -485,7 +491,11 @@ using namespace modsecurity::operators; #endif namespace yy { +<<<<<<< HEAD #line 489 "seclang-parser.hh" +======= +#line 490 "seclang-parser.hh" +>>>>>>> 3e285811 (Moves rule* headers to src/) @@ -8626,7 +8636,11 @@ switch (yykind) } } // yy +<<<<<<< HEAD #line 8630 "seclang-parser.hh" +======= +#line 8609 "seclang-parser.hh" +>>>>>>> 3e285811 (Moves rule* headers to src/) diff --git a/src/parser/seclang-parser.yy b/src/parser/seclang-parser.yy index 064cf11d..a63a1f63 100644 --- a/src/parser/seclang-parser.yy +++ b/src/parser/seclang-parser.yy @@ -17,9 +17,9 @@ class Driver; } } -#include "modsecurity/rule_unconditional.h" -#include "modsecurity/rule_with_operator.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_unconditional.h" +#include "src/rule_with_operator.h" +#include "src/rule_with_actions.h" #include "src/rule_script.h" #include "src/actions/accuracy.h" diff --git a/headers/modsecurity/rule_marker.h b/src/rule_marker.h similarity index 100% rename from headers/modsecurity/rule_marker.h rename to src/rule_marker.h diff --git a/src/rule_message.cc b/src/rule_message.cc index 70712d4a..31bf1903 100644 --- a/src/rule_message.cc +++ b/src/rule_message.cc @@ -20,7 +20,7 @@ #include "modsecurity/transaction.h" #include "src/utils/string.h" #include "src/actions/tag.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/rule_script.h b/src/rule_script.h index 6375d8ee..eaeef2fa 100644 --- a/src/rule_script.h +++ b/src/rule_script.h @@ -32,7 +32,7 @@ #include "src/actions/log_data.h" #include "src/actions/severity.h" #include "src/variables/variable.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" #ifndef SRC_RULE_SCRIPT_H_ diff --git a/src/rule_unconditional.cc b/src/rule_unconditional.cc index 5f5390bd..abd79dfa 100644 --- a/src/rule_unconditional.cc +++ b/src/rule_unconditional.cc @@ -13,7 +13,7 @@ * */ -#include "modsecurity/rule_unconditional.h" +#include "src/rule_unconditional.h" namespace modsecurity { diff --git a/headers/modsecurity/rule_unconditional.h b/src/rule_unconditional.h similarity index 87% rename from headers/modsecurity/rule_unconditional.h rename to src/rule_unconditional.h index a10b5993..f1b44f99 100644 --- a/headers/modsecurity/rule_unconditional.h +++ b/src/rule_unconditional.h @@ -22,15 +22,15 @@ #include #endif -#ifndef HEADERS_MODSECURITY_RULE_UNCONDITIONAL_H_ -#define HEADERS_MODSECURITY_RULE_UNCONDITIONAL_H_ +#ifndef SRC_RULE_UNCONDITIONAL_H_ +#define SRC_RULE_UNCONDITIONAL_H_ #include "modsecurity/modsecurity.h" #include "modsecurity/variable_value.h" #include "modsecurity/rule.h" #include "modsecurity/rules_set.h" -#include "modsecurity/rule_with_actions.h" #include "modsecurity/actions/action.h" +#include "src/rule_with_actions.h" #ifdef __cplusplus @@ -60,4 +60,4 @@ class RuleUnconditional : public RuleWithActions { #endif -#endif // HEADERS_MODSECURITY_RULE_UNCONDITIONAL_H_ +#endif // SRC_RULE_UNCONDITIONAL_H_ diff --git a/src/rule_with_actions.cc b/src/rule_with_actions.cc index 27abceb2..bfbbcb85 100644 --- a/src/rule_with_actions.cc +++ b/src/rule_with_actions.cc @@ -29,7 +29,7 @@ #include "modsecurity/modsecurity.h" #include "modsecurity/rule_message.h" #include "modsecurity/rules_set.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" #include "src/actions/accuracy.h" #include "src/actions/block.h" #include "src/actions/capture.h" @@ -360,10 +360,8 @@ void RuleWithActions::executeTransformations( int none = 0; ModSecString ssin; - ssin.assign(in.c_str()); - - TransformationResult a = TransformationResult(&ssin); - results.push_back(a); + ssin.assign(in.c_str(), in.size()); + results.push_back(TransformationResult(&ssin)); std::string path(""); @@ -418,8 +416,8 @@ void RuleWithActions::executeTransformations( + std::to_string(results.size()) + \ " values to be tested."); } else { - results.pop_front(); - results.push_back(TransformationResult(&ssin)); + //results.push_back(TransformationResult(nullptr, ssin)); + //results.pop_front(); } */ } @@ -441,7 +439,7 @@ void RuleWithActions::executeTransformation( void RuleWithActions::executeTransformation( Transaction *transaction, - ModSecString in, + ModSecString &in, TransformationsResults *ret, Transformation *transformation) { diff --git a/headers/modsecurity/rule_with_actions.h b/src/rule_with_actions.h similarity index 99% rename from headers/modsecurity/rule_with_actions.h rename to src/rule_with_actions.h index 085a65dd..d67042b5 100644 --- a/headers/modsecurity/rule_with_actions.h +++ b/src/rule_with_actions.h @@ -22,8 +22,8 @@ #include #endif -#ifndef HEADERS_MODSECURITY_RULE_WITH_ACTIONS_H_ -#define HEADERS_MODSECURITY_RULE_WITH_ACTIONS_H_ +#ifndef SRC_RULE_WITH_ACTIONS_H_ +#define SRC_RULE_WITH_ACTIONS_H_ #include "modsecurity/transaction.h" #include "modsecurity/modsecurity.h" @@ -223,7 +223,7 @@ class RuleWithActions : public Rule { static void executeTransformation( Transaction *transaction, - ModSecString in, + ModSecString &in, TransformationsResults *ret, Transformation *transformation); @@ -545,4 +545,5 @@ class RuleWithActions : public Rule { #endif -#endif // HEADERS_MODSECURITY_RULE_WITH_ACTIONS_H_ \ No newline at end of file +#endif // SRC_RULE_WITH_ACTIONS_H_ + diff --git a/src/rule_with_operator.cc b/src/rule_with_operator.cc index b56cf819..9ada85c1 100644 --- a/src/rule_with_operator.cc +++ b/src/rule_with_operator.cc @@ -13,7 +13,6 @@ * */ -#include "modsecurity/rule_with_operator.h" #include @@ -41,6 +40,7 @@ #include "src/actions/set_var.h" #include "src/actions/block.h" #include "src/variables/variable.h" +#include "src/rule_with_operator.h" namespace modsecurity { @@ -265,6 +265,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) { } var->evaluate(trans, this, &e); for (const VariableValue *v : e) { + TransformationsResults transformationsResults; const std::string &value = v->getValue(); const std::string &key = v->getKeyWithCollection(); @@ -291,8 +292,6 @@ bool RuleWithOperator::evaluate(Transaction *trans) { continue; } - TransformationsResults transformationsResults; - executeTransformations(trans, value, transformationsResults); auto iter = transformationsResults.begin(); @@ -303,8 +302,8 @@ bool RuleWithOperator::evaluate(Transaction *trans) { while (iter != transformationsResults.end()) { bool ret; auto &valueTemp = *iter; - // FIXME: this copy is not necessary. - std::string *valueAfterTrans = new std::string(valueTemp.getAfter()->c_str()); + // FIXME: this copy is not necessary. + std::string *valueAfterTrans = new std::string(valueTemp.getAfter()->c_str(), valueTemp.getAfter()->size()); ret = executeOperatorAt(trans, key, *valueAfterTrans); @@ -315,6 +314,7 @@ bool RuleWithOperator::evaluate(Transaction *trans) { for (auto &i : v->getOrigin()) { trans->messageGetLast()->m_reference.append(i->toText()); } + auto iter2 = transformationsResults.begin(); while (iter2 != transformationsResults.end()) { if (iter2->getTransformationName()) { @@ -323,8 +323,8 @@ bool RuleWithOperator::evaluate(Transaction *trans) { /* if (iter == iter2) { break; - } else { - trans->messageGetLast()->m_reference.append("--"); + } else if (iter2->getTransformationName()) { + trans->messageGetLast()->m_reference.append(","); } */ iter2++; diff --git a/headers/modsecurity/rule_with_operator.h b/src/rule_with_operator.h similarity index 90% rename from headers/modsecurity/rule_with_operator.h rename to src/rule_with_operator.h index 71da6ddf..b7cf3065 100644 --- a/headers/modsecurity/rule_with_operator.h +++ b/src/rule_with_operator.h @@ -22,20 +22,19 @@ #include #endif -#ifndef HEADERS_MODSECURITY_RULE_WITH_OPERATOR_H_ -#define HEADERS_MODSECURITY_RULE_WITH_OPERATOR_H_ +#ifndef SRC_RULE_WITH_OPERATOR_H_ +#define SRC_RULE_WITH_OPERATOR_H_ #include "modsecurity/transaction.h" #include "modsecurity/modsecurity.h" #include "modsecurity/variable_value.h" #include "modsecurity/rule.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" #ifdef __cplusplus namespace modsecurity { -using TransformationsResults = std::list; class RuleWithOperator : public RuleWithActions { public: @@ -91,4 +90,5 @@ class RuleWithOperator : public RuleWithActions { #endif -#endif // HEADERS_MODSECURITY_RULE_WITH_OPERATOR_H_ +#endif // SRC_RULE_WITH_OPERATOR_H_ + diff --git a/src/rules.cc b/src/rules.cc index b35664fb..e2a70c65 100644 --- a/src/rules.cc +++ b/src/rules.cc @@ -14,7 +14,7 @@ */ #include "modsecurity/rules.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity { diff --git a/src/rules_set.cc b/src/rules_set.cc index 0ca3fbfd..4295e1b2 100644 --- a/src/rules_set.cc +++ b/src/rules_set.cc @@ -20,7 +20,7 @@ #include #include "modsecurity/rules_set.h" -#include "modsecurity/rule_marker.h" +#include "src/rule_marker.h" #include "modsecurity/modsecurity.h" #include "modsecurity/transaction.h" #include "src/parser/driver.h" diff --git a/src/rules_set_phases.cc b/src/rules_set_phases.cc index 184738b1..6f3acd19 100644 --- a/src/rules_set_phases.cc +++ b/src/rules_set_phases.cc @@ -13,17 +13,8 @@ * */ -#include -#include -#include -#include -#include - #include "modsecurity/rules_set_phases.h" -#include "modsecurity/rule.h" -#include "modsecurity/rules.h" -#include "modsecurity/modsecurity.h" - +#include "src/rule_with_operator.h" namespace modsecurity { @@ -47,6 +38,7 @@ int RulesSetPhases::append(RulesSetPhases *from, std::ostringstream *err) { v.reserve(m_rulesAtPhase[i].size()); for (size_t z = 0; z < m_rulesAtPhase[i].size(); z++) { RuleWithOperator *rule_ckc = dynamic_cast(m_rulesAtPhase[i].at(z).get()); + //RuleWithOperator *rule_ckc = dynamic_cast(m_rulesAtPhase->at(i).get()); if (!rule_ckc) { continue; } @@ -62,7 +54,6 @@ int RulesSetPhases::append(RulesSetPhases *from, std::ostringstream *err) { } amount_of_rules = amount_of_rules + res; - /** * An action set in a child will overwrite an action set on a parent. * @@ -91,6 +82,7 @@ int RulesSetPhases::append(RulesSetPhases *from, std::ostringstream *err) { void RulesSetPhases::dump() const { for (int i = 0; i <= modsecurity::Phases::NUMBER_OF_PHASES; i++) { + const Rules *rules = &m_rulesAtPhase[i]; std::cout << "Phase: " << std::to_string(i); std::cout << " (" << std::to_string(m_rulesAtPhase[i].size()); std::cout << " rules)" << std::endl; @@ -99,5 +91,14 @@ void RulesSetPhases::dump() const { } -} // namespace modsecurity +Rules *RulesSetPhases::operator[](int index) { + return &m_rulesAtPhase[index]; +} + +Rules *RulesSetPhases::at(int index) { + return &m_rulesAtPhase[index]; +} + + +} // namespace modsecurity diff --git a/src/run_time_string.cc b/src/run_time_string.cc index a470f5e7..2c433cff 100644 --- a/src/run_time_string.cc +++ b/src/run_time_string.cc @@ -25,7 +25,7 @@ #include "src/variables/highest_severity.h" #include "src/utils/string.h" #include "src/variables/variable.h" -#include "modsecurity/rule_with_operator.h" +#include "src/rule_with_operator.h" namespace modsecurity { diff --git a/src/transaction.cc b/src/transaction.cc index 17b8a889..66674681 100644 --- a/src/transaction.cc +++ b/src/transaction.cc @@ -52,6 +52,7 @@ #include "modsecurity/rules_set_properties.h" #include "src/actions/disruptive/allow.h" #include "src/variables/remote_user.h" +#include "src/rule_with_actions.h" diff --git a/src/variables/rule.h b/src/variables/rule.h index 76d13a8c..1d63d50f 100644 --- a/src/variables/rule.h +++ b/src/variables/rule.h @@ -24,7 +24,8 @@ #include "src/actions/severity.h" #include "src/actions/log_data.h" #include "src/actions/msg.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" + namespace modsecurity { diff --git a/src/variables/xml.cc b/src/variables/xml.cc index 8e434c86..3c9604ce 100644 --- a/src/variables/xml.cc +++ b/src/variables/xml.cc @@ -42,7 +42,7 @@ #include "src/request_body_processor/xml.h" #include "modsecurity/actions/action.h" #include "src/actions/xmlns.h" -#include "modsecurity/rule_with_actions.h" +#include "src/rule_with_actions.h" namespace modsecurity {