Skip to content

Commit d071b46

Browse files
committed
Add failing tests for MaD with pointer content
1 parent f737054 commit d071b46

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
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/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)