diff --git a/apache2/msc_logging.c b/apache2/msc_logging.c index 5dc7ec1e..7944c523 100644 --- a/apache2/msc_logging.c +++ b/apache2/msc_logging.c @@ -461,12 +461,26 @@ msre_rule *return_chained_rule(const msre_rule *current, modsec_rec *msr) { rule = rules[i]; if (rule != NULL) { if (strncmp(current->unparsed,rule->unparsed,strlen(current->unparsed)) == 0) { + if (i < arr->nelts -1) { next_rule = rules[i+1]; } else { next_rule = rules[i]; } + if (next_rule == NULL || next_rule->chain_starter == NULL) + return NULL; + + if(current->chain_starter == NULL && next_rule->chain_starter != NULL) { + if (strncmp(current->unparsed, next_rule->chain_starter->unparsed, strlen(current->unparsed)) != 0) + return NULL; + } + + if(current->chain_starter != NULL && next_rule->chain_starter != NULL) { + if (strncmp(current->chain_starter->unparsed, rule->chain_starter->unparsed, strlen(current->chain_starter->unparsed)) != 0) + return NULL; + } + if (msr->txcfg->debuglog_level >= 9) { msr_log(msr, 9, "Logging [K]: Found chained rule: \"%s\" and next node: \"%s\".", log_escape(msr->mp, current->unparsed), next_rule == NULL ? "-" : log_escape(msr->mp, next_rule->unparsed)); }