fix(egress): container map refreshed on start; no new_geo for anycast CDNs (2.2.2)
CI / Format and vet (pull_request) Successful in 1m43s
CI / Dependency audit (pull_request) Successful in 39s
CI / Tests (Linux, race detector) (pull_request) Successful in 2m37s

A LambdaMail redeploy swapped rspamd and clamav addresses and the hub judged
the next minute with the stale containers.map, filing SURBL/DNS traffic under
clamav and freshclam under dns. The host kit now runs urutau-containers-watch
(docker events -> map rewrite) and the probe polls the file every 2 s.

new_geo is skipped for large CDNs/clouds: anycast addresses carry a
meaningless database country (1.1.1.1 in AU, Cloudflare edges in CA).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-19 15:25:23 -03:00
1 parent 87178dbc94
commit 65015158dc
17 files changed
+81 -14

No files matched your search

+23
View File
@@ -700,3 +700,26 @@ func TestEngineDst(t *testing.T) {
t.Fatal("dst found outside the window")
}
}
func TestNewGeoSkipsAnycastCDN(t *testing.T) {
geo := func(s string) (string, string, string) {
switch s {
case "1.1.1.1":
return "AU", "AS13335", "Cloudflare"
case "149.154.166.110":
return "NL", "", ""
case "203.0.113.50":
return "DE", "AS197540", "netcup"
}
return "BR", "AS2", "y"
}
e := newEng(t, Config{Geo: geo})
e.IngestEvent(mk(t0, "10.0.3.5", "203.0.113.1", "tcp", 443))
e.IngestEvent(mk(t0.Add(25*time.Hour), "10.0.3.5", "1.1.1.1", "udp", 53)) // Cloudflare anycast
e.IngestEvent(mk(t0.Add(25*time.Hour), "10.0.3.5", "149.154.166.110", "tcp", 443)) // Telegram prefix, no ASN
e.IngestEvent(mk(t0.Add(26*time.Hour), "10.0.3.5", "203.0.113.50", "tcp", 443))
g := kinds(rep(e), "new_geo")
if len(g) != 1 || g[0].Dst != "203.0.113.50" {
t.Fatalf("new_geo: %+v", g)
}
}
+3 -1
View File
@@ -752,7 +752,9 @@ func (e *Engine) checks(ws *wstate, ev Event, dport uint16, t int64, ds *dstStat
if ws.role != RoleScanner && !fan && ds.cc != "" && isGlobal(ev.Dst) {
if _, seen := ws.geo[ds.cc]; !seen {
ws.geo[ds.cc] = struct{}{}
if t-ws.first >= int64(e.cfg.Learn/time.Second) {
// Anycast CDNs and big clouds: the database country of 1.1.1.1 or a
// Cloudflare edge says nothing about where the traffic goes.
if t-ws.first >= int64(e.cfg.Learn/time.Second) && !commonCloudASNs[ds.asn] && !inCommonCDN(ev.Dst) {
e.addFinding("new_geo", "low", ws.name, dst, dport, ev.Proto, t, 0, 0, "first contact with country "+ds.cc+" "+ds.asn, 1)
}
} else if len(ws.geo) > 300 {