2

Add background IP intel and restore dashboard stats

This commit is contained in:
2026-03-12 11:10:59 +01:00
parent 14a711038b
commit 1822e2148a
9 changed files with 506 additions and 31 deletions

View File

@@ -139,4 +139,18 @@ func TestStoreRecordsEventsAndState(t *testing.T) {
if !found || loadedInvestigation.Bot == nil || loadedInvestigation.Bot.Name != "Googlebot" {
t.Fatalf("unexpected investigation payload: found=%v investigation=%+v", found, loadedInvestigation)
}
investigations, err := db.GetInvestigationsForIPs(ctx, []string{event.ClientIP, "198.51.100.99"})
if err != nil {
t.Fatalf("get investigations for ips: %v", err)
}
if len(investigations) != 1 || investigations[event.ClientIP].Bot == nil {
t.Fatalf("unexpected investigations map: %+v", investigations)
}
userAgents, err := db.ListRecentUserAgentsForIP(ctx, event.ClientIP, 10)
if err != nil {
t.Fatalf("list recent user agents: %v", err)
}
if len(userAgents) != 1 || userAgents[0] != event.UserAgent {
t.Fatalf("unexpected user agents: %#v", userAgents)
}
}