From the architecture review, "Construction, start and stop", under "discriminator.NewCoreRuleSet is construction code in the decision package": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next, where discriminator is now waf. Line numbers are that commit's.
What is there
waf.NewCoreRuleSet (internal/waf/proxy.go:184) takes the whole *config.WAF, picks the Core Rule Set's settings out of it, and calls coreruleset.New.
It returns nil, nil twice while the Core Rule Set is off, each under //nolint:nilnil, and wraps one error with a setting's name.
It has two callers: the provider newCoreRuleSet in internal/sww/waf.go:179, which only calls it and wraps its error, and the test helper newWAFWith in internal/waf/proxy_test.go:507.
Why it matters
Since the fx wiring, internal/sww builds every other part of waf from the settings, one provider each. This is the one part still built in the package that decides, and waf has no use for it: waf.Params.CoreRuleSet takes the part already built.
What changes
The body of waf.NewCoreRuleSet moves into newCoreRuleSet in internal/sww/waf.go, beside newAlertQueue and newRuleFiles, which do the same job for their parts.
waf exports no NewCoreRuleSet. The comment on waf.Params.CoreRuleSet no longer names it.
The test helper in internal/waf builds the Core Rule Set with coreruleset.New itself, as it builds the other parts.
A test of what the function does, such as the check of the exclusions file while the mode is off, moves with it to internal/sww.
What stays
While SWW_WAF_CORE_RULE_SET_MODE is off, there is no Core Rule Set, and a set exclusions file is still loaded once to check it.
An exclusions file coreruleset.New refuses stops waf at start, with the same message.
Done when
internal/waf holds no function that builds the Core Rule Set from the settings;
behaviour is unchanged: every existing test passes with no assertion changed;
make check passes.
Model: fable-5-2
From the architecture review, "Construction, start and stop", under "`discriminator.NewCoreRuleSet` is construction code in the decision package": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173831. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`, where `discriminator` is now `waf`. Line numbers are that commit's.
### What is there
- `waf.NewCoreRuleSet` (`internal/waf/proxy.go:184`) takes the whole `*config.WAF`, picks the Core Rule Set's settings out of it, and calls `coreruleset.New`.
- It returns `nil, nil` twice while the Core Rule Set is off, each under `//nolint:nilnil`, and wraps one error with a setting's name.
- It has two callers: the provider `newCoreRuleSet` in `internal/sww/waf.go:179`, which only calls it and wraps its error, and the test helper `newWAFWith` in `internal/waf/proxy_test.go:507`.
### Why it matters
Since the fx wiring, `internal/sww` builds every other part of `waf` from the settings, one provider each. This is the one part still built in the package that decides, and `waf` has no use for it: `waf.Params.CoreRuleSet` takes the part already built.
### What changes
- The body of `waf.NewCoreRuleSet` moves into `newCoreRuleSet` in `internal/sww/waf.go`, beside `newAlertQueue` and `newRuleFiles`, which do the same job for their parts.
- `waf` exports no `NewCoreRuleSet`. The comment on `waf.Params.CoreRuleSet` no longer names it.
- The test helper in `internal/waf` builds the Core Rule Set with `coreruleset.New` itself, as it builds the other parts.
- A test of what the function does, such as the check of the exclusions file while the mode is off, moves with it to `internal/sww`.
### What stays
- While `SWW_WAF_CORE_RULE_SET_MODE` is off, there is no Core Rule Set, and a set exclusions file is still loaded once to check it.
- An exclusions file `coreruleset.New` refuses stops `waf` at start, with the same message.
### Done when
- `internal/waf` holds no function that builds the Core Rule Set from the settings;
- behaviour is unchanged: every existing test passes with no assertion changed;
- `make check` passes.
Model: fable-5-2
clawbot
self-assigned this 2026-11-19 17:12:42 +01:00
newCoreRuleSet in internal/sww/waf.go now builds the Core Rule Set from the settings itself, and waf no longer exports NewCoreRuleSet. The internal/waf test helper builds it with coreruleset.New while the mode is not off. The exclusions-file tests were already in internal/sww, so none moved.
Judgement call: the internal/waf test helper skips the exclusions-file check while the mode is off, since no internal/waf test sets that file.
Model: opus-5-5
PR: https://git.eeqj.de/sneak/smallwebwaf/pulls/465, branch `issue-434-core-rule-set-in-sww`.
`newCoreRuleSet` in `internal/sww/waf.go` now builds the Core Rule Set from the settings itself, and `waf` no longer exports `NewCoreRuleSet`. The `internal/waf` test helper builds it with `coreruleset.New` while the mode is not off. The exclusions-file tests were already in `internal/sww`, so none moved.
Judgement call: the `internal/waf` test helper skips the exclusions-file check while the mode is off, since no `internal/waf` test sets that file.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
From the architecture review, "Construction, start and stop", under "
discriminator.NewCoreRuleSetis construction code in the decision package": #283 (comment). Approved for building: #283 (comment). The code was read at809d266onnext, wherediscriminatoris nowwaf. Line numbers are that commit's.What is there
waf.NewCoreRuleSet(internal/waf/proxy.go:184) takes the whole*config.WAF, picks the Core Rule Set's settings out of it, and callscoreruleset.New.nil, niltwice while the Core Rule Set is off, each under//nolint:nilnil, and wraps one error with a setting's name.newCoreRuleSetininternal/sww/waf.go:179, which only calls it and wraps its error, and the test helpernewWAFWithininternal/waf/proxy_test.go:507.Why it matters
Since the fx wiring,
internal/swwbuilds every other part ofwaffrom the settings, one provider each. This is the one part still built in the package that decides, andwafhas no use for it:waf.Params.CoreRuleSettakes the part already built.What changes
waf.NewCoreRuleSetmoves intonewCoreRuleSetininternal/sww/waf.go, besidenewAlertQueueandnewRuleFiles, which do the same job for their parts.wafexports noNewCoreRuleSet. The comment onwaf.Params.CoreRuleSetno longer names it.internal/wafbuilds the Core Rule Set withcoreruleset.Newitself, as it builds the other parts.internal/sww.What stays
SWW_WAF_CORE_RULE_SET_MODEis off, there is no Core Rule Set, and a set exclusions file is still loaded once to check it.coreruleset.Newrefuses stopswafat start, with the same message.Done when
internal/wafholds no function that builds the Core Rule Set from the settings;make checkpasses.Model: fable-5-2
PR: #465, branch
issue-434-core-rule-set-in-sww.newCoreRuleSetininternal/sww/waf.gonow builds the Core Rule Set from the settings itself, andwafno longer exportsNewCoreRuleSet. Theinternal/waftest helper builds it withcoreruleset.Newwhile the mode is not off. The exclusions-file tests were already ininternal/sww, so none moved.Judgement call: the
internal/waftest helper skips the exclusions-file check while the mode is off, since nointernal/waftest sets that file.Model: opus-5-5