Skip to content

Commit 0129167

Browse files
committed
Convert Beego's MapGet method to MaD
1 parent b86f0cf commit 0129167

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

go/ql/lib/ext/github.com.astaxie.beego.model.yml

+2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ extensions:
66
- ["github.com/astaxie/beego", "", False, "HTML2str", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
77
- ["github.com/astaxie/beego", "", False, "Htmlquote", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
88
- ["github.com/astaxie/beego", "", False, "Htmlunquote", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
9+
- ["github.com/astaxie/beego", "", False, "MapGet", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
910
- ["github.com/astaxie/beego", "", False, "ParseForm", "", "", "Argument[0]", "Argument[1]", "taint", "manual"]
1011
- ["github.com/astaxie/beego", "", False, "Str2html", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
1112
- ["github.com/astaxie/beego", "", False, "Substr", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
1213
- ["github.com/beego/beego/server/web", "", False, "HTML2str", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
1314
- ["github.com/beego/beego/server/web", "", False, "Htmlquote", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
1415
- ["github.com/beego/beego/server/web", "", False, "Htmlunquote", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
16+
- ["github.com/beego/beego/server/web", "", False, "MapGet", "", "", "Argument[0]", "ReturnValue[0]", "taint", "manual"]
1517
- ["github.com/beego/beego/server/web", "", False, "ParseForm", "", "", "Argument[0]", "Argument[1]", "taint", "manual"]
1618
- ["github.com/beego/beego/server/web", "", False, "Str2html", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]
1719
- ["github.com/beego/beego/server/web", "", False, "Substr", "", "", "Argument[0]", "ReturnValue", "taint", "manual"]

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

-9
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,6 @@ module Beego {
270270
override DataFlow::Node getAMessageComponent() { result = this.getAnArgument() }
271271
}
272272

273-
private class TopLevelTaintPropagators extends TaintTracking::FunctionModel {
274-
TopLevelTaintPropagators() { this.hasQualifiedName(packagePath(), "MapGet") }
275-
276-
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
277-
input.isParameter(0) and
278-
output.isResult(0)
279-
}
280-
}
281-
282273
private class HtmlQuoteSanitizer extends SharedXss::Sanitizer {
283274
HtmlQuoteSanitizer() {
284275
exists(DataFlow::CallNode c | c.getTarget().hasQualifiedName(packagePath(), "Htmlquote") |

go/ql/test/library-tests/semmle/go/frameworks/Beego/ReflectedXss.expected

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
edges
22
| file://:0:0:0:0 | parameter 0 of HTML2str | file://:0:0:0:0 | [summary] to write: return (return[0]) in HTML2str |
33
| file://:0:0:0:0 | parameter 0 of Htmlunquote | file://:0:0:0:0 | [summary] to write: return (return[0]) in Htmlunquote |
4+
| file://:0:0:0:0 | parameter 0 of MapGet | file://:0:0:0:0 | [summary] to write: return (return[0]) in MapGet |
45
| file://:0:0:0:0 | parameter 0 of ParseForm | file://:0:0:0:0 | [summary] to write: argument 1 in ParseForm |
56
| file://:0:0:0:0 | parameter 0 of ReadAll | file://:0:0:0:0 | [summary] to write: return (return[0]) in ReadAll |
67
| file://:0:0:0:0 | parameter 0 of SliceChunk | file://:0:0:0:0 | [summary] to write: return (return[0]) in SliceChunk |
@@ -42,7 +43,7 @@ edges
4243
| test.go:137:23:137:42 | call to Data | test.go:137:23:137:62 | type assertion |
4344
| test.go:193:15:193:26 | call to Data | test.go:194:36:194:53 | type assertion |
4445
| test.go:193:15:193:26 | call to Data | test.go:195:39:195:56 | type assertion |
45-
| test.go:193:15:193:26 | call to Data | test.go:197:14:197:28 | type assertion |
46+
| test.go:193:15:193:26 | call to Data | test.go:196:28:196:56 | type assertion |
4647
| test.go:193:15:193:26 | call to Data | test.go:198:36:198:53 | type assertion |
4748
| test.go:193:15:193:26 | call to Data | test.go:199:34:199:51 | type assertion |
4849
| test.go:194:21:194:54 | call to HTML2str | test.go:194:14:194:55 | type conversion |
@@ -51,6 +52,9 @@ edges
5152
| test.go:195:21:195:57 | call to Htmlunquote | test.go:195:14:195:58 | type conversion |
5253
| test.go:195:39:195:56 | type assertion | file://:0:0:0:0 | parameter 0 of Htmlunquote |
5354
| test.go:195:39:195:56 | type assertion | test.go:195:21:195:57 | call to Htmlunquote |
55+
| test.go:196:2:196:68 | ... := ...[0] | test.go:197:14:197:28 | type assertion |
56+
| test.go:196:28:196:56 | type assertion | file://:0:0:0:0 | parameter 0 of MapGet |
57+
| test.go:196:28:196:56 | type assertion | test.go:196:2:196:68 | ... := ...[0] |
5458
| test.go:198:21:198:54 | call to Str2html | test.go:198:14:198:55 | type conversion |
5559
| test.go:198:36:198:53 | type assertion | file://:0:0:0:0 | parameter 0 of Str2html |
5660
| test.go:198:36:198:53 | type assertion | test.go:198:21:198:54 | call to Str2html |
@@ -144,6 +148,7 @@ nodes
144148
| file://:0:0:0:0 | [summary] to write: return (return[0]) in HTML2str | semmle.label | [summary] to write: return (return[0]) in HTML2str |
145149
| file://:0:0:0:0 | [summary] to write: return (return[0]) in Htmlunquote | semmle.label | [summary] to write: return (return[0]) in Htmlunquote |
146150
| file://:0:0:0:0 | [summary] to write: return (return[0]) in Items | semmle.label | [summary] to write: return (return[0]) in Items |
151+
| file://:0:0:0:0 | [summary] to write: return (return[0]) in MapGet | semmle.label | [summary] to write: return (return[0]) in MapGet |
147152
| file://:0:0:0:0 | [summary] to write: return (return[0]) in ReadAll | semmle.label | [summary] to write: return (return[0]) in ReadAll |
148153
| file://:0:0:0:0 | [summary] to write: return (return[0]) in SliceChunk | semmle.label | [summary] to write: return (return[0]) in SliceChunk |
149154
| file://:0:0:0:0 | [summary] to write: return (return[0]) in SliceDiff | semmle.label | [summary] to write: return (return[0]) in SliceDiff |
@@ -162,6 +167,7 @@ nodes
162167
| file://:0:0:0:0 | [summary] to write: return (return[0]) in Substr | semmle.label | [summary] to write: return (return[0]) in Substr |
163168
| file://:0:0:0:0 | parameter 0 of HTML2str | semmle.label | parameter 0 of HTML2str |
164169
| file://:0:0:0:0 | parameter 0 of Htmlunquote | semmle.label | parameter 0 of Htmlunquote |
170+
| file://:0:0:0:0 | parameter 0 of MapGet | semmle.label | parameter 0 of MapGet |
165171
| file://:0:0:0:0 | parameter 0 of ParseForm | semmle.label | parameter 0 of ParseForm |
166172
| file://:0:0:0:0 | parameter 0 of ReadAll | semmle.label | parameter 0 of ReadAll |
167173
| file://:0:0:0:0 | parameter 0 of SliceChunk | semmle.label | parameter 0 of SliceChunk |
@@ -225,6 +231,8 @@ nodes
225231
| test.go:195:14:195:58 | type conversion | semmle.label | type conversion |
226232
| test.go:195:21:195:57 | call to Htmlunquote | semmle.label | call to Htmlunquote |
227233
| test.go:195:39:195:56 | type assertion | semmle.label | type assertion |
234+
| test.go:196:2:196:68 | ... := ...[0] | semmle.label | ... := ...[0] |
235+
| test.go:196:28:196:56 | type assertion | semmle.label | type assertion |
228236
| test.go:197:14:197:28 | type assertion | semmle.label | type assertion |
229237
| test.go:198:14:198:55 | type conversion | semmle.label | type conversion |
230238
| test.go:198:21:198:54 | call to Str2html | semmle.label | call to Str2html |
@@ -312,6 +320,7 @@ nodes
312320
subpaths
313321
| test.go:194:36:194:53 | type assertion | file://:0:0:0:0 | parameter 0 of HTML2str | file://:0:0:0:0 | [summary] to write: return (return[0]) in HTML2str | test.go:194:21:194:54 | call to HTML2str |
314322
| test.go:195:39:195:56 | type assertion | file://:0:0:0:0 | parameter 0 of Htmlunquote | file://:0:0:0:0 | [summary] to write: return (return[0]) in Htmlunquote | test.go:195:21:195:57 | call to Htmlunquote |
323+
| test.go:196:28:196:56 | type assertion | file://:0:0:0:0 | parameter 0 of MapGet | file://:0:0:0:0 | [summary] to write: return (return[0]) in MapGet | test.go:196:2:196:68 | ... := ...[0] |
315324
| test.go:198:36:198:53 | type assertion | file://:0:0:0:0 | parameter 0 of Str2html | file://:0:0:0:0 | [summary] to write: return (return[0]) in Str2html | test.go:198:21:198:54 | call to Str2html |
316325
| test.go:199:34:199:51 | type assertion | file://:0:0:0:0 | parameter 0 of Substr | file://:0:0:0:0 | [summary] to write: return (return[0]) in Substr | test.go:199:21:199:58 | call to Substr |
317326
| test.go:202:18:202:33 | selection of Form | file://:0:0:0:0 | parameter 0 of ParseForm | file://:0:0:0:0 | [summary] to write: argument 1 in ParseForm | test.go:201:6:201:6 | definition of s |

0 commit comments

Comments
 (0)