Also update QL tests

This commit is contained in:
Owen Mansel-Chan
2024-09-24 16:18:59 +01:00
parent 6e428d5083
commit b0caabac86
7 changed files with 59 additions and 37 deletions

View File

@@ -0,0 +1,3 @@
testFailures
invalidModelRow
failures

View File

@@ -2,6 +2,30 @@ import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
import TestUtilities.InlineExpectationsTest
import MakeTest<FlowTest>
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
}
module Flow = TaintTracking::Global<Config>;
module FlowTest implements TestSig {
string getARelevantTag() { result = "ql_I1" }
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ql_I1" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
element = sink.toString() and
value = ""
)
}
}
class MySource extends RemoteFlowSource::Range instanceof DataFlow::Node {
MySource() {
@@ -30,13 +54,3 @@ class MySink extends FileSystemAccess::Range, DataFlow::CallNode {
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
}
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }

View File

@@ -0,0 +1,3 @@
testFailures
invalidModelRow
failures

View File

@@ -2,6 +2,30 @@ import go
import semmle.go.dataflow.ExternalFlow
import ModelValidation
import semmle.go.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
import TestUtilities.InlineExpectationsTest
import MakeTest<FlowTest>
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
}
module Flow = TaintTracking::Global<Config>;
module FlowTest implements TestSig {
string getARelevantTag() { result = "ql_S1" }
predicate hasActualResult(Location location, string element, string tag, string value) {
tag = "ql_S1" and
exists(DataFlow::Node sink | Flow::flowTo(sink) |
sink.hasLocationInfo(location.getFile().getAbsolutePath(), location.getStartLine(),
location.getStartColumn(), location.getEndLine(), location.getEndColumn()) and
element = sink.toString() and
value = ""
)
}
}
class MySource extends RemoteFlowSource::Range instanceof DataFlow::Node {
MySource() {
@@ -30,13 +54,3 @@ class MySink extends FileSystemAccess::Range, DataFlow::CallNode {
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
}
module Config implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
predicate isSink(DataFlow::Node sink) { sink = any(FileSystemAccess fsa).getAPathArgument() }
}
module Flow = DataFlow::Global<Config>;
query predicate paths(DataFlow::Node source, DataFlow::Node sink) { Flow::flow(source, sink) }

View File

@@ -1,5 +0,0 @@
invalidModelRow
paths
| test.go:8:7:8:16 | call to Source | test.go:10:9:10:9 | y |
| test.go:32:7:32:16 | call to Source | test.go:34:9:34:9 | y |
| test.go:44:7:44:16 | call to Source | test.go:46:9:46:9 | y |

View File

@@ -1,7 +0,0 @@
invalidModelRow
paths
| test.go:8:7:8:16 | call to Source | test.go:10:9:10:9 | y |
| test.go:20:7:20:16 | call to Source | test.go:22:9:22:9 | y |
| test.go:32:7:32:16 | call to Source | test.go:34:9:34:9 | y |
| test.go:44:7:44:16 | call to Source | test.go:46:9:46:9 | y |
| test.go:68:7:68:16 | call to Source | test.go:70:9:70:9 | y |

View File

@@ -7,7 +7,7 @@ import (
func TestI1(t test.I1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
}
func TestI2(t test.I2) {
@@ -19,7 +19,7 @@ func TestI2(t test.I2) {
func TestS1(t test.S1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] ql_S1
}
func TestS2(t test.S2) {
@@ -31,7 +31,7 @@ func TestS2(t test.S2) {
func TestSEmbedI1(t test.SEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
}
func TestSEmbedI2(t test.SEmbedI2) {
@@ -43,7 +43,7 @@ func TestSEmbedI2(t test.SEmbedI2) {
func TestIEmbedI1(t test.IEmbedI1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t]
t.Sink(y) // $ I1[f] I1[t] IEmbedI1[t] SEmbedI1[t] ql_I1 ql_S1
}
func TestIEmbedI2(t test.IEmbedI2) {
@@ -67,7 +67,7 @@ func TestSImplEmbedI2(t test.SImplEmbedI2) {
func TestSEmbedS1(t test.SEmbedS1) {
x := t.Source()
y := t.Step(x)
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t]
t.Sink(y) // $ I1[t] IEmbedI1[t] S1[f] S1[t] SEmbedI1[t] ql_S1
}
func TestSEmbedS2(t test.SEmbedS2) {