Skip to content

Commit bcfce56

Browse files
authored
Merge pull request #15547 from aschackmull/csharp/contentdataflow
C#: Simplify, getASuccessor is pruned now.
2 parents a54caea + dfc9c4d commit bcfce56

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/internal/ContentDataFlow.qll

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ module Global<ConfigSig ContentConfig> {
277277
}
278278
}
279279

280-
// important to use `edges` and not `PathNode::getASuccessor()`, as the latter
281-
// is not pruned for reachability
282-
private predicate pathSucc = Flow::PathGraph::edges/2;
283-
284280
/**
285281
* Provides a big-step flow relation, where flow stops at read/store steps that
286282
* must be recorded, and flow via `subpaths` such that reads/stores inside
@@ -290,10 +286,7 @@ module Global<ConfigSig ContentConfig> {
290286
private predicate reachesSink(Flow::PathNode node) {
291287
FlowConfig::isSink(node.getNode(), node.getState())
292288
or
293-
exists(Flow::PathNode mid |
294-
pathSucc(node, mid) and
295-
reachesSink(mid)
296-
)
289+
reachesSink(node.getASuccessor())
297290
}
298291

299292
/**
@@ -302,7 +295,7 @@ module Global<ConfigSig ContentConfig> {
302295
*/
303296
pragma[nomagic]
304297
private predicate excludeStep(Flow::PathNode pred, Flow::PathNode succ) {
305-
pathSucc(pred, succ) and
298+
pred.getASuccessor() = succ and
306299
(
307300
// we need to record reads/stores inside summarized callables
308301
Flow::PathGraph::subpaths(pred, _, _, succ)
@@ -356,7 +349,7 @@ module Global<ConfigSig ContentConfig> {
356349

357350
pragma[nomagic]
358351
private predicate step(Flow::PathNode pred, Flow::PathNode succ) {
359-
pathSucc(pred, succ) and
352+
pred.getASuccessor() = succ and
360353
not excludeStep(pred, succ)
361354
}
362355

@@ -471,7 +464,7 @@ module Global<ConfigSig ContentConfig> {
471464
exists(Flow::PathNode mid |
472465
nodeReaches(source, scReads, scStores, mid, reads, stores) and
473466
storeStep(mid.getNode(), mid.getState(), c, node.getNode(), node.getState()) and
474-
pathSucc(mid, node)
467+
mid.getASuccessor() = node
475468
)
476469
}
477470

@@ -483,7 +476,7 @@ module Global<ConfigSig ContentConfig> {
483476
exists(Flow::PathNode mid |
484477
nodeReaches(source, scReads, scStores, mid, reads, stores) and
485478
readStep(mid.getNode(), mid.getState(), c, node.getNode(), node.getState()) and
486-
pathSucc(mid, node)
479+
mid.getASuccessor() = node
487480
)
488481
}
489482

0 commit comments

Comments
 (0)