Skip to content

Commit a78e04e

Browse files
authored
Merge pull request #15795 from atorralba/atorralba/go/macaron-sources
Go: Add Macaron sources
2 parents 05aaf2b + 7286f56 commit a78e04e

File tree

6 files changed

+97
-83
lines changed

6 files changed

+97
-83
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Added dataflow sources for the package `gopkg.in/macaron.v1`.

go/ql/lib/ext/gopkg.in.macaron.model.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: sourceModel
5+
data:
6+
- ["gopkg.in/macaron", "Context", True, "AllParams", "", "", "ReturnValue", "remote", "manual"]
7+
- ["gopkg.in/macaron", "Context", True, "GetCookie", "", "", "ReturnValue", "remote", "manual"]
8+
- ["gopkg.in/macaron", "Context", True, "GetSecureCookie", "", "", "ReturnValue[0]", "remote", "manual"]
9+
- ["gopkg.in/macaron", "Context", True, "GetSuperSecureCookie", "", "", "ReturnValue[0]", "remote", "manual"]
10+
- ["gopkg.in/macaron", "Context", True, "GetFile", "", "", "ReturnValue[0]", "remote", "manual"]
11+
- ["gopkg.in/macaron", "Context", True, "Params", "", "", "ReturnValue", "remote", "manual"]
12+
- ["gopkg.in/macaron", "Context", True, "ParamsEscape", "", "", "ReturnValue", "remote", "manual"]
13+
- ["gopkg.in/macaron", "Context", True, "Query", "", "", "ReturnValue", "remote", "manual"]
14+
- ["gopkg.in/macaron", "Context", True, "QueryEscape", "", "", "ReturnValue", "remote", "manual"]
15+
- ["gopkg.in/macaron", "Context", True, "QueryStrings", "", "", "ReturnValue", "remote", "manual"]
16+
- ["gopkg.in/macaron", "RequestBody", True, "Bytes", "", "", "ReturnValue[0]", "remote", "manual"]
17+
- ["gopkg.in/macaron", "RequestBody", True, "String", "", "", "ReturnValue[0]", "remote", "manual"]
218
- addsTo:
319
pack: codeql/go-all
420
extensible: summaryModel
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
testFailures
2+
failures
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import go
2+
import TestUtilities.InlineExpectationsTest
3+
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>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
//go:generate depstubber -vendor gopkg.in/macaron.v1 Context,RequestBody
4+
5+
import (
6+
"gopkg.in/macaron.v1"
7+
)
8+
9+
func sources(ctx *macaron.Context, body *macaron.RequestBody) {
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
22+
}

go/ql/test/library-tests/semmle/go/frameworks/Macaron/vendor/gopkg.in/macaron.v1/stub.go

Lines changed: 35 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)