Skip to content

Commit 0d670f8

Browse files
committed
fix type assertion errors and create more source()s for better tests
1 parent ea40081 commit 0d670f8

File tree

1 file changed

+9
-12
lines changed
  • go/ql/test/library-tests/semmle/go/frameworks/Fasthttp

1 file changed

+9
-12
lines changed

go/ql/test/library-tests/semmle/go/frameworks/Fasthttp/fasthttp.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,34 @@ func sink(interface{}) {
1919

2020
func fasthttpClient() {
2121
userInput := "127.0.0.1:8909"
22-
userInputByte := []byte("user Controlled input")
2322
fasthttp.DialDualStack(userInput) // $ SsrfSink=userInput
2423
fasthttp.Dial(userInput) // $ SsrfSink=userInput
2524
fasthttp.DialTimeout(userInput, 5) // $ SsrfSink=userInput
2625
fasthttp.DialDualStackTimeout(userInput, 5) // $ SsrfSink=userInput
2726

2827
res := &fasthttp.Response{}
2928
req := &fasthttp.Request{}
30-
req.SetHost(source())
29+
req.SetHost(source().(string))
3130
sink(req) // $ hasTaintFlow="req"
32-
req.SetHostBytes(userInputByte)
31+
req.SetHostBytes(source().([]byte))
3332
sink(req) // $ hasTaintFlow="req"
34-
req.SetRequestURI(userInput)
33+
req.SetRequestURI(source().(string))
3534
sink(req) // $ hasTaintFlow="req"
36-
req.SetRequestURIBytes(userInputByte)
35+
req.SetRequestURIBytes(source().([]byte))
3736
sink(req) // $ hasTaintFlow="req"
3837

3938
uri := fasthttp.AcquireURI()
4039
userInput = "UserControlled.com:80"
41-
userInputByte = []byte("UserControlled.com:80")
42-
uri.SetHost(source())
40+
uri.SetHost(source().(string))
4341
sink(uri) // $ hasTaintFlow="uri"
44-
uri.SetHostBytes(source())
42+
uri.SetHostBytes(source().([]byte))
4543
sink(uri) // $ hasTaintFlow="uri"
4644
userInput = "http://UserControlled.com"
47-
userInputByte = []byte("http://UserControlled.com")
48-
uri.Update(source())
45+
uri.Update(source().(string))
4946
sink(uri) // $ hasTaintFlow="uri"
50-
uri.UpdateBytes(source())
47+
uri.UpdateBytes(source().([]byte))
5148
sink(uri) // $ hasTaintFlow="uri"
52-
uri.Parse(source(), source())
49+
uri.Parse(source().([]byte), source().([]byte))
5350
sink(uri) // $ hasTaintFlow="uri"
5451
req.SetURI(uri)
5552

0 commit comments

Comments
 (0)