Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6331173

Browse files
committed
C++: Add localExprFlow and localExprTaint
This is for ODASA-8053.
1 parent 00fe473 commit 6331173

4 files changed

Lines changed: 23 additions & 0 deletions

File tree

change-notes/1.23/analysis-cpp.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ The following changes in version 1.23 affect C/C++ analysis in all applications.
2525
picture of the partial flow paths from a given source. The feature is
2626
disabled by default and can be enabled for individual configurations by
2727
overriding `int explorationLimit()`.
28+
* There is now a `DataFlow::localExprFlow` predicate and a
29+
`TaintTracking::localExprTaint` predicate to make it easy to use the most
30+
common case of local data flow and taint: from one `Expr` to another.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
490490
*/
491491
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
492492

493+
/**
494+
* Holds if data can flow from `e1` to `e2` in zero or more
495+
* local (intra-procedural) steps.
496+
*/
497+
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
498+
493499
/**
494500
* Holds if the initial value of `v`, if it is a source, flows to `var`.
495501
*/

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ predicate localTaint(DataFlow::Node source, DataFlow::Node sink) {
8080
localTaintStep*(source, sink)
8181
}
8282

83+
/**
84+
* Holds if taint can flow from `e1` to `e2` in zero or more
85+
* local (intra-procedural) steps.
86+
*/
87+
predicate localExprTaint(Expr e1, Expr e2) {
88+
localTaint(DataFlow::exprNode(e1), DataFlow::exprNode(e2))
89+
}
90+
8391
/**
8492
* Holds if we do not propagate taint from `fromExpr` to `toExpr`
8593
* even though `toExpr` is the AST parent of `fromExpr`.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ predicate simpleLocalFlowStep(Node nodeFrom, Node nodeTo) {
178178
*/
179179
predicate localFlow(Node source, Node sink) { localFlowStep*(source, sink) }
180180

181+
/**
182+
* Holds if data can flow from `e1` to `e2` in zero or more
183+
* local (intra-procedural) steps.
184+
*/
185+
predicate localExprFlow(Expr e1, Expr e2) { localFlow(exprNode(e1), exprNode(e2)) }
186+
181187
/**
182188
* A guard that validates some expression.
183189
*

0 commit comments

Comments
 (0)