Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 1m29s
CI / Tests (Linux, race detector) (push) Failing after 1m48s
CI / Dependency audit (push) Successful in 21s
Release / ci (push) Failing after 1m50s
Release / Build image (amd64) (push) Skipped
Release / Build image (arm64) (push) Skipped
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Always-on Go service (stdlib only) that follows the Traefik JSON access log, the sshd log and the fail2ban log of a host, classifies attacks, scores sources, keeps bounded aggregates with snapshots, and serves an embedded dashboard with live updates, offline geolocation (DB-IP Lite), privacy-friendly traffic analytics, an exportable blocklist and token-authenticated federation between instances. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package geo
|
|
|
|
import (
|
|
"bytes"
|
|
"net/netip"
|
|
"testing"
|
|
)
|
|
|
|
// A node_count so large that node_count*node_bytes overflows must be refused:
|
|
// before the fix the tree-size check passed and lookups indexed outside the file.
|
|
func TestOverflowingNodeCountIsRefused(t *testing.T) {
|
|
u64 := func(v uint64) []byte {
|
|
b := []byte{}
|
|
for i := 7; i >= 0; i-- {
|
|
b = append(b, byte(v>>(8*uint(i))))
|
|
}
|
|
return append([]byte{0x08, 0x02}, b...)
|
|
}
|
|
str := func(s string) []byte { return append([]byte{0x40 | byte(len(s))}, s...) }
|
|
u16 := func(v uint16) []byte { return []byte{0xa2, byte(v >> 8), byte(v)} }
|
|
for _, count := range []uint64{1 << 63, 1 << 62, 1<<64 - 1, 1 << 40} {
|
|
var m bytes.Buffer
|
|
m.WriteByte(0xe5)
|
|
m.Write(str("node_count"))
|
|
m.Write(u64(count))
|
|
m.Write(str("record_size"))
|
|
m.Write(u16(24))
|
|
m.Write(str("ip_version"))
|
|
m.Write(u16(4))
|
|
m.Write(str("binary_format_major_version"))
|
|
m.Write(u16(2))
|
|
m.Write(str("build_epoch"))
|
|
m.Write(u16(1))
|
|
var f bytes.Buffer
|
|
f.Write(bytes.Repeat([]byte{0x7f}, 64))
|
|
f.Write(make([]byte, 16))
|
|
f.WriteString("\xab\xcd\xefMaxMind.com")
|
|
f.Write(m.Bytes())
|
|
r, err := newReader(f.Bytes())
|
|
if err == nil {
|
|
func() {
|
|
defer func() {
|
|
if p := recover(); p != nil {
|
|
t.Fatalf("node_count %d accepted and a lookup panicked: %v", count, p)
|
|
}
|
|
}()
|
|
r.find(netip.MustParseAddr("8.8.8.8"))
|
|
}()
|
|
t.Fatalf("node_count %d must be refused", count)
|
|
}
|
|
}
|
|
}
|