Skip to content

Commit 964a0a5

Browse files
committed
DataFlow: Add has{Source,Sink}InDiffRange
1 parent 93ba865 commit 964a0a5

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ private import codeql.util.Unit
88
private import codeql.util.Option
99
private import codeql.util.Boolean
1010
private import codeql.util.Location
11+
private import codeql.util.AlertFiltering
1112
private import codeql.dataflow.DataFlow
1213
private import DataFlowImplStage1
1314

@@ -19,6 +20,8 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1920
private import DataFlowImplCommonPublic
2021
private import Aliases
2122

23+
private module AlertFiltering = AlertFilteringImpl<Location>;
24+
2225
/**
2326
* An input configuration for data flow using flow state. This signature equals
2427
* `StateConfigSig`, but requires explicit implementation of all predicates.
@@ -3389,6 +3392,38 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
33893392
*/
33903393
predicate flowToExpr(Expr sink) { flowTo(exprNode(sink)) }
33913394

3395+
/**
3396+
* Holds if the configuration has at least one source in the diff range as
3397+
* determined by `AlertFiltering`. This predicate is independent of whether
3398+
* diff-informed mode is observed by the configuration and is also
3399+
* independent whether there was flow.
3400+
*/
3401+
pragma[nomagic]
3402+
predicate hasSourceInDiffRange() {
3403+
exists(Node source |
3404+
Config::isSource(source, _) and
3405+
AlertFiltering::filterByLocation(Config::getASelectedSourceLocation(source))
3406+
// TODO: also require `Config::isSink(_, _)`? Because if the source
3407+
// isn't reachable, it may as well not be there.
3408+
)
3409+
}
3410+
3411+
/**
3412+
* Holds if the configuration has at least one sink in the diff range as
3413+
* determined by `AlertFiltering`. This predicate is independent of whether
3414+
* diff-informed mode is observed by the configuration and is also
3415+
* independent whether there was flow.
3416+
*/
3417+
pragma[nomagic]
3418+
predicate hasSinkInDiffRange() {
3419+
exists(Node sink |
3420+
Config::isSink(sink, _) and
3421+
AlertFiltering::filterByLocation(Config::getASelectedSinkLocation(sink))
3422+
// TODO: also require `Config::isSource(_, _)`? Because if the sink
3423+
// isn't reachable, it may as well not be there.
3424+
)
3425+
}
3426+
33923427
/**
33933428
* INTERNAL: Only for debugging.
33943429
*

0 commit comments

Comments
 (0)