Skip to content

Ruby: Eliminate bad isLocalSourceNode antijoin #9262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,28 @@ private module Cached {
)
}

pragma[nomagic]
private predicate reachedFromExprOrEntrySsaDef(Node n) {
localFlowStepTypeTracker(any(Node n0 |
n0 instanceof ExprNode
or
entrySsaDefinition(n0)
), n)
or
exists(Node mid |
reachedFromExprOrEntrySsaDef(mid) and
localFlowStepTypeTracker(mid, n)
)
}

cached
predicate isLocalSourceNode(Node n) {
n instanceof ParameterNode
or
n instanceof PostUpdateNodes::ExprPostUpdateNode
or
// Nodes that can't be reached from another entry definition or expression.
not localFlowStepTypeTracker+(any(Node n0 |
n0 instanceof ExprNode
or
entrySsaDefinition(n0)
), n)
not reachedFromExprOrEntrySsaDef(n)
or
// Ensure all entry SSA definitions are local sources -- for parameters, this
// is needed by type tracking. Note that when the parameter has a default value,
Expand Down