Skip to content

Commit 5490f3a

Browse files
committed
Add tests for interface embedding interface
1 parent 279800e commit 5490f3a

22 files changed

+217
-15
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
invalidModelRow
2+
paths
3+
| test.go:8:7:8:16 | call to Source | test.go:10:9:10:9 | y |
4+
| test.go:14:7:14:16 | call to Source | test.go:16:9:16:9 | y |
5+
| test.go:20:7:20:16 | call to Source | test.go:22:9:22:9 | y |
6+
| test.go:26:7:26:16 | call to Source | test.go:28:9:28:9 | y |
7+
| test.go:32:7:32:16 | call to Source | test.go:34:9:34:9 | y |
8+
| test.go:38:7:38:16 | call to Source | test.go:40:9:40:9 | y |
9+
| test.go:44:7:44:16 | call to Source | test.go:46:9:46:9 | y |
10+
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
11+
| test.go:56:7:56:16 | call to Source | test.go:58:9:58:9 | y |
12+
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
13+
| test.go:68:7:68:16 | call to Source | test.go:70:9:70:9 | y |
14+
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
15+
| test.go:80:7:80:16 | call to Source | test.go:82:9:82:9 | y |
16+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
17+
sources
18+
| test.go:8:7:8:16 | call to Source |
19+
| test.go:14:7:14:16 | call to Source |
20+
| test.go:20:7:20:16 | call to Source |
21+
| test.go:26:7:26:16 | call to Source |
22+
| test.go:32:7:32:16 | call to Source |
23+
| test.go:38:7:38:16 | call to Source |
24+
| test.go:44:7:44:16 | call to Source |
25+
| test.go:50:7:50:16 | call to Source |
26+
| test.go:56:7:56:16 | call to Source |
27+
| test.go:62:7:62:16 | call to Source |
28+
| test.go:68:7:68:16 | call to Source |
29+
| test.go:74:7:74:16 | call to Source |
30+
| test.go:80:7:80:16 | call to Source |
31+
| test.go:86:7:86:16 | call to Source |
32+
sinks
33+
| test.go:10:9:10:9 | y |
34+
| test.go:16:9:16:9 | y |
35+
| test.go:22:9:22:9 | y |
36+
| test.go:28:9:28:9 | y |
37+
| test.go:34:9:34:9 | y |
38+
| test.go:40:9:40:9 | y |
39+
| test.go:46:9:46:9 | y |
40+
| test.go:52:9:52:9 | y |
41+
| test.go:58:9:58:9 | y |
42+
| test.go:64:9:64:9 | y |
43+
| test.go:70:9:70:9 | y |
44+
| test.go:76:9:76:9 | y |
45+
| test.go:82:9:82:9 | y |
46+
| test.go:88:9:88:9 | y |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: sourceModel
5+
data:
6+
- ["github.com/nonexistent/test", "IEmbedI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
7+
- addsTo:
8+
pack: codeql/go-all
9+
extensible: summaryModel
10+
data:
11+
- ["github.com/nonexistent/test", "IEmbedI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
12+
- addsTo:
13+
pack: codeql/go-all
14+
extensible: sinkModel
15+
data:
16+
- ["github.com/nonexistent/test", "IEmbedI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import go
2+
import semmle.go.dataflow.ExternalFlow
3+
import ModelValidation
4+
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
5+
6+
module Config implements DataFlow::ConfigSig {
7+
predicate isSource(DataFlow::Node source) { sources(source) }
8+
9+
predicate isSink(DataFlow::Node sink) { sinks(sink) }
10+
}
11+
12+
module Flow = DataFlow::Global<Config>;
13+
14+
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
15+
16+
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
17+
18+
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
invalidModelRow
2+
paths
3+
| test.go:14:7:14:16 | call to Source | test.go:16:9:16:9 | y |
4+
| test.go:26:7:26:16 | call to Source | test.go:28:9:28:9 | y |
5+
| test.go:38:7:38:16 | call to Source | test.go:40:9:40:9 | y |
6+
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
7+
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
8+
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
9+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
10+
sources
11+
| test.go:14:7:14:16 | call to Source |
12+
| test.go:26:7:26:16 | call to Source |
13+
| test.go:38:7:38:16 | call to Source |
14+
| test.go:50:7:50:16 | call to Source |
15+
| test.go:62:7:62:16 | call to Source |
16+
| test.go:74:7:74:16 | call to Source |
17+
| test.go:86:7:86:16 | call to Source |
18+
sinks
19+
| test.go:16:9:16:9 | y |
20+
| test.go:28:9:28:9 | y |
21+
| test.go:40:9:40:9 | y |
22+
| test.go:52:9:52:9 | y |
23+
| test.go:64:9:64:9 | y |
24+
| test.go:76:9:76:9 | y |
25+
| test.go:88:9:88:9 | y |
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/go-all
4+
extensible: sourceModel
5+
data:
6+
- ["github.com/nonexistent/test", "IEmbedI2", True, "Source", "", "", "ReturnValue", "remote", "manual"]
7+
- addsTo:
8+
pack: codeql/go-all
9+
extensible: summaryModel
10+
data:
11+
- ["github.com/nonexistent/test", "IEmbedI2", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
12+
- addsTo:
13+
pack: codeql/go-all
14+
extensible: sinkModel
15+
data:
16+
- ["github.com/nonexistent/test", "IEmbedI2", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import go
2+
import semmle.go.dataflow.ExternalFlow
3+
import ModelValidation
4+
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
5+
6+
module Config implements DataFlow::ConfigSig {
7+
predicate isSource(DataFlow::Node source) { sources(source) }
8+
9+
predicate isSink(DataFlow::Node sink) { sinks(sink) }
10+
}
11+
12+
module Flow = DataFlow::Global<Config>;
13+
14+
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
15+
16+
query predicate sources(DataFlow::Node source) { source instanceof RemoteFlowSource }
17+
18+
query predicate sinks(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/mad_SEmbedI1_subtypes_true.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ paths
1212
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
1313
| test.go:68:7:68:16 | call to Source | test.go:70:9:70:9 | y |
1414
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
15+
| test.go:80:7:80:16 | call to Source | test.go:82:9:82:9 | y |
16+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
1517
sources
1618
| test.go:8:7:8:16 | call to Source |
1719
| test.go:14:7:14:16 | call to Source |
@@ -25,6 +27,8 @@ sources
2527
| test.go:62:7:62:16 | call to Source |
2628
| test.go:68:7:68:16 | call to Source |
2729
| test.go:74:7:74:16 | call to Source |
30+
| test.go:80:7:80:16 | call to Source |
31+
| test.go:86:7:86:16 | call to Source |
2832
sinks
2933
| test.go:10:9:10:9 | y |
3034
| test.go:16:9:16:9 | y |
@@ -38,3 +42,5 @@ sinks
3842
| test.go:64:9:64:9 | y |
3943
| test.go:70:9:70:9 | y |
4044
| test.go:76:9:76:9 | y |
45+
| test.go:82:9:82:9 | y |
46+
| test.go:88:9:88:9 | y |

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/mad_SEmbedI2_subtypes_true.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ paths
66
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
77
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
88
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
9+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
910
sources
1011
| test.go:14:7:14:16 | call to Source |
1112
| test.go:26:7:26:16 | call to Source |
1213
| test.go:38:7:38:16 | call to Source |
1314
| test.go:50:7:50:16 | call to Source |
1415
| test.go:62:7:62:16 | call to Source |
1516
| test.go:74:7:74:16 | call to Source |
17+
| test.go:86:7:86:16 | call to Source |
1618
sinks
1719
| test.go:16:9:16:9 | y |
1820
| test.go:28:9:28:9 | y |
1921
| test.go:40:9:40:9 | y |
2022
| test.go:52:9:52:9 | y |
2123
| test.go:64:9:64:9 | y |
2224
| test.go:76:9:76:9 | y |
25+
| test.go:88:9:88:9 | y |

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/mad_SImplEmbedI1_subtypes_true.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ paths
1212
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
1313
| test.go:68:7:68:16 | call to Source | test.go:70:9:70:9 | y |
1414
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
15+
| test.go:80:7:80:16 | call to Source | test.go:82:9:82:9 | y |
16+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
1517
sources
1618
| test.go:8:7:8:16 | call to Source |
1719
| test.go:14:7:14:16 | call to Source |
@@ -25,6 +27,8 @@ sources
2527
| test.go:62:7:62:16 | call to Source |
2628
| test.go:68:7:68:16 | call to Source |
2729
| test.go:74:7:74:16 | call to Source |
30+
| test.go:80:7:80:16 | call to Source |
31+
| test.go:86:7:86:16 | call to Source |
2832
sinks
2933
| test.go:10:9:10:9 | y |
3034
| test.go:16:9:16:9 | y |
@@ -38,3 +42,5 @@ sinks
3842
| test.go:64:9:64:9 | y |
3943
| test.go:70:9:70:9 | y |
4044
| test.go:76:9:76:9 | y |
45+
| test.go:82:9:82:9 | y |
46+
| test.go:88:9:88:9 | y |

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/mad_SImplEmbedI2_subtypes_true.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@ paths
66
| test.go:50:7:50:16 | call to Source | test.go:52:9:52:9 | y |
77
| test.go:62:7:62:16 | call to Source | test.go:64:9:64:9 | y |
88
| test.go:74:7:74:16 | call to Source | test.go:76:9:76:9 | y |
9+
| test.go:86:7:86:16 | call to Source | test.go:88:9:88:9 | y |
910
sources
1011
| test.go:14:7:14:16 | call to Source |
1112
| test.go:26:7:26:16 | call to Source |
1213
| test.go:38:7:38:16 | call to Source |
1314
| test.go:50:7:50:16 | call to Source |
1415
| test.go:62:7:62:16 | call to Source |
1516
| test.go:74:7:74:16 | call to Source |
17+
| test.go:86:7:86:16 | call to Source |
1618
sinks
1719
| test.go:16:9:16:9 | y |
1820
| test.go:28:9:28:9 | y |
1921
| test.go:40:9:40:9 | y |
2022
| test.go:52:9:52:9 | y |
2123
| test.go:64:9:64:9 | y |
2224
| test.go:76:9:76:9 | y |
25+
| test.go:88:9:88:9 | y |

0 commit comments

Comments
 (0)