Skip to content

Commit 19acc8d

Browse files
committed
TEMP: DataFlow: Java-only flow including base
This won't work for other languages until we can annotate a `forceLocal` call with `local?`.
1 parent 799b285 commit 19acc8d

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

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

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3376,24 +3376,81 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
33763376
import S6
33773377

33783378
/**
3379-
* Holds if data can flow from `source` to `sink`.
3379+
* Holds if data can flow from `source` to `sink`. When running in overlay
3380+
* incremental mode on a supported language, this predicate only has
3381+
* results where either the source or sink is in the overlay database.
33803382
*/
3381-
predicate flow(Node source, Node sink) {
3383+
private predicate flowIncremental(Node source, Node sink) {
33823384
exists(PathNode source0, PathNode sink0 |
33833385
flowPath(source0, sink0) and source0.getNode() = source and sink0.getNode() = sink
33843386
)
33853387
}
33863388

3389+
overlay[local]
3390+
private predicate flowLocal(Node source, Node sink) =
3391+
forceLocal(flowIncremental/2)(source, sink)
3392+
3393+
/**
3394+
* Holds if data can flow from `source` to `sink`.
3395+
*/
3396+
predicate flow(Node source, Node sink) {
3397+
flowIncremental(source, sink)
3398+
or
3399+
flowLocal(source, sink)
3400+
}
3401+
3402+
/**
3403+
* Holds if data can flow from some source to `sink`. When running in
3404+
* overlay incremental mode on a supported language, this predicate only
3405+
* has results where either the source or sink is in the overlay database.
3406+
*/
3407+
private predicate flowToIncremental(Node sink) {
3408+
exists(PathNode n | n.isSink() and n.getNode() = sink)
3409+
}
3410+
3411+
overlay[local]
3412+
private predicate flowToLocal(Node sink) = forceLocal(flowToIncremental/1)(sink)
3413+
33873414
/**
33883415
* Holds if data can flow from some source to `sink`.
33893416
*/
3390-
predicate flowTo(Node sink) { exists(PathNode n | n.isSink() and n.getNode() = sink) }
3417+
predicate flowTo(Node sink) {
3418+
flowToIncremental(sink)
3419+
or
3420+
flowToLocal(sink)
3421+
}
33913422

33923423
/**
33933424
* Holds if data can flow from some source to `sink`.
33943425
*/
33953426
predicate flowToExpr(Expr sink) { flowTo(exprNode(sink)) }
33963427

3428+
/**
3429+
* Holds if data can flow from `source` to some sink. When running in
3430+
* overlay incremental mode on a supported language, this predicate only
3431+
* has results where either the source or sink is in the overlay database.
3432+
*/
3433+
private predicate flowFromIncremental(Node source) {
3434+
exists(PathNode n | n.isSource() and n.getNode() = source)
3435+
}
3436+
3437+
overlay[local]
3438+
private predicate flowFromLocal(Node source) = forceLocal(flowFromIncremental/1)(source)
3439+
3440+
/**
3441+
* Holds if data can flow from `source` to some sink.
3442+
*/
3443+
predicate flowFrom(Node source) {
3444+
flowFromIncremental(source)
3445+
or
3446+
flowFromLocal(source)
3447+
}
3448+
3449+
/**
3450+
* Holds if data can flow from `source` to some sink.
3451+
*/
3452+
predicate flowFromExpr(Expr source) { flowFrom(exprNode(source)) }
3453+
33973454
/**
33983455
* INTERNAL: Only for debugging.
33993456
*

0 commit comments

Comments
 (0)