config: give the fixed-value settings named types (closes #427) #466

Open
clawbot wants to merge 1 commits from issue-427-typed-fixed-value-settings into next
pull from: issue-427-typed-fixed-value-settings
Collaborator

The five config.WAF settings with a fixed set of values get named string types declared in config. Their fields, the readers in config and every comparison in waf and sww use the types' constants. Values, defaults, the settings log line, the metrics' mode label and the alerts' mode detail keep the same strings.

New types and constants, all in internal/config/waf.go:

  • BytesCounted: BytesCountedResponse, BytesCountedRequest, BytesCountedBoth.
  • LookupSource: LookupSourceGeoJS, LookupSourceFile, LookupSourceOff.
  • ReputationAction, for both BlocklistAction and DNSBLAbuseIPDBAction: ReputationActionDeny, ReputationActionLimit, ReputationActionLog.
  • CoreRuleSetMode: the existing CoreRuleSetModeOff, CoreRuleSetModeDetect and CoreRuleSetModeBlock, now typed.

Removed duplicates: fileSource in config and deny in internal/waf/reputation.go.

Disclosures:

  • Judgement call: the two action settings share one type, since they have one set of values and one reader.
  • Judgement call: the private off in config stays. These settings no longer use it, but timeouts, sizes and rate limits still do.
  • countedBytes in internal/waf/bans.go names every case for exhaustive. Both, and any other value, still count both directions, as the old default did.
  • Tests changed only in types: three environment values gained string(...), and two expected actions in internal/config/waf_test.go are config.ReputationAction. No assertion changed.

Issue: #427

Model: opus-5-5

The five `config.WAF` settings with a fixed set of values get named string types declared in `config`. Their fields, the readers in `config` and every comparison in `waf` and `sww` use the types' constants. Values, defaults, the settings log line, the metrics' `mode` label and the alerts' `mode` detail keep the same strings. New types and constants, all in `internal/config/waf.go`: - `BytesCounted`: `BytesCountedResponse`, `BytesCountedRequest`, `BytesCountedBoth`. - `LookupSource`: `LookupSourceGeoJS`, `LookupSourceFile`, `LookupSourceOff`. - `ReputationAction`, for both `BlocklistAction` and `DNSBLAbuseIPDBAction`: `ReputationActionDeny`, `ReputationActionLimit`, `ReputationActionLog`. - `CoreRuleSetMode`: the existing `CoreRuleSetModeOff`, `CoreRuleSetModeDetect` and `CoreRuleSetModeBlock`, now typed. Removed duplicates: `fileSource` in `config` and `deny` in `internal/waf/reputation.go`. Disclosures: - Judgement call: the two action settings share one type, since they have one set of values and one reader. - Judgement call: the private `off` in `config` stays. These settings no longer use it, but timeouts, sizes and rate limits still do. - `countedBytes` in `internal/waf/bans.go` names every case for `exhaustive`. Both, and any other value, still count both directions, as the old `default` did. - Tests changed only in types: three environment values gained `string(...)`, and two expected actions in `internal/config/waf_test.go` are `config.ReputationAction`. No assertion changed. Issue: https://git.eeqj.de/sneak/smallwebwaf/issues/427 Model: opus-5-5
clawbot added the needs-review label 2026-11-19 17:54:20 +01:00
clawbot self-assigned this 2026-11-19 17:54:20 +01:00
clawbot added 1 commit 2026-11-19 17:54:20 +01:00
BytesCounted, LookupSource, BlocklistAction, DNSBLAbuseIPDBAction and
CoreRuleSetMode become named string types declared in config, with
constants for their values. Every comparison in waf and sww uses the
constants, and the private duplicates fileSource and deny go. The two
action settings share ReputationAction. The values and the strings
written to logs, metrics and alerts are unchanged.

Model: opus-5-5
Author
Collaborator

Verdict: PASS
Head: 99af37c01b

The five fixed-value settings now have named types in config, every comparison outside config uses their constants, and behaviour and test assertions are unchanged, which meets #427.

  • Judgement call accepted: the private off in config stays, because the timeout, size and rate-limit settings still use it, although the issue listed it among the duplicates to remove.

Model: opus-5-5

Verdict: PASS Head: 99af37c01bbe789ffe60233d3882e5134b38ac58 The five fixed-value settings now have named types in `config`, every comparison outside `config` uses their constants, and behaviour and test assertions are unchanged, which meets https://git.eeqj.de/sneak/smallwebwaf/issues/427. - Judgement call accepted: the private `off` in `config` stays, because the timeout, size and rate-limit settings still use it, although the issue listed it among the duplicates to remove. Model: opus-5-5
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.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue-427-typed-fixed-value-settings:issue-427-typed-fixed-value-settings
git checkout issue-427-typed-fixed-value-settings
Sign in to join this conversation.