Skip to content

Commit 7286f56

Browse files
committed
Change tests to inline expectations
1 parent fc12537 commit 7286f56

File tree

3 files changed

+30
-25
lines changed

3 files changed

+30
-25
lines changed
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
| sources.go:10:6:10:20 | call to AllParams |
2-
| sources.go:11:6:11:22 | call to GetCookie |
3-
| sources.go:12:2:12:31 | ... = ...[0] |
4-
| sources.go:13:2:13:40 | ... = ...[0] |
5-
| sources.go:14:2:14:26 | ... = ...[0] |
6-
| sources.go:15:6:15:19 | call to Params |
7-
| sources.go:16:6:16:25 | call to ParamsEscape |
8-
| sources.go:17:6:17:18 | call to Query |
9-
| sources.go:18:6:18:24 | call to QueryEscape |
10-
| sources.go:19:6:19:25 | call to QueryStrings |
11-
| sources.go:20:2:20:20 | ... = ...[0] |
12-
| sources.go:21:2:21:21 | ... = ...[0] |
1+
testFailures
2+
failures
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
import go
2+
import TestUtilities.InlineExpectationsTest
23

3-
select any(UntrustedFlowSource ufs)
4+
module UntrustedFlowSourceTest implements TestSig {
5+
string getARelevantTag() { result = "UntrustedFlowSource" }
6+
7+
predicate hasActualResult(Location location, string element, string tag, string value) {
8+
exists(UntrustedFlowSource src |
9+
src.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
10+
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
11+
element = src.toString() and
12+
value = "" and
13+
tag = "UntrustedFlowSource"
14+
)
15+
}
16+
}
17+
18+
import MakeTest<UntrustedFlowSourceTest>

go/ql/test/library-tests/semmle/go/frameworks/Macaron/sources.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import (
77
)
88

99
func sources(ctx *macaron.Context, body *macaron.RequestBody) {
10-
_ = ctx.AllParams()
11-
_ = ctx.GetCookie("")
12-
_, _ = ctx.GetSecureCookie("")
13-
_, _ = ctx.GetSuperSecureCookie("", "")
14-
_, _, _ = ctx.GetFile("")
15-
_ = ctx.Params("")
16-
_ = ctx.ParamsEscape("")
17-
_ = ctx.Query("")
18-
_ = ctx.QueryEscape("")
19-
_ = ctx.QueryStrings("")
20-
_, _ = body.Bytes()
21-
_, _ = body.String()
10+
_ = ctx.AllParams() // $UntrustedFlowSource
11+
_ = ctx.GetCookie("") // $UntrustedFlowSource
12+
_, _ = ctx.GetSecureCookie("") // $UntrustedFlowSource
13+
_, _ = ctx.GetSuperSecureCookie("", "") // $UntrustedFlowSource
14+
_, _, _ = ctx.GetFile("") // $UntrustedFlowSource
15+
_ = ctx.Params("") // $UntrustedFlowSource
16+
_ = ctx.ParamsEscape("") // $UntrustedFlowSource
17+
_ = ctx.Query("") // $UntrustedFlowSource
18+
_ = ctx.QueryEscape("") // $UntrustedFlowSource
19+
_ = ctx.QueryStrings("") // $UntrustedFlowSource
20+
_, _ = body.Bytes() // $UntrustedFlowSource
21+
_, _ = body.String() // $UntrustedFlowSource
2222
}

0 commit comments

Comments
 (0)