fix(fed): sanitize peer rows, cap peer bytes, add --peer-blocklist
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
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 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and vet (push) Successful in 24s
CI / Tests (Linux, race detector) (push) Successful in 34s
CI / Dependency audit (push) Successful in 14s
Release / Plan (reuse the published image?) (push) Successful in 3s
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 4s
Peer events and summary rows are rebuilt from validated fields (address, country code, category) and the forged/unban flags from peers are ignored. The live relay drops a peer that exceeds about 1 MB/s, also within a single window. --peer-blocklist=off keeps the hub's blocklist to local observations. UI polish: plural forms, blocklist preview and downloads follow the active slice, compact IP cards on phones. Docs for the 1.1.0 interface. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f4b295f582
commit
783b0cba3e
31 files changed
+355
-127
No files matched your search
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/core"
|
||||
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/fed"
|
||||
"git.lucasrguerra.dev.br/ciberfauna/urutau/internal/store"
|
||||
)
|
||||
|
||||
@@ -240,3 +242,32 @@ func TestPeerStreamIsPeerOnly(t *testing.T) {
|
||||
t.Fatal("no event")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPeerBlocklistOffUsesLocalOnly(t *testing.T) {
|
||||
const ptk = "peer-secret-0123456789-abcdefghijklmnopqr"
|
||||
strongHits := func(st *store.Store, ip string) {
|
||||
for i := 0; i < 8; i++ {
|
||||
st.Ingest(core.Event{Time: time.Now(), IP: ip, Cat: core.Exploit, Strong: true, Source: "traefik", Method: "GET", Path: "/x"})
|
||||
}
|
||||
}
|
||||
remote := store.New(store.Config{Name: "remote"})
|
||||
strongHits(remote, "45.94.31.7") // only the peer saw it
|
||||
rs := httptest.NewServer(New(Options{Token: utok, PeerTokens: []string{ptk}, Store: remote}))
|
||||
defer rs.Close()
|
||||
p, _ := fed.ParsePeer("edge=" + rs.URL)
|
||||
hub := fed.NewHub([]fed.Peer{p}, ptk)
|
||||
hub.Refresh(context.Background())
|
||||
for _, off := range []bool{false, true} {
|
||||
st := store.New(store.Config{Name: "o"})
|
||||
strongHits(st, "45.94.31.5")
|
||||
hh := New(Options{Token: utok, Store: st, Hub: hub, LocalBlocklist: off})
|
||||
w := do(hh, "GET", "/api/v1/blocklist.txt", map[string]string{"Authorization": "Bearer " + utok}, nil)
|
||||
b := w.Body.String()
|
||||
if w.Code != 200 || !strings.Contains(b, "45.94.31.5") {
|
||||
t.Fatalf("off=%v: local IP missing: %d %s", off, w.Code, b)
|
||||
}
|
||||
if has := strings.Contains(b, "45.94.31.7"); has == off {
|
||||
t.Fatalf("off=%v: peer-only IP listed=%v: %s", off, has, b)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user