waf: heuristics pass facts through typed fields of decision (closes #442)
check / check (push) Failing after 16m24s
check / check (push) Failing after 16m24s
The tags, what observe mode would have done, the broken limit and the three reputation flags are fields of decision, each naming what sets it. The log line is written from them and from the lookup answer, and no heuristic, ban note or alert reads it back. A ban's notes take the request's method, Host and User-Agent from decision, since the report's steps have no request to read them from. Model: opus-5-5
This commit is contained in:
1 parent
91444a37b3
commit
17bbea919a
11 files changed
+64
-40
No files matched your search
+12
-8
@@ -45,8 +45,11 @@ func (a activeBan) check(
|
||||
}
|
||||
|
||||
ban, banned, madePermanent := check(rq.client, now)
|
||||
|
||||
var expires string
|
||||
if banned {
|
||||
rq.line.BanExpires = banExpires(ban)
|
||||
expires = banExpires(ban)
|
||||
rq.line.BanExpires = expires
|
||||
}
|
||||
|
||||
if madePermanent {
|
||||
@@ -61,7 +64,7 @@ func (a activeBan) check(
|
||||
return &verdict{
|
||||
action: banAction(ban.Permanent()),
|
||||
figures: map[string]any{
|
||||
figureNetblock: ban.Netblock.String(), "ban_expires": rq.line.BanExpires,
|
||||
figureNetblock: ban.Netblock.String(), "ban_expires": expires,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -148,6 +151,7 @@ func (b banMaker) banForLimit(
|
||||
rq.line.LimitHit = hit.Window
|
||||
}
|
||||
|
||||
rq.brokeLimit = true
|
||||
rq.line.Offence = requestlog.OffenceLimit
|
||||
|
||||
b.metrics.LimitHit(hit)
|
||||
@@ -259,9 +263,9 @@ func (b banMaker) withClientNotes(
|
||||
status int,
|
||||
netblock netip.Prefix,
|
||||
) bans.Notes {
|
||||
notes.ASN = rq.line.ASN
|
||||
notes.ASName = rq.line.ASName
|
||||
notes.Country = rq.line.Country
|
||||
notes.ASN = rq.lookupAnswer.ASN
|
||||
notes.ASName = rq.lookupAnswer.ASName
|
||||
notes.Country = rq.lookupAnswer.Country
|
||||
notes.Reputation = rq.reputation
|
||||
notes.Request = rq.noted(now, status)
|
||||
notes.Requests = b.netblockRequests(netblock)
|
||||
@@ -328,11 +332,11 @@ func (b banMaker) netblockRequests(netblock netip.Prefix) int64 {
|
||||
func (rq *request) noted(now time.Time, status int) bans.Request {
|
||||
return bans.Request{
|
||||
Time: now,
|
||||
Method: rq.line.Method,
|
||||
Host: rq.line.Host,
|
||||
Method: rq.method,
|
||||
Host: rq.host,
|
||||
Path: rq.requestURI,
|
||||
Status: status,
|
||||
UserAgent: rq.line.UserAgent,
|
||||
UserAgent: rq.userAgent,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user