Skip to content

Commit 4191b18

Browse files
committed
Dataflow: Add flowFrom predicates to mirror flowTo.
1 parent 848677e commit 4191b18

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

shared/dataflow/codeql/dataflow/internal/DataFlowImpl.qll

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,28 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
207207
flowLocal(source, sink) and Config::observeOverlayInformedIncrementalMode()
208208
}
209209

210+
/**
211+
* Holds if data can flow from `source` to some sink.
212+
* This is a local predicate that only has results local to the overlay/base database.
213+
*/
214+
predicate flowFromLocal(Node source) = forceLocal(Flow::flowFrom/1)(source)
215+
216+
/**
217+
* Holds if data can flow from `source` to some sink.
218+
*/
219+
predicate flowFrom(Node source) {
220+
Flow::flowFrom(source)
221+
or
222+
// If we are overlay informed (i.e. we are not diff-informed), we
223+
// merge in the local results which includes the base database results.
224+
flowFromLocal(source) and Config::observeOverlayInformedIncrementalMode()
225+
}
226+
227+
/**
228+
* Holds if data can flow from `source` to some sink.
229+
*/
230+
predicate flowFromExpr(Lang::DataFlowExpr source) { flowFrom(exprNode(source)) }
231+
210232
/**
211233
* Holds if data can flow from some source to `sink`.
212234
* This is a local predicate that only has results local to the overlay/base database.
@@ -3501,6 +3523,16 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
35013523
)
35023524
}
35033525

3526+
/**
3527+
* Holds if data can flow from `source` to some sink.
3528+
*/
3529+
predicate flowFrom(Node source) { exists(PathNode n | n.isSource() and n.getNode() = source) }
3530+
3531+
/**
3532+
* Holds if data can flow from `source` to some sink.
3533+
*/
3534+
predicate flowFromExpr(Expr source) { flowFrom(exprNode(source)) }
3535+
35043536
/**
35053537
* Holds if data can flow from some source to `sink`.
35063538
*/

0 commit comments

Comments
 (0)