Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +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) }

/** 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() }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion ruby/ql/lib/codeql/ruby/frameworks/ActiveStorage.qll
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ActiveStorageFilenameSanitizedCall extends Path::PathSanitization::Range,
ActiveStorageFilenameSanitizedCall() {
this.getReceiver() =
API::getTopLevelMember("ActiveStorage").getMember("Filename").getAnInstantiation() and
this.asExpr().getExpr().(MethodCall).getMethodName() = "sanitized"
this.getMethodName() = "sanitized"
}
}

Expand Down
8 changes: 3 additions & 5 deletions ruby/ql/lib/codeql/ruby/frameworks/Files.qll
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,15 @@ module IO {
api = "IO" and
exists(IOInstanceStrict ii |
this.getReceiver() = ii and
this.asExpr().getExpr().(MethodCall).getMethodName() =
ioFileReaderMethodName(classMethodCall)
this.getMethodName() = ioFileReaderMethodName(classMethodCall)
)
or
// File instance methods
classMethodCall = false and
api = "File" and
exists(File::FileInstance fi |
this.getReceiver() = fi and
this.asExpr().getExpr().(MethodCall).getMethodName() =
ioFileReaderMethodName(classMethodCall)
this.getMethodName() = ioFileReaderMethodName(classMethodCall)
)
// TODO: enumeration style methods such as `each`, `foreach`, etc.
}
Expand Down Expand Up @@ -232,7 +230,7 @@ module File {
// Instance methods
exists(FileInstance fi |
this.getReceiver() = fi and
this.asExpr().getExpr().(MethodCall).getMethodName() = ["path", "to_path"]
this.getMethodName() = ["path", "to_path"]
)
}
}
Expand Down
2 changes: 0 additions & 2 deletions ruby/ql/lib/codeql/ruby/frameworks/StandardLibrary.qll
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class KernelMethodCall extends DataFlow::CallNode {
)
}

string getMethodName() { result = methodCall.getMethodName() }

int getNumberOfArguments() { result = methodCall.getNumberOfArguments() }
}

Expand Down