Release / Publish tags (push) Successful in 16s
Release / Plan (reuse the published image?) (push) Successful in 4s
Release / ci (push) Successful in 1m47s
Release / Build image (amd64) (push) Successful in 21s
Release / Build image (arm64) (push) Successful in 23s
CI / Format and vet (push) Successful in 27s
CI / Tests (Linux, race detector) (push) Successful in 1m20s
CI / Dependency audit (push) Successful in 31s
CI / Docker image (build and smoke test) (push) Skipped
Release / Gitea release (push) Successful in 5s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|