Moves rule* headers to src/

This commit is contained in:
Felipe Zimmerle
2019-02-26 21:59:08 -03:00
parent 38a814411b
commit bab7d6ccdf
43 changed files with 284 additions and 83 deletions

View File

@@ -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 {

View File

@@ -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<int64_t> &ids, std::ostringstream *err);
int append(Rules *from,
const std::vector<int64_t> &ids,
std::ostringstream *err);
bool insert(const std::shared_ptr<Rule> &rule);
bool insert(std::shared_ptr<Rule> rule, const std::vector<int64_t> *ids, std::ostringstream *err);
bool insert(std::shared_ptr<Rule> rule,
const std::vector<int64_t> *ids,
std::ostringstream *err);
size_t size() const;
std::shared_ptr<Rule> operator[](int index) const;
std::shared_ptr<Rule> at(int index) const;
@@ -58,6 +65,8 @@ class Rules {
std::vector<std::shared_ptr<actions::transformations::Transformation> > m_defaultTransformations;
std::vector<std::shared_ptr<Rule> > m_rules;
void dump();
};

View File

@@ -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];

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -20,7 +20,7 @@
#include <memory>
#include "src/operators/operator.h"
#include "modsecurity/rule.h"
#include "src/rule_with_actions.h"
#include "modsecurity/rule_message.h"
namespace modsecurity {

View File

@@ -21,7 +21,7 @@
#include <vector>
#include "src/operators/operator.h"
#include "modsecurity/rule_with_actions.h"
#include "src/rule_with_actions.h"
#if PCRE_HAVE_JIT

View File

@@ -19,7 +19,7 @@
#include <list>
#include "src/operators/operator.h"
#include "modsecurity/rule_with_actions.h"
#include "src/rule_with_actions.h"
namespace modsecurity {

View File

@@ -20,7 +20,7 @@
#include <list>
#include "src/operators/operator.h"
#include "modsecurity/rule_with_actions.h"
#include "src/rule_with_actions.h"
namespace modsecurity {

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), 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<actions::Action> > (), new actions::SetVar(actions::SetVarOperation::unsetOperation, std::move(yystack_[0].value.as < std::unique_ptr<Variable> > ())));
}
#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<actions::Action> > (), new actions::SetVar(actions::SetVarOperation::setToOneOperation, std::move(yystack_[0].value.as < std::unique_ptr<Variable> > ())));
}
#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<actions::Action> > (), new actions::SetVar(actions::SetVarOperation::setOperation, std::move(yystack_[2].value.as < std::unique_ptr<Variable> > ()), std::move(yystack_[0].value.as < std::unique_ptr<RunTimeString> > ())));
}
#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<actions::Action> > (), new actions::SetVar(actions::SetVarOperation::sumAndSetOperation, std::move(yystack_[2].value.as < std::unique_ptr<Variable> > ()), std::move(yystack_[0].value.as < std::unique_ptr<RunTimeString> > ())));
}
#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<actions::Action> > (), new actions::SetVar(actions::SetVarOperation::substractAndSetOperation, std::move(yystack_[2].value.as < std::unique_ptr<Variable> > ()), std::move(yystack_[0].value.as < std::unique_ptr<RunTimeString> > ())));
}
#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<RunTimeString> > ()->appendText(yystack_[0].value.as < std::string > ());
yylhs.value.as < std::unique_ptr<RunTimeString> > () = std::move(yystack_[1].value.as < std::unique_ptr<RunTimeString> > ());
@@ -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<RunTimeString> > ()->appendVar(std::move(yystack_[0].value.as < std::unique_ptr<Variable> > ()));
yylhs.value.as < std::unique_ptr<RunTimeString> > () = std::move(yystack_[1].value.as < std::unique_ptr<RunTimeString> > ());
@@ -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<RunTimeString> 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<RunTimeString> r(new RunTimeString());
r->appendVar(std::move(yystack_[0].value.as < std::unique_ptr<Variable> > ()));
@@ -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) {

View File

@@ -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 <cassert>
# include <cstdlib> // 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/)

View File

@@ -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"

View File

@@ -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 {

View File

@@ -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_

View File

@@ -13,7 +13,7 @@
*
*/
#include "modsecurity/rule_unconditional.h"
#include "src/rule_unconditional.h"
namespace modsecurity {

View File

@@ -22,15 +22,15 @@
#include <utility>
#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_

View File

@@ -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) {

View File

@@ -22,8 +22,8 @@
#include <utility>
#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_
#endif // SRC_RULE_WITH_ACTIONS_H_

View File

@@ -13,7 +13,6 @@
*
*/
#include "modsecurity/rule_with_operator.h"
#include <stdio.h>
@@ -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++;

View File

@@ -22,20 +22,19 @@
#include <utility>
#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<TransformationResult>;
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_

View File

@@ -14,7 +14,7 @@
*/
#include "modsecurity/rules.h"
#include "modsecurity/rule_with_actions.h"
#include "src/rule_with_actions.h"
namespace modsecurity {

View File

@@ -20,7 +20,7 @@
#include <vector>
#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"

View File

@@ -13,17 +13,8 @@
*
*/
#include <ctime>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#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<RuleWithOperator *>(m_rulesAtPhase[i].at(z).get());
//RuleWithOperator *rule_ckc = dynamic_cast<RuleWithOperator *>(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

View File

@@ -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 {

View File

@@ -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"

View File

@@ -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 {

View File

@@ -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 {