Skip to content

Commit 9a496e6

Browse files
committed
Ruby: Drive-by fix type-tracking through params with default values
1 parent d08c0f7 commit 9a496e6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,17 @@ private module Cached {
285285
// and we can remove this case.
286286
n.asExpr().getExpr() instanceof Self
287287
or
288+
// Nodes that can't be reached from another parameter or expression.
288289
not localFlowStepTypeTracker+(any(Node e |
289290
e instanceof ExprNode
290291
or
291292
e instanceof ParameterNode
292293
), n)
294+
or
295+
// Ensure all parameter SSA nodes are local sources -- this is needed by type tracking.
296+
// Note that when the parameter has a default value, it will be reachable from an
297+
// expression (the default value) and therefore won't be caught by the rule above.
298+
n = LocalFlow::getParameterDefNode(_)
293299
}
294300

295301
cached

0 commit comments

Comments
 (0)