waf: run the trap paths, rule files and Core Rule Set during the GeoJS wait (closes #405)
check / check (push) Failing after 1m56s

While the lookup waits for GeoJS, the trap paths, the rule files and the
Core Rule Set run at the same time as the checks after the lookup. The
first side to refuse answers the request; what the other side finds leaves
no trace. Those three checks have 500 ms together: past it, the request is
refused with 503 as checks_timed_out, with no ban and no offence.

Tests hold GeoJS and the Core Rule Set with stand-ins under synctest. The
test helper lifts the 500 ms limit for tests that run the real Core Rule
Set, which the race detector slows past it.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-17 04:27:26 +00:00
1 parent caa3079847
commit 098bbe8878
19 files changed
+900 -83

No files matched your search

+15 -3
View File
@@ -13,8 +13,8 @@ import (
"sneak.berlin/go/smallwebwaf/internal/rules"
)
// ruleFiles checks the request against the rules of the rule files at now,
// notes the ids of those it matches in the log line, adds the tag
// ruleFiles takes the rules of the rule files the request matched, which
// findBesideLookup found, notes their ids in the log line, adds the tag
// exploitsignature when it matches any, and refuses the request
// when the last rule it matches refuses it: with ActionBlockedByBlockRule for a
// block rule, and for a ban rule with the action for the ban it makes. A ban
@@ -31,7 +31,7 @@ func (ruleFiles) check(
rq *request,
now time.Time,
) *verdict {
matched := rq.h.rules.Match(rq.in)
matched := rq.findings.rules
for _, rule := range matched {
rq.line.RuleIDs = append(rq.line.RuleIDs, rule.ID)
@@ -70,3 +70,15 @@ func (ruleFiles) check(
return nil
}
}
// refusedByRule reports whether ruleFiles refuses a request that matched
// matched: whether the last of them is a block rule or a ban rule.
func refusedByRule(matched []rules.Rule) bool {
if len(matched) == 0 {
return false
}
action := matched[len(matched)-1].Action
return action == rules.ActionBlock || action == rules.ActionBan
}