refactor: move private address guard into netguard

Checks need the same protection as identity provider requests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 01:12:53 +01:00
1 parent b52698ffbc
commit bc8e934568
4 files changed
+113 -48

No files matched your search

-24
View File
@@ -4,33 +4,9 @@ import (
"errors"
"net/http"
"net/http/httptest"
"net/netip"
"testing"
)
func TestIsPublic(t *testing.T) {
tests := map[string]bool{
"8.8.8.8": true,
"2606:4700::1111": true,
"127.0.0.1": false,
"10.1.2.3": false,
"172.16.0.1": false,
"192.168.1.1": false,
"169.254.169.254": false,
"100.64.0.1": false,
"0.0.0.0": false,
"::1": false,
"fd00::1": false,
"fe80::1": false,
"::ffff:127.0.0.1": false,
}
for addr, want := range tests {
if got := isPublic(netip.MustParseAddr(addr)); got != want {
t.Errorf("isPublic(%s) = %t, want %t", addr, got, want)
}
}
}
func TestSafeHTTPClientBlocksLoopback(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
defer srv.Close()