Implement Canvas V2 subgraphs, assets and asynchronous AI execution
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/netip"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestCanvasImageFetchRejectsPrivateAndMetadataNetworks(t *testing.T) {
|
||||
for _, raw := range []string{"127.0.0.1", "10.0.0.1", "169.254.169.254", "172.16.0.1", "192.168.1.1", "100.100.100.200", "168.63.129.16", "0.0.0.1", "198.18.0.1", "224.0.0.1", "255.255.255.255", "::1", "::ffff:127.0.0.1", "fe80::1", "fc00::1", "2001:db8::1"} {
|
||||
if canvasPublicIP(netip.MustParseAddr(raw)) {
|
||||
t.Errorf("private/reserved image host accepted: %s", raw)
|
||||
}
|
||||
}
|
||||
for _, raw := range []string{"8.8.8.8", "1.1.1.1", "2606:4700:4700::1111"} {
|
||||
if !canvasPublicIP(netip.MustParseAddr(raw)) {
|
||||
t.Errorf("public host rejected: %s", raw)
|
||||
}
|
||||
}
|
||||
for _, raw := range []string{"http://example.com/image.png", "file:///etc/passwd", "https://user:password@example.com/x"} {
|
||||
if canvasImageURL(raw) {
|
||||
t.Errorf("unsafe source accepted: %s", raw)
|
||||
}
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
if _, err := fetchCanvasImage(ctx, "https://127.0.0.1/image.png"); err == nil {
|
||||
t.Fatal("loopback image fetch permitted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user