From 2f3637eb109c52a014d95437d40f6c38d7f7e9f2 Mon Sep 17 00:00:00 2001 From: Flotapponnier <160007691+Flotapponnier@users.noreply.github.com> Date: Wed, 16 Sep 2026 15:37:21 +0200 Subject: [PATCH] head-lag: redact keyed reference URLs in the subscription log (#2401) Claude-Session: https://claude.ai/code/session_01HJgbZCqjR4nvCfcJSzofbw Co-authored-by: Flotapponnier Co-authored-by: Claude Opus 5 (1M context) (cherry picked from commit ab5e852e93d908bac0a2f3a1ec90e61f34073462) --- .../cmd/script/reference_monitor.go | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/harnesses/aggregator-head-lag/cmd/script/reference_monitor.go b/harnesses/aggregator-head-lag/cmd/script/reference_monitor.go index b44c67604..6fcb4bb10 100644 --- a/harnesses/aggregator-head-lag/cmd/script/reference_monitor.go +++ b/harnesses/aggregator-head-lag/cmd/script/reference_monitor.go @@ -3,6 +3,7 @@ package main import ( "encoding/json" "fmt" + neturl "net/url" "os" "strings" "sync" @@ -217,7 +218,7 @@ func refConnect(p HeadLagPool, url string, stopChan <-chan struct{}) error { if err := conn.WriteJSON(sub); err != nil { return fmt.Errorf("subscribe: %w", err) } - fmt.Printf("[HEAD-LAG][REF][%s] subscribed to %s on %s\n", p.ChainName, p.Address, url) + fmt.Printf("[HEAD-LAG][REF][%s] subscribed to %s on %s\n", p.ChainName, p.Address, redactURL(url)) go func() { t := time.NewTicker(25 * time.Second) @@ -290,3 +291,25 @@ func refConnect(p HeadLagPool, url string, stopChan <-chan struct{}) error { reference.observe(p.ChainName, r.TransactionHash, now) } } + +// redactURL hides the query string and any path segment that looks like +// a key: keyed reference endpoints (Helius, Alchemy) carry the credential +// in the URL, and the subscription log is read by more people than hold +// the key. +func redactURL(raw string) string { + u, err := neturl.Parse(raw) + if err != nil { + return "" + } + if u.RawQuery != "" { + u.RawQuery = "" + } + parts := strings.Split(u.Path, "/") + for i, seg := range parts { + if len(seg) >= 20 { + parts[i] = "" + } + } + u.Path = strings.Join(parts, "/") + return u.String() +}