Skip to content

Commit 85ecd19

Browse files
author
Felipe Zimmerle
committed
Adds full support to UpdateActionById.
Issue #1800
1 parent 3e8e28d commit 85ecd19

17 files changed

+961
-717
lines changed

Diff for: CHANGES

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.3 - YYYY-MMM-DD (to be released)
22
-------------------------------------
33

4+
- Adds support to UpdateActionById.
5+
[Issue #1800 - @zimmerle, @victorhora, @NisariAIT]
46
- Add correct C function prototypes for msc_init and msc_create_rule_set
57
[Issue #1922 - @steven-j-wojcik]
68
- Allow LuaJIT 2.1 to be used

Diff for: Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ TESTS+=test/test-cases/regression/variable-RESPONSE_BODY.json
183183
TESTS+=test/test-cases/regression/config-calling_phases_by_name.json
184184
TESTS+=test/test-cases/regression/variable-FILES_COMBINED_SIZE.json
185185
TESTS+=test/test-cases/regression/variable-FULL_REQUEST_LENGTH.json
186+
TESTS+=test/test-cases/regression/config-update-action-by-id.json
186187
TESTS+=test/test-cases/regression/config-update-target-by-id.json
187188
TESTS+=test/test-cases/regression/variable-REQUEST_HEADERS.json
188189
TESTS+=test/test-cases/regression/misc.json

Diff for: headers/modsecurity/rule.h

+17-24
Original file line numberDiff line numberDiff line change
@@ -124,36 +124,29 @@ class Rule {
124124
std::shared_ptr<std::string> transStr,
125125
int nth);
126126

127-
std::vector<actions::Action *> m_actionsRuntimePos;
128-
std::vector<actions::Action *> m_actionsRuntimePre;
127+
actions::Action *m_theDisruptiveAction;
128+
actions::LogData *m_logData;
129+
actions::Msg *m_msg;
130+
actions::Severity *m_severity;
129131
bool m_chained;
130-
Rule *m_chainedRule;
131-
std::string m_fileName;
132-
int m_lineNumber;
133-
std::string m_marker;
134-
operators::Operator *m_op;
132+
bool m_containsCaptureAction;
133+
bool m_containsMultiMatchAction;
134+
bool m_containsStaticBlockAction;
135135
bool m_secMarker;
136-
modsecurity::Variables::Variables *m_variables;
137-
138-
139136
int64_t m_ruleId;
140-
std::string m_rev;
141-
// msg ?
142-
std::string m_ver;
143-
//std::string m_logData;
144-
145-
//if (child->severity != NOT_SET) merged->severity = child->severity;
146137
int m_accuracy;
138+
int m_lineNumber;
147139
int m_maturity;
148140
int m_phase;
149-
150-
bool m_containsStaticDisruptiveAction;
151-
bool m_containsCaptureAction;
152-
bool m_containsMultiMatchAction;
153-
bool m_containsStaticBlockAction;
154-
actions::Severity *m_severity;
155-
actions::LogData *m_logData;
156-
actions::Msg *m_msg;
141+
modsecurity::Variables::Variables *m_variables;
142+
operators::Operator *m_op;
143+
Rule *m_chainedRule;
144+
std::string m_fileName;
145+
std::string m_marker;
146+
std::string m_rev;
147+
std::string m_ver;
148+
std::vector<actions::Action *> m_actionsRuntimePos;
149+
std::vector<actions::Action *> m_actionsRuntimePre;
157150
std::vector<actions::SetVar *> m_actionsSetVar;
158151
std::vector<actions::Tag *> m_actionsTag;
159152
private:

Diff for: src/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ ACTIONS = \
106106
actions/accuracy.cc \
107107
actions/action.cc \
108108
actions/audit_log.cc \
109+
actions/block.cc \
109110
actions/capture.cc \
110111
actions/chain.cc \
111112
actions/ctl/audit_log_parts.cc \
@@ -119,7 +120,6 @@ ACTIONS = \
119120
actions/ctl/rule_remove_by_tag.cc \
120121
actions/ctl/request_body_access.cc\
121122
actions/disruptive/allow.cc \
122-
actions/disruptive/block.cc \
123123
actions/disruptive/deny.cc \
124124
actions/disruptive/redirect.cc \
125125
actions/disruptive/pass.cc \

Diff for: src/actions/action.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "modsecurity/rule.h"
2323
#include "src/utils/string.h"
2424

25-
#include "src/actions/disruptive/block.h"
25+
#include "src/actions/block.h"
2626
#include "src/actions/chain.h"
2727
#include "src/actions/disruptive/deny.h"
2828
#include "src/actions/disruptive/redirect.h"

Diff for: src/actions/disruptive/block.cc renamed to src/actions/block.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*/
1515

16-
#include "src/actions/disruptive/block.h"
16+
#include "src/actions/block.h"
1717

1818
#include <iostream>
1919
#include <string>
@@ -27,7 +27,6 @@
2727

2828
namespace modsecurity {
2929
namespace actions {
30-
namespace disruptive {
3130

3231

3332
bool Block::evaluate(Rule *rule, Transaction *transaction,
@@ -37,8 +36,7 @@ bool Block::evaluate(Rule *rule, Transaction *transaction,
3736
#endif
3837

3938
for (Action *a : transaction->m_rules->m_defaultActions[rule->m_phase]) {
40-
if (a->isDisruptive() == false
41-
|| dynamic_cast<actions::disruptive::Block *>(a) != NULL) {
39+
if (a->isDisruptive() == false) {
4240
continue;
4341
}
4442
a->evaluate(rule, transaction, rm);
@@ -48,6 +46,5 @@ bool Block::evaluate(Rule *rule, Transaction *transaction,
4846
}
4947

5048

51-
} // namespace disruptive
5249
} // namespace actions
5350
} // namespace modsecurity

Diff for: src/actions/disruptive/block.h renamed to src/actions/block.h

-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ namespace modsecurity {
2929
class Transaction;
3030

3131
namespace actions {
32-
namespace disruptive {
3332

3433

3534
class Block : public Action {
@@ -38,11 +37,9 @@ class Block : public Action {
3837

3938
bool evaluate(Rule *rule, Transaction *transaction,
4039
std::shared_ptr<RuleMessage> rm) override;
41-
bool isDisruptive() override { return true; }
4240
};
4341

4442

45-
} // namespace disruptive
4643
} // namespace actions
4744
} // namespace modsecurity
4845
#endif

Diff for: src/parser/driver.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ int Driver::addSecRule(Rule *rule) {
8181
if (lastRule->m_chainedRule == NULL) {
8282
rule->m_phase = lastRule->m_phase;
8383
lastRule->m_chainedRule = rule;
84-
if (rule->m_containsStaticDisruptiveAction) {
84+
if (rule->m_theDisruptiveAction) {
8585
m_parserError << "Disruptive actions can only be specified by";
8686
m_parserError << " chain starter rules.";
8787
return false;
@@ -94,7 +94,7 @@ int Driver::addSecRule(Rule *rule) {
9494
}
9595
if (a->m_chained && a->m_chainedRule == NULL) {
9696
a->m_chainedRule = rule;
97-
if (a->m_containsStaticDisruptiveAction) {
97+
if (a->m_theDisruptiveAction) {
9898
m_parserError << "Disruptive actions can only be ";
9999
m_parserError << "specified by chain starter rules.";
100100
return false;

0 commit comments

Comments
 (0)