mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +03:00
Adds support to rules with actions without quotes
This commit is contained in:
parent
0087a602f1
commit
941b9e75c4
@ -248,6 +248,7 @@ using ModSecurity::Variables::Variable;
|
|||||||
%type <std::vector<Variable *> *> variables
|
%type <std::vector<Variable *> *> variables
|
||||||
%type <Variable *> var
|
%type <Variable *> var
|
||||||
%type <Action *> act
|
%type <Action *> act
|
||||||
|
%type <std::vector<Action *> *> actings
|
||||||
|
|
||||||
%printer { yyoutput << $$; } <*>;
|
%printer { yyoutput << $$; } <*>;
|
||||||
%%
|
%%
|
||||||
@ -336,10 +337,24 @@ audit_log:
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
actings:
|
||||||
|
QUOTATION_MARK actions SPACE QUOTATION_MARK
|
||||||
|
{
|
||||||
|
$$ = $2;
|
||||||
|
}
|
||||||
|
| QUOTATION_MARK actions QUOTATION_MARK
|
||||||
|
{
|
||||||
|
$$ = $2;
|
||||||
|
}
|
||||||
|
| actions
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
expression:
|
expression:
|
||||||
audit_log
|
audit_log
|
||||||
| DIRECTIVE SPACE variables SPACE OPERATOR SPACE QUOTATION_MARK actions SPACE QUOTATION_MARK
|
| DIRECTIVE SPACE variables SPACE OPERATOR SPACE actings
|
||||||
| DIRECTIVE SPACE variables SPACE OPERATOR SPACE QUOTATION_MARK actions QUOTATION_MARK
|
|
||||||
{
|
{
|
||||||
Operator *op = Operator::instantiate($5);
|
Operator *op = Operator::instantiate($5);
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
@ -350,15 +365,14 @@ expression:
|
|||||||
Rule *rule = new Rule(
|
Rule *rule = new Rule(
|
||||||
/* op */ op,
|
/* op */ op,
|
||||||
/* variables */ $3,
|
/* variables */ $3,
|
||||||
/* actions */ $8
|
/* actions */ $7
|
||||||
);
|
);
|
||||||
|
|
||||||
if (driver.addSecRule(rule) == false) {
|
if (driver.addSecRule(rule) == false) {
|
||||||
YYERROR;
|
YYERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| DIRECTIVE SPACE variables SPACE FREE_TEXT SPACE QUOTATION_MARK actions SPACE QUOTATION_MARK
|
| DIRECTIVE SPACE variables SPACE FREE_TEXT SPACE actings
|
||||||
| DIRECTIVE SPACE variables SPACE FREE_TEXT SPACE QUOTATION_MARK actions QUOTATION_MARK
|
|
||||||
{
|
{
|
||||||
Operator *op = Operator::instantiate("\"@rx " + $5 + "\"");
|
Operator *op = Operator::instantiate("\"@rx " + $5 + "\"");
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
@ -369,7 +383,25 @@ expression:
|
|||||||
Rule *rule = new Rule(
|
Rule *rule = new Rule(
|
||||||
/* op */ op,
|
/* op */ op,
|
||||||
/* variables */ $3,
|
/* variables */ $3,
|
||||||
/* actions */ $8
|
/* actions */ $7
|
||||||
|
);
|
||||||
|
|
||||||
|
if (driver.addSecRule(rule) == false) {
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
| DIRECTIVE SPACE variables SPACE OPERATOR
|
||||||
|
{
|
||||||
|
Operator *op = Operator::instantiate("\"@rx " + $5 + "\"");
|
||||||
|
const char *error = NULL;
|
||||||
|
if (op->init(&error) == false) {
|
||||||
|
driver.error(@0, error);
|
||||||
|
YYERROR;
|
||||||
|
}
|
||||||
|
Rule *rule = new Rule(
|
||||||
|
/* op */ op,
|
||||||
|
/* variables */ $3,
|
||||||
|
/* actions */ NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
if (driver.addSecRule(rule) == false) {
|
if (driver.addSecRule(rule) == false) {
|
||||||
|
@ -97,6 +97,7 @@ Rule::Rule(Operator *_op,
|
|||||||
m_secmarker(false),
|
m_secmarker(false),
|
||||||
m_marker(""),
|
m_marker(""),
|
||||||
m_referenceCount(0) {
|
m_referenceCount(0) {
|
||||||
|
if (actions != NULL) {
|
||||||
for (Action *a : *actions) {
|
for (Action *a : *actions) {
|
||||||
if (a->action_kind == Action::ConfigurationKind) {
|
if (a->action_kind == Action::ConfigurationKind) {
|
||||||
actions_conf.push_back(a);
|
actions_conf.push_back(a);
|
||||||
@ -111,6 +112,7 @@ Rule::Rule(Operator *_op,
|
|||||||
delete a;
|
delete a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* If phase is not entered, we assume phase 2. For historical reasons.
|
* If phase is not entered, we assume phase 2. For historical reasons.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user