feat(waf): Phase 1 — Migration + Service + Handler — v1.2.66

- Migration 0037: waf_configs-Tabelle (domain_id FK, enabled=false default,
  mode/paranoia_level/rule_exclusions/trusted_proxies/custom_rules)
- models/waf.go: WafConfig-Model
- services/waf/waf.go: Repo (List, GetByDomain, Upsert, ListEnabled)
- handlers/waf.go: GET /waf/configs, GET /waf/configs/:id, PUT /waf/configs/:id
  — GET liefert Default-Config (disabled) wenn noch kein Row existiert
- main.go: WafHandler registriert

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Debian
2026-06-02 15:28:29 +02:00
parent b7b40ad641
commit 72f793552e
6 changed files with 291 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
-- +goose Up
CREATE TABLE IF NOT EXISTS waf_configs (
id SERIAL PRIMARY KEY,
domain_id BIGINT NOT NULL REFERENCES domains(id) ON DELETE CASCADE,
enabled BOOLEAN NOT NULL DEFAULT false,
mode TEXT NOT NULL DEFAULT 'detection'
CHECK (mode IN ('detection','blocking')),
paranoia_level INT NOT NULL DEFAULT 1
CHECK (paranoia_level BETWEEN 1 AND 4),
rule_exclusions TEXT[] NOT NULL DEFAULT '{}',
trusted_proxies TEXT[] NOT NULL DEFAULT '{}',
custom_rules TEXT NOT NULL DEFAULT '',
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT waf_configs_domain_unique UNIQUE (domain_id)
);
-- +goose Down
DROP TABLE IF EXISTS waf_configs;