Core Rule Set tests: check WordPress's recorded requests as the other apps' (closes #284)
check / check (push) Successful in 5m4s
check / check (push) Successful in 5m4s
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
This commit was merged in pull request #293.
This commit is contained in:
1 parent
f8d769fc17
commit
fb25f5ebd2
1 file changed
+1
-25
@@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user