From d8fa244e73fcb9d333b9a0092de25be5e5b7477b Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Tue, 10 Nov 2026 14:35:18 +0000 Subject: [PATCH] Core Rule Set tests: check WordPress's recorded requests as the other apps' (closes #284) TestOrdinaryWordPressRequestsPass skipped the inspection that reads bodies for a request with no body, including one with a Content-Type. It now calls wantRecordedRequestsPass. Model: opus-5-5 --- internal/coreruleset/recorded_test.go | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/internal/coreruleset/recorded_test.go b/internal/coreruleset/recorded_test.go index 0b27942..b126a4f 100644 --- a/internal/coreruleset/recorded_test.go +++ b/internal/coreruleset/recorded_test.go @@ -13,8 +13,6 @@ import ( "slices" "strings" "testing" - - "sneak.berlin/go/smallwebwaf/internal/coreruleset" ) // giteaRequests returns the recorded ordinary gitea requests in testdata. @@ -178,27 +176,5 @@ func TestOrdinaryVaultwardenRequestsPass(t *testing.T) { func TestOrdinaryWordPressRequestsPass(t *testing.T) { t.Parallel() - const threshold = 5 // SWW_WAF_ANOMALY_THRESHOLD's default - - defaults, bodies := atDefaults(t), readingBodiesUpTo64K(t) - - for _, recorded := range recordedRequests(t, "wordpress-requests.txt") { - t.Run(recorded.Method+" "+recorded.Target, func(t *testing.T) { - t.Parallel() - - r := request{recorded.Method, recorded.Target, recorded.Headers} - - crsSets := []*coreruleset.CoreRuleSet{defaults} - if recorded.Body != "" { - crsSets = append(crsSets, bodies) - } - - for _, crs := range crsSets { - got, _ := inspectBody(t, crs, r, recorded.Body) - if got.Score >= threshold { - t.Errorf("%s %s %.200q refused: %+v", r.method, r.target, recorded.Body, got) - } - } - }) - } + wantRecordedRequestsPass(t, "wordpress-requests.txt") }