feat!: Urutau 2.0.0, ultralight probes and a single analysis hub
CI / Format and vet (pull_request) Failing after 53s
CI / Dependency audit (pull_request) Successful in 33s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m1s
CI / Docker images (build and smoke test) (pull_request) Failing after 47s

Each server runs an ultralight probe (scratch image, ~7 MiB RSS) that
tails the logs, ships raw lines to the hub over HTTPS with an on-disk
spool, and applies enforce decisions locally. The hub keeps one node per
probe (primary node = the 1.x data dir, unchanged), does all analysis and
serves the UI. Peer federation is removed. 'urutau import' brings 1.x
data dirs in with hash and count verification. UI: probes page, host
qualified incidents, IPs never wrap, egress heatmap labels, live and
replay globes no longer auto-rotate, replay repeat, live traffic metrics.

BREAKING CHANGE: URUTAU_PEERS, URUTAU_PEER_* and /api/v1/peer/* are gone;
log path variables move from the hub to the probe. See docs/migration-2.0.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-15 22:14:50 -03:00
1 parent 23a7a5963a
commit 8546d14cef
130 files changed
+9396 -3311

No files matched your search

+2 -62
View File
@@ -18,7 +18,7 @@ import (
func setup(t *testing.T) (http.Handler, *store.Store) {
st := store.New(store.Config{Name: "oracle", Version: "test"})
st.Ingest(core.Event{Time: time.Now(), IP: "45.94.31.4", Cat: core.Exploit, Strong: true, Source: "traefik", Domain: "a.example", Method: "GET", Path: "/<img src=x onerror=alert(1)>"})
h := New(Options{Token: "user-token-0123456789-abcdefghijklmnop", PeerTokens: []string{"peer-token-0123456789-abcdefghijklmnopq"}, Version: "test", Store: st})
h := New(Options{Token: "user-token-0123456789-abcdefghijklmnop", Version: "test", Store: st})
return h, st
}
@@ -240,7 +240,7 @@ func mustPrefixes(l string) []netip.Prefix {
func federated(t *testing.T, mod func(*Options)) http.Handler {
st := store.New(store.Config{Name: "oracle", Version: "test"})
st.Ingest(core.Event{Time: time.Now(), IP: "45.94.31.4", Cat: core.Exploit, Strong: true, Source: "traefik", Method: "GET", Path: "/x"})
o := Options{Token: "user-token-0123456789-abcdefghijklmnop", PeerTokens: []string{"peer-token-0123456789-abcdefghijklmnopq"}, Version: "test", Store: st,
o := Options{Token: "user-token-0123456789-abcdefghijklmnop", Version: "test", Store: st,
TrustedProxy: mustPrefixes("172.16.0.0/12")}
if mod != nil {
mod(&o)
@@ -248,66 +248,6 @@ func federated(t *testing.T, mod func(*Options)) http.Handler {
return New(o)
}
func TestPeerTokenOnlyOpensExport(t *testing.T) {
h, _ := setup(t)
peer := map[string]string{"Authorization": "Bearer peer-token-0123456789-abcdefghijklmnopq"}
user := map[string]string{"Authorization": "Bearer user-token-0123456789-abcdefghijklmnop"}
for _, p := range []string{"/api/v1/summary", "/api/v1/traffic", "/api/v1/ip/45.94.31.4", "/api/v1/ips", "/api/v1/events/stream",
"/api/v1/blocklist.txt", "/api/v1/blocklist.json", "/api/v1/geo", "/api/v1/live/recent"} {
if w := do(h, "GET", p, peer, nil); w.Code != http.StatusForbidden {
t.Errorf("peer token on %s: %d (want 403)", p, w.Code)
}
if w := do(h, "GET", p, nil, nil); w.Code != http.StatusUnauthorized {
t.Errorf("no credential on %s: %d (want 401)", p, w.Code)
}
}
if w := do(h, "GET", "/api/v1/peer/export", nil, nil); w.Code != 401 {
t.Fatalf("export without credential: %d", w.Code)
}
if w := do(h, "GET", "/api/v1/peer/export", user, nil); w.Code != 401 {
t.Fatalf("the user token must not open the export: %d", w.Code)
}
w := do(h, "GET", "/api/v1/peer/export?range=7d", peer, nil)
if w.Code != 200 || !strings.Contains(w.Body.String(), `"v":1`) || !strings.Contains(w.Body.String(), "45.94.31.4") || !strings.Contains(w.Body.String(), `"traffic"`) {
t.Fatalf("export %d %.200s", w.Code, w.Body)
}
// without a peer token configured the route does not exist
h2 := federated(t, func(o *Options) { o.PeerTokens = nil })
if w := do(h2, "GET", "/api/v1/peer/export", peer, nil); w.Code != 404 {
t.Fatalf("federation disabled: %d", w.Code)
}
}
func TestPeerAllowAndRealClientIP(t *testing.T) {
peer := map[string]string{"Authorization": "Bearer peer-token-0123456789-abcdefghijklmnopq"}
h := federated(t, func(o *Options) { o.PeerAllow = mustPrefixes("203.0.113.0/24") })
with := func(remote, xff string) *httptest.ResponseRecorder {
hd := map[string]string{"Authorization": peer["Authorization"], "X-Remote": remote}
if xff != "" {
hd["X-Forwarded-For"] = xff
}
return do(h, "GET", "/api/v1/peer/export", hd, nil)
}
if w := with("198.51.100.9:1", ""); w.Code != 403 {
t.Fatalf("outside the allow list: %d", w.Code)
}
if w := with("203.0.113.8:1", ""); w.Code != 200 {
t.Fatalf("inside the allow list: %d", w.Code)
}
if w := with("198.51.100.9:1", "203.0.113.8"); w.Code != 403 {
t.Fatalf("forged XFF from an untrusted source must not pass: %d", w.Code)
}
if w := with("172.18.0.2:1", "203.0.113.8"); w.Code != 200 {
t.Fatalf("XFF from the trusted proxy is the real client: %d", w.Code)
}
if w := with("172.18.0.2:1", "198.51.100.77"); w.Code != 403 {
t.Fatalf("real client outside the list behind the proxy: %d", w.Code)
}
if w := with("172.18.0.2:1", "203.0.113.8, 198.51.100.77"); w.Code != 403 {
t.Fatalf("the proxy appended the real client on the right: %d", w.Code)
}
}
func TestLoginRateLimitUsesRealClientBehindProxy(t *testing.T) {
loginBlockedDelay = 0
h := federated(t, nil)