GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — SerialSpan/ice_config_test.go at main · eleree/SerialSpan Expand file tree/ Copy pathice_config_test.goMore file actions 60 lines (56 loc) · 2.45 KB / Copy pathice_config_test.goFile metadata and controls60 lines (56 loc) · 2.45 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 package main import ( "net/http" "net/http/httptest" "strings" "testing" "shareserial/websocket" ) func TestSTUNConfigurationBoundsAndInjection(t *testing.T) { for _, value := range []string{"", "stun:stun.example.test", "stun:192.0.2.1:18444", "stun:[2001:db8::1]", "stun:[2001:db8::1]:3478", "stun:a.test:3478, stun:b.test:18444"} { if _, err := parseSTUNURLs(value); err != nil { t.Fatalf("valid STUN configuration rejected: %v", err) } } for _, value := range []string{"https://example.test", "turn:example.test", "stun:user:[email protected]", "stun://example.test", "stun:a.test/path", "stun:a.test?transport=tcp", "stun:a.test#x", "stun:a.test\n", "stun:a.test:0", "stun:a.test:65536", "stun:", "stun:<script>", "stun:a.test,stun:b.test,stun:c.test,stun:d.test,stun:e.test", strings.Repeat("x", 1025)} { if _, err := parseSTUNURLs(value); err == nil { t.Fatalf("invalid STUN configuration accepted: %q", value) } } urls, err := parseSTUNURLs("stun:a.test,stun:a.test") if err != nil || len(urls) != 1 { t.Fatal("duplicate STUN servers were not bounded") } } func TestDeploymentICEScriptIsBoundedSameOriginAndNotCacheable(t *testing.T) { for _, configuration := range []string{"", "stun:192.0.2.1:18444"} { router, err := newRouterTrusted(websocket.NewHub(), nil, configuration) if err != nil { t.Fatal(err) } var first string for _, query := range []string{"", "?stun=stun:attacker.test"} { response := httptest.NewRecorder() router.ServeHTTP(response, httptest.NewRequest(http.MethodGet, "/api/serial-p2p-config.js"+query, nil)) if response.Code != 200 || !strings.Contains(response.Header().Get("Content-Type"), "application/javascript") || response.Header().Get("Cache-Control") != "no-store" || response.Header().Get("X-Content-Type-Options") != "nosniff" { t.Fatalf("unsafe configuration response: %d %v", response.Code, response.Header()) } body := response.Body.String() if configuration == "" && !strings.Contains(body, `"iceServers":[]`) { t.Fatal("default contacted an external ICE service") } if configuration != "" && !strings.Contains(body, configuration) { t.Fatal("operator STUN setting was not served") } if first == "" { first = body } else if first != body { t.Fatal("URL query overrode operator configuration") } } } if _, err := newRouterTrusted(websocket.NewHub(), nil, "stun:user:secret@host"); err == nil { t.Fatal("invalid configuration reached router") } } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |