Give ban causes, limit kinds, alert events, actions and dispositions named types (closes #428)
check / check (push) Successful in 5m27s
check / check (push) Successful in 5m27s
Each fixed set of string constants becomes a named string type in the package that owns it, and the fields and parameters that carry it use the type: bans.Cause, ratelimit.LimitKind, alerts.Event, alerts.DestinationName, rules.Action, requestlog.Action, requestlog.Offence, requestlog.WAFLineKind and wafprotocol.Disposition. Every value keeps its string, so the logs, state files, alerts and metrics do not change. The switches exhaustive now checks list their missing cases. Model: opus-5-5
This commit is contained in:
1 parent
86bb33bf07
commit
de78a12801
43 files changed
+373
-255
No files matched your search
@@ -292,7 +292,7 @@ func startAppWithAlerts(
|
||||
// the time raised, for ban, with its netblock, cause, reason and notes,
|
||||
// which ends at expires, as the log line gives it.
|
||||
func banAlert(
|
||||
event string,
|
||||
event alerts.Event,
|
||||
raised time.Time,
|
||||
client string,
|
||||
ban bans.Ban,
|
||||
@@ -307,7 +307,9 @@ func banAlert(
|
||||
Netblock: ban.Netblock,
|
||||
Reason: ban.Reason,
|
||||
Detail: map[string]any{
|
||||
"cause": ban.Cause, "ban_expires": expires, "notes": ban.Notes,
|
||||
"cause": string(
|
||||
ban.Cause,
|
||||
), "ban_expires": expires, "notes": ban.Notes,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -315,7 +317,7 @@ func banAlert(
|
||||
// attackAlert is banAlert for a ban for the probe rule of testRules, with
|
||||
// the netblock and the notes of ban.
|
||||
func attackAlert(
|
||||
event string,
|
||||
event alerts.Event,
|
||||
raised time.Time,
|
||||
client string,
|
||||
ban bans.Ban,
|
||||
|
||||
Reference in new issue
Block a user