mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-03-09 09:01:51 +01:00
MEDIUM: config: report misplaced http-request rules
Recently, the http-request ruleset started to be used a lot and some bug reports were caused by misplaced http-request rules because there was no warning if they're after a redirect or use_backend rule. Let's fix this now. http-request rules are just after the block rules.
This commit is contained in:
parent
f51658dac4
commit
5002f57186
@ -320,6 +320,19 @@ int warnif_rule_after_block(struct proxy *proxy, const char *file, int line, con
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Report a warning if a rule is placed after an 'http_request' rule.
|
||||
* Return 1 if the warning has been emitted, otherwise 0.
|
||||
*/
|
||||
int warnif_rule_after_http_req(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||
{
|
||||
if (!LIST_ISEMPTY(&proxy->http_req_rules)) {
|
||||
Warning("parsing [%s:%d] : a '%s' rule placed after an 'http-request' rule will still be processed before.\n",
|
||||
file, line, arg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Report a warning if a rule is placed after a reqrewrite rule.
|
||||
* Return 1 if the warning has been emitted, otherwise 0.
|
||||
*/
|
||||
@ -374,6 +387,16 @@ int warnif_rule_after_use_backend(struct proxy *proxy, const char *file, int lin
|
||||
|
||||
/* report a warning if a block rule is dangerously placed */
|
||||
int warnif_misplaced_block(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||
{
|
||||
return warnif_rule_after_http_req(proxy, file, line, arg) ||
|
||||
warnif_rule_after_reqxxx(proxy, file, line, arg) ||
|
||||
warnif_rule_after_reqadd(proxy, file, line, arg) ||
|
||||
warnif_rule_after_redirect(proxy, file, line, arg) ||
|
||||
warnif_rule_after_use_backend(proxy, file, line, arg);
|
||||
}
|
||||
|
||||
/* report a warning if an http-request rule is dangerously placed */
|
||||
int warnif_misplaced_http_req(struct proxy *proxy, const char *file, int line, const char *arg)
|
||||
{
|
||||
return warnif_rule_after_reqxxx(proxy, file, line, arg) ||
|
||||
warnif_rule_after_reqadd(proxy, file, line, arg) ||
|
||||
@ -2748,6 +2771,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
|
||||
goto out;
|
||||
}
|
||||
|
||||
err_code |= warnif_misplaced_http_req(curproxy, file, linenum, args[0]);
|
||||
err_code |= warnif_cond_conflicts(rule->cond,
|
||||
(curproxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR,
|
||||
file, linenum);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user