@@ -57,12 +57,12 @@ func test() {
5757
5858 // x net websocket dial bad
5959 http .HandleFunc ("/ex2" , func (w http.ResponseWriter , r * http.Request ) {
60- untrustedInput := r .Referer ()
60+ untrustedInput := r .Referer () // $ Source
6161
6262 origin := "http://localhost/"
6363
6464 // bad as input is directly passed to dial function
65- ws , _ := websocket .Dial (untrustedInput , "" , origin )
65+ ws , _ := websocket .Dial (untrustedInput , "" , origin ) // $ Alert
6666 var msg = make ([]byte , 512 )
6767 var n int
6868 n , _ = ws .Read (msg )
@@ -71,12 +71,12 @@ func test() {
7171
7272 // x net websocket dialConfig bad
7373 http .HandleFunc ("/ex3" , func (w http.ResponseWriter , r * http.Request ) {
74- untrustedInput := r .Referer ()
74+ untrustedInput := r .Referer () // $ Source
7575
7676 origin := "http://localhost/"
7777 // bad as input is directly used
78- config , _ := websocket .NewConfig (untrustedInput , origin ) // good
79- ws2 , _ := websocket .DialConfig (config )
78+ config , _ := websocket .NewConfig (untrustedInput , origin ) // $ Sink
79+ ws2 , _ := websocket .DialConfig (config ) // $ Alert
8080 var msg = make ([]byte , 512 )
8181 var n int
8282 n , _ = ws2 .Read (msg )
@@ -85,10 +85,10 @@ func test() {
8585
8686 // nhooyr websocket dial bad
8787 http .HandleFunc ("/ex4" , func (w http.ResponseWriter , r * http.Request ) {
88- untrustedInput := r .Referer ()
88+ untrustedInput := r .Referer () // $ Source
8989
9090 // bad as input is used directly
91- nhooyr .Dial (context .TODO (), untrustedInput , nil )
91+ nhooyr .Dial (context .TODO (), untrustedInput , nil ) // $ Alert
9292 w .WriteHeader (500 )
9393 })
9494
@@ -104,10 +104,10 @@ func test() {
104104
105105 // gorilla websocket Dialer.Dial bad
106106 http .HandleFunc ("/ex6" , func (w http.ResponseWriter , r * http.Request ) {
107- untrustedInput := r .Referer ()
107+ untrustedInput := r .Referer () // $ Source
108108
109109 dialer := gorilla.Dialer {}
110- dialer .Dial (untrustedInput , r .Header )
110+ dialer .Dial (untrustedInput , r .Header ) // $ Alert
111111 })
112112
113113 // gorilla websocket Dialer.Dial good
@@ -123,10 +123,10 @@ func test() {
123123
124124 // gorilla websocket Dialer.DialContext bad
125125 http .HandleFunc ("/ex8" , func (w http.ResponseWriter , r * http.Request ) {
126- untrustedInput := r .Referer ()
126+ untrustedInput := r .Referer () // $ Source
127127
128128 dialer := gorilla.Dialer {}
129- dialer .DialContext (context .TODO (), untrustedInput , r .Header )
129+ dialer .DialContext (context .TODO (), untrustedInput , r .Header ) // $ Alert
130130 })
131131
132132 // gorilla websocket Dialer.DialContext good
@@ -151,15 +151,15 @@ func test() {
151151
152152 // gobwas websocket Dial bad
153153 http .HandleFunc ("/ex11" , func (w http.ResponseWriter , r * http.Request ) {
154- untrustedInput := r .Referer ()
155- gobwas .Dial (context .TODO (), untrustedInput )
154+ untrustedInput := r .Referer () // $ Source
155+ gobwas .Dial (context .TODO (), untrustedInput ) // $ Alert
156156 })
157157
158158 // gobwas websocket Dialer.Dial bad
159159 http .HandleFunc ("/ex12" , func (w http.ResponseWriter , r * http.Request ) {
160- untrustedInput := r .Referer ()
160+ untrustedInput := r .Referer () // $ Source
161161 dialer := gobwas.Dialer {}
162- dialer .Dial (context .TODO (), untrustedInput )
162+ dialer .Dial (context .TODO (), untrustedInput ) // $ Alert
163163 })
164164
165165 // gobwas websocket Dialer.Dial good
@@ -192,16 +192,16 @@ func test() {
192192
193193 // sac007 websocket BuildProxy bad
194194 http .HandleFunc ("/ex15" , func (w http.ResponseWriter , r * http.Request ) {
195- untrustedInput := r .Referer ()
195+ untrustedInput := r .Referer () // $ Source
196196
197- _ = sac .BuildProxy (untrustedInput )
197+ _ = sac .BuildProxy (untrustedInput ) // $ Alert
198198 })
199199
200200 // sac007 websocket New bad
201201 http .HandleFunc ("/ex16" , func (w http.ResponseWriter , r * http.Request ) {
202- untrustedInput := r .Referer ()
202+ untrustedInput := r .Referer () // $ Source
203203
204- _ = sac .New (untrustedInput )
204+ _ = sac .New (untrustedInput ) // $ Alert
205205 })
206206
207207 log .Println (http .ListenAndServe (":80" , nil ))
0 commit comments