Skip to content

Commit 9e8cef5

Browse files
committed
Ruby: fix type-tracking flow-through for new->initialize calls
1 parent 93678e5 commit 9e8cef5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ruby/ql/lib/codeql/ruby/typetracking/TypeTrackerSpecific.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,23 @@ private predicate flowThrough(DataFlowPublic::ParameterNode param) {
8989
)
9090
}
9191

92+
/** Holds if there is flow from `arg` to `p` via the call `call`, not counting `new -> initialize` call steps. */
93+
pragma[nomagic]
94+
predicate callStepNoInitialize(
95+
ExprNodes::CallCfgNode call, Node arg, DataFlowPrivate::ParameterNodeImpl p
96+
) {
97+
exists(DataFlowDispatch::ParameterPosition pos |
98+
argumentPositionMatch(call, arg, pos) and
99+
p.isSourceParameterOf(DataFlowDispatch::getTarget(call), pos)
100+
)
101+
}
102+
92103
/** Holds if there is a level step from `nodeFrom` to `nodeTo`, which may depend on the call graph. */
93104
pragma[nomagic]
94105
predicate levelStepCall(Node nodeFrom, Node nodeTo) {
95106
exists(DataFlowPublic::ParameterNode param |
96107
flowThrough(param) and
97-
callStep(nodeTo.asExpr(), nodeFrom, param)
108+
callStepNoInitialize(nodeTo.asExpr(), nodeFrom, param)
98109
)
99110
}
100111

0 commit comments

Comments
 (0)