check / check (push) Waiting to run
The tags, what observe mode would have done, the broken limit and the three reputation flags are fields of decision, each naming what sets it. The log line is written from them and from the lookup answer, and no heuristic, ban note or alert reads it back. A ban's notes take the request's method, Host and User-Agent from decision, since the report's steps have no request to read them from. Model: opus-5-5
37 lines
680 B
Go
37 lines
680 B
Go
package waf
|
|
|
|
// The heuristic tag_deny. It reads SWW_WAF_TAG_DENY.
|
|
|
|
import (
|
|
"context"
|
|
"slices"
|
|
"time"
|
|
|
|
"sneak.berlin/go/smallwebwaf/internal/requestlog"
|
|
)
|
|
|
|
// tagDeny refuses a request that carries a tag in SWW_WAF_TAG_DENY. Its figure is
|
|
// the first such tag, in sorted order.
|
|
type tagDeny struct {
|
|
tags []string // SWW_WAF_TAG_DENY
|
|
}
|
|
|
|
func (tagDeny) name() string { return "tag_deny" }
|
|
|
|
func (t tagDeny) check(
|
|
_ context.Context,
|
|
rq *request,
|
|
_ time.Time,
|
|
) *verdict {
|
|
for _, tag := range rq.tags {
|
|
if slices.Contains(t.tags, tag) {
|
|
return &verdict{
|
|
action: requestlog.ActionClientDenied,
|
|
figures: map[string]any{"tag": tag},
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|