Skip to content

Commit bad72c4

Browse files
authored
Merge pull request github#13244 from MathiasVP/promote-product-flow
C++: Promote the product-dataflow library out of experimental
2 parents 8daa8d7 + 81dbfec commit bad72c4

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/dataflow/ProductFlow.qll renamed to cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/ProductFlow.qll

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1-
import semmle.code.cpp.ir.dataflow.DataFlow
2-
private import semmle.code.cpp.ir.dataflow.internal.DataFlowPrivate
3-
private import semmle.code.cpp.ir.dataflow.internal.DataFlowUtil
4-
private import semmle.code.cpp.ir.dataflow.internal.DataFlowImplCommon
1+
/**
2+
* Provides a library for global (inter-procedural) data flow analysis of two
3+
* values "simultaneously". This can be used, for example, if you want to track
4+
* a memory allocation as well as the size of the allocation.
5+
*
6+
* Intuitively, you can think of this as regular dataflow, but where each node
7+
* in the dataflow graph has been replaced by a pair of nodes `(node1, node2)`,
8+
* and two node pairs `(n11, n12)`, `(n21, n22)` is then connected by a dataflow
9+
* edge if there's a regular dataflow edge between `n11` and `n21`, and `n12`
10+
* and `n22`.
11+
*
12+
* Note that the above intuition does not reflect the actual implementation.
13+
*/
14+
15+
import semmle.code.cpp.dataflow.new.DataFlow
16+
private import DataFlowPrivate
17+
private import DataFlowUtil
18+
private import DataFlowImplCommon
519
private import codeql.util.Unit
620

21+
/**
22+
* Provides classes for performing global (inter-procedural) data flow analyses
23+
* on a product dataflow graph.
24+
*/
725
module ProductFlow {
26+
/** An input configuration for product data-flow. */
827
signature module ConfigSig {
928
/**
1029
* Holds if `(source1, source2)` is a relevant data flow source.
@@ -70,6 +89,9 @@ module ProductFlow {
7089
default predicate isBarrierIn2(DataFlow::Node node) { none() }
7190
}
7291

92+
/**
93+
* The output of a global data flow computation.
94+
*/
7395
module Global<ConfigSig Config> {
7496
private module StateConfig implements StateConfigSig {
7597
class FlowState1 = Unit;
@@ -138,6 +160,7 @@ module ProductFlow {
138160
import GlobalWithState<StateConfig>
139161
}
140162

163+
/** An input configuration for data flow using flow state. */
141164
signature module StateConfigSig {
142165
bindingset[this]
143166
class FlowState1;
@@ -247,6 +270,9 @@ module ProductFlow {
247270
default predicate isBarrierIn2(DataFlow::Node node) { none() }
248271
}
249272

273+
/**
274+
* The output of a global data flow computation.
275+
*/
250276
module GlobalWithState<StateConfigSig Config> {
251277
class PathNode1 = Flow1::PathNode;
252278

@@ -260,6 +286,7 @@ module ProductFlow {
260286

261287
class FlowState2 = Config::FlowState2;
262288

289+
/** Holds if data can flow from `(source1, source2)` to `(sink1, sink2)`. */
263290
predicate flowPath(
264291
Flow1::PathNode source1, Flow2::PathNode source2, Flow1::PathNode sink1, Flow2::PathNode sink2
265292
) {

cpp/ql/src/experimental/Likely Bugs/ArrayAccessProductFlow.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
import cpp
13-
import experimental.semmle.code.cpp.dataflow.ProductFlow
13+
import semmle.code.cpp.ir.dataflow.internal.ProductFlow
1414
import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.RangeAnalysis
1515
import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticExprSpecific
1616
import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.Bound

cpp/ql/src/experimental/Likely Bugs/OverrunWriteProductFlow.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414

1515
import cpp
16-
import experimental.semmle.code.cpp.dataflow.ProductFlow
16+
import semmle.code.cpp.ir.dataflow.internal.ProductFlow
1717
import semmle.code.cpp.ir.IR
1818
import semmle.code.cpp.models.interfaces.Allocation
1919
import semmle.code.cpp.models.interfaces.ArrayFunction

cpp/ql/src/experimental/Security/CWE/CWE-193/InvalidPointerDeref.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import cpp
19-
import experimental.semmle.code.cpp.dataflow.ProductFlow
19+
import semmle.code.cpp.ir.dataflow.internal.ProductFlow
2020
import semmle.code.cpp.rangeanalysis.new.internal.semantic.analysis.RangeAnalysis
2121
import semmle.code.cpp.rangeanalysis.new.internal.semantic.SemanticExprSpecific
2222
import semmle.code.cpp.ir.IR

0 commit comments

Comments
 (0)