Rename the settings whose names do not say what they control (closes #234)
check / check (push) Waiting to run

Applies the setting renames of the naming audit under the SWW_WAF_ and
SWW_RPROXY_ prefixes, with sneak's names for the IP reputation cache
time and the two time limits, which now take milliseconds. The rproxy
log field default_disposition becomes waf_backend_no_answer, and
config.Config and config.FromEnvironment become config.WAF and
config.WAFFromEnvironment. Go fields, test names and prose follow. No
aliases; nothing reads the old names.

Model: opus-5-5
This commit is contained in:
clawbot committed 2026-11-12 09:08:49 +00:00
1 parent 101cc0aba5
commit a18926ec4d
100 files changed
+2181 -1935

No files matched your search

+6 -6
View File
@@ -1,5 +1,5 @@
// Package rules reads the rule files: the plain text files in
// SWW_WAF_RULES_DIR, one rule to a line, that each request is checked
// SWW_WAF_RULE_FILES_DIR, one rule to a line, that each request is checked
// against, as the "Rule files" section of SPEC.md describes. They are read
// at start, and again once the directory has had no change for a short
// time after one is edited, added or removed.
@@ -40,7 +40,7 @@ const (
// extension ends the name of every rule file.
const extension = ".rules"
// quietTime is how long SWW_WAF_RULES_DIR must go without a change before
// quietTime is how long SWW_WAF_RULE_FILES_DIR must go without a change before
// the rule files are read again, so that a file still being written, such
// as one saved in place, appended to or copied in with scp, is read only
// once whole.
@@ -103,9 +103,9 @@ type Rule struct {
// Params are what Load needs.
type Params struct {
// Dir is the directory of the rule files (SWW_WAF_RULES_DIR).
// Dir is the directory of the rule files (SWW_WAF_RULE_FILES_DIR).
Dir string
// Enabled is SWW_WAF_RULES_ENABLED: while it is false, no file is read
// Enabled is SWW_WAF_RULE_FILES_ENABLED: while it is false, no file is read
// and no rule loaded.
Enabled bool
// ProcessLog receives how many rules were read, and the error in a
@@ -275,7 +275,7 @@ func read(dir string) ([]Rule, string, error) {
entries, err := os.ReadDir(dir)
if err != nil {
return nil, dir, fmt.Errorf(
"SWW_WAF_RULES_DIR cannot be read: %w",
"SWW_WAF_RULE_FILES_DIR cannot be read: %w",
err,
)
}
@@ -310,7 +310,7 @@ func readFile(
rules []Rule,
places map[string]string,
) ([]Rule, error) {
//nolint:gosec // a rule file, in SWW_WAF_RULES_DIR
//nolint:gosec // a rule file, in SWW_WAF_RULE_FILES_DIR
data, err := os.ReadFile(path)
if err != nil {
return nil, err
+2 -2
View File
@@ -323,7 +323,7 @@ func TestDirectoryThatDoesNotExistStopsTheStart(t *testing.T) {
dir := filepath.Join(t.TempDir(), "rules.d")
wantRefused(t, dir, "SWW_WAF_RULES_DIR cannot be read: open "+dir+
wantRefused(t, dir, "SWW_WAF_RULE_FILES_DIR cannot be read: open "+dir+
": no such file or directory")
}
@@ -352,7 +352,7 @@ func TestEmptyDirectoryLoadsNoRulesAndSaysSo(t *testing.T) {
func TestRuleFilesOffReadNothing(t *testing.T) {
t.Parallel()
// SWW_WAF_RULES_DIR does not exist, which would stop the start.
// SWW_WAF_RULE_FILES_DIR does not exist, which would stop the start.
params, _ := newParams(filepath.Join(t.TempDir(), "rules.d"))
params.Enabled = false