@@ -60,6 +60,8 @@ using TransformationResults = std::list<TransformationResult>;
60
60
using Transformation = actions::transformations::Transformation;
61
61
using Transformations = std::vector<Transformation *>;
62
62
63
+ using Actions = std::vector<actions::Action *>;
64
+
63
65
using Tags = std::vector<actions::Tag *>;
64
66
using SetVars = std::vector<actions::SetVar *>;
65
67
using MatchActions = std::vector<actions::Action *>;
@@ -137,49 +139,21 @@ class RuleMarker : public RuleBase {
137
139
};
138
140
139
141
140
- class Rule : public RuleBase {
142
+ class RuleWithActions : public RuleBase {
141
143
public:
142
- Rule (operators::Operator *op,
143
- variables::Variables *variables,
144
- std::vector<actions::Action *> *actions,
145
- Transformations *transformations,
146
- std::unique_ptr<std::string> fileName,
147
- int lineNumber);
148
- explicit Rule (const std::string &marker,
149
- std::unique_ptr<std::string> fileName,
150
- int lineNumber);
151
- virtual ~Rule ();
144
+ RuleWithActions (
145
+ Actions *a,
146
+ Transformations *t,
147
+ std::unique_ptr<std::string> fileName,
148
+ int lineNumber);
152
149
153
- virtual bool evaluate (Transaction *transaction,
154
- std::shared_ptr<RuleMessage> rm) override ;
150
+ ~RuleWithActions ();
155
151
156
- void organizeActions (std::vector<actions::Action *> *actions);
157
- void cleanUpActions ();
158
152
void executeAction (Transaction *trans,
159
- bool containsBlock, std::shared_ptr<RuleMessage> ruleMessage,
160
- actions::Action *a, bool context);
161
-
162
-
163
- void getVariablesExceptions (Transaction *t,
164
- variables::Variables *exclusion, variables::Variables *addition);
165
- inline void getFinalVars (variables::Variables *vars,
166
- variables::Variables *eclusion, Transaction *trans);
167
- void executeActionsAfterFullMatch (Transaction *trasn,
168
- bool containsDisruptive, std::shared_ptr<RuleMessage> ruleMessage);
169
-
170
- bool executeOperatorAt (Transaction *trasn, const std::string &key,
171
- std::string value, std::shared_ptr<RuleMessage> rm);
172
- void executeActionsIndependentOfChainedRuleResult (Transaction *trasn,
173
- bool *b, std::shared_ptr<RuleMessage> ruleMessage);
174
- static inline void updateMatchedVars (Transaction *trasn, const std::string &key,
175
- const std::string &value);
176
- static inline void cleanMatchedVars (Transaction *trasn);
177
-
178
- std::vector<actions::Action *> getActionsByName (const std::string& name,
179
- Transaction *t);
180
- bool containsTag (const std::string& name, Transaction *t);
181
- bool containsMsg (const std::string& name, Transaction *t);
182
-
153
+ bool containsBlock,
154
+ std::shared_ptr<RuleMessage> ruleMessage,
155
+ actions::Action *a,
156
+ bool context);
183
157
184
158
void executeTransformations (
185
159
Transaction *trasn, const std::string &value, TransformationResults &ret);
@@ -191,15 +165,22 @@ class Rule : public RuleBase {
191
165
std::string *path,
192
166
int *nth) const ;
193
167
168
+ void executeActionsIndependentOfChainedRuleResult (Transaction *trasn,
169
+ bool *b, std::shared_ptr<RuleMessage> ruleMessage);
170
+ void executeActionsAfterFullMatch (Transaction *trasn,
171
+ bool containsDisruptive, std::shared_ptr<RuleMessage> ruleMessage);
194
172
195
-
196
- inline bool isUnconditional () const { return m_operator == NULL ; }
173
+ std::vector<actions::Action *> getActionsByName (const std::string& name,
174
+ Transaction *t);
175
+ bool containsTag (const std::string& name, Transaction *t);
176
+ bool containsMsg (const std::string& name, Transaction *t);
197
177
198
178
inline bool isChained () const { return m_isChained == true ; }
199
179
inline bool hasCaptureAction () const { return m_containsCaptureAction == true ; }
200
180
inline void setChained (bool b) { m_isChained = b; }
201
181
inline bool hasDisruptiveAction () const { return m_disruptiveAction != NULL ; }
202
-
182
+ inline bool hasBlockAction () const { return m_containsStaticBlockAction == true ; }
183
+ inline bool hasMultimatch () const { return m_containsMultiMatchAction == true ; }
203
184
204
185
inline bool hasLogData () const { return m_logData != NULL ; }
205
186
std::string logData (Transaction *t);
@@ -208,27 +189,14 @@ class Rule : public RuleBase {
208
189
inline bool hasSeverity () const { return m_severity != NULL ; }
209
190
int severity () const ;
210
191
211
- std::string getOperatorName () const ;
212
-
213
- int64_t m_ruleId;
214
-
215
- virtual std::string getReference () override {
216
- return std::to_string (m_ruleId);
217
- }
218
-
219
- std::unique_ptr<Rule> m_chainedRuleChild;
220
- Rule *m_chainedRuleParent;
221
-
222
- std::string m_marker;
223
192
std::string m_rev;
224
193
std::string m_ver;
225
194
int m_accuracy;
226
195
int m_maturity;
227
196
228
- private:
229
- modsecurity::variables::Variables *m_variables;
230
- operators::Operator *m_operator;
197
+ int64_t m_ruleId;
231
198
199
+ private:
232
200
/* actions */
233
201
actions::Action *m_disruptiveAction;
234
202
actions::LogData *m_logData;
@@ -245,11 +213,51 @@ class Rule : public RuleBase {
245
213
bool m_containsMultiMatchAction:1 ;
246
214
bool m_containsStaticBlockAction:1 ;
247
215
bool m_isChained:1 ;
248
- bool m_isSecMarker:1 ;
249
- bool m_unconditional:1 ;
216
+ };
217
+
218
+
219
+ class Rule : public RuleWithActions {
220
+ public:
221
+ Rule (operators::Operator *op,
222
+ variables::Variables *variables,
223
+ std::vector<actions::Action *> *actions,
224
+ Transformations *transformations,
225
+ std::unique_ptr<std::string> fileName,
226
+ int lineNumber);
227
+
228
+ virtual ~Rule ();
229
+
230
+ bool evaluate (Transaction *transaction,
231
+ std::shared_ptr<RuleMessage> rm) override ;
232
+
233
+ void getVariablesExceptions (Transaction *t,
234
+ variables::Variables *exclusion, variables::Variables *addition);
235
+ inline void getFinalVars (variables::Variables *vars,
236
+ variables::Variables *eclusion, Transaction *trans);
237
+
238
+ bool executeOperatorAt (Transaction *trasn, const std::string &key,
239
+ std::string value, std::shared_ptr<RuleMessage> rm);
240
+
241
+ static void updateMatchedVars (Transaction *trasn, const std::string &key,
242
+ const std::string &value);
243
+ static void cleanMatchedVars (Transaction *trasn);
244
+
245
+ inline bool isUnconditional () const { return m_operator == NULL ; }
246
+
247
+ std::string getOperatorName () const ;
250
248
249
+ virtual std::string getReference () override {
250
+ return std::to_string (m_ruleId);
251
+ }
251
252
253
+ std::unique_ptr<Rule> m_chainedRuleChild;
254
+ Rule *m_chainedRuleParent;
252
255
256
+ private:
257
+ modsecurity::variables::Variables *m_variables;
258
+ operators::Operator *m_operator;
259
+
260
+ bool m_unconditional:1 ;
253
261
};
254
262
255
263
} // namespace modsecurity
0 commit comments