Skip to content

Commit 8b85744

Browse files
committed
Ruby: use lambdaCreation and handle "proc" in there
1 parent 4ae90e3 commit 8b85744

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
13001300
creation.asExpr() =
13011301
any(CfgNodes::ExprNodes::MethodCallCfgNode mc |
13021302
c.asCallable() = mc.getBlock().getExpr() and
1303-
mc.getExpr().getMethodName() = "lambda"
1303+
mc.getExpr().getMethodName() = ["lambda", "proc"]
13041304
)
13051305
)
13061306
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ class Node extends TNode {
7373
CallableNode asCallable() {
7474
result = this
7575
or
76-
exists(CallNode call |
77-
call.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
78-
call.getMethodName() = ["proc", "lambda"] and
79-
call.getBlock() = result and
80-
this = call
76+
exists(DataFlowCallable c |
77+
lambdaCreation(this, _, c) and
78+
result.asCallableAstNode() = c.asCallable()
8179
)
8280
}
8381
}

0 commit comments

Comments
 (0)