C++: Add models-as-data models for ZMQ networking library + wiring.

This commit is contained in:
Geoffrey White
2024-03-28 17:57:20 +00:00
parent 16f9ad06ef
commit fa26b55452
7 changed files with 69 additions and 10 deletions

View File

@@ -41,3 +41,4 @@ private import implementations.SqLite3
private import implementations.PostgreSql
private import implementations.System
private import implementations.StructuredExceptionHandling
private import implementations.ZMQ

View File

@@ -0,0 +1,36 @@
/**
* Provides implementation classes modeling the ZeroMQ networking library.
*/
import semmle.code.cpp.models.interfaces.FlowSource
/**
* Remote flow sources.
*/
private class ZMQSource extends SourceModelCsv {
override predicate row(string row) {
row =
[
";;false;zmq_recv;;;Argument[*1];remote",
";;false;zmq_recvmsg;;;Argument[*1];remote",
";;false;zmq_msg_recv;;;Argument[*0];remote",
]
}
}
/**
* Remote flow sinks.
*/
private class ZMQSinks extends SinkModelCsv {
override predicate row(string row) {
row =
[
";;false;zmq_send;;;Argument[*1];remote-sink",
";;false;zmq_msg_init_data;;;Argument[*1];remote-sink",
";;false;zmq_sendmsg;;;Argument[*1];remote-sink",
";;false;zmq_msg_send;;;Argument[*0];remote-sink",
]
}
}
// TODO: flow into / through zmq_msg_data ?

View File

@@ -93,6 +93,9 @@ abstract class RemoteFlowSink extends DataFlow::Node {
abstract string getSinkType();
}
/**
* A remote flow sink derived from the `RemoteFlowSinkFunction` model.
*/
private class RemoteParameterSink extends RemoteFlowSink {
string sourceType;
@@ -106,3 +109,12 @@ private class RemoteParameterSink extends RemoteFlowSink {
override string getSinkType() { result = sourceType }
}
/**
* A remote flow sink defined in a CSV model.
*/
private class RemoteFlowFromCSVSink extends RemoteFlowSink {
RemoteFlowFromCSVSink() { sinkNode(this, "remote-sink") }
override string getSinkType() { result = "remote flow sink" }
}