Rename discriminator to waf everywhere (closes #312)
check / check (push) Failing after 2m11s

The command is now `sww waf`, and the package is `internal/waf`. Types,
functions, files, tests, comments, docs, the Dockerfile, the runit
script, `script/`, compose examples, the log field `waf_line` and the
`X-From-Waf` test header follow. No behaviour changes, and no setting
changes name: rproxy already finds the waf through `SWRP_WAF_BACKEND`.

Done with one `sed -i` (Discriminator and DISCRIMINATOR to WAF,
discriminator to waf) over the files `git grep -i discriminator`
listed, as sneak allowed for this rename, then `git mv` for the
package and files. By hand afterwards: the header's spelling, which
the linter requires, and the padding after `waf` in `sww`'s usage
text.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 01:15:09 +00:00
1 parent ad36dd1775
commit d31a052aff
89 files changed
+1454 -1489

No files matched your search

+18 -18
View File
@@ -1,5 +1,5 @@
// Package requestlog writes the lines sww prints on stdout: one
// JSON object per request, two from discriminator and a short one from rproxy,
// JSON object per request, two from waf and a short one from rproxy,
// marked "type":"request", and the process's own messages as JSON lines marked
// "type":"process".
package requestlog
@@ -14,9 +14,9 @@ import (
"sneak.berlin/go/smallwebwaf/internal/ratelimit"
)
// The action a request line names: what discriminator did with the request.
// The action a request line names: what waf did with the request.
const (
// ActionForward is a request discriminator allowed, which rproxy passes to
// ActionForward is a request waf allowed, which rproxy passes to
// the app.
ActionForward = "forward"
@@ -55,7 +55,7 @@ const (
// ActionCountryDenied is a request refused because its client's country
// is not in SWW_EXCLUSIVELY_ALLOWED_COUNTRIES.
ActionCountryDenied = "country_denied"
// ActionOwnEndpoint is a request discriminator answered at one of its own
// ActionOwnEndpoint is a request waf answered at one of its own
// endpoints, or a question about a path under /_sww/.
ActionOwnEndpoint = "own_endpoint"
)
@@ -69,14 +69,14 @@ const OffenceLimit = "limit"
// that broke the error burst.
const LimitHitMinuteRefusals = "minute_refusals"
// The discriminator_line a request line names, which says which of
// discriminator's two lines about a question it is.
// The waf_line a request line names, which says which of
// waf's two lines about a question it is.
const (
// DiscriminatorLineDecision is discriminator's line at its decision.
DiscriminatorLineDecision = "decision"
// DiscriminatorLineReport is discriminator's line when rproxy's report
// WAFLineDecision is waf's line at its decision.
WAFLineDecision = "decision"
// WAFLineReport is waf's line when rproxy's report
// comes, with the decision's fields and the report's together.
DiscriminatorLineReport = "report"
WAFLineReport = "report"
)
// timeLayout is RFC 3339 with milliseconds.
@@ -89,9 +89,9 @@ const timeLayout = "2006-01-02T15:04:05.000Z07:00"
//nolint:tagliatelle // docs/request-log.md names the fields in snake_case
type Line struct {
Type string `json:"type"`
// DiscriminatorLine is DiscriminatorLineDecision or DiscriminatorLineReport
// on discriminator's two lines about a question.
DiscriminatorLine string `json:"discriminator_line,omitempty"`
// WAFLine is WAFLineDecision or WAFLineReport
// on waf's two lines about a question.
WAFLine string `json:"waf_line,omitempty"`
// The standard web log fields. Scheme is how the client reached rproxy, or
// the trusted proxy in front of it.
@@ -111,7 +111,7 @@ type Line struct {
UserAgent string `json:"user_agent"`
// Request detail. RequestID is the id rproxy made for the request, or for a
// request to discriminator's own endpoints a new one. ForwardedFor is the
// request to waf's own endpoints a new one. ForwardedFor is the
// X-Forwarded-For header as received. ClientGroup is the netblock the
// client is counted as. ASN, ASName and Country are the client's AS
// number, AS name and country, as looked up.
@@ -131,7 +131,7 @@ type Line struct {
HasAuthorization bool `json:"has_authorization,omitempty"`
HasCookie bool `json:"has_cookie,omitempty"`
// Response detail, of discriminator's own answer. Aborted is true when
// Response detail, of waf's own answer. Aborted is true when
// rproxy, or the admin's tool, went away before the answer.
ResponseContentType string `json:"response_content_type,omitempty"`
Aborted bool `json:"aborted,omitempty"`
@@ -142,7 +142,7 @@ type Line struct {
// taken with a request it would have refused: ActionClientDenied,
// ActionTemporarilyBanned, ActionPermanentlyBanned, ActionCountryDenied,
// ActionClientIsRateLimited, ActionBlockedByBlockRule,
// ActionBlockedByCoreRuleSet, or, in discriminator,
// ActionBlockedByCoreRuleSet, or, in waf,
// ActionRequestHeaderTooLarge for the header limits.
WouldAction string `json:"would_action,omitempty"`
// Heuristic is the name of the heuristic that refused the request, in
@@ -151,7 +151,7 @@ type Line struct {
Heuristic string `json:"heuristic,omitempty"`
HeuristicFigures map[string]any `json:"heuristic_figures,omitempty"`
// AfterAnswerHeuristic and AfterAnswerHeuristicFigures are the same for
// the heuristic that banned the client after discriminator answered the
// the heuristic that banned the client after waf answered the
// request.
AfterAnswerHeuristic string `json:"after_answer_heuristic,omitempty"`
AfterAnswerHeuristicFigures map[string]any `json:"after_answer_heuristic_figures,omitempty"` //nolint:lll // a struct tag cannot be split
@@ -231,7 +231,7 @@ type RProxyLine struct {
// sooner. DurationResponseMS runs from then until the answer ends.
DurationRequestMS float64 `json:"duration_request_ms"`
DurationResponseMS float64 `json:"duration_response_ms"`
// Disposition is the valid disposition discriminator answered or, while
// Disposition is the valid disposition waf answered or, while
// DefaultDisposition is true, the value of SWRP_DEFAULT_DISPOSITION. It is ""
// when neither gave one.
Disposition string `json:"disposition,omitempty"`