Skip to content

Commit 8c2e8df

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

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

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

Lines changed: 34 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

@@ -18,6 +19,7 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
1819
private import DataFlowImplCommon::MakeImplCommon<Location, Lang>
1920
private import DataFlowImplCommonPublic
2021
private import Aliases
22+
private module AlertFiltering = AlertFilteringImpl<Location>;
2123

2224
/**
2325
* An input configuration for data flow using flow state. This signature equals
@@ -3389,6 +3391,38 @@ module MakeImpl<LocationSig Location, InputSig<Location> Lang> {
33893391
*/
33903392
predicate flowToExpr(Expr sink) { flowTo(exprNode(sink)) }
33913393

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

0 commit comments

Comments
 (0)