Skip to content

Commit 64be958

Browse files
authored
Merge pull request #9262 from hvitved/ruby/local-source-node-antijoin
Ruby: Eliminate bad `isLocalSourceNode` antijoin
2 parents 23d64ff + bbdedf5 commit 64be958

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,18 +298,28 @@ private module Cached {
298298
)
299299
}
300300

301+
pragma[nomagic]
302+
private predicate reachedFromExprOrEntrySsaDef(Node n) {
303+
localFlowStepTypeTracker(any(Node n0 |
304+
n0 instanceof ExprNode
305+
or
306+
entrySsaDefinition(n0)
307+
), n)
308+
or
309+
exists(Node mid |
310+
reachedFromExprOrEntrySsaDef(mid) and
311+
localFlowStepTypeTracker(mid, n)
312+
)
313+
}
314+
301315
cached
302316
predicate isLocalSourceNode(Node n) {
303317
n instanceof ParameterNode
304318
or
305319
n instanceof PostUpdateNodes::ExprPostUpdateNode
306320
or
307321
// Nodes that can't be reached from another entry definition or expression.
308-
not localFlowStepTypeTracker+(any(Node n0 |
309-
n0 instanceof ExprNode
310-
or
311-
entrySsaDefinition(n0)
312-
), n)
322+
not reachedFromExprOrEntrySsaDef(n)
313323
or
314324
// Ensure all entry SSA definitions are local sources -- for parameters, this
315325
// is needed by type tracking. Note that when the parameter has a default value,

0 commit comments

Comments
 (0)