Skip to content

Commit 5858732

Browse files
committed
Ruby: change useStep signature
1 parent e6fdd4d commit 5858732

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

ruby/ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -289,22 +289,22 @@ module API {
289289
* Holds if `ref` is a use of a node that should have an incoming edge labeled `lbl`,
290290
* from a use node that flows to `node`.
291291
*/
292-
private predicate useStep(string lbl, ExprCfgNode node, DataFlow::Node ref) {
292+
private predicate useStep(string lbl, DataFlow::Node node, DataFlow::Node ref) {
293293
// // Referring to an attribute on a node that is a use of `base`:
294294
// pred = `Rails` part of `Rails::Whatever`
295295
// lbl = `Whatever`
296296
// ref = `Rails::Whatever`
297297
exists(ExprNodes::ConstantAccessCfgNode c, ConstantReadAccess read |
298298
not exists(resolveTopLevel(read)) and
299-
node = c.getScopeExpr() and
299+
node.asExpr() = c.getScopeExpr() and
300300
lbl = Label::member(read.getName()) and
301301
ref.asExpr() = c and
302302
read = c.getExpr()
303303
)
304304
or
305305
// Calling a method on a node that is a use of `base`
306306
exists(ExprNodes::MethodCallCfgNode call, string name |
307-
node = call.getReceiver() and
307+
node.asExpr() = call.getReceiver() and
308308
name = call.getExpr().getMethodName() and
309309
lbl = Label::return(name) and
310310
name != "new" and
@@ -313,7 +313,7 @@ module API {
313313
or
314314
// Calling the `new` method on a node that is a use of `base`, which creates a new instance
315315
exists(ExprNodes::MethodCallCfgNode call |
316-
node = call.getReceiver() and
316+
node.asExpr() = call.getReceiver() and
317317
lbl = Label::instance() and
318318
call.getExpr().getMethodName() = "new" and
319319
ref.asExpr() = call
@@ -324,9 +324,8 @@ module API {
324324
private predicate isUse(DataFlow::Node nd) {
325325
useRoot(_, nd)
326326
or
327-
exists(ExprCfgNode node, DataFlow::LocalSourceNode pred |
328-
pred = useCandFwd() and
329-
pred.flowsTo(any(DataFlow::ExprNode n | n.getExprNode() = node)) and
327+
exists(DataFlow::Node node |
328+
useCandFwd().flowsTo(node) and
330329
useStep(_, node, nd)
331330
)
332331
}
@@ -401,9 +400,9 @@ module API {
401400
pred = MkRoot() and
402401
useRoot(lbl, ref)
403402
or
404-
exists(ExprCfgNode node, DataFlow::Node src |
403+
exists(DataFlow::Node node, DataFlow::Node src |
405404
pred = MkUse(src) and
406-
trackUseNode(src).flowsTo(any(DataFlow::ExprNode n | n.getExprNode() = node)) and
405+
trackUseNode(src).flowsTo(node) and
407406
useStep(lbl, node, ref)
408407
)
409408
)

0 commit comments

Comments
 (0)