@@ -151,69 +151,69 @@ std::string Rules::getParserError() {
151
151
}
152
152
153
153
154
- int Rules::evaluate (int phase, Transaction *transaction ) {
154
+ int Rules::evaluate (int phase, Transaction *t ) {
155
155
if (phase > modsecurity::Phases::NUMBER_OF_PHASES) {
156
156
return 0 ;
157
157
}
158
158
159
159
std::vector<Rule *> rules = m_rules[phase];
160
160
161
- debug (9 , " This phase consists of " + std::to_string (rules. size ()) + \
162
- " rule(s)." );
161
+ t-> debug (9 , " This phase consists of " \
162
+ + std::to_string (rules. size ()) + " rule(s)." );
163
163
164
- if (transaction ->m_allowType == actions::disruptive::FromNowOnAllowType
164
+ if (t ->m_allowType == actions::disruptive::FromNowOnAllowType
165
165
&& phase != modsecurity::Phases::LoggingPhase) {
166
- debug (9 , " Skipping all rules evaluation on this phase as request " \
166
+ t-> debug (9 , " Skipping all rules evaluation on this phase as request " \
167
167
" through the utilization of an `allow' action." );
168
168
return true ;
169
169
}
170
- if (transaction ->m_allowType == actions::disruptive::RequestAllowType
170
+ if (t ->m_allowType == actions::disruptive::RequestAllowType
171
171
&& phase <= modsecurity::Phases::RequestBodyPhase) {
172
- debug (9 , " Skipping all rules evaluation on this phase as request " \
172
+ t-> debug (9 , " Skipping all rules evaluation on this phase as request " \
173
173
" through the utilization of an `allow' action." );
174
174
return true ;
175
175
}
176
- if (transaction ->m_allowType != actions::disruptive::NoneAllowType) {
177
- transaction ->m_allowType = actions::disruptive::NoneAllowType;
176
+ if (t ->m_allowType != actions::disruptive::NoneAllowType) {
177
+ t ->m_allowType = actions::disruptive::NoneAllowType;
178
178
}
179
179
180
180
for (int i = 0 ; i < rules.size (); i++) {
181
181
Rule *rule = rules[i];
182
- if (transaction ->m_marker .empty () == false ) {
182
+ if (t ->m_marker .empty () == false ) {
183
183
#ifndef NO_LOGS
184
- debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
185
- + " ' due to a SecMarker: " + transaction ->m_marker );
184
+ t-> debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
185
+ + " ' due to a SecMarker: " + t ->m_marker );
186
186
m_secmarker_skipped++;
187
- debug (9 , " Rule: " + rule->m_marker );
187
+ t-> debug (9 , " Rule: " + rule->m_marker );
188
188
#endif
189
- if (rule->m_secMarker && rule->m_marker == transaction ->m_marker ) {
189
+ if (rule->m_secMarker && rule->m_marker == t ->m_marker ) {
190
190
#ifndef NO_LOGS
191
- debug (4 , " Out of a SecMarker after skip " \
191
+ t-> debug (4 , " Out of a SecMarker after skip " \
192
192
+ std::to_string (m_secmarker_skipped) + " rules." );
193
193
#endif
194
- transaction ->m_marker .clear ();
194
+ t ->m_marker .clear ();
195
195
#ifndef NO_LOGS
196
196
m_secmarker_skipped = 0 ;
197
197
#endif
198
198
}
199
- } else if (transaction ->m_skip_next > 0 ) {
200
- transaction ->m_skip_next --;
201
- debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
199
+ } else if (t ->m_skip_next > 0 ) {
200
+ t ->m_skip_next --;
201
+ t-> debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
202
202
+ " ' due to a `skip' action. Still " + \
203
- std::to_string (transaction ->m_skip_next ) + " to be skipped." );
204
- } else if (transaction ->m_allowType
203
+ std::to_string (t ->m_skip_next ) + " to be skipped." );
204
+ } else if (t ->m_allowType
205
205
!= actions::disruptive::NoneAllowType) {
206
- debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
206
+ t-> debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
207
207
+ " ' as request trough the utilization of an `allow' action." );
208
208
} else if (m_exceptions.contains (rule->m_ruleId )) {
209
- debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
209
+ t-> debug (9 , " Skipped rule id '" + std::to_string (rule->m_ruleId ) \
210
210
+ " '. Removed by an SecRuleRemove directive." );
211
211
} else {
212
212
bool remove_rule = false ;
213
213
if (m_exceptions.m_remove_rule_by_msg .empty () == false ) {
214
214
for (auto &z : m_exceptions.m_remove_rule_by_msg ) {
215
- if (rule->containsMsg (z, transaction ) == true ) {
216
- debug (9 , " Skipped rule id '" \
215
+ if (rule->containsMsg (z, t ) == true ) {
216
+ t-> debug (9 , " Skipped rule id '" \
217
217
+ std::to_string (rule->m_ruleId ) \
218
218
+ " '. Removed by a SecRuleRemoveByMsg directive." );
219
219
remove_rule = true ;
@@ -227,8 +227,8 @@ int Rules::evaluate(int phase, Transaction *transaction) {
227
227
228
228
if (m_exceptions.m_remove_rule_by_tag .empty () == false ) {
229
229
for (auto &z : m_exceptions.m_remove_rule_by_tag ) {
230
- if (rule->containsTag (z, transaction ) == true ) {
231
- debug (9 , " Skipped rule id '" \
230
+ if (rule->containsTag (z, t ) == true ) {
231
+ t-> debug (9 , " Skipped rule id '" \
232
232
+ std::to_string (rule->m_ruleId ) \
233
233
+ " '. Removed by a SecRuleRemoveByTag directive." );
234
234
remove_rule = true ;
@@ -240,19 +240,19 @@ int Rules::evaluate(int phase, Transaction *transaction) {
240
240
}
241
241
}
242
242
243
- for (auto &z : transaction ->m_ruleRemoveByTag ) {
244
- if (rule->containsTag (z, transaction ) == true ) {
245
- debug (9 , " Skipped rule id '" \
243
+ for (auto &z : t ->m_ruleRemoveByTag ) {
244
+ if (rule->containsTag (z, t ) == true ) {
245
+ t-> debug (9 , " Skipped rule id '" \
246
246
+ std::to_string (rule->m_ruleId ) \
247
247
+ " '. Skipped due to a ruleRemoveByTag action." );
248
248
remove_rule = true ;
249
249
break ;
250
250
}
251
251
}
252
252
253
- rule->evaluate (transaction , NULL );
254
- if (transaction ->m_it .disruptive == true ) {
255
- debug (8 , " Skipping this phase as this " \
253
+ rule->evaluate (t , NULL );
254
+ if (t ->m_it .disruptive == true ) {
255
+ t-> debug (8 , " Skipping this phase as this " \
256
256
" request was already intercepted." );
257
257
break ;
258
258
}
@@ -284,10 +284,10 @@ int Rules::merge(Rules *from) {
284
284
}
285
285
286
286
287
-
288
- void Rules::debug ( int level, std::string message ) {
287
+ void Rules::debug ( int level, const std::string &id,
288
+ const std::string &uri, const std::string &msg ) {
289
289
if (m_debugLog != NULL ) {
290
- m_debugLog->write (level, message );
290
+ m_debugLog->write (level, id, uri, msg );
291
291
}
292
292
}
293
293
0 commit comments