config: export the setting names waf logs (closes #448) #472

Open
clawbot wants to merge 1 commits from issue-448-config-setting-name-constants into next
pull from: issue-448-config-setting-name-constants
Collaborator

Closes #448.

config now exports a constant for each setting name that waf writes into a log line's setting figure or a ban's LimitPercentSetting. config's reader, its start-up checks and internal/waf all use the constants, so each name is written once.

The constants, in internal/config/waf.go:

  • ExclusivelyAllowedCountriesSetting
  • TagLimitPercentSetting
  • ASNBytesLimitPercentSetting
  • CountryBytesLimitPercentSetting
  • UnknownCountryLimitPercentSetting
  • ASNLimitPercentURLSetting
  • BlocklistActionSetting
  • DNSBLAbuseIPDBActionSetting

Not obvious from the diff:

  • Tests keep their own literals. They assert the exact name that leaves the process, so a wrong constant still fails them. No test changed.
  • limitPercentages keeps its local tagSetting, now set from config.TagLimitPercentSetting. Spelling the constant at each use pushed the function over the funlen limit.
  • Names in comments, error text and metric help text are unchanged, as the issue says.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/smallwebwaf/issues/448. `config` now exports a constant for each setting name that `waf` writes into a log line's `setting` figure or a ban's `LimitPercentSetting`. `config`'s reader, its start-up checks and `internal/waf` all use the constants, so each name is written once. The constants, in `internal/config/waf.go`: - `ExclusivelyAllowedCountriesSetting` - `TagLimitPercentSetting` - `ASNBytesLimitPercentSetting` - `CountryBytesLimitPercentSetting` - `UnknownCountryLimitPercentSetting` - `ASNLimitPercentURLSetting` - `BlocklistActionSetting` - `DNSBLAbuseIPDBActionSetting` Not obvious from the diff: - Tests keep their own literals. They assert the exact name that leaves the process, so a wrong constant still fails them. No test changed. - `limitPercentages` keeps its local `tagSetting`, now set from `config.TagLimitPercentSetting`. Spelling the constant at each use pushed the function over the `funlen` limit. - Names in comments, error text and metric help text are unchanged, as the issue says. Model: opus-5-5
clawbot added 1 commit 2026-11-19 18:44:35 +01:00
waf wrote eight setting names as string literals into log lines and
ban notes, and config wrote each again where it reads the setting. A
rename that missed one would log a setting that does not exist. config
now exports a constant for each name, used by its reader and by waf.

Model: opus-5-5
clawbot added the needs-review label 2026-11-19 18:44:37 +01:00
clawbot self-assigned this 2026-11-19 18:44:38 +01:00
Some checks are pending
check / check (push) Waiting to run
You are not authorized to merge this pull request.
This pull request can be merged automatically.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-448-config-setting-name-constants:issue-448-config-setting-name-constants
git checkout issue-448-config-setting-name-constants
Sign in to join this conversation.