Skip to content

Commit 6a67bd5

Browse files
committed
Add tests for MaD inheritance
1 parent 95c18ce commit 6a67bd5

32 files changed

+771
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module semmle.go.Packages
2+
3+
go 1.21
4+
5+
require github.com/nonexistent/test v0.0.0-20200203000000-0000000000000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
sources
16+
| test.go:8:7:8:16 | call to Source |
17+
| test.go:14:7:14:16 | call to Source |
18+
| test.go:20:7:20:16 | call to Source |
19+
| test.go:26:7:26:16 | call to Source |
20+
| test.go:32:7:32:16 | call to Source |
21+
| test.go:38:7:38:16 | call to Source |
22+
| test.go:44:7:44:16 | call to Source |
23+
| test.go:50:7:50:16 | call to Source |
24+
| test.go:56:7:56:16 | call to Source |
25+
| test.go:62:7:62:16 | call to Source |
26+
| test.go:68:7:68:16 | call to Source |
27+
| test.go:74:7:74:16 | call to Source |
28+
sinks
29+
| test.go:10:9:10:9 | y |
30+
| test.go:16:9:16:9 | y |
31+
| test.go:22:9:22:9 | y |
32+
| test.go:28:9:28:9 | y |
33+
| test.go:34:9:34:9 | y |
34+
| test.go:40:9:40:9 | y |
35+
| test.go:46:9:46:9 | y |
36+
| test.go:52:9:52:9 | y |
37+
| test.go:58:9:58:9 | y |
38+
| test.go:64:9:64:9 | y |
39+
| test.go:70:9:70:9 | y |
40+
| test.go:76:9:76:9 | y |
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", "StructEmbeddingAndOverridingI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
7+
- addsTo:
8+
pack: codeql/go-all
9+
extensible: summaryModel
10+
data:
11+
- ["github.com/nonexistent/test", "StructEmbeddingAndOverridingI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
12+
- addsTo:
13+
pack: codeql/go-all
14+
extensible: sinkModel
15+
data:
16+
- ["github.com/nonexistent/test", "StructEmbeddingAndOverridingI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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() }
19+
// predicate foo() {
20+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
sources
16+
| test.go:8:7:8:16 | call to Source |
17+
| test.go:14:7:14:16 | call to Source |
18+
| test.go:20:7:20:16 | call to Source |
19+
| test.go:26:7:26:16 | call to Source |
20+
| test.go:32:7:32:16 | call to Source |
21+
| test.go:38:7:38:16 | call to Source |
22+
| test.go:44:7:44:16 | call to Source |
23+
| test.go:50:7:50:16 | call to Source |
24+
| test.go:56:7:56:16 | call to Source |
25+
| test.go:62:7:62:16 | call to Source |
26+
| test.go:68:7:68:16 | call to Source |
27+
| test.go:74:7:74:16 | call to Source |
28+
sinks
29+
| test.go:10:9:10:9 | y |
30+
| test.go:16:9:16:9 | y |
31+
| test.go:22:9:22:9 | y |
32+
| test.go:28:9:28:9 | y |
33+
| test.go:34:9:34:9 | y |
34+
| test.go:40:9:40:9 | y |
35+
| test.go:46:9:46:9 | y |
36+
| test.go:52:9:52:9 | y |
37+
| test.go:58:9:58:9 | y |
38+
| test.go:64:9:64:9 | y |
39+
| test.go:70:9:70:9 | y |
40+
| test.go:76:9:76:9 | y |
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", "StructEmbeddingI1", True, "Source", "", "", "ReturnValue", "remote", "manual"]
7+
- addsTo:
8+
pack: codeql/go-all
9+
extensible: summaryModel
10+
data:
11+
- ["github.com/nonexistent/test", "StructEmbeddingI1", True, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
12+
- addsTo:
13+
pack: codeql/go-all
14+
extensible: sinkModel
15+
data:
16+
- ["github.com/nonexistent/test", "StructEmbeddingI1", True, "Sink", "", "", "Argument[0]", "path-injection", "manual"]
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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
invalidModelRow
2+
paths
3+
| test.go:8:7:8:16 | call to Source | test.go:10:9:10:9 | y |
4+
| test.go:32:7:32:16 | call to Source | test.go:34:9:34:9 | y |
5+
sources
6+
| test.go:8:7:8:16 | call to Source |
7+
| test.go:32:7:32:16 | call to Source |
8+
sinks
9+
| test.go:10:9:10:9 | y |
10+
| test.go:34:9:34: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", "I1", False, "Source", "", "", "ReturnValue", "remote", "manual"]
7+
- addsTo:
8+
pack: codeql/go-all
9+
extensible: summaryModel
10+
data:
11+
- ["github.com/nonexistent/test", "I1", False, "Step", "", "", "Argument[0]", "ReturnValue", "value", "manual"]
12+
- addsTo:
13+
pack: codeql/go-all
14+
extensible: sinkModel
15+
data:
16+
- ["github.com/nonexistent/test", "I1", False, "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() }

0 commit comments

Comments
 (0)