feat: 1.4.0 second firewall, egress analysis and HTML report
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 28s
CI / Dependency audit (push) Successful in 16s
CI / Tests (Linux, race detector) (push) Successful in 1m3s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Skipped
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Successful in 13s
Release / Gitea release (push) Successful in 3s

Optional second firewall (URUTAU_ENFORCE off/observe/on) through the host
fail2ban, outbound traffic analysis (beaconing, mining, spam, DNS bypass,
unauthorised scans) with authorised scanner workloads, host kit in
deploy/host and a printable HTML report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-14 23:35:34 -03:00
1 parent 3adaa007ec
commit c33cca22e3
59 files changed
+7364 -24

No files matched your search

+62
View File
@@ -8,6 +8,7 @@ import (
"net/http/httptest"
"os"
"path/filepath"
"strings"
"testing"
"time"
@@ -195,3 +196,64 @@ func TestIPDetailConsistentOnSyntheticLogs(t *testing.T) {
t.Skip("synthetic data sets not available")
}
}
func TestEnforceConfig(t *testing.T) {
c, err := ParseFlags("x", []string{"--insecure-no-auth", "--bind", "127.0.0.1:1"})
if err != nil || c.Enforce != "off" || c.EnforceLog != "/logs/enforce/decisions.log" || c.EnforceShare != "off" || c.EnforceThreshold != 5 || c.EnforceMaxPerMin != 60 {
t.Fatalf("%+v %v", c, err)
}
for _, bad := range [][]string{{"--enforce=maybe"}, {"--enforce-share=x"}, {"--enforce-threshold=0"}, {"--enforce-max-per-min=0"}} {
c, err := ParseFlags("x", append([]string{"--insecure-no-auth", "--bind", "127.0.0.1:1", "--data-dir", t.TempDir()}, bad...))
if err != nil {
continue
}
if _, err := c.Validate(""); err == nil {
t.Errorf("%v accepted", bad)
}
}
t.Setenv("URUTAU_ENFORCE", "observe")
t.Setenv("URUTAU_ENFORCE_THRESHOLD", "9")
c, _ = ParseFlags("x", nil)
if c.Enforce != "observe" || c.EnforceThreshold != 9 {
t.Fatalf("env %+v", c)
}
}
func TestDoctorEnforce(t *testing.T) {
var got []Check
add := func(n, s, d string) { got = append(got, Check{n, s, d}) }
doctorEnforce(Config{Enforce: "on", EnforceLog: t.TempDir() + "/x/d.log", EnforceThreshold: 5}, add)
doctorEnforce(Config{Enforce: "on", EnforceLog: "/proc/nope/d.log"}, add)
doctorEnforce(Config{Enforce: "off"}, add)
if got[0].Status != "ok" || !strings.Contains(got[0].Detail, "mode=on") || got[1].Status != "fail" || got[2].Status != "off" {
t.Fatalf("%+v", got)
}
}
func TestDoctorEnforceCloudflare(t *testing.T) {
lg := filepath.Join(t.TempDir(), "access.log")
os.WriteFile(lg, []byte(`{"ClientHost":"104.16.1.1"}`+"\n"+`{"ClientHost":"203.0.114.5"}`+"\n"), 0o600)
var got []Check
add := func(n, s, d string) { got = append(got, Check{n, s, d}) }
doctorEnforce(Config{Enforce: "on", EnforceLog: t.TempDir() + "/x/d.log", TraefikLog: lg}, add)
if len(got) != 2 || got[1].Name != "enforce-cdn" || got[1].Status != "warn" {
t.Fatalf("%+v", got)
}
got = nil
doctorEnforce(Config{Enforce: "observe", EnforceLog: t.TempDir() + "/x/d.log", TraefikLog: lg}, add)
if len(got) != 1 {
t.Fatalf("%+v", got)
}
}
func TestEgressExtraAllow(t *testing.T) {
t.Setenv("URUTAU_EGRESS_ALLOW", "203.0.113.0/24, 198.51.100.7 ,bad")
got := egressExtraAllow(Config{Peers: []string{"p=https://192.0.2.9:8443"}})
var s []string
for _, p := range got {
s = append(s, p.String())
}
if strings.Join(s, " ") != "192.0.2.9/32 203.0.113.0/24 198.51.100.7/32" {
t.Fatalf("%v", s)
}
}