Skip to content

Commit 4dca4a7

Browse files
committed
Dataflow: Restrict partial flow to either forward or reverse flow.
1 parent ec58b20 commit 4dca4a7

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,7 +4357,27 @@ module MakeImpl<InputSig Lang> {
43574357
tftuples = -1
43584358
}
43594359

4360-
module FlowExploration<explorationLimitSig/0 explorationLimit> {
4360+
private signature predicate flag();
4361+
4362+
private predicate flagEnable() { any() }
4363+
4364+
private predicate flagDisable() { none() }
4365+
4366+
module FlowExplorationFwd<explorationLimitSig/0 explorationLimit> {
4367+
import FlowExploration<explorationLimit/0, flagEnable/0, flagDisable/0>
4368+
4369+
predicate partialFlow = partialFlowFwd/3;
4370+
}
4371+
4372+
module FlowExplorationRev<explorationLimitSig/0 explorationLimit> {
4373+
import FlowExploration<explorationLimit/0, flagDisable/0, flagEnable/0>
4374+
4375+
predicate partialFlow = partialFlowRev/3;
4376+
}
4377+
4378+
private module FlowExploration<
4379+
explorationLimitSig/0 explorationLimit, flag/0 flagFwd, flag/0 flagRev>
4380+
{
43614381
private predicate callableStep(DataFlowCallable c1, DataFlowCallable c2) {
43624382
exists(NodeEx node1, NodeEx node2 |
43634383
jumpStepEx(node1, node2)
@@ -4526,6 +4546,7 @@ module MakeImpl<InputSig Lang> {
45264546
NodeEx node, FlowState state, CallContext cc, TSummaryCtx1 sc1, TSummaryCtx2 sc2,
45274547
TSummaryCtx3 sc3, TSummaryCtx4 sc4, DataFlowType t, PartialAccessPath ap
45284548
) {
4549+
flagFwd() and
45294550
sourceNode(node, state) and
45304551
cc instanceof CallContextAny and
45314552
sc1 = TSummaryCtx1None() and
@@ -4543,6 +4564,7 @@ module MakeImpl<InputSig Lang> {
45434564
NodeEx node, FlowState state, TRevSummaryCtx1 sc1, TRevSummaryCtx2 sc2,
45444565
TRevSummaryCtx3 sc3, PartialAccessPath ap
45454566
) {
4567+
flagRev() and
45464568
revSinkNode(node, state) and
45474569
sc1 = TRevSummaryCtx1None() and
45484570
sc2 = TRevSummaryCtx2None() and
@@ -5223,7 +5245,7 @@ module MakeImpl<InputSig Lang> {
52235245
)
52245246
}
52255247

5226-
private predicate partialFlow(PartialPathNode source, PartialPathNode node) {
5248+
private predicate fwdPartialFlow(PartialPathNode source, PartialPathNode node) {
52275249
source.isFwdSource() and
52285250
node = source.getASuccessor+()
52295251
}
@@ -5245,8 +5267,8 @@ module MakeImpl<InputSig Lang> {
52455267
*
52465268
* To use this in a `path-problem` query, import the module `PartialPathGraph`.
52475269
*/
5248-
predicate partialFlow(PartialPathNode source, PartialPathNode node, int dist) {
5249-
partialFlow(source, node) and
5270+
predicate partialFlowFwd(PartialPathNode source, PartialPathNode node, int dist) {
5271+
fwdPartialFlow(source, node) and
52505272
dist = node.getSourceDistance()
52515273
}
52525274

0 commit comments

Comments
 (0)