package waf // The heuristic tag_deny. It reads SWW_WAF_TAG_DENY and SWW_WAF_BAN_RESPONSE. import ( "context" "slices" "time" "sneak.berlin/go/smallwebwaf/internal/requestlog" ) // tagDeny refuses a request that carries a tag in SWW_WAF_TAG_DENY, with // SWW_WAF_BAN_RESPONSE. Its figure is the first such tag, in sorted order. type tagDeny struct { tags []string // SWW_WAF_TAG_DENY banResponse int // SWW_WAF_BAN_RESPONSE } 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, status: t.banResponse, figures: map[string]any{"tag": tag}, } } } return nil }