Skip to content

Commit 538d3df

Browse files
alonzopappgwwaf
authored andcommitted
trunk the name to 252 to allow rule info to be propegated to the error log (both apache & iis) (#120)
(cherry picked from commit 565dc00)
1 parent 8a01db4 commit 538d3df

File tree

1 file changed

+7
-33
lines changed

1 file changed

+7
-33
lines changed

apache2/re_operators.c

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -865,13 +865,8 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
865865
char *hmac = NULL, *valid = NULL;
866866
char *hash_link = NULL, *nlink = NULL;
867867

868-
if (strlen(pattern) > 252) {
869-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %s.",
868+
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %.252s.",
870869
pattern, var->name);
871-
} else {
872-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%s\" at %s.",
873-
pattern, var->name);
874-
}
875870

876871
valid = strstr(target, msr->txcfg->crypto_param_name);
877872

@@ -880,13 +875,8 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
880875
if (msr->txcfg->debuglog_level >= 9)
881876
msr_log(msr, 9, "Request URI without hash parameter [%s]", target);
882877

883-
if (strlen(pattern) > 252) {
884-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %s. No Hash parameter",
885-
pattern, var->name);
886-
} else {
887-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%s\" at %s. No Hash parameter",
878+
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %.252s. No Hash parameter",
888879
pattern, var->name);
889-
}
890880
return 1;
891881
} else {
892882

@@ -902,14 +892,8 @@ static int msre_op_validateHash_execute(modsec_rec *msr, msre_rule *rule, msre_v
902892
hash_link = do_hash_link(msr, (char *)nlink, HASH_ONLY);
903893

904894
if(strcmp(hmac, hash_link) != 0) {
905-
906-
if (strlen(pattern) > 252) {
907-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %s. Hash parameter hash value = [%s] Requested URI hash value = [%s]",
908-
pattern, var->name, hmac, hash_link);
909-
} else {
910-
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%s\" at %s. Hash parameter hash value = [%s] Requested URI hash value = [%s]",
895+
*error_msg = apr_psprintf(msr->mp, "Request URI matched \"%.252s ...\" at %.252s. Hash parameter hash value = [%s] Requested URI hash value = [%s]",
911896
pattern, var->name, hmac, hash_link);
912-
}
913897
return 1;
914898
}
915899
}
@@ -1180,14 +1164,9 @@ static int msre_op_rx_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
11801164
/* We no longer escape the pattern here as it is done when logging */
11811165
char *pattern = apr_pstrdup(msr->mp, log_escape(msr->mp, regex->pattern ? regex->pattern : "<Unknown Match>"));
11821166

1183-
/* This message will be logged. */
1184-
if (strlen(pattern) > 252) {
1185-
*error_msg = apr_psprintf(msr->mp, "Pattern match \"%.252s ...\" at %s.",
1186-
pattern, var->name);
1187-
} else {
1188-
*error_msg = apr_psprintf(msr->mp, "Pattern match \"%s\" at %s.",
1189-
pattern, var->name);
1190-
}
1167+
/* This message will be logged. only the first 252 from the Pattern & the match */
1168+
*error_msg = apr_psprintf(msr->mp, "Pattern match \"%.252s\" at %.252s ....",
1169+
pattern, var->name);
11911170

11921171
return 1;
11931172
}
@@ -1425,13 +1404,8 @@ static int msre_op_pm_execute(modsec_rec *msr, msre_rule *rule, msre_var *var, c
14251404
char *match_escaped = log_escape(msr->mp, match ? match : "<Unknown Match>");
14261405

14271406
/* This message will be logged. */
1428-
if (strlen(match_escaped) > 252) {
1429-
*error_msg = apr_psprintf(msr->mp, "Matched phrase \"%.252s ...\" at %s.",
1430-
match_escaped, var->name);
1431-
} else {
1432-
*error_msg = apr_psprintf(msr->mp, "Matched phrase \"%s\" at %s.",
1407+
*error_msg = apr_psprintf(msr->mp, "Matched phrase \"%.252s ...\" at %.252s.",
14331408
match_escaped, var->name);
1434-
}
14351409

14361410
/* Handle capture as tx.0=match */
14371411
if (capture) {

0 commit comments

Comments
 (0)