waf: decide every visitor request within rproxy's timeout (closes #394)
check / check (push) Failing after 3m43s
check / check (push) Failing after 3m43s
The Core Rule Set is the one check whose time a visitor can stretch. At paranoia level 4 it took over 2 s on a request with an 8 KiB request line, three 8 KiB Cookie lines and a 64 KiB form body. SWW_WAF_CORE_RULE_SET_BODY_INSPECTION_SIZE now takes at most 8K. The Core Rule Set also reads no JSON body over 1 KiB, since Coraza turns JSON into up to 8 times its size in names and values. That brings such a request under 1 s. A test per kind of input times the Core Rule Set on the worst request within the limits, at the slowest settings. SPEC.md lists the limits that bound it. Model: opus-5-5
This commit is contained in:
1 parent
23788920f7
commit
a2705dfa7a
10 files changed
+488
-85
No files matched your search
+12
-10
@@ -616,7 +616,7 @@ func TestCoreRuleSetSettings(t *testing.T) {
|
||||
coreRuleSetScoreThreshold: "10",
|
||||
coreRuleSetDisabledRules: "942100, 920350",
|
||||
coreRuleSetExemptPaths: "/api/, /static/",
|
||||
coreRuleSetBodyInspectionSize: "32K",
|
||||
coreRuleSetBodyInspectionSize: "4K",
|
||||
exclusionsFile: "/etc/sww/crs-exclusions.conf",
|
||||
},
|
||||
config.WAF{
|
||||
@@ -625,7 +625,7 @@ func TestCoreRuleSetSettings(t *testing.T) {
|
||||
CoreRuleSetScoreThreshold: 10,
|
||||
CoreRuleSetDisabledRules: []int{942100, 920350},
|
||||
CoreRuleSetExemptPaths: []string{"/api/", "/static/"},
|
||||
CoreRuleSetBodyInspectionSize: 32 << 10,
|
||||
CoreRuleSetBodyInspectionSize: 4 << 10,
|
||||
CoreRuleSetExclusionsFile: "/etc/sww/crs-exclusions.conf",
|
||||
},
|
||||
},
|
||||
@@ -762,15 +762,15 @@ func TestInvalidAppsStopsTheStart(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCoreRuleSetBodyInspectionSizeOf64K(t *testing.T) {
|
||||
func TestCoreRuleSetBodyInspectionSizeOf8K(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
cfg := wafFromEnvironment(
|
||||
t,
|
||||
environment{coreRuleSetBodyInspectionSize: "64K"},
|
||||
environment{coreRuleSetBodyInspectionSize: "8K"},
|
||||
)
|
||||
if cfg.CoreRuleSetBodyInspectionSize != 64<<10 {
|
||||
t.Errorf("64K read as %d", cfg.CoreRuleSetBodyInspectionSize)
|
||||
if cfg.CoreRuleSetBodyInspectionSize != 8<<10 {
|
||||
t.Errorf("8K read as %d", cfg.CoreRuleSetBodyInspectionSize)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,11 +819,13 @@ func TestInvalidCoreRuleSetSettingStopsTheStart(t *testing.T) {
|
||||
coreRuleSetBodyInspectionSize, "128KB",
|
||||
`"128KB" is not a size such as 512K, 100M or 5G, or off`,
|
||||
},
|
||||
{coreRuleSetBodyInspectionSize, "65K", `"65K" is more than 64K, the most waf ` +
|
||||
`gets of a body`},
|
||||
{
|
||||
coreRuleSetBodyInspectionSize, "65537",
|
||||
`"65537" is more than 64K, the most waf gets of a body`,
|
||||
coreRuleSetBodyInspectionSize, "9K",
|
||||
`"9K" is more than 8K, the most the Core Rule Set can read in time`,
|
||||
},
|
||||
{
|
||||
coreRuleSetBodyInspectionSize, "8193",
|
||||
`"8193" is more than 8K, the most the Core Rule Set can read in time`,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.name+"="+tc.value, func(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user