ruby: push getMethodName into DataFlow::CallNode

This commit is contained in:
Alex Ford
2021-11-16 17:11:26 +00:00
parent 286c894f34
commit c8cdbfa352
4 changed files with 9 additions and 19 deletions

View File

@@ -58,16 +58,9 @@ class CallNode extends LocalSourceNode {
/** Gets the data-flow node corresponding to the named argument of the call corresponding to this data-flow node */
Node getKeywordArgument(string name) { result.asExpr() = node.getKeywordArgument(name) }
}
/** A data-flow node corresponding to a method call in the control-flow graph. */
class MethodCallNode extends CallNode {
private CfgNodes::ExprNodes::MethodCallCfgNode node;
MethodCallNode() { node = this.asExpr() }
/** Gets the name of the the method called by the method call corresponding to this data-flow node */
string getMethodName() { result = node.getExpr().getMethodName() }
/** Gets the name of the the method called by the method call (if any) corresponding to this data-flow node */
string getMethodName() { result = node.getExpr().(MethodCall).getMethodName() }
}
/**

View File

@@ -5,8 +5,7 @@ private import codeql.ruby.DataFlow
private import codeql.ruby.dataflow.FlowSummary
/** Defines calls to `ActiveStorage::Filename#sanitized` as path sanitizers. */
class ActiveStorageFilenameSanitizedCall extends Path::PathSanitization::Range,
DataFlow::MethodCallNode {
class ActiveStorageFilenameSanitizedCall extends Path::PathSanitization::Range, DataFlow::CallNode {
ActiveStorageFilenameSanitizedCall() {
this.getReceiver() =
API::getTopLevelMember("ActiveStorage").getMember("Filename").getAnInstantiation() and

View File

@@ -99,7 +99,7 @@ module IO {
}
/**
* A `DataFlow::MethodCallNode` that reads data using the `IO` class. For example,
* A `DataFlow::CallNode` that reads data using the `IO` class. For example,
* the `IO.read call in:
*
* ```rb
@@ -112,7 +112,7 @@ module IO {
* filesystem. For working with filesystem accesses specifically, see
* `IOFileReader` or the `FileSystemReadAccess` concept.
*/
class IOReader extends DataFlow::MethodCallNode {
class IOReader extends DataFlow::CallNode {
private boolean classMethodCall;
private string api;
@@ -149,7 +149,7 @@ module IO {
}
/**
* A `DataFlow::MethodCallNode` that reads data from the filesystem using the `IO`
* A `DataFlow::CallNode` that reads data from the filesystem using the `IO`
* class. For example, the `IO.read call in:
*
* ```rb
@@ -217,7 +217,7 @@ module File {
/**
* A call to a `File` method that may return one or more filenames.
*/
class FileModuleFilenameSource extends FileNameSource, DataFlow::MethodCallNode {
class FileModuleFilenameSource extends FileNameSource, DataFlow::CallNode {
FileModuleFilenameSource() {
// Class methods
this =
@@ -236,7 +236,7 @@ module File {
}
private class FileModulePermissionModification extends FileSystemPermissionModification::Range,
DataFlow::MethodCallNode {
DataFlow::CallNode {
private DataFlow::Node permissionArg;
FileModulePermissionModification() {
@@ -319,7 +319,7 @@ module FileUtils {
}
private class FileUtilsPermissionModification extends FileSystemPermissionModification::Range,
DataFlow::MethodCallNode {
DataFlow::CallNode {
private DataFlow::Node permissionArg;
FileUtilsPermissionModification() {

View File

@@ -26,8 +26,6 @@ class KernelMethodCall extends DataFlow::CallNode {
)
}
string getMethodName() { result = methodCall.getMethodName() }
int getNumberOfArguments() { result = methodCall.getNumberOfArguments() }
}