Skip to content

Commit d28c420

Browse files
authored
Merge pull request github#13453 from owen-mc/go/test-mad-pointer-content
Go: Add failing tests for MaD with pointer content
2 parents 7387653 + 74b39b4 commit d28c420

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlow/completetest.ext.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ extensions:
2222
- ["github.com/nonexistent/test", "", False, "GetMapKey", "", "", "Argument[0].MapKey", "ReturnValue", "value", "manual"]
2323
- ["github.com/nonexistent/test", "", False, "SetElement", "", "", "Argument[0]", "ReturnValue.Element", "value", "manual"]
2424
- ["github.com/nonexistent/test", "C", False, "Get", "", "", "Argument[-1].Field[github.com/nonexistent/test.C.F]", "ReturnValue", "value", "manual"]
25+
- ["github.com/nonexistent/test", "C", False, "GetThroughPointer", "", "", "Argument[-1].Field[github.com/nonexistent/test.C.F]", "ReturnValue", "value", "manual"]
2526
- ["github.com/nonexistent/test", "C", False, "Set", "", "", "Argument[0]", "Argument[-1].Field[github.com/nonexistent/test.C.F]", "value", "manual"]
27+
- ["github.com/nonexistent/test", "C", False, "SetThroughPointer", "", "", "Argument[0]", "Argument[-1].Field[github.com/nonexistent/test.C.F]", "value", "manual"]
2628

2729
- addsTo:
2830
pack: codeql/go-all

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlow/sinks.expected

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ invalidModelRow
2626
| test.go:133:10:133:17 | call to Get | qltest |
2727
| test.go:137:10:137:17 | call to Get | qltest |
2828
| test.go:142:10:142:17 | call to Get | qltest |
29-
| test.go:148:17:148:20 | arg1 | qltest |
30-
| test.go:148:23:148:26 | arg2 | qltest |
31-
| test.go:148:29:148:32 | arg3 | qltest |
29+
| test.go:146:10:146:14 | selection of F | qltest |
30+
| test.go:149:10:149:32 | call to GetThroughPointer | qltest |
31+
| test.go:153:10:153:32 | call to GetThroughPointer | qltest |
32+
| test.go:158:10:158:32 | call to GetThroughPointer | qltest |
33+
| test.go:164:17:164:20 | arg1 | qltest |
34+
| test.go:164:23:164:26 | arg2 | qltest |
35+
| test.go:164:29:164:32 | arg3 | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlow/srcs.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ invalidModelRow
1717
| test.go:132:15:132:22 | call to Src1 | qltest |
1818
| test.go:136:9:136:16 | call to Src1 | qltest |
1919
| test.go:140:9:140:16 | call to Src1 | qltest |
20+
| test.go:145:24:145:31 | call to Src1 | qltest |
21+
| test.go:148:17:148:24 | call to Src1 | qltest |
22+
| test.go:152:24:152:31 | call to Src1 | qltest |
23+
| test.go:156:24:156:31 | call to Src1 | qltest |

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlow/test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,22 @@ func simpleflow() {
141141
c4.Set("")
142142
b.Sink1(c4.Get()) // $ SPURIOUS: hasTaintFlow="call to Get" // because we currently don't clear content
143143

144+
cp1 := &test.C{""}
145+
cp1.SetThroughPointer(a.Src1().(string))
146+
b.Sink1(cp1.F) // $ MISSING: hasTaintFlow="selection of F"
147+
148+
cp2 := &test.C{a.Src1().(string)}
149+
b.Sink1(cp2.GetThroughPointer()) // $ MISSING: hasTaintFlow="call to GetThroughPointer"
150+
151+
cp3 := &test.C{""}
152+
cp3.SetThroughPointer(a.Src1().(string))
153+
b.Sink1(cp3.GetThroughPointer()) // $ hasTaintFlow="call to GetThroughPointer"
154+
155+
cp4 := &test.C{""}
156+
cp4.SetThroughPointer(a.Src1().(string))
157+
cp4.SetThroughPointer("")
158+
b.Sink1(cp4.GetThroughPointer()) // $ SPURIOUS: hasTaintFlow="call to GetThroughPointer" // because we currently don't clear content
159+
144160
arg1 := src
145161
arg2 := src
146162
arg3 := src

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlow/vendor/github.com/nonexistent/test/stub.go

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

0 commit comments

Comments
 (0)