@@ -273,7 +273,7 @@ class RulesProperties {
273
273
std::ostringstream *err) {
274
274
int amount_of_rules = 0 ;
275
275
276
- amount_of_rules = appendRules (from-> m_rules , to-> m_rules , err);
276
+ amount_of_rules = appendRules (from, to, err);
277
277
if (amount_of_rules < 0 ) {
278
278
return amount_of_rules;
279
279
}
@@ -426,20 +426,22 @@ class RulesProperties {
426
426
427
427
428
428
static int appendRules (
429
- std::vector<modsecurity::Rule *> *from,
430
- std::vector<modsecurity::Rule *> *to,
429
+ RulesProperties *from,
430
+ RulesProperties *to,
431
431
std::ostringstream *err) {
432
+ std::vector<modsecurity::Rule *> *from_rules = from->m_rules ;
433
+ std::vector<modsecurity::Rule *> *to_rules = to->m_rules ;
432
434
int amount_of_rules = 0 ;
433
435
for (int i = 0 ; i < modsecurity::Phases::NUMBER_OF_PHASES; i++) {
434
- std::vector<modsecurity::Rule *> *rules_to = to +i;
435
- std::vector<modsecurity::Rule *> *rules_from = from +i;
436
+ std::vector<modsecurity::Rule *> *rules_to = to_rules +i;
437
+ std::vector<modsecurity::Rule *> *rules_from = from_rules +i;
436
438
for (size_t j = 0 ; j < rules_from->size (); j++) {
437
439
Rule *rule = rules_from->at (j);
438
- for ( size_t z = 0 ; z < rules_to-> size (); z++) {
439
- Rule *rule_ckc = rules_to-> at (z);
440
- if (rule_ckc-> m_ruleId == rule-> m_ruleId &&
441
- rule_ckc-> m_secMarker == false &&
442
- rule-> m_secMarker == false ) {
440
+ bool do_check = rule-> m_secMarker == false ;
441
+
442
+ if (do_check) {
443
+ std::set< int64_t >::iterator it = to-> m_ruleIds . find (rule-> m_ruleId );
444
+ if (it != to-> m_ruleIds . end () ) {
443
445
if (err != NULL ) {
444
446
*err << " Rule id: " \
445
447
<< std::to_string (rule->m_ruleId ) \
@@ -448,9 +450,13 @@ class RulesProperties {
448
450
return -1 ;
449
451
}
450
452
}
453
+
451
454
amount_of_rules++;
452
455
rules_to->push_back (rule);
453
456
rule->refCountIncrease ();
457
+
458
+ if (do_check)
459
+ to->m_ruleIds .insert (rule->m_ruleId );
454
460
}
455
461
}
456
462
return amount_of_rules;
@@ -492,6 +498,7 @@ class RulesProperties {
492
498
ConfigString m_secWebAppId;
493
499
std::vector<actions::Action *> m_defaultActions[8 ];
494
500
std::vector<modsecurity::Rule *> m_rules[8 ];
501
+ std::set<int64_t > m_ruleIds;
495
502
ConfigUnicodeMap m_unicodeMapTable;
496
503
};
497
504
0 commit comments