Monorepo for Tangled tangled.org
1

Configure Feed

Select the types of activity you want to include in your feed.

Labels

None yet.

Participants 1
AT URI
at://did:plc:dfl62fgb7wtjj3fcbb72naae/sh.tangled.repo.pull/3mqzoslh2nj22
+71 -71
Interdiff #0 #1
+1 -1
appview/serververify/verify.go
··· 12 12 "tangled.org/core/appview/db" 13 13 "tangled.org/core/orm" 14 14 "tangled.org/core/rbac" 15 - "tangled.org/core/util/netutil" 15 + "tangled.org/core/netutil" 16 16 "tangled.org/core/xrpc/xrpcclient" 17 17 ) 18 18
+1 -1
knotmirror/knotstream/slurper.go
··· 18 18 "tangled.org/core/knotmirror/db" 19 19 "tangled.org/core/knotmirror/models" 20 20 "tangled.org/core/log" 21 - "tangled.org/core/util/netutil" 21 + "tangled.org/core/netutil" 22 22 ) 23 23 24 24 type KnotSlurper struct {
+1 -1
knotmirror/xrpc/xrpc.go
··· 17 17 "tangled.org/core/knotmirror/knotstream" 18 18 "tangled.org/core/knotmirror/repoindexer" 19 19 "tangled.org/core/log" 20 - "tangled.org/core/util/netutil" 20 + "tangled.org/core/netutil" 21 21 ) 22 22 23 23 type Xrpc struct {
-51
util/netutil/ssrf.go
··· 1 - package netutil 2 - 3 - import ( 4 - "fmt" 5 - "net" 6 - "net/http" 7 - "net/url" 8 - 9 - "github.com/bluesky-social/indigo/util/ssrf" 10 - "github.com/gorilla/websocket" 11 - ) 12 - 13 - // SSRFDialer returns a net.Dialer that refuses non-public IPs. 14 - func SSRFDialer(dev bool) *net.Dialer { 15 - if dev { 16 - return &net.Dialer{} 17 - } 18 - return ssrf.PublicOnlyDialer() 19 - } 20 - 21 - // SSRFTransport returns an http.Transport that refuses non-public IPs. 22 - func SSRFTransport(dev bool) *http.Transport { 23 - if dev { 24 - return &http.Transport{} 25 - } 26 - return ssrf.PublicOnlyTransport() 27 - } 28 - 29 - // SSRFWebsocketDialer returns a websocket.Dialer that refuses non-public IPs. 30 - func SSRFWebsocketDialer(dev bool) *websocket.Dialer { 31 - dialer := *websocket.DefaultDialer 32 - dialer.NetDialContext = SSRFDialer(dev).DialContext 33 - return &dialer 34 - } 35 - 36 - func EnforceWSSURL(rawURL string, dev bool) (*url.URL, error) { 37 - u, err := url.Parse(rawURL) 38 - if err != nil { 39 - return nil, fmt.Errorf("invalid url: %w", err) 40 - } 41 - switch u.Scheme { 42 - case "wss": 43 - case "ws": 44 - if !dev { 45 - return nil, fmt.Errorf("insecure scheme %q is prohibited in production; use wss://", u.Scheme) 46 - } 47 - default: 48 - return nil, fmt.Errorf("unsupported websocket scheme %q", u.Scheme) 49 - } 50 - return u, nil 51 - }
-17
util/netutil/ssrf_test.go
··· 1 - package netutil 2 - 3 - import ( 4 - "testing" 5 - 6 - "github.com/gorilla/websocket" 7 - ) 8 - 9 - func TestSSRFWebsocketDialerPreservesHandshakeTimeout(t *testing.T) { 10 - dialer := SSRFWebsocketDialer(false) 11 - if dialer.HandshakeTimeout != websocket.DefaultDialer.HandshakeTimeout { 12 - t.Fatalf("HandshakeTimeout = %v, want %v", dialer.HandshakeTimeout, websocket.DefaultDialer.HandshakeTimeout) 13 - } 14 - if dialer.NetDialContext == nil { 15 - t.Fatal("NetDialContext is nil; public-only dialing is not enforced") 16 - } 17 - }
+51
netutil/ssrf.go
··· 1 + package netutil 2 + 3 + import ( 4 + "fmt" 5 + "net" 6 + "net/http" 7 + "net/url" 8 + 9 + "github.com/bluesky-social/indigo/util/ssrf" 10 + "github.com/gorilla/websocket" 11 + ) 12 + 13 + // SSRFDialer returns a net.Dialer that refuses non-public IPs. 14 + func SSRFDialer(dev bool) *net.Dialer { 15 + if dev { 16 + return &net.Dialer{} 17 + } 18 + return ssrf.PublicOnlyDialer() 19 + } 20 + 21 + // SSRFTransport returns an http.Transport that refuses non-public IPs. 22 + func SSRFTransport(dev bool) *http.Transport { 23 + if dev { 24 + return &http.Transport{} 25 + } 26 + return ssrf.PublicOnlyTransport() 27 + } 28 + 29 + // SSRFWebsocketDialer returns a websocket.Dialer that refuses non-public IPs. 30 + func SSRFWebsocketDialer(dev bool) *websocket.Dialer { 31 + dialer := *websocket.DefaultDialer 32 + dialer.NetDialContext = SSRFDialer(dev).DialContext 33 + return &dialer 34 + } 35 + 36 + func EnforceWSSURL(rawURL string, dev bool) (*url.URL, error) { 37 + u, err := url.Parse(rawURL) 38 + if err != nil { 39 + return nil, fmt.Errorf("invalid url: %w", err) 40 + } 41 + switch u.Scheme { 42 + case "wss": 43 + case "ws": 44 + if !dev { 45 + return nil, fmt.Errorf("insecure scheme %q is prohibited in production; use wss://", u.Scheme) 46 + } 47 + default: 48 + return nil, fmt.Errorf("unsupported websocket scheme %q", u.Scheme) 49 + } 50 + return u, nil 51 + }
+17
netutil/ssrf_test.go
··· 1 + package netutil 2 + 3 + import ( 4 + "testing" 5 + 6 + "github.com/gorilla/websocket" 7 + ) 8 + 9 + func TestSSRFWebsocketDialerPreservesHandshakeTimeout(t *testing.T) { 10 + dialer := SSRFWebsocketDialer(false) 11 + if dialer.HandshakeTimeout != websocket.DefaultDialer.HandshakeTimeout { 12 + t.Fatalf("HandshakeTimeout = %v, want %v", dialer.HandshakeTimeout, websocket.DefaultDialer.HandshakeTimeout) 13 + } 14 + if dialer.NetDialContext == nil { 15 + t.Fatal("NetDialContext is nil; public-only dialing is not enforced") 16 + } 17 + }

History

9 rounds 0 comments
Sign up or Login to add to the discussion
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Checking mergeability…
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
2/3 success, 1/3 failed
Expand
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Expand 0 comments
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
2/3 success, 1/3 failed
Expand
Expand 0 comments
ptr.pet submitted #1
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
2/3 success, 1/3 failed
Expand
Expand 0 comments
ptr.pet submitted #0
1 commit
Expand
netutil: extract common SSRF and secure-scheme guards
3/3 success
Expand
Expand 0 comments