Skip to content

Commit c8cdbfa

Browse files
committed
ruby: push getMethodName into DataFlow::CallNode
1 parent 286c894 commit c8cdbfa

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,9 @@ class CallNode extends LocalSourceNode {
5858

5959
/** Gets the data-flow node corresponding to the named argument of the call corresponding to this data-flow node */
6060
Node getKeywordArgument(string name) { result.asExpr() = node.getKeywordArgument(name) }
61-
}
62-
63-
/** A data-flow node corresponding to a method call in the control-flow graph. */
64-
class MethodCallNode extends CallNode {
65-
private CfgNodes::ExprNodes::MethodCallCfgNode node;
66-
67-
MethodCallNode() { node = this.asExpr() }
6861

69-
/** Gets the name of the the method called by the method call corresponding to this data-flow node */
70-
string getMethodName() { result = node.getExpr().getMethodName() }
62+
/** Gets the name of the the method called by the method call (if any) corresponding to this data-flow node */
63+
string getMethodName() { result = node.getExpr().(MethodCall).getMethodName() }
7164
}
7265

7366
/**

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ private import codeql.ruby.DataFlow
55
private import codeql.ruby.dataflow.FlowSummary
66

77
/** Defines calls to `ActiveStorage::Filename#sanitized` as path sanitizers. */
8-
class ActiveStorageFilenameSanitizedCall extends Path::PathSanitization::Range,
9-
DataFlow::MethodCallNode {
8+
class ActiveStorageFilenameSanitizedCall extends Path::PathSanitization::Range, DataFlow::CallNode {
109
ActiveStorageFilenameSanitizedCall() {
1110
this.getReceiver() =
1211
API::getTopLevelMember("ActiveStorage").getMember("Filename").getAnInstantiation() and

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ module IO {
9999
}
100100

101101
/**
102-
* A `DataFlow::MethodCallNode` that reads data using the `IO` class. For example,
102+
* A `DataFlow::CallNode` that reads data using the `IO` class. For example,
103103
* the `IO.read call in:
104104
*
105105
* ```rb
@@ -112,7 +112,7 @@ module IO {
112112
* filesystem. For working with filesystem accesses specifically, see
113113
* `IOFileReader` or the `FileSystemReadAccess` concept.
114114
*/
115-
class IOReader extends DataFlow::MethodCallNode {
115+
class IOReader extends DataFlow::CallNode {
116116
private boolean classMethodCall;
117117
private string api;
118118

@@ -149,7 +149,7 @@ module IO {
149149
}
150150

151151
/**
152-
* A `DataFlow::MethodCallNode` that reads data from the filesystem using the `IO`
152+
* A `DataFlow::CallNode` that reads data from the filesystem using the `IO`
153153
* class. For example, the `IO.read call in:
154154
*
155155
* ```rb
@@ -217,7 +217,7 @@ module File {
217217
/**
218218
* A call to a `File` method that may return one or more filenames.
219219
*/
220-
class FileModuleFilenameSource extends FileNameSource, DataFlow::MethodCallNode {
220+
class FileModuleFilenameSource extends FileNameSource, DataFlow::CallNode {
221221
FileModuleFilenameSource() {
222222
// Class methods
223223
this =
@@ -236,7 +236,7 @@ module File {
236236
}
237237

238238
private class FileModulePermissionModification extends FileSystemPermissionModification::Range,
239-
DataFlow::MethodCallNode {
239+
DataFlow::CallNode {
240240
private DataFlow::Node permissionArg;
241241

242242
FileModulePermissionModification() {
@@ -319,7 +319,7 @@ module FileUtils {
319319
}
320320

321321
private class FileUtilsPermissionModification extends FileSystemPermissionModification::Range,
322-
DataFlow::MethodCallNode {
322+
DataFlow::CallNode {
323323
private DataFlow::Node permissionArg;
324324

325325
FileUtilsPermissionModification() {

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class KernelMethodCall extends DataFlow::CallNode {
2626
)
2727
}
2828

29-
string getMethodName() { result = methodCall.getMethodName() }
30-
3129
int getNumberOfArguments() { result = methodCall.getNumberOfArguments() }
3230
}
3331

0 commit comments

Comments
 (0)