Skip to content

Commit 65d9327

Browse files
committed
Add CallNode class
1 parent 57d8ba6 commit 65d9327

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

ql/src/codeql_ruby/ApiGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module API {
4646
/**
4747
* Gets a call to a method on the receiver represented by this API component.
4848
*/
49-
DataFlow::Node getAMethodCall(string method) {
49+
DataFlow::CallNode getAMethodCall(string method) {
5050
result = getMethodCallNode(method).getAnImmediateUse()
5151
}
5252

ql/src/codeql_ruby/controlflow/CfgNodes.qll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ module ExprNodes {
235235
/** Gets the `n`th argument of this call. */
236236
final ExprCfgNode getArgument(int n) { e.hasCfgChild(e.getArgument(n), this, result) }
237237

238+
/** Gets the the keyword argument whose key is `keyword` of this call. */
239+
final ExprCfgNode getKeywordArgument(string keyword) {
240+
e.hasCfgChild(e.getKeywordArgument(keyword), this, result)
241+
}
242+
238243
/** Gets the number of arguments of this call. */
239244
final int getNumberOfArguments() { result = e.getNumberOfArguments() }
240245

ql/src/codeql_ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ class Node extends TNode {
3939
}
4040
}
4141

42+
/** A data-flow node corresponding to a call in the control-flow graph. */
43+
class CallNode extends LocalSourceNode {
44+
private CfgNodes::ExprNodes::CallCfgNode node;
45+
46+
CallNode() { node = this.asExpr() }
47+
48+
/** Gets the data-flow node corresponding to the receiver of the call corresponding to this data-flow node */
49+
Node getReceiver() { result.asExpr() = node.getReceiver() }
50+
51+
/** Gets the data-flow node corresponding to the `n`th argument of the call corresponding to this data-flow node */
52+
Node getArgument(int n) { result.asExpr() = node.getArgument(n) }
53+
54+
/** Gets the data-flow node corresponding to the named argument of the call corresponding to this data-flow node */
55+
Node getKeywordArgument(string name) { result.asExpr() = node.getKeywordArgument(name) }
56+
}
57+
4258
/**
4359
* An expression, viewed as a node in a data flow graph.
4460
*

0 commit comments

Comments
 (0)