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
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:
1 parent
8f1ac462d1
commit
b7462c14fa
325 files changed
+19117
-1307
No files matched your search
+22
-27
@@ -17,7 +17,8 @@ import (
|
||||
// cannot be linked across days, and nothing here reaches a snapshot or the API.
|
||||
|
||||
const (
|
||||
anMinutes = 24 * 60
|
||||
anMinutes = 49 * 60 // minute buckets (48 h plus one hour of margin)
|
||||
anDays = 31 // daily buckets for the tops
|
||||
maxDomains = 24
|
||||
visCap = 20000
|
||||
anTop = 40
|
||||
@@ -46,7 +47,7 @@ type domData struct {
|
||||
MinReq [anMinutes]uint32
|
||||
MinPages [anMinutes]uint32
|
||||
Hours [hourSlots]anHour
|
||||
Days [8]anDay
|
||||
Days [anDays]anDay
|
||||
Last int64 // unix time of the last request, for pruning idle domains
|
||||
// in memory only, never in a snapshot (unexported fields are skipped by gob)
|
||||
vis map[uint64]struct{}
|
||||
@@ -254,7 +255,7 @@ func (s *Store) Traffic(ev core.Event) {
|
||||
hs.Lat[latBucket(ev.DurationNS)]++
|
||||
}
|
||||
|
||||
dd := &d.Days[int(day%8)]
|
||||
dd := &d.Days[int(day%anDays)]
|
||||
if dd.Day != day {
|
||||
*dd = anDay{Day: day}
|
||||
}
|
||||
@@ -340,7 +341,7 @@ func orUnknown(s string) string {
|
||||
// TrafficData is the mergeable analytics payload.
|
||||
type TrafficData struct {
|
||||
Host string `json:"host"`
|
||||
Range string `json:"range"`
|
||||
Range RangeInfo `json:"range"`
|
||||
Domain string `json:"domain"`
|
||||
Generated int64 `json:"generated"`
|
||||
Domains []Count `json:"domains"`
|
||||
@@ -399,32 +400,26 @@ func (t *TrafficData) Finish() {
|
||||
t.P50, t.P95 = round1(quantile(t.Lat, 0.5)), round1(quantile(t.Lat, 0.95))
|
||||
}
|
||||
|
||||
// Traffic returns the analytics of one domain ("" or "all": every domain).
|
||||
// TrafficSummary returns the analytics of one domain for a named range.
|
||||
func (s *Store) TrafficSummary(rangeName, domain string) TrafficData {
|
||||
rg := ParseRange(rangeName)
|
||||
return s.TrafficFor(ParseRange(rangeName), domain)
|
||||
}
|
||||
|
||||
// TrafficFor returns the analytics of one domain ("" or "all": every domain).
|
||||
func (s *Store) TrafficFor(rg Range, domain string) TrafficData {
|
||||
now := s.now().Unix()
|
||||
out := TrafficData{Host: s.cfg.Name, Range: rg.Name, Domain: domain, Generated: now}
|
||||
from, to := rg.bounds(now)
|
||||
out := TrafficData{Host: s.cfg.Name, Range: rg.Info(now), Domain: domain, Generated: now}
|
||||
if out.Domain == "" {
|
||||
out.Domain = "all"
|
||||
}
|
||||
// timeline grid
|
||||
var nb int
|
||||
var step int64
|
||||
switch rg.Name {
|
||||
case "1h":
|
||||
nb, step = 60, 60
|
||||
case "24h":
|
||||
nb, step = 96, 900
|
||||
default:
|
||||
nb, step = 168, 3600
|
||||
}
|
||||
endB := now / step
|
||||
start := (endB - int64(nb) + 1) * step
|
||||
g := rg.grid(now)
|
||||
nb, step, start := g.N, g.Step, g.Start
|
||||
out.Timeline.Start, out.Timeline.Step = start, step
|
||||
out.Timeline.Req, out.Timeline.Pages = make([]uint32, nb), make([]uint32, nb)
|
||||
|
||||
firstHour := (now - int64(rg.Dur.Seconds())) / 3600
|
||||
firstDay := (now - int64(rg.Dur.Seconds())) / 86400
|
||||
firstHour, lastHour := start/3600, to/3600
|
||||
firstDay, lastDay := from/86400, to/86400
|
||||
maps := [8]map[string]uint32{{}, {}, {}, {}, {}, {}, {}, {}}
|
||||
domReq := map[string]uint32{}
|
||||
|
||||
@@ -433,14 +428,14 @@ func (s *Store) TrafficSummary(rangeName, domain string) TrafficData {
|
||||
var reqRange uint32
|
||||
for i := range d.Hours {
|
||||
h := &d.Hours[i]
|
||||
if h.Hour == 0 || h.Hour < firstHour || h.Hour > now/3600+1 {
|
||||
if h.Hour == 0 || h.Hour < firstHour || h.Hour > lastHour {
|
||||
continue
|
||||
}
|
||||
reqRange += h.Req
|
||||
if out.Domain != "all" && out.Domain != name {
|
||||
continue
|
||||
}
|
||||
if rg.Name == "7d" {
|
||||
if !g.minute() {
|
||||
out.Requests += uint64(h.Req)
|
||||
out.Pages += uint64(h.Pages)
|
||||
if b := (h.Hour*3600 - start) / step; b >= 0 && b < int64(nb) {
|
||||
@@ -461,8 +456,8 @@ func (s *Store) TrafficSummary(rangeName, domain string) TrafficData {
|
||||
if out.Domain != "all" && out.Domain != name {
|
||||
continue
|
||||
}
|
||||
if rg.Name != "7d" {
|
||||
for m := start / 60; m <= now/60; m++ {
|
||||
if g.minute() {
|
||||
for m := start / 60; m <= to/60; m++ {
|
||||
i := int(m % anMinutes)
|
||||
if d.MinSt[i] != m {
|
||||
continue
|
||||
@@ -477,7 +472,7 @@ func (s *Store) TrafficSummary(rangeName, domain string) TrafficData {
|
||||
}
|
||||
for i := range d.Days {
|
||||
dd := &d.Days[i]
|
||||
if dd.Day == 0 || dd.Day < firstDay || dd.Day > now/86400 {
|
||||
if dd.Day == 0 || dd.Day < firstDay || dd.Day > lastDay {
|
||||
continue
|
||||
}
|
||||
out.Visitors += uint64(dd.Visitors)
|
||||
|
||||
Reference in new issue
Block a user