Core Rule Set tests: check WordPress's recorded requests as the other apps' #293

Merged
clawbot merged 1 commits from issue-284-wordpress-recorded-requests into next 2026-11-10 15:57:53 +01:00
+1 -25
View File
@@ -13,8 +13,6 @@ import (
"slices" "slices"
"strings" "strings"
"testing" "testing"
"sneak.berlin/go/smallwebwaf/internal/coreruleset"
) )
// giteaRequests returns the recorded ordinary gitea requests in testdata. // giteaRequests returns the recorded ordinary gitea requests in testdata.
@@ -178,27 +176,5 @@ func TestOrdinaryVaultwardenRequestsPass(t *testing.T) {
func TestOrdinaryWordPressRequestsPass(t *testing.T) { func TestOrdinaryWordPressRequestsPass(t *testing.T) {
t.Parallel() t.Parallel()
const threshold = 5 // SWW_WAF_ANOMALY_THRESHOLD's default wantRecordedRequestsPass(t, "wordpress-requests.txt")
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)
}
}
})
}
} }