Read every setting through viper and rename the settings (closes #211)
check / check (push) Failing after 3m27s

Every setting of discriminator and rproxy is read through viper, in place
of the os.LookupEnv function Main passed down. NewViper turns AutomaticEnv
and AllowEmptyEnv on, so a setting that is set but empty reads as set. A
setting may also be given as a file, the _FILE form, which rproxy's
settings now have too; rproxy still writes nothing to disk.

The settings are renamed. Discriminator's take the prefix SWW_WAF_,
rproxy's take SWW_RPROXY_, and the shared SWW_COMMAND keeps SWW_. The Core
Rule Set's settings take SWW_WAF_CORE_RULE_SET_ rather than SWW_WAF_WAF_.
Every place a name appeared changed: the code, the viper keys, tests,
documents, examples, the README's settings table and the image files.

Model: deepseek-v4-pro
This commit is contained in:
sneak committed 2026-11-07 06:41:11 +00:00
1 parent beb503b233
commit 68da92f414
89 files changed
+2027 -1916

No files matched your search

+3 -3
View File
@@ -39,7 +39,7 @@ const (
// reportBodyLimit is the longest body SPEC.md lets a report have.
reportBodyLimit = 1 << 20
// anomalyClientPerMinute is the anomaly threshold these tests set.
anomalyClientPerMinute = "SWW_ANOMALY_CLIENT_REQUESTS_PER_MINUTE"
anomalyClientPerMinute = "SWW_WAF_ANOMALY_CLIENT_REQUESTS_PER_MINUTE"
)
// The fields of a report, as "discriminator" in SPEC.md names them.
@@ -181,7 +181,7 @@ func (s *Discriminator) history() ratelimit.History {
}
// metrics returns what the metrics endpoint answers, for a server started with
// the token as SWW_METRICS_TOKEN.
// the token as SWW_WAF_METRICS_TOKEN.
func (s *Discriminator) metrics() string {
s.t.Helper()
@@ -1485,7 +1485,7 @@ func TestALargeBodyAnnouncedAndLongHeadersAreNoReasonToRefuse(t *testing.T) {
func TestLogLevelHoldsBackNoRequestLine(t *testing.T) {
t.Parallel()
s := startDiscriminator(t, "", map[string]string{"SWW_LOG_LEVEL": "error"})
s := startDiscriminator(t, "", map[string]string{"SWW_WAF_LOG_LEVEL": "error"})
// A refused question would write a process warning, held back at error.
req := s.question(siteA, client, "/")