C++: Add library tests for YML extension models.

This commit is contained in:
Geoffrey White
2024-05-23 17:25:29 +01:00
parent 3f66b635a4
commit 34130d50d3
11 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
testFailures
failures

View File

@@ -0,0 +1,24 @@
import TestUtilities.dataflow.FlowTestCommon
import cpp
import semmle.code.cpp.ir.dataflow.DataFlow
import semmle.code.cpp.dataflow.ExternalFlow
module IRTest {
private import semmle.code.cpp.ir.IR
private import semmle.code.cpp.ir.dataflow.TaintTracking
/** Common data flow configuration to be used by tests. */
module TestAllocationConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
sourceNode(source, _)
}
predicate isSink(DataFlow::Node sink) {
sinkNode(sink, "test-sink")
}
}
module IRFlow = TaintTracking::Global<TestAllocationConfig>;
}
import MakeTest<IRFlowTest<IRTest::IRFlow>>

View File

@@ -0,0 +1,7 @@
import cpp
import semmle.code.cpp.ir.dataflow.DataFlow
import semmle.code.cpp.dataflow.ExternalFlow
from DataFlow::Node node, string kind
where sinkNode(node, kind)
select node, kind

View File

@@ -0,0 +1,7 @@
import cpp
import semmle.code.cpp.ir.dataflow.DataFlow
import semmle.code.cpp.dataflow.ExternalFlow
from DataFlow::Node node, string kind
where sourceNode(node, kind)
select node, kind

View File

@@ -0,0 +1,8 @@
import cpp
import semmle.code.cpp.ir.dataflow.DataFlow
import semmle.code.cpp.dataflow.ExternalFlow
import semmle.code.cpp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
from DataFlow::Node node1, DataFlow::Node node2
where FlowSummaryImpl::Private::Steps::summaryThroughStepTaint(node1, node2, _)
select node1, node2

View File

@@ -0,0 +1,16 @@
int ymlSource();
void ymlSink(int value);
int ymlStep(int value);
void test() {
int x = ymlSource();
ymlSink(0);
ymlSink(x); // $ MISSING: ir
int y = ymlStep(x);
ymlSink(y); // $ MISSING: ir
}

View File

@@ -0,0 +1,7 @@
| Dubious namespace "" in sink model. |
| Dubious namespace "" in source model. |
| Dubious namespace "" in summary model. |
| Dubious type "" in sink model. |
| Dubious type "" in source model. |
| Dubious type "" in summary model. |
| Invalid kind "remote-sink" in sink model. |

View File

@@ -0,0 +1,2 @@
import cpp
import semmle.code.cpp.dataflow.ExternalFlow::CsvValidation