waf: decide every visitor request within rproxy's timeout (closes #394)
check / check (push) Failing after 2m58s

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, which
brings that 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:
sneak committed 2026-11-15 17:09:00 +00:00
1 parent 23788920f7
commit 8c236369f0
9 files changed
+402 -63

No files matched your search

+6 -6
View File
@@ -365,8 +365,8 @@ var (
"it names the file to look clients up in",
)
errDBPathUnused = errors.New("only file reads it")
errOver64K = errors.New(
"is more than 64K, the most waf gets of a body")
errOver8K = errors.New(
"is more than 8K, the most the Core Rule Set can read in time")
errNotDurationAboveZero = errors.New(
"is not a duration above zero, such as 1h or 7d")
errNotNumberAboveZero = errors.New(
@@ -1601,16 +1601,16 @@ func durationOrDays(value string) (time.Duration, error) {
}
// parseCoreRuleSetBodyInspectionSize reads the most of a request body the Core Rule Set
// reads: a size as parseSize reads it, or off, but at most 64K, since waf
// gets no more of a body than that.
// reads: a size as parseSize reads it, or off, but at most 8K, so that one
// request cannot keep the Core Rule Set busy past rproxy's timeout.
func parseCoreRuleSetBodyInspectionSize(value string) (int64, error) {
limit, err := parseSize(value)
if err != nil {
return 0, err
}
if limit > 64*kibibyte {
return 0, fmt.Errorf("%q %w", value, errOver64K)
if limit > 8*kibibyte {
return 0, fmt.Errorf("%q %w", value, errOver8K)
}
return limit, nil