@@ -57,12 +57,12 @@ func test() {
57
57
58
58
// x net websocket dial bad
59
59
http .HandleFunc ("/ex2" , func (w http.ResponseWriter , r * http.Request ) {
60
- untrustedInput := r .Referer ()
60
+ untrustedInput := r .Referer () // $ Source
61
61
62
62
origin := "http://localhost/"
63
63
64
64
// bad as input is directly passed to dial function
65
- ws , _ := websocket .Dial (untrustedInput , "" , origin )
65
+ ws , _ := websocket .Dial (untrustedInput , "" , origin ) // $ Alert
66
66
var msg = make ([]byte , 512 )
67
67
var n int
68
68
n , _ = ws .Read (msg )
@@ -71,12 +71,12 @@ func test() {
71
71
72
72
// x net websocket dialConfig bad
73
73
http .HandleFunc ("/ex3" , func (w http.ResponseWriter , r * http.Request ) {
74
- untrustedInput := r .Referer ()
74
+ untrustedInput := r .Referer () // $ Source
75
75
76
76
origin := "http://localhost/"
77
77
// 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
80
80
var msg = make ([]byte , 512 )
81
81
var n int
82
82
n , _ = ws2 .Read (msg )
@@ -85,10 +85,10 @@ func test() {
85
85
86
86
// nhooyr websocket dial bad
87
87
http .HandleFunc ("/ex4" , func (w http.ResponseWriter , r * http.Request ) {
88
- untrustedInput := r .Referer ()
88
+ untrustedInput := r .Referer () // $ Source
89
89
90
90
// bad as input is used directly
91
- nhooyr .Dial (context .TODO (), untrustedInput , nil )
91
+ nhooyr .Dial (context .TODO (), untrustedInput , nil ) // $ Alert
92
92
w .WriteHeader (500 )
93
93
})
94
94
@@ -104,10 +104,10 @@ func test() {
104
104
105
105
// gorilla websocket Dialer.Dial bad
106
106
http .HandleFunc ("/ex6" , func (w http.ResponseWriter , r * http.Request ) {
107
- untrustedInput := r .Referer ()
107
+ untrustedInput := r .Referer () // $ Source
108
108
109
109
dialer := gorilla.Dialer {}
110
- dialer .Dial (untrustedInput , r .Header )
110
+ dialer .Dial (untrustedInput , r .Header ) // $ Alert
111
111
})
112
112
113
113
// gorilla websocket Dialer.Dial good
@@ -123,10 +123,10 @@ func test() {
123
123
124
124
// gorilla websocket Dialer.DialContext bad
125
125
http .HandleFunc ("/ex8" , func (w http.ResponseWriter , r * http.Request ) {
126
- untrustedInput := r .Referer ()
126
+ untrustedInput := r .Referer () // $ Source
127
127
128
128
dialer := gorilla.Dialer {}
129
- dialer .DialContext (context .TODO (), untrustedInput , r .Header )
129
+ dialer .DialContext (context .TODO (), untrustedInput , r .Header ) // $ Alert
130
130
})
131
131
132
132
// gorilla websocket Dialer.DialContext good
@@ -151,15 +151,15 @@ func test() {
151
151
152
152
// gobwas websocket Dial bad
153
153
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
156
156
})
157
157
158
158
// gobwas websocket Dialer.Dial bad
159
159
http .HandleFunc ("/ex12" , func (w http.ResponseWriter , r * http.Request ) {
160
- untrustedInput := r .Referer ()
160
+ untrustedInput := r .Referer () // $ Source
161
161
dialer := gobwas.Dialer {}
162
- dialer .Dial (context .TODO (), untrustedInput )
162
+ dialer .Dial (context .TODO (), untrustedInput ) // $ Alert
163
163
})
164
164
165
165
// gobwas websocket Dialer.Dial good
@@ -192,16 +192,16 @@ func test() {
192
192
193
193
// sac007 websocket BuildProxy bad
194
194
http .HandleFunc ("/ex15" , func (w http.ResponseWriter , r * http.Request ) {
195
- untrustedInput := r .Referer ()
195
+ untrustedInput := r .Referer () // $ Source
196
196
197
- _ = sac .BuildProxy (untrustedInput )
197
+ _ = sac .BuildProxy (untrustedInput ) // $ Alert
198
198
})
199
199
200
200
// sac007 websocket New bad
201
201
http .HandleFunc ("/ex16" , func (w http.ResponseWriter , r * http.Request ) {
202
- untrustedInput := r .Referer ()
202
+ untrustedInput := r .Referer () // $ Source
203
203
204
- _ = sac .New (untrustedInput )
204
+ _ = sac .New (untrustedInput ) // $ Alert
205
205
})
206
206
207
207
log .Println (http .ListenAndServe (":80" , nil ))
0 commit comments