Skip to content

Commit 25f0382

Browse files
committed
Ruby: replace asMethod with asCallableAstNode
1 parent af5a378 commit 25f0382

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ class ModuleNode instanceof Module {
822822
*
823823
* Does not take inheritance into account.
824824
*/
825-
MethodNode getAnOwnSingletonMethod() { result.asMethod() = super.getAnOwnSingletonMethod() }
825+
MethodNode getAnOwnSingletonMethod() {
826+
result.asCallableAstNode() = super.getAnOwnSingletonMethod()
827+
}
826828

827829
/**
828830
* Gets the singleton method named `name` declared in this module (or in a singleton class
@@ -841,7 +843,7 @@ class ModuleNode instanceof Module {
841843
* Does not take inheritance into account.
842844
*/
843845
MethodNode getAnOwnInstanceMethod() {
844-
result.asMethod() = this.getADeclaration().getAMethod().(Method)
846+
result.asCallableAstNode() = this.getADeclaration().getAMethod().(Method)
845847
}
846848

847849
/**
@@ -860,7 +862,7 @@ class ModuleNode instanceof Module {
860862
* Does not take inheritance into account.
861863
*/
862864
ParameterNode getAnOwnInstanceSelf() {
863-
result = TSelfParameterNode(this.getAnOwnInstanceMethod().asMethod())
865+
result = TSelfParameterNode(this.getAnOwnInstanceMethod().asCallableAstNode())
864866
}
865867

866868
/**
@@ -1015,10 +1017,10 @@ class MethodNode extends CallableNode {
10151017
MethodNode() { super.asCallableAstNode() instanceof MethodBase }
10161018

10171019
/** Gets the underlying AST node for this method. */
1018-
MethodBase asMethod() { result = this.asCallableAstNode() }
1020+
override MethodBase asCallableAstNode() { result = super.asCallableAstNode() }
10191021

10201022
/** Gets the name of this method. */
1021-
string getMethodName() { result = this.asMethod().getName() }
1023+
string getMethodName() { result = this.asCallableAstNode().getName() }
10221024
}
10231025

10241026
/**
@@ -1028,7 +1030,7 @@ class BlockNode extends CallableNode {
10281030
BlockNode() { super.asCallableAstNode() instanceof Block }
10291031

10301032
/** Gets the underlying AST node for this block. */
1031-
Block asBlock() { result = this.asCallableAstNode() }
1033+
override Block asCallableAstNode() { result = super.asCallableAstNode() }
10321034
}
10331035

10341036
/**

ruby/ql/lib/codeql/ruby/frameworks/ActionController.qll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ class ActionControllerClass extends DataFlow::ClassNode {
5555
/**
5656
* Gets an `ActionControllerActionMethod` defined in this class.
5757
*/
58-
ActionControllerActionMethod getAnAction() { result = this.getAnInstanceMethod().asMethod() }
58+
ActionControllerActionMethod getAnAction() {
59+
result = this.getAnInstanceMethod().asCallableAstNode()
60+
}
5961

6062
/**
6163
* Gets a `self` that possibly refers to an instance of this class.
@@ -99,7 +101,7 @@ class ActionControllerActionMethod extends Method, Http::Server::RequestHandler:
99101
private ActionControllerClass controllerClass;
100102

101103
ActionControllerActionMethod() {
102-
this = controllerClass.getAnInstanceMethod().asMethod() and not this.isPrivate()
104+
this = controllerClass.getAnInstanceMethod().asCallableAstNode() and not this.isPrivate()
103105
}
104106

105107
/**
@@ -140,7 +142,7 @@ class ActionControllerActionMethod extends Method, Http::Server::RequestHandler:
140142
exists(string name, DataFlow::MethodNode m |
141143
isRoute(result, name, controllerClass) and
142144
m = controllerClass.getInstanceMethod(name) and
143-
this = m.asMethod()
145+
this = m.asCallableAstNode()
144146
)
145147
}
146148
}
@@ -379,7 +381,7 @@ class RedirectToCall extends MethodCall {
379381
ActionControllerActionMethod getRedirectActionMethod() {
380382
exists(string name |
381383
this.getKeywordArgument("action").getConstantValue().isStringlikeValue(name) and
382-
result = controller.getInstanceMethod(name).asMethod()
384+
result = controller.getInstanceMethod(name).asCallableAstNode()
383385
)
384386
}
385387

@@ -441,7 +443,7 @@ class ActionControllerHelperMethod extends Method {
441443
exists(DataFlow::MethodNode m, string name |
442444
m = controllerClass.getInstanceMethod(name) and
443445
actionControllerHasHelperMethodCall(controllerClass, name) and
444-
this = m.asMethod()
446+
this = m.asCallableAstNode()
445447
)
446448
}
447449

0 commit comments

Comments
 (0)