Skip to content

Commit 0ca5994

Browse files
author
Felipe Zimmerle
committed
Adds support for ctl:ruleRemoveByTag action
1 parent 9537cfc commit 0ca5994

16 files changed

+7387
-7143
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.x - YYYY-MMM-DD (To be released)
22
-------------------------------------
33

4+
- Adds support for ctl:ruleRemoveById
5+
[@zimmerle]
46
- Fix SecUploadDir configuration merge
57
[Issue #1720 - @zimmerle, @gjvanetten]
68
- Include all prerequisites for "make check" into dist archive

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ TESTS+=test/test-cases/regression/action-ctl_request_body_access.json
9191
TESTS+=test/test-cases/regression/action-ctl_request_body_processor.json
9292
TESTS+=test/test-cases/regression/action-ctl_rule_engine.json
9393
TESTS+=test/test-cases/regression/action-ctl_rule_remove_by_id.json
94+
TESTS+=test/test-cases/regression/action-ctl_rule_remove_by_tag.json
9495
TESTS+=test/test-cases/regression/action-ctl_rule_remove_target_by_id.json
9596
TESTS+=test/test-cases/regression/action-ctl_rule_remove_target_by_tag.json
9697
TESTS+=test/test-cases/regression/action-disruptive.json

headers/modsecurity/transaction.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,11 @@ class Transaction : public TransactionAnchoredVariables {
438438
*/
439439
std::list<int > m_ruleRemoveById;
440440

441+
/**
442+
*
443+
*/
444+
std::list<std::string> m_ruleRemoveByTag;
445+
441446
/**
442447
*
443448
*/

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ ACTIONS = \
115115
actions/ctl/rule_remove_target_by_tag.cc \
116116
actions/ctl/rule_remove_target_by_id.cc \
117117
actions/ctl/rule_remove_by_id.cc \
118+
actions/ctl/rule_remove_by_tag.cc \
118119
actions/ctl/request_body_access.cc\
119120
actions/disruptive/allow.cc \
120121
actions/disruptive/block.cc \

src/actions/ctl/rule_remove_by_tag.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* ModSecurity, http://www.modsecurity.org/
3+
* Copyright (c) 2015 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 [email protected].
13+
*
14+
*/
15+
16+
#include "src/actions/ctl/rule_remove_by_tag.h"
17+
18+
#include <iostream>
19+
#include <string>
20+
21+
#include "modsecurity/transaction.h"
22+
23+
namespace modsecurity {
24+
namespace actions {
25+
namespace ctl {
26+
27+
28+
bool RuleRemoveByTag::init(std::string *error) {
29+
std::string what(m_parser_payload, 16, m_parser_payload.size() - 16);
30+
m_tag = what;
31+
32+
return true;
33+
}
34+
35+
bool RuleRemoveByTag::evaluate(Rule *rule, Transaction *transaction) {
36+
transaction->m_ruleRemoveByTag.push_back(m_tag);
37+
return true;
38+
}
39+
40+
41+
} // namespace ctl
42+
} // namespace actions
43+
} // namespace modsecurity

src/actions/ctl/rule_remove_by_tag.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* ModSecurity, http://www.modsecurity.org/
3+
* Copyright (c) 2015 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 [email protected].
13+
*
14+
*/
15+
16+
#include <string>
17+
18+
#include "modsecurity/actions/action.h"
19+
#include "modsecurity/transaction.h"
20+
21+
22+
#ifndef SRC_ACTIONS_CTL_RULE_REMOVE_BY_TAG_H_
23+
#define SRC_ACTIONS_CTL_RULE_REMOVE_BY_TAG_H_
24+
25+
namespace modsecurity {
26+
namespace actions {
27+
namespace ctl {
28+
29+
30+
class RuleRemoveByTag : public Action {
31+
public:
32+
explicit RuleRemoveByTag(std::string action)
33+
: Action(action, RunTimeOnlyIfMatchKind),
34+
m_tag("") { }
35+
36+
bool init(std::string *error) override;
37+
bool evaluate(Rule *rule, Transaction *transaction) override;
38+
39+
std::string m_tag;
40+
};
41+
42+
43+
} // namespace ctl
44+
} // namespace actions
45+
} // namespace modsecurity
46+
47+
#endif // SRC_ACTIONS_CTL_RULE_REMOVE_BY_TAG_H_

0 commit comments

Comments
 (0)