package store import ( "testing" "time" "git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core" ) func TestTalliesFromRealRegistry(t *testing.T) { s := store30("oracle") l := openLog(t) s.SetEventLog(l) for i := 0; i < 41; i++ { s.Ingest(core.Event{Time: t0.Add(-time.Duration(20+i) * time.Minute), IP: "43.139.48.108", Cat: core.SSHFail, Source: "ssh", User: "root"}) } for i := 0; i < 30; i++ { s.Ingest(core.Event{Time: t0.Add(-time.Duration(30+i) * time.Minute), IP: "129.213.151.234", Cat: core.Scanner, Source: "traefik", Domain: "a.example", Method: "GET", Path: "/.env", Status: 404, UA: "curl/8"}) } l.Flush() from := t0.Add(-24 * time.Hour).Unix() m := s.AttackTallies(from) if m["43.139.48.108"].SSH != 41 || m["129.213.151.234"].Web != 30 { t.Fatalf("tallies: %+v", m) } if x := s.AttackTally("43.139.48.108", from); x.SSH != 41 { t.Fatalf("one: %+v", x) } rows := s.AttackRoster(from) got := map[string]bool{} for _, r := range rows { got[r.IP] = true } if !got["43.139.48.108"] || !got["129.213.151.234"] { t.Fatalf("roster: %+v", rows) } }