1313 *
1414 */
1515
16- #ifdef __cplusplus
17-
18- #include < string>
19- #include < iostream>
20- #include < memory>
21-
22- #endif
23-
24- #include " modsecurity/intervention.h"
25- #include " modsecurity/rule.h"
26- #include " modsecurity/rule_with_actions.h"
27-
2816#ifndef HEADERS_MODSECURITY_ACTIONS_ACTION_H_
2917#define HEADERS_MODSECURITY_ACTIONS_ACTION_H_
3018
3119#ifdef __cplusplus
3220
21+ #include < string>
22+ #include < memory>
23+
3324namespace modsecurity {
3425class Transaction ;
3526class RuleWithOperator ;
27+ class RuleWithActions ;
28+ class RuleMessage ;
3629
3730namespace actions {
3831
3932
4033class Action {
4134 public:
35+ /* *
36+ *
37+ * Define the action kind regarding to the execution time.
38+ *
39+ *
40+ */
41+ enum class Kind {
42+ /* *
43+ *
44+ * Action that are executed while loading the configuration. For instance
45+ * the rule ID or the rule phase.
46+ *
47+ */
48+ ConfigurationKind,
49+ /* *
50+ *
51+ * Those are actions that demands to be executed before call the operator.
52+ * For instance the tranformations.
53+ *
54+ *
55+ */
56+ RunTimeBeforeMatchAttemptKind,
57+ /* *
58+ *
59+ * Actions that are executed after the execution of the operator, only if
60+ * the operator returned Match (or True). For instance the disruptive
61+ * actions.
62+ *
63+ */
64+ RunTimeOnlyIfMatchKind,
65+ };
66+
4267 explicit Action (const std::string& _action)
4368 : m_isNone(false ),
4469 temporaryAction(false ),
45- action_kind(2 ),
70+ action_kind(Kind::RunTimeOnlyIfMatchKind ),
4671 m_name(nullptr ),
4772 m_parser_payload(" " ) {
4873 set_name_and_payload (_action);
4974 }
50- explicit Action (const std::string& _action, int kind)
75+ explicit Action (const std::string& _action, Kind kind)
5176 : m_isNone(false ),
5277 temporaryAction(false ),
5378 action_kind(kind),
@@ -74,8 +99,6 @@ class Action {
7499
75100 virtual ~Action () { }
76101
77- virtual std::string evaluate (const std::string &exp,
78- Transaction *transaction);
79102 virtual bool evaluate (RuleWithActions *rule, Transaction *transaction);
80103 virtual bool evaluate (RuleWithActions *rule, Transaction *transaction,
81104 std::shared_ptr<RuleMessage> ruleMessage) {
@@ -87,9 +110,9 @@ class Action {
87110
88111 void set_name_and_payload (const std::string& data) {
89112 size_t pos = data.find (" :" );
90- std::string t = " t:" ;
113+ const char t[] = " t:" ;
91114
92- if (data.compare (0 , t. length () , t) == 0 ) {
115+ if (data.compare (0 , std::size (t) - 1 , t) == 0 ) {
93116 pos = data.find (" :" , 2 );
94117 }
95118
@@ -109,41 +132,9 @@ class Action {
109132
110133 bool m_isNone;
111134 bool temporaryAction;
112- int action_kind;
135+ Kind action_kind;
113136 std::shared_ptr<std::string> m_name;
114137 std::string m_parser_payload;
115-
116- /* *
117- *
118- * Define the action kind regarding to the execution time.
119- *
120- *
121- */
122- enum Kind {
123- /* *
124- *
125- * Action that are executed while loading the configuration. For instance
126- * the rule ID or the rule phase.
127- *
128- */
129- ConfigurationKind,
130- /* *
131- *
132- * Those are actions that demands to be executed before call the operator.
133- * For instance the tranformations.
134- *
135- *
136- */
137- RunTimeBeforeMatchAttemptKind,
138- /* *
139- *
140- * Actions that are executed after the execution of the operator, only if
141- * the operator returned Match (or True). For instance the disruptive
142- * actions.
143- *
144- */
145- RunTimeOnlyIfMatchKind,
146- };
147138 };
148139
149140
0 commit comments