Skip to content

Commit f2352d8

Browse files
committed
Data flow: Inline local(Expr|Instruction)?(Flow|Taint)
Computing a full transitive closure is often bad; by inlining all calls we are providing more context to the QL optimizer.
1 parent 56ac990 commit f2352d8

File tree

13 files changed

+25
-1
lines changed

13 files changed

+25
-1
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowUtil.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,12 +592,14 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
592592
* Holds if data flows from `source` to `sink` in zero or more local
593593
* (intra-procedural) steps.
594594
*/
595+
pragma[inline]
595596
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
596597

597598
/**
598599
* Holds if data can flow from `e1` to `e2` in zero or more
599600
* local (intra-procedural) steps.
600601
*/
602+
pragma[inline]
601603
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
602604

603605
/**

cpp/ql/lib/semmle/code/cpp/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,14 @@ predicate localAdditionalTaintStep(DataFlow::Node nodeFrom, DataFlow::Node nodeT
124124
* Holds if taint may propagate from `source` to `sink` in zero or more local
125125
* (intra-procedural) steps.
126126
*/
127+
pragma[inline]
127128
predicate localTaint(DataFlow::Node source, DataFlow::Node sink) { localTaintStep*(source, sink) }
128129

129130
/**
130131
* Holds if taint can flow from `e1` to `e2` in zero or more
131132
* local (intra-procedural) steps.
132133
*/
134+
pragma[inline]
133135
predicate localExprTaint(Expr e1, Expr e2) {
134136
localTaint(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
135137
}

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,12 +1032,14 @@ SideEffectInstruction getSideEffectFor(CallInstruction call, int argument) {
10321032
* Holds if data flows from `source` to `sink` in zero or more local
10331033
* (intra-procedural) steps.
10341034
*/
1035+
pragma[inline]
10351036
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
10361037

10371038
/**
10381039
* Holds if data can flow from `i1` to `i2` in zero or more
10391040
* local (intra-procedural) steps.
10401041
*/
1042+
pragma[inline]
10411043
predicate localInstructionFlow(Instruction e1, Instruction e2) {
10421044
localFlow(instructionNode(e1), instructionNode(e2))
10431045
}
@@ -1046,6 +1048,7 @@ predicate localInstructionFlow(Instruction e1, Instruction e2) {
10461048
* Holds if data can flow from `e1` to `e2` in zero or more
10471049
* local (intra-procedural) steps.
10481050
*/
1051+
pragma[inline]
10491052
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
10501053

10511054
private newtype TContent =

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,14 @@ private predicate operandToInstructionTaintStep(Operand opFrom, Instruction inst
121121
* Holds if taint may propagate from `source` to `sink` in zero or more local
122122
* (intra-procedural) steps.
123123
*/
124+
pragma[inline]
124125
predicate localTaint(DataFlow::Node source, DataFlow::Node sink) { localTaintStep*(source, sink) }
125126

126127
/**
127128
* Holds if taint can flow from `i1` to `i2` in zero or more
128129
* local (intra-procedural) steps.
129130
*/
131+
pragma[inline]
130132
predicate localInstructionTaint(Instruction i1, Instruction i2) {
131133
localTaint(DataFlow::instructionNode(i1), DataFlow::instructionNode(i2))
132134
}
@@ -135,6 +137,7 @@ predicate localInstructionTaint(Instruction i1, Instruction i2) {
135137
* Holds if taint can flow from `e1` to `e2` in zero or more
136138
* local (intra-procedural) steps.
137139
*/
140+
pragma[inline]
138141
predicate localExprTaint(Expr e1, Expr e2) {
139142
localTaint(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
140143
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPublic.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
160160
* Holds if data can flow from `e1` to `e2` in zero or more
161161
* local (intra-procedural) steps.
162162
*/
163+
pragma[inline]
163164
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
164165

165166
/**

csharp/ql/lib/semmle/code/csharp/dataflow/internal/TaintTrackingPublic.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ private import TaintTrackingPrivate
55
* Holds if taint propagates from `source` to `sink` in zero or more local
66
* (intra-procedural) steps.
77
*/
8+
pragma[inline]
89
predicate localTaint(DataFlow::Node source, DataFlow::Node sink) { localTaintStep*(source, sink) }
910

1011
/**
1112
* Holds if taint can flow from `e1` to `e2` in zero or more
1213
* local (intra-procedural) steps.
1314
*/
15+
pragma[inline]
1416
predicate localExprTaint(Expr e1, Expr e2) {
1517
localTaint(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
1618
}

docs/ql-libraries/dataflow/dataflow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Recommendations:
9292
See the C/C++ implementation, which makes use of this feature. Another use of
9393
this indirection is to hide synthesized local steps that are only relevant
9494
for global flow. See the C# implementation for an example of this.
95-
* Define `predicate localFlow(Node node1, Node node2) { localFlowStep*(node1, node2) }`.
95+
* Define `pragma[inline] predicate localFlow(Node node1, Node node2) { localFlowStep*(node1, node2) }`.
9696
* Make the local flow step relation in `simpleLocalFlowStep` follow
9797
def-to-first-use and use-to-next-use steps for SSA variables. Def-use steps
9898
also work, but the upside of `use-use` steps is that sources defined in terms

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,14 @@ private module ThisFlow {
7474
* Holds if data can flow from `node1` to `node2` in zero or more
7575
* local (intra-procedural) steps.
7676
*/
77+
pragma[inline]
7778
predicate localFlow(Node node1, Node node2) { localFlowStep*(node1, node2) }
7879

7980
/**
8081
* Holds if data can flow from `e1` to `e2` in zero or more
8182
* local (intra-procedural) steps.
8283
*/
84+
pragma[inline]
8385
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
8486

8587
/**

java/ql/lib/semmle/code/java/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ private import semmle.code.java.frameworks.JaxWS
2121
* Holds if taint can flow from `src` to `sink` in zero or more
2222
* local (intra-procedural) steps.
2323
*/
24+
pragma[inline]
2425
predicate localTaint(DataFlow::Node src, DataFlow::Node sink) { localTaintStep*(src, sink) }
2526

2627
/**
2728
* Holds if taint can flow from `src` to `sink` in zero or more
2829
* local (intra-procedural) steps.
2930
*/
31+
pragma[inline]
3032
predicate localExprTaint(Expr src, Expr sink) {
3133
localTaint(DataFlow::exprNode(src), DataFlow::exprNode(sink))
3234
}

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowUtil.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ predicate localFlowStep(Node nodeFrom, Node nodeTo) { simpleLocalFlowStep(nodeFr
1515
* Holds if data flows from `source` to `sink` in zero or more local
1616
* (intra-procedural) steps.
1717
*/
18+
pragma[inline]
1819
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
1920

2021
/**

0 commit comments

Comments
 (0)