Name request log actions so they say what they mean (closes #229)
check / check (push) Successful in 4m12s

Rename too_large, rate_limited, rule_blocked and denied, and split banned
into temporarily_banned and permanently_banned by whether the ban runs out.
A client under both a temporary and a permanent ban gets the permanent one.
A request that makes a ban permanent gets permanently_banned. A ban rule, a
trap path or a CrowdSec decision gets the value for the ban it makes, and in
observe mode would_action names the ban enforce mode would have made.

The offence kind rule_blocked follows, as a metric label and a key in
clients.json.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-09 04:34:40 +00:00
1 parent d7c62f2854
commit a8b978dfc9
47 files changed
+519 -297

No files matched your search

+4 -4
View File
@@ -28,7 +28,7 @@ func (refusalLimit) check(_ context.Context, rq *request, now time.Time) *verdic
return nil
}
if !rq.attack && !rq.ruleBlocked && !rq.wafBlocked {
if !rq.attack && !rq.blockedByBlockRule && !rq.wafBlocked {
return nil
}
@@ -42,13 +42,13 @@ func (refusalLimit) check(_ context.Context, rq *request, now time.Time) *verdic
status := rq.out.status
switch rq.line.WouldAction {
case requestlog.ActionRuleBlocked, requestlog.ActionWAFBlocked:
case requestlog.ActionBlockedByBlockRule, requestlog.ActionWAFBlocked:
status = http.StatusForbidden
case requestlog.ActionBanned:
case requestlog.ActionTemporarilyBanned, requestlog.ActionPermanentlyBanned:
status = cfg.BanResponse
}
rq.banForLimit(now, hit, status)
return &verdict{action: requestlog.ActionBanned, figures: limitFigures(hit)}
return &verdict{figures: limitFigures(hit)}
}