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
@@ -164,7 +164,7 @@ func TestABanThroughOneSiteRefusesTheClientOnTheOther(t *testing.T) {
|
||||
|
||||
// One request's three lines carry one id, rproxy's with waf's answer.
|
||||
line := firstOut.line(t, "path", bannedProbe)
|
||||
if line["disposition"] != wafprotocol.DispositionDeny ||
|
||||
if line["disposition"] != string(wafprotocol.DispositionDeny) ||
|
||||
line["client_ip"] != placed {
|
||||
t.Errorf("rproxy's line is %v", line)
|
||||
}
|
||||
@@ -249,7 +249,7 @@ func TestTheSiteAnswersWhileWAFIsStoppedAndStartedAgain(t *testing.T) {
|
||||
wantStatus(t, site+"/after-stop", placed, http.StatusOK)
|
||||
|
||||
line := out.line(t, "path", "/after-stop")
|
||||
if line["disposition"] != wafprotocol.DispositionAllow ||
|
||||
if line["disposition"] != string(wafprotocol.DispositionAllow) ||
|
||||
line["waf_backend_no_answer"] != true {
|
||||
t.Errorf("rproxy's line is %v", line)
|
||||
}
|
||||
@@ -608,8 +608,8 @@ func TestRProxyAsksAWAFThatSpeaksHTTP2OverHTTP1(t *testing.T) {
|
||||
if r.Header.Get(wafprotocol.ClientHeader) != "" {
|
||||
protocols <- r.Proto
|
||||
|
||||
w.Header().
|
||||
Set(wafprotocol.DispositionHeader, wafprotocol.DispositionDeny)
|
||||
w.Header().Set(wafprotocol.DispositionHeader,
|
||||
string(wafprotocol.DispositionDeny))
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
}
|
||||
}))
|
||||
@@ -692,8 +692,8 @@ func TestRProxyStoppingWaitsForAReportBeingSent(t *testing.T) {
|
||||
backend := httptest.NewServer(http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Header.Get(wafprotocol.ClientHeader) != "" {
|
||||
w.Header().
|
||||
Set(wafprotocol.DispositionHeader, wafprotocol.DispositionAllow)
|
||||
w.Header().Set(wafprotocol.DispositionHeader,
|
||||
string(wafprotocol.DispositionAllow))
|
||||
|
||||
return
|
||||
}
|
||||
@@ -795,8 +795,8 @@ func TestRProxyStoppingCutsOffARequestAfterFiveSeconds(t *testing.T) {
|
||||
|
||||
backend := httptest.NewServer(http.HandlerFunc(
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().
|
||||
Set(wafprotocol.DispositionHeader, wafprotocol.DispositionAllow)
|
||||
w.Header().Set(wafprotocol.DispositionHeader,
|
||||
string(wafprotocol.DispositionAllow))
|
||||
}))
|
||||
t.Cleanup(backend.Close)
|
||||
|
||||
|
||||
Reference in new issue
Block a user