config exports the names of the settings written into log lines and ban notes #448

Open
opened 2026-11-19 17:14:27 +01:00 by clawbot · 1 comment
Collaborator

From the architecture review, "internal/config, and values with a fixed set of choices", under "Setting names are written out again where they are logged": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next. Line numbers and setting names are that commit's.

The review asked whether the settings change through viper already keeps the names in one place. It does not: WAFFromEnvironment names each setting in a string literal of its own.

What is there

Eight string literals in internal/waf hold a setting's name that leaves the process as data, in the setting figure of the log line and the LimitPercentSetting of a ban's notes:

  • internal/waf/biased.go: SWW_WAF_UNKNOWN_COUNTRY_LIMIT_PERCENT (line 56), SWW_WAF_ASN_LIMIT_PERCENT_URL (62), SWW_WAF_BLOCKLIST_ACTION (69), SWW_WAF_DNSBL_ABUSEIPDB_ACTION (78), SWW_WAF_TAG_LIMIT_PERCENT (82), SWW_WAF_ASN_BYTES_LIMIT_PERCENT (110), SWW_WAF_COUNTRY_BYTES_LIMIT_PERCENT (118);
  • internal/waf/countries.go: SWW_WAF_EXCLUSIVELY_ALLOWED_COUNTRIES (line 36).

internal/config/waf.go writes each of these names again where it reads the setting.

Why it matters

The settings have been renamed twice. Each of these literals is found by text search only. One missed leaves log lines and ban notes that name a setting which does not exist.

What changes

  • config exports a constant for the name of each of these eight settings.
  • config's own reader and internal/waf both use it. Neither writes the name as a literal.

What stays

  • The names themselves, and so every log line and ban note.
  • Setting names in error messages, log messages and metric help text stay as they are. The review left those out: they are prose, and the start-up ones are worded where the setting is known.
  • No constant is added for a setting whose name is not written into a log line or a ban's notes.

Done when

  • each of the eight names is written once, in config;
  • behaviour is unchanged: every existing test passes with no assertion changed;
  • make check passes;
  • the PR body lists the eight constants' names.

Model: fable-5-2

From the architecture review, "`internal/config`, and values with a fixed set of choices", under "Setting names are written out again where they are logged": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173841. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`. Line numbers and setting names are that commit's. The review asked whether the settings change through viper already keeps the names in one place. It does not: `WAFFromEnvironment` names each setting in a string literal of its own. ### What is there Eight string literals in `internal/waf` hold a setting's name that leaves the process as data, in the `setting` figure of the log line and the `LimitPercentSetting` of a ban's notes: - `internal/waf/biased.go`: `SWW_WAF_UNKNOWN_COUNTRY_LIMIT_PERCENT` (line 56), `SWW_WAF_ASN_LIMIT_PERCENT_URL` (62), `SWW_WAF_BLOCKLIST_ACTION` (69), `SWW_WAF_DNSBL_ABUSEIPDB_ACTION` (78), `SWW_WAF_TAG_LIMIT_PERCENT` (82), `SWW_WAF_ASN_BYTES_LIMIT_PERCENT` (110), `SWW_WAF_COUNTRY_BYTES_LIMIT_PERCENT` (118); - `internal/waf/countries.go`: `SWW_WAF_EXCLUSIVELY_ALLOWED_COUNTRIES` (line 36). `internal/config/waf.go` writes each of these names again where it reads the setting. ### Why it matters The settings have been renamed twice. Each of these literals is found by text search only. One missed leaves log lines and ban notes that name a setting which does not exist. ### What changes - `config` exports a constant for the name of each of these eight settings. - `config`'s own reader and `internal/waf` both use it. Neither writes the name as a literal. ### What stays - The names themselves, and so every log line and ban note. - Setting names in error messages, log messages and metric help text stay as they are. The review left those out: they are prose, and the start-up ones are worded where the setting is known. - No constant is added for a setting whose name is not written into a log line or a ban's notes. ### Done when - each of the eight names is written once, in `config`; - behaviour is unchanged: every existing test passes with no assertion changed; - `make check` passes; - the PR body lists the eight constants' names. Model: fable-5-2
clawbot self-assigned this 2026-11-19 17:14:27 +01:00
Author
Collaborator

Built in #472, branch issue-448-config-setting-name-constants. config exports a constant for each of the eight names. Its reader, its start-up checks and internal/waf use them, and no test changed.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/472, branch `issue-448-config-setting-name-constants`. `config` exports a constant for each of the eight names. Its reader, its start-up checks and `internal/waf` use them, and no test changed. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/smallwebwaf#448