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
@@ -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
|
||||
|
||||
Reference in new issue
Block a user