Skip to content

Commit 7e37c2b

Browse files
authored
Merge pull request #485 from owen-mc/add-new-location-for-beego
Add new module path for beego and xmlpath
2 parents 9e45b08 + ff317e6 commit 7e37c2b

File tree

6 files changed

+59
-25
lines changed

6 files changed

+59
-25
lines changed

ql/src/semmle/go/frameworks/Beego.qll

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
/**
22
* Provides classes for working with untrusted flow sources, sinks and taint propagators
3-
* from the `github.com/astaxie/beego` package.
3+
* from the `github.com/beego/beego` package.
44
*/
55

66
import go
77
import semmle.go.security.Xss
88
private import semmle.go.security.SafeUrlFlowCustomizations
99

1010
module Beego {
11-
/** Gets the package name `github.com/astaxie/beego`. */
11+
/** Gets the module path `github.com/astaxie/beego` or `github.com/beego/beego`. */
1212
bindingset[result]
13-
string packagePath() { result = package("github.com/astaxie/beego", "") }
13+
string modulePath() { result = ["github.com/astaxie/beego", "github.com/beego/beego"] }
1414

15-
/** Gets the context subpackage name `github.com/astaxie/beego/context`. */
15+
/** Gets the path for the root package of beego. */
1616
bindingset[result]
17-
string contextPackagePath() { result = package("github.com/astaxie/beego", "context") }
17+
string packagePath() { result = package(modulePath(), "") }
1818

19-
/** Gets the logs subpackage name `github.com/astaxie/beego/logs`. */
19+
/** Gets the path for the context package of beego. */
2020
bindingset[result]
21-
string logsPackagePath() { result = package("github.com/astaxie/beego", "logs") }
21+
string contextPackagePath() { result = package(modulePath(), "context") }
2222

23-
/** Gets the utils subpackage name `github.com/astaxie/beego/utils`. */
23+
/** Gets the path for the logs package of beego. */
2424
bindingset[result]
25-
string utilsPackagePath() { result = package("github.com/astaxie/beego", "utils") }
25+
string logsPackagePath() { result = package(modulePath(), "logs") }
26+
27+
/** Gets the path for the utils package of beego. */
28+
bindingset[result]
29+
string utilsPackagePath() { result = package(modulePath(), "utils") }
2630

2731
/**
2832
* `BeegoInput` sources of untrusted data.

ql/src/semmle/go/frameworks/GoRestfulHttp.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import go
22

33
/**
4-
* Provides models of the go-restful library (`https://github.com/emicklei/go-restful`).
4+
* Provides models of the [go-restful library](https://github.com/emicklei/go-restful).
55
*/
66
private module GoRestfulHttp {
77
/** Gets the package name `github.com/emicklei/go-restful`. */

ql/src/semmle/go/frameworks/SQL.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ module SQL {
206206
private class SqlxSink extends SQL::QueryString::Range {
207207
SqlxSink() {
208208
exists(Method meth, string name, int n |
209-
meth.hasQualifiedName(package("github.com/jmoiron", "sqlx"), ["DB", "Tx"], name) and
209+
meth.hasQualifiedName(package("github.com/jmoiron/sqlx", ""), ["DB", "Tx"], name) and
210210
this = meth.getACall().getArgument(n)
211211
|
212212
name = ["Select", "Get"] and n = 1

ql/src/semmle/go/frameworks/WebSocket.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,5 +319,5 @@ module NhooyrWebSocket {
319319
module GobwasWs {
320320
/** Gets the package name `github.com/gobwas/ws`. */
321321
bindingset[result]
322-
string packagePath() { result = package("github.com/gobwas", "ws") }
322+
string packagePath() { result = package("github.com/gobwas/ws", "") }
323323
}

ql/src/semmle/go/frameworks/XPath.qll

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ module XPath {
2828
*/
2929
abstract class Range extends DataFlow::Node { }
3030

31-
/** An XPath expression string used in an API function of the https://github.com/antchfx/xpath package. */
31+
/**
32+
* An XPath expression string used in an API function of the
33+
* [XPath](https://github.com/antchfx/xpath) package.
34+
*/
3235
private class AntchfxXpathXPathExpressionString extends Range {
3336
AntchfxXpathXPathExpressionString() {
3437
exists(Function f, string name | name.matches("Compile%") |
@@ -48,7 +51,10 @@ module XPath {
4851
}
4952
}
5053

51-
/** An XPath expression string used in an API function of the https://github.com/antchfx/htmlquery package. */
54+
/**
55+
* An XPath expression string used in an API function of the
56+
* [htmlquery](https://github.com/antchfx/htmlquery) package.
57+
*/
5258
private class AntchfxHtmlqueryXPathExpressionString extends Range {
5359
AntchfxHtmlqueryXPathExpressionString() {
5460
exists(Function f, string name | name.matches("Find%") |
@@ -63,7 +69,10 @@ module XPath {
6369
}
6470
}
6571

66-
/** An XPath expression string used in an API function of the https://github.com/antchfx/xmlquery package. */
72+
/**
73+
* An XPath expression string used in an API function of the
74+
* [xmlquery](https://github.com/antchfx/xmlquery) package.
75+
*/
6776
private class AntchfxXmlqueryXPathExpressionString extends Range {
6877
AntchfxXmlqueryXPathExpressionString() {
6978
exists(Function f, string name | name.matches("Find%") |
@@ -83,7 +92,10 @@ module XPath {
8392
}
8493
}
8594

86-
/** An XPath expression string used in an API function of the https://github.com/antchfx/jsonquery package. */
95+
/**
96+
* An XPath expression string used in an API function of the
97+
* [jsonquery](https://github.com/antchfx/jsonquery) package.
98+
*/
8799
private class AntchfxJsonqueryXPathExpressionString extends Range {
88100
AntchfxJsonqueryXPathExpressionString() {
89101
exists(Function f, string name | name.matches("Find%") |
@@ -98,22 +110,28 @@ module XPath {
98110
}
99111
}
100112

101-
/** An XPath expression string used in an API function of the https://github.com/go-xmlpath/xmlpath package. */
113+
/**
114+
* An XPath expression string used in an API function of the
115+
* [xmlpath](https://github.com/go-xmlpath/xmlpath) package.
116+
*/
102117
private class GoXmlpathXmlpathXPathExpressionString extends Range {
103118
GoXmlpathXmlpathXPathExpressionString() {
104119
exists(Function f, string name | name.matches("Compile%") |
105-
f.hasQualifiedName(package("github.com/go-xmlpath/xmlpath", ""), name) and
120+
f.hasQualifiedName(XmlPath::packagePath(), name) and
106121
this = f.getACall().getArgument(0)
107122
)
108123
or
109124
exists(Function f, string name | name.matches("MustCompile%") |
110-
f.hasQualifiedName(package("github.com/go-xmlpath/xmlpath", ""), name) and
125+
f.hasQualifiedName(XmlPath::packagePath(), name) and
111126
this = f.getACall().getArgument(0)
112127
)
113128
}
114129
}
115130

116-
/** An XPath expression string used in an API function of the https://github.com/ChrisTrenkamp/goxpath package. */
131+
/**
132+
* An XPath expression string used in an API function of the
133+
* [goxpath](https://github.com/ChrisTrenkamp/goxpath) package.
134+
*/
117135
private class ChrisTrenkampGoxpathXPathExpressionString extends Range {
118136
ChrisTrenkampGoxpathXPathExpressionString() {
119137
exists(Function f, string name | name.matches("Parse%") |
@@ -128,7 +146,10 @@ module XPath {
128146
}
129147
}
130148

131-
/** An XPath expression string used in an API function of the https://github.com/santhosh-tekuri/xpathparser package. */
149+
/**
150+
* An XPath expression string used in an API function of the
151+
* [xpathparser](https://github.com/santhosh-tekuri/xpathparser) package.
152+
*/
132153
private class SanthoshTekuriXpathparserXPathExpressionString extends Range {
133154
SanthoshTekuriXpathparserXPathExpressionString() {
134155
exists(Function f, string name | name.matches("Parse%") |
@@ -143,7 +164,10 @@ module XPath {
143164
}
144165
}
145166

146-
/** An XPath expression string used in an API function of the https://github.com/jbowtie/gokogiri package. */
167+
/**
168+
* An XPath expression string used in an API function of the
169+
* [gokogiri]https://github.com/jbowtie/gokogiri) package.
170+
*/
147171
private class JbowtieGokogiriXPathExpressionString extends Range {
148172
JbowtieGokogiriXPathExpressionString() {
149173
exists(Function f, string name | name.matches("Compile%") |
@@ -164,3 +188,11 @@ module XPath {
164188
}
165189
}
166190
}
191+
192+
module XmlPath {
193+
/** Gets the package name `github.com/go-xmlpath/xmlpath` or `gopkg.in/xmlpath`. */
194+
bindingset[result]
195+
string packagePath() {
196+
result = package(["github.com/go-xmlpath/xmlpath", "gopkg.in/xmlpath"], "")
197+
}
198+
}

ql/src/semmle/go/security/ExternalAPIs.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ private import Logrus
1717
abstract class SafeExternalAPIFunction extends Function { }
1818

1919
private predicate isDefaultSafePackage(Package package) {
20-
package.getPath() in [
21-
"time", "unicode/utf8", package("http://gopkg.in/go-playground/validator", "")
22-
]
20+
package.getPath() in ["time", "unicode/utf8", package("gopkg.in/go-playground/validator", "")]
2321
}
2422

2523
/** The default set of "safe" external APIs. */

0 commit comments

Comments
 (0)