mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-17 22:56:18 +03:00
Fix logging MATCHED_VARS issue
This commit is contained in:
parent
352514f7d8
commit
cf97731cc0
@ -1129,7 +1129,7 @@ void sec_audit_logger(modsec_rec *msr) {
|
|||||||
/* Matched Rules */
|
/* Matched Rules */
|
||||||
for(i = 0; i < msr->matched_rules->nelts; i++) {
|
for(i = 0; i < msr->matched_rules->nelts; i++) {
|
||||||
rule = ((msre_rule **)msr->matched_rules->elts)[i];
|
rule = ((msre_rule **)msr->matched_rules->elts)[i];
|
||||||
if (rule != NULL && rule->actionset != NULL && rule->actionset->is_chained) {
|
if ((rule != NULL) && (rule->actionset != NULL) && rule->actionset->is_chained && (rule->chain_starter == NULL)) {
|
||||||
text = apr_psprintf(msr->mp, "Chain Starter [Match]: %s\n", rule->unparsed);
|
text = apr_psprintf(msr->mp, "Chain Starter [Match]: %s\n", rule->unparsed);
|
||||||
sec_auditlog_write(msr, text, strlen(text));
|
sec_auditlog_write(msr, text, strlen(text));
|
||||||
do {
|
do {
|
||||||
@ -1153,9 +1153,13 @@ void sec_audit_logger(modsec_rec *msr) {
|
|||||||
}
|
}
|
||||||
rule = next_rule;
|
rule = next_rule;
|
||||||
} while (rule != NULL && rule->actionset != NULL && rule->actionset->is_chained);
|
} while (rule != NULL && rule->actionset != NULL && rule->actionset->is_chained);
|
||||||
} else {
|
text = apr_psprintf(msr->mp, "\n");
|
||||||
text = apr_psprintf(msr->mp, "Rule [Match]: %s\n", rule->unparsed);
|
|
||||||
sec_auditlog_write(msr, text, strlen(text));
|
sec_auditlog_write(msr, text, strlen(text));
|
||||||
|
} else {
|
||||||
|
if ((rule != NULL) && (rule->actionset != NULL) && !rule->actionset->is_chained && (rule->chain_starter == NULL)) {
|
||||||
|
text = apr_psprintf(msr->mp, "Rule [Match]: %s\n\n", rule->unparsed);
|
||||||
|
sec_auditlog_write(msr, text, strlen(text));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1880,6 +1880,16 @@ static int var_matched_vars_names_generate(modsec_rec *msr, msre_var *var, msre_
|
|||||||
rvar->name = apr_psprintf(mptmp, "MATCHED_VARS_NAMES:%s",
|
rvar->name = apr_psprintf(mptmp, "MATCHED_VARS_NAMES:%s",
|
||||||
log_escape_nq(mptmp, str->name));
|
log_escape_nq(mptmp, str->name));
|
||||||
|
|
||||||
|
if(var->is_counting == 0)
|
||||||
|
rvar->is_counting = 0;
|
||||||
|
else
|
||||||
|
rvar->is_counting = 1;
|
||||||
|
|
||||||
|
if(var->is_negated == 0)
|
||||||
|
rvar->is_negated = 0;
|
||||||
|
else
|
||||||
|
rvar->is_negated = 1;
|
||||||
|
|
||||||
apr_table_setn(vartab, rvar->name, (void *)rvar);
|
apr_table_setn(vartab, rvar->name, (void *)rvar);
|
||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
@ -1923,7 +1933,6 @@ static int var_matched_vars_generate(modsec_rec *msr, msre_var *var, msre_rule *
|
|||||||
/* If we had a match add this argument to the collection. */
|
/* If we had a match add this argument to the collection. */
|
||||||
if (match && (strncmp(str->name,"MATCHED_VARS:",13) != 0) && (strncmp(str->name,"MATCHED_VARS_NAMES:",19))) {
|
if (match && (strncmp(str->name,"MATCHED_VARS:",13) != 0) && (strncmp(str->name,"MATCHED_VARS_NAMES:",19))) {
|
||||||
|
|
||||||
//msre_var *rvar = apr_pmemdup(mptmp, var, sizeof(msre_var));
|
|
||||||
msre_var *rvar = apr_palloc(mptmp, sizeof(msre_var));
|
msre_var *rvar = apr_palloc(mptmp, sizeof(msre_var));
|
||||||
|
|
||||||
rvar->value = apr_pstrndup(mptmp, str->value, str->value_len);
|
rvar->value = apr_pstrndup(mptmp, str->value, str->value_len);
|
||||||
@ -1931,6 +1940,16 @@ static int var_matched_vars_generate(modsec_rec *msr, msre_var *var, msre_rule *
|
|||||||
rvar->name = apr_psprintf(mptmp, "MATCHED_VARS:%s",
|
rvar->name = apr_psprintf(mptmp, "MATCHED_VARS:%s",
|
||||||
log_escape_nq(mptmp, str->name));
|
log_escape_nq(mptmp, str->name));
|
||||||
|
|
||||||
|
if(var->is_counting == 0)
|
||||||
|
rvar->is_counting = 0;
|
||||||
|
else
|
||||||
|
rvar->is_counting = 1;
|
||||||
|
|
||||||
|
if(var->is_negated == 0)
|
||||||
|
rvar->is_negated = 0;
|
||||||
|
else
|
||||||
|
rvar->is_negated = 1;
|
||||||
|
|
||||||
apr_table_setn(vartab, rvar->name, (void *)rvar);
|
apr_table_setn(vartab, rvar->name, (void *)rvar);
|
||||||
|
|
||||||
if (msr->txcfg->debuglog_level >= 9) {
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user