Skip to content

Ruby: Add getBlock and getNumberOfArguments predicates to DataFlow::CallNode #7391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 14, 2021
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 @@ -61,6 +61,12 @@ class CallNode extends LocalSourceNode {

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

/** Gets the number of arguments of this call. */
int getNumberOfArguments() { result = node.getNumberOfArguments() }

/** Gets the block of this call. */
Node getBlock() { result.asExpr() = node.getBlock() }
}

/**
Expand Down
4 changes: 1 addition & 3 deletions ruby/ql/lib/codeql/ruby/frameworks/Rails.qll
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private class ConfigSourceNode extends DataFlow::LocalSourceNode {
configCall = this.asExpr().getExpr()
|
configureCallNode = getAConfigureCallNode() and
block = configureCallNode.asExpr().getExpr().(MethodCall).getBlock() and
block = configureCallNode.getBlock().asExpr().getExpr() and
configCall.getParent+() = block and
configCall.getMethodName() = "config"
)
Expand All @@ -84,8 +84,6 @@ private class CallAgainstConfig extends DataFlow::CallNode {
CallAgainstConfig() { this.getReceiver() instanceof ConfigNode }

MethodCall getCall() { result = this.asExpr().getExpr() }

Block getBlock() { result = this.getCall().getBlock() }
}

private class ActionControllerConfigNode extends DataFlow::Node {
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 {
)
)
}

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

/**
Expand Down