Skip to content

Commit b0caaba

Browse files
committed
Also update QL tests
1 parent 6e428d5 commit b0caaba

File tree

7 files changed

+59
-37
lines changed

7 files changed

+59
-37
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
testFailures
2+
invalidModelRow
3+
failures

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/ql_i1.ql renamed to go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/ql_I1.ql

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@ import go
22
import semmle.go.dataflow.ExternalFlow
33
import ModelValidation
44
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
5+
import TestUtilities.InlineExpectationsTest
6+
import MakeTest<FlowTest>
7+
8+
module Config implements DataFlow::ConfigSig {
9+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
10+
11+
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
12+
}
13+
14+
module Flow = TaintTracking::Global<Config>;
15+
16+
module FlowTest implements TestSig {
17+
string getARelevantTag() { result = "ql_I1" }
18+
19+
predicate hasActualResult(Location location, string element, string tag, string value) {
20+
tag = "ql_I1" and
21+
exists(DataFlow::Node sink | Flow::flowTo(sink) |
22+
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
23+
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
24+
element = sink.toString() and
25+
value = ""
26+
)
27+
}
28+
}
529

630
class MySource extends RemoteFlowSource::Range instanceof DataFlow::Node {
731
MySource() {
@@ -30,13 +54,3 @@ class MySink extends FileSystemAccess::Range, DataFlow::CallNode {
3054

3155
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
3256
}
33-
34-
module Config implements DataFlow::ConfigSig {
35-
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
36-
37-
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
38-
}
39-
40-
module Flow = DataFlow::Global<Config>;
41-
42-
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
testFailures
2+
invalidModelRow
3+
failures

go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/ql_s1.ql renamed to go/ql/test/library-tests/semmle/go/dataflow/ExternalFlowInheritance/ql_S1.ql

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@ import go
22
import semmle.go.dataflow.ExternalFlow
33
import ModelValidation
44
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
5+
import TestUtilities.InlineExpectationsTest
6+
import MakeTest<FlowTest>
7+
8+
module Config implements DataFlow::ConfigSig {
9+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
10+
11+
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
12+
}
13+
14+
module Flow = TaintTracking::Global<Config>;
15+
16+
module FlowTest implements TestSig {
17+
string getARelevantTag() { result = "ql_S1" }
18+
19+
predicate hasActualResult(Location location, string element, string tag, string value) {
20+
tag = "ql_S1" and
21+
exists(DataFlow::Node sink | Flow::flowTo(sink) |
22+
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
23+
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
24+
element = sink.toString() and
25+
value = ""
26+
)
27+
}
28+
}
529

630
class MySource extends RemoteFlowSource::Range instanceof DataFlow::Node {
731
MySource() {
@@ -30,13 +54,3 @@ class MySink extends FileSystemAccess::Range, DataFlow::CallNode {
3054

3155
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
3256
}
33-
34-
module Config implements DataFlow::ConfigSig {
35-
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
36-
37-
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
38-
}
39-
40-
module Flow = DataFlow::Global<Config>;
41-
42-
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }

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

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func TestI1(t test.I1) {
88
x := t.Source()
99
y := t.Step(x)
10-
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
10+
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
1111
}
1212

1313
func TestI2(t test.I2) {
@@ -19,7 +19,7 @@ func TestI2(t test.I2) {
1919
func TestS1(t test.S1) {
2020
x := t.Source()
2121
y := t.Step(x)
22-
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
22+
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] ql_S1
2323
}
2424

2525
func TestS2(t test.S2) {
@@ -31,7 +31,7 @@ func TestS2(t test.S2) {
3131
func TestSEmbedI1(t test.SEmbedI1) {
3232
x := t.Source()
3333
y := t.Step(x)
34-
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
34+
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
3535
}
3636

3737
func TestSEmbedI2(t test.SEmbedI2) {
@@ -43,7 +43,7 @@ func TestSEmbedI2(t test.SEmbedI2) {
4343
func TestIEmbedI1(t test.IEmbedI1) {
4444
x := t.Source()
4545
y := t.Step(x)
46-
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
46+
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
4747
}
4848

4949
func TestIEmbedI2(t test.IEmbedI2) {
@@ -67,7 +67,7 @@ func TestSImplEmbedI2(t test.SImplEmbedI2) {
6767
func TestSEmbedS1(t test.SEmbedS1) {
6868
x := t.Source()
6969
y := t.Step(x)
70-
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
70+
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] ql_S1
7171
}
7272

7373
func TestSEmbedS2(t test.SEmbedS2) {

0 commit comments

Comments
 (0)