feat: 1.2.0 attack intelligence, replay, 30-day history and new interface
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 27s
CI / Dependency audit (push) Successful in 18s
CI / Tests (Linux, race detector) (push) Successful in 58s
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 5s

Intelligence: attack families mapped to MITRE ATT&CK, network type from
ASN/rDNS without external APIs, request cadence, sessions with
recon/probe/exploit/access/banned stages, campaigns across IPs, verdict
with reasons, recommended actions, exposure detection (2xx with a body
on sensitive paths), STIX 2.1 export, FCrDNS for search engine bots,
optional Tor exit list.

Data: 30-day retention, twelve ranges plus custom from/to, an on-disk
event log (daily files, hourly gzip members, size cap, corruption and
disk-full tolerant), /events, /period, /metrics with stable per-hour
metrics, an extended /ip/{ip}, and peer /period merged on the hub.

Interface: layout system with fixed card sizes, range picker in the
URL, IP analysis page, Replay page, Geography down to state and city
(Natural Earth admin-1), Live page redesigned with stable metrics and a
reusable attack map. Demo data and documentation screenshots.

Security: bounded and deadline-limited period computations, linear
campaign clustering, singleflight caches, sanitized peer studies, event
query budgets, gzip bomb guard.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lucas RayanandClaude Opus 5.5 committed 2026-11-14 21:45:59 -03:00
1 parent 8f1ac462d1
commit b7462c14fa
325 files changed
+19117 -1307

No files matched your search

+75 -26
View File
@@ -5,6 +5,7 @@ import (
"math"
"net/netip"
"strings"
"time"
"unicode/utf8"
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core"
@@ -22,13 +23,15 @@ type PeerExport struct {
Traffic map[string]TrafficData `json:"traffic"`
}
// Export builds the peer document for a range.
func (s *Store) Export(rangeName string) PeerExport {
rg := ParseRange(rangeName)
all := s.TrafficSummary(rg.Name, "all")
e := PeerExport{V: ExportVersion, Summary: s.Summary(rg.Name), Traffic: map[string]TrafficData{"all": all}}
// Export builds the peer document for a named range.
func (s *Store) Export(rangeName string) PeerExport { return s.ExportFor(ParseRange(rangeName)) }
// ExportFor builds the peer document for a window.
func (s *Store) ExportFor(rg Range) PeerExport {
all := s.TrafficFor(rg, "all")
e := PeerExport{V: ExportVersion, Summary: s.SummaryFor(rg), Traffic: map[string]TrafficData{"all": all}}
for _, d := range all.Domains {
e.Traffic[d.Key] = s.TrafficSummary(rg.Name, d.Key)
e.Traffic[d.Key] = s.TrafficFor(rg, d.Key)
}
return e
}
@@ -84,14 +87,18 @@ func fixGrid(series map[string][]uint32, cats []string, nb int) {
// Sanitize bounds everything that came from a peer: a compromised peer must
// not be able to inflate the hub's memory or break its charts. It rejects
// documents of the wrong schema version.
func (e *PeerExport) Sanitize(rangeName string) error {
func (e *PeerExport) Sanitize(rangeName string) error { return e.SanitizeRange(ParseRange(rangeName)) }
// SanitizeRange is Sanitize for any window; the grid is recomputed locally.
func (e *PeerExport) SanitizeRange(rg Range) error {
if e.V != ExportVersion {
return errBadExport
}
rg := ParseRange(rangeName)
nowU := time.Now().Unix()
s := &e.Summary
s.Version = clipS(s.Version, 32)
s.Range, s.Attribution = rg.Name, clipS(s.Attribution, 200)
s.Range, s.Attribution = rg.Info(nowU), clipS(s.Attribution, 200)
s.Rates = sanitizeRates(s.Rates)
if len(s.Hosts) > 4 {
s.Hosts = s.Hosts[:4]
}
@@ -100,8 +107,9 @@ func (e *PeerExport) Sanitize(rangeName string) error {
s.Hosts[i].Location = sanitizeLocation(s.Hosts[i].Location)
}
// timeline: the grid is fixed by the range
nb := int(rg.Dur.Seconds()) / int(rg.Step)
s.Timeline.Step, s.Timeline.Cats = rg.Step, catStrings()
gr := rg.grid(nowU)
nb := gr.N
s.Timeline.Step, s.Timeline.Cats = gr.Step, catStrings()
if s.Timeline.Series == nil {
s.Timeline.Series = map[string][]uint32{}
}
@@ -171,6 +179,7 @@ func (e *PeerExport) Sanitize(rangeName string) error {
r.IP, r.Cat, r.Source = clipS(r.IP, 45), clipS(r.Cat, 20), clipS(r.Source, 20)
r.Domain, r.Method, r.Path = clipS(r.Domain, 100), clipS(r.Method, 12), clipS(r.Path, 240)
r.User, r.Jail = clipS(r.User, 64), clipS(r.Jail, 40)
sanitizeFeedDetail(r)
}
kept := s.Recent[:0]
for _, r := range s.Recent {
@@ -208,25 +217,17 @@ func (e *PeerExport) Sanitize(rangeName string) error {
delete(e.Traffic, k)
continue
}
t.sanitize(rg)
t.sanitize(rg, nowU)
e.Traffic[k] = t
}
return nil
}
func trafficGrid(rg Range) (int, int64) {
switch rg.Name {
case "1h":
return 60, 60
case "24h":
return 96, 900
}
return 168, 3600
}
func (t *TrafficData) sanitize(rg Range) {
nb, step := trafficGrid(rg)
t.Range = rg.Name
func (t *TrafficData) sanitize(rg Range, nowU int64) {
gr := rg.grid(nowU)
nb, step := gr.N, gr.Step
t.Range = rg.Info(nowU)
t.Timeline.Start = gr.Start
t.Domain = clipS(t.Domain, 253)
t.Timeline.Step = step
if len(t.Timeline.Req) != nb {
@@ -244,7 +245,55 @@ func (t *TrafficData) sanitize(rg Range) {
}
// SanitizeTraffic bounds a TrafficData received from elsewhere.
func SanitizeTraffic(t *TrafficData, rangeName string) { t.sanitize(ParseRange(rangeName)) }
func SanitizeTraffic(t *TrafficData, rangeName string) {
t.sanitize(ParseRange(rangeName), time.Now().Unix())
}
// SanitizeTrafficRange bounds a TrafficData received for any window.
func SanitizeTrafficRange(t *TrafficData, rg Range) { t.sanitize(rg, time.Now().Unix()) }
// sanitizeFeedDetail bounds the investigation fields of a feed row from a peer.
func sanitizeFeedDetail(r *FeedEvent) {
r.UA, r.Fam, r.Marker = clipS(r.UA, 200), clipS(r.Fam, 40), clipS(r.Marker, 80)
r.ID = 0
if len(r.Tech) > 8 {
r.Tech = r.Tech[:8]
}
for i := range r.Tech {
r.Tech[i] = clipS(r.Tech[i], 16)
}
if r.Bytes < 0 || r.Bytes > 1<<40 {
r.Bytes = 0
}
if r.DurMS < 0 || r.DurMS > 1<<31 {
r.DurMS = 0
}
f := ""
for _, c := range r.Flags {
if strings.ContainsRune("SWGFX", c) && !strings.ContainsRune(f, c) {
f += string(c)
}
}
r.Flags = f
}
func sanitizeRates(r Rates) Rates {
capU := func(v uint64) uint64 { return min(v, 1<<40) }
r.Last15m, r.Last1h, r.Last24h, r.PrevPeriod = capU(r.Last15m), capU(r.Last1h), capU(r.Last24h), capU(r.PrevPeriod)
for _, f := range []*float64{&r.PerHourAvg24h, &r.PerHourAvg7d} {
if !finite(*f) || *f > 1e12 {
*f = 0
}
}
if r.ChangePct != nil && (math.IsNaN(*r.ChangePct) || math.IsInf(*r.ChangePct, 0)) {
r.ChangePct = nil
}
if r.PeakHour.T < 0 {
r.PeakHour = PeakHour{}
}
r.NewAttackers, r.ActiveAttackers = max(0, min(r.NewAttackers, 1<<30)), max(0, min(r.ActiveAttackers, 1<<30))
return r
}
var validStates = map[string]bool{"following": true, "waiting": true, "backfill": true, "error": true, "disabled": true}