Files
urutau/internal/rdns/fcrdns_test.go
T
Lucas RayanandClaude Opus 5.5 b7462c14fa
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
feat: 1.2.0 attack intelligence, replay, 30-day history and new interface
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>
2026-11-14 21:45:59 -03:00

59 lines
1.6 KiB
Go

package rdns
import (
"context"
"errors"
"testing"
)
func TestFCrDNS(t *testing.T) {
r := New()
calls := 0
r.lookup = func(_ context.Context, ip string) ([]string, error) {
calls++
switch ip {
case "66.249.66.1":
return []string{"crawl-66-249-66-1.googlebot.com."}, nil
case "6.6.6.6": // claims to be google, forward does not confirm
return []string{"fake.googlebot.com."}, nil
case "7.7.7.7": // reverse name outside the allowed domains
return []string{"host.evil.example."}, nil
case "157.55.39.1":
return []string{"msnbot-157-55-39-1.search.msn.com."}, nil
}
return nil, errors.New("nxdomain")
}
r.forward = func(_ context.Context, name string) ([]string, error) {
switch name {
case "crawl-66-249-66-1.googlebot.com":
return []string{"66.249.66.1"}, nil
case "fake.googlebot.com":
return []string{"1.2.3.4"}, nil
case "msnbot-157-55-39-1.search.msn.com":
return []string{"157.55.39.1"}, nil
}
return nil, errors.New("nxdomain")
}
g := []string{"googlebot.com", "google.com"}
if !r.FCrDNS("66.249.66.1", g) {
t.Fatal("real googlebot must verify")
}
if r.FCrDNS("6.6.6.6", g) || r.FCrDNS("7.7.7.7", g) || r.FCrDNS("8.8.8.8", g) {
t.Fatal("impostors must fail")
}
if r.FCrDNS("66.249.66.1", []string{"search.msn.com"}) {
t.Fatal("a Google address is not Bing")
}
if !r.FCrDNS("157.55.39.1", []string{"search.msn.com"}) {
t.Fatal("bingbot")
}
n := calls
r.FCrDNS("66.249.66.1", g)
if calls != n {
t.Fatal("results must be cached")
}
if r.FCrDNS("10.0.0.1", g) || r.FCrDNS("garbage", g) || r.FCrDNS("fe80::1%eth0", g) {
t.Fatal("private and invalid addresses are never looked up")
}
}