@@ -56,11 +56,19 @@ using TransformationResult = std::pair<std::shared_ptr<std::string>,
5656 std::shared_ptr<std::string>>;
5757using TransformationResults = std::list<TransformationResult>;
5858
59+ using Transformation = actions::transformations::Transformation;
60+ using Transformations = std::vector<Transformation *>;
61+
62+ using Tags = std::vector<actions::Tag *>;
63+ using SetVars = std::vector<actions::SetVar *>;
64+ using MatchActions = std::vector<actions::Action *>;
65+
5966class Rule {
6067 public:
61- Rule (operators::Operator *_op,
62- variables::Variables *_variables,
63- std::vector<actions::Action *> *_actions,
68+ Rule (operators::Operator *op,
69+ variables::Variables *variables,
70+ std::vector<actions::Action *> *actions,
71+ Transformations *transformations,
6472 std::unique_ptr<std::string> fileName,
6573 int lineNumber);
6674 explicit Rule (const std::string &marker);
@@ -108,37 +116,67 @@ class Rule {
108116 int *nth) const ;
109117
110118
111- actions::Action *m_theDisruptiveAction;
112- actions::LogData *m_logData;
113- actions::Msg *m_msg;
114- actions::Severity *m_severity;
115- bool m_chained;
116- bool m_containsCaptureAction;
117- bool m_containsMultiMatchAction;
118- bool m_containsStaticBlockAction;
119- bool m_secMarker;
119+
120+ inline bool isUnconditional () const { return m_operator == NULL ; }
121+
122+ virtual bool isMarker () { return m_isSecMarker; }
123+
124+ inline bool isChained () const { return m_isChained == true ; }
125+ inline bool hasCaptureAction () const { return m_containsCaptureAction == true ; }
126+ inline void setChained (bool b) { m_isChained = b; }
127+ inline bool hasDisruptiveAction () const { return m_disruptiveAction != NULL ; }
128+
129+
130+ inline bool hasLogData () const { return m_logData != NULL ; }
131+ std::string logData (Transaction *t);
132+ inline bool hasMsg () const { return m_msg != NULL ; }
133+ std::string msg (Transaction *t);
134+ inline bool hasSeverity () const { return m_severity != NULL ; }
135+ int severity () const ;
136+ int getPhase () const { return m_phase; }
137+ void setPhase (int phase) { m_phase = phase; }
138+
139+ std::string getOperatorName () const ;
140+
120141 int64_t m_ruleId;
121- int m_accuracy;
122- int m_lineNumber;
123- int m_maturity;
124- int m_phase;
125- modsecurity::variables::Variables *m_variables;
126- operators::Operator *m_op;
127142 std::unique_ptr<Rule> m_chainedRuleChild;
128143 Rule *m_chainedRuleParent;
144+
129145 std::shared_ptr<std::string> m_fileName;
146+
130147 std::string m_marker;
131148 std::string m_rev;
132149 std::string m_ver;
133- std::vector<actions::Action *> m_actionsRuntimePos;
134- std::vector<actions::Action *> m_actionsRuntimePre;
135- std::vector<actions::SetVar *> m_actionsSetVar;
136- std::vector<actions::Tag *> m_actionsTag;
150+ int m_accuracy;
151+ int m_maturity;
152+ int m_lineNumber;
137153
138154 private:
139- bool m_unconditional;
140- };
155+ modsecurity::variables::Variables *m_variables;
156+ operators::Operator *m_operator;
157+
158+ /* actions */
159+ actions::Action *m_disruptiveAction;
160+ actions::LogData *m_logData;
161+ actions::Msg *m_msg;
162+ actions::Severity *m_severity;
163+ MatchActions m_actionsRuntimePos;
164+ SetVars m_actionsSetVar;
165+ Tags m_actionsTag;
166+
167+ /* actions > transformations */
168+ Transformations m_transformations;
141169
170+ bool m_containsCaptureAction:1 ;
171+ bool m_containsMultiMatchAction:1 ;
172+ bool m_containsStaticBlockAction:1 ;
173+ bool m_isChained:1 ;
174+ bool m_isSecMarker:1 ;
175+ bool m_unconditional:1 ;
176+
177+ int m_phase;
178+
179+ };
142180
143181} // namespace modsecurity
144182#endif
0 commit comments