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

+41 -95
View File
@@ -89,17 +89,17 @@ func TestFlagsTrustedAndIgnoreAlias(t *testing.T) {
t.Fatalf("%+v", c)
}
c.Bind = "0.0.0.0:1"
if _, err := c.Validate(tok); err != nil {
if err := c.Validate(tok); err != nil {
t.Fatal(err)
}
c.MonitorUA = "("
if _, err := c.Validate(tok); err == nil {
if err := c.Validate(tok); err == nil {
t.Fatal("bad regex must be rejected")
}
if _, err := (Config{Ignore: "nonsense", MonitorUA: "", Retention: 168 * time.Hour}).Validate(tok); err == nil {
if err := (Config{Ignore: "nonsense", MonitorUA: "", Retention: 168 * time.Hour}).Validate(tok); err == nil {
t.Fatal("bad cidr must be rejected")
}
if _, err := (Config{NoAuth: true, Bind: "0.0.0.0:1", Retention: 168 * time.Hour}).Validate(""); err == nil {
if err := (Config{NoAuth: true, Bind: "0.0.0.0:1", Retention: 168 * time.Hour}).Validate(""); err == nil {
t.Fatal("no-auth must require loopback")
}
}
@@ -143,48 +143,45 @@ func TestEnrichmentFeedsThreatAndTraffic(t *testing.T) {
func TestTokenAndFederationValidation(t *testing.T) {
base := Config{Bind: "0.0.0.0:1", Retention: 168 * time.Hour, MonitorUA: "", Ignore: DefaultIgnore, TrustedProxy: DefaultTrustedProxy}
peerTok := "peer-token-0123456789-abcdefghijklmnopq"
if _, err := base.Validate("short-token-1234567890"); err == nil {
if err := base.Validate("short-token-1234567890"); err == nil {
t.Fatal("URUTAU_TOKEN under 32 characters must be refused")
}
if _, err := base.Validate(tok); err != nil {
if err := base.Validate(tok); err != nil {
t.Fatal(err)
}
c := base
c.PeerToken = "short-peer"
if _, err := c.Validate(tok); err == nil {
t.Fatal("peer token under 32 characters must be refused")
}
c.PeerToken = tok
if _, err := c.Validate(tok); err == nil {
t.Fatal("peer token equal to URUTAU_TOKEN must be refused")
}
c.PeerToken = peerTok
if _, err := c.Validate(tok); err != nil {
t.Fatal(err)
}
c.Peers = []string{"hostinger=https://urutau.example.org"}
c.PeerToken = ""
if _, err := c.Validate(tok); err == nil {
t.Fatal("peers without a peer token must be refused")
}
c.PeerToken = peerTok
c.Peers = []string{"hostinger=http://urutau.example.org"}
if _, err := c.Validate(tok); err == nil {
t.Fatal("plain http to a non-loopback peer must be refused")
}
c.Peers = []string{"h=http://127.0.0.1:8791"}
if _, err := c.Validate(tok); err != nil {
t.Fatalf("http is fine on loopback: %v", err)
}
c.PeerAllow, c.Peers = "not-a-cidr", nil
if _, err := c.Validate(tok); err == nil {
t.Fatal("bad --peer-allow must be refused")
}
cfg, err := ParseFlags("serve", []string{"--peer-allow", "203.0.113.0/24", "--peer-allow", "198.51.100.7", "--trusted-proxy", "10.0.0.0/8"})
if err != nil || cfg.PeerAllow != "203.0.113.0/24,198.51.100.7" || cfg.TrustedProxy != "10.0.0.0/8" {
cfg, err := ParseFlags("serve", []string{"--trusted-proxy", "10.0.0.0/8"})
if err != nil || cfg.TrustedProxy != "10.0.0.0/8" {
t.Fatalf("%+v %v", cfg, err)
}
bad := base
bad.Name = "Not Valid"
if err := bad.Validate(tok); err == nil {
t.Fatal("the primary probe name must follow wire.ValidName")
}
}
func TestRemovedEnvIsFatal(t *testing.T) {
t.Setenv("URUTAU_PEERS", "hostinger=https://x.example.org")
_, err := CheckRemovedEnv(os.LookupEnv)
if err == nil || !strings.Contains(err.Error(), "URUTAU_PEERS") || !strings.Contains(err.Error(), "migration-2.0") {
t.Fatalf("PEERS must stop the hub with a pointer to the guide: %v", err)
}
t.Setenv("URUTAU_PEERS", "")
os.Unsetenv("URUTAU_PEERS")
t.Setenv("URUTAU_PEER_TOKEN_HOSTINGER", "x")
if _, err := CheckRemovedEnv(os.LookupEnv); err == nil {
t.Fatal("per peer token must stop the hub")
}
os.Unsetenv("URUTAU_PEER_TOKEN_HOSTINGER")
t.Setenv("URUTAU_TRAEFIK_LOG", "/x")
warn, err := CheckRemovedEnv(os.LookupEnv)
if err != nil || len(warn) != 1 {
t.Fatalf("the 1.x image variables only warn: %v %v", warn, err)
}
t.Setenv("URUTAU_ENFORCE_LOG", "/x")
if _, err := CheckRemovedEnv(os.LookupEnv); err == nil {
t.Fatal("URUTAU_ENFORCE_LOG must be fatal")
}
}
func TestCorruptSnapshotDoesNotStopStartup(t *testing.T) {
@@ -306,13 +303,13 @@ func (panicEnr) UA(string) core.UAInfo { return core.UAInfo{} }
func TestTokenQualityAndFiles(t *testing.T) {
base := Config{Bind: "0.0.0.0:1", Retention: 168 * time.Hour, Ignore: DefaultIgnore, TrustedProxy: DefaultTrustedProxy}
if _, err := base.Validate(strings.Repeat("a", 40)); err == nil {
if err := base.Validate(strings.Repeat("a", 40)); err == nil {
t.Fatal("aaaa... must be refused: too few distinct characters")
}
if _, err := base.Validate("abababababababababababababababab"); err == nil {
if err := base.Validate("abababababababababababababababab"); err == nil {
t.Fatal("two distinct characters must be refused")
}
if _, err := base.Validate(tok); err != nil {
if err := base.Validate(tok); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
@@ -329,57 +326,6 @@ func TestTokenQualityAndFiles(t *testing.T) {
}
}
func TestPerPeerTokens(t *testing.T) {
t.Setenv("URUTAU_PEER_TOKEN", "")
t.Setenv("URUTAU_PEER_TOKEN_HOSTINGER", "hostinger-token-0123456789-abcdefghijklmn")
f := filepath.Join(t.TempDir(), "o")
os.WriteFile(f, []byte("oracle-token-0123456789-abcdefghijklmnopq\n"), 0o600)
t.Setenv("URUTAU_PEER_TOKEN_MY_ORACLE_FILE", f)
c, err := ParseFlags("serve", []string{"--peer", "hostinger=https://h.example.org", "--peer", "my-oracle=https://o.example.org"})
if err != nil {
t.Fatal(err)
}
peers, err := c.Validate(tok)
if err != nil {
t.Fatal(err)
}
if peers[0].Token != "hostinger-token-0123456789-abcdefghijklmn" || peers[1].Token != "oracle-token-0123456789-abcdefghijklmnopq" {
t.Fatalf("per peer tokens: %+v", peers)
}
// Client tokens sent to peers never open the local export: a compromised
// peer knows its own token and must not read this instance with it.
if len(c.PeerTokens) != 0 {
t.Fatalf("per peer client tokens must not open the local export: %v", c.PeerTokens)
}
c.Peers = append(c.Peers, "nobody=https://n.example.org")
if _, err := c.Validate(tok); err == nil {
t.Fatal("a peer without any token must be refused")
}
}
func TestPeerServerTokenOnlyOpensExport(t *testing.T) {
t.Setenv("URUTAU_PEER_TOKEN", "server-side-token-Zq8vN3pL0xK7mR2wT5yB9cD")
t.Setenv("URUTAU_PEER_TOKEN_HOSTINGER", "client-side-token-Hj4kL9mN2pQ7rS1tV6wX3yZ")
c, err := ParseFlags("serve", []string{"--peer", "hostinger=https://h.example.org"})
if err != nil {
t.Fatal(err)
}
if len(c.PeerTokens) != 1 || c.PeerTokens[0] != "server-side-token-Zq8vN3pL0xK7mR2wT5yB9cD" {
t.Fatalf("export tokens: %v", c.PeerTokens)
}
}
func TestPeerNameTokenCollision(t *testing.T) {
t.Setenv("URUTAU_PEER_TOKEN", "server-side-token-Zq8vN3pL0xK7mR2wT5yB9cD")
c, err := ParseFlags("serve", []string{"--peer", "my-peer=https://a.example.org", "--peer", "my_peer=https://b.example.org"})
if err != nil {
t.Fatal(err)
}
if _, err := c.Validate(tok); err == nil || !strings.Contains(err.Error(), "share the token variable") {
t.Fatalf("colliding peer names must be refused, got %v", err)
}
}
// Without explicit configuration, X-Forwarded-For is only believed from loopback.
func TestTrustedProxyDefaultIsLoopback(t *testing.T) {
os.Unsetenv("URUTAU_TRUSTED_PROXY")
@@ -423,7 +369,7 @@ func TestLocationFlagIsValidated(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if _, err := c.Validate("zK3vQ9xT2mLp7WdR4nYb8HsJ6cFg1UaE5oXi0VtN"); (err == nil) != tc.ok {
if err := c.Validate("zK3vQ9xT2mLp7WdR4nYb8HsJ6cFg1UaE5oXi0VtN"); (err == nil) != tc.ok {
t.Errorf("%q: %v", tc.v, err)
}
}