Skip to content

Commit 573c5c5

Browse files
committed
Ruby: Rename getAnImmediateUse -> asSource
1 parent f2403e2 commit 573c5c5

File tree

11 files changed

+17
-24
lines changed

11 files changed

+17
-24
lines changed

ruby/ql/lib/codeql/ruby/ApiGraphs.qll

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module API {
111111
* Unlike `getAUse()`, this predicate only gets the immediate references, not the indirect uses
112112
* found via data flow.
113113
*/
114-
DataFlow::LocalSourceNode getAnImmediateUse() { Impl::use(this, result) }
114+
DataFlow::LocalSourceNode asSource() { Impl::use(this, result) }
115115

116116
/**
117117
* Gets a data-flow node corresponding the value flowing into this API component.
@@ -126,9 +126,7 @@ module API {
126126
/**
127127
* Gets a call to a method on the receiver represented by this API component.
128128
*/
129-
DataFlow::CallNode getAMethodCall(string method) {
130-
result = this.getReturn(method).getAnImmediateUse()
131-
}
129+
DataFlow::CallNode getAMethodCall(string method) { result = this.getReturn(method).asSource() }
132130

133131
/**
134132
* Gets a node representing member `m` of this API component.
@@ -203,7 +201,7 @@ module API {
203201
/**
204202
* Gets a `new` call to the function represented by this API component.
205203
*/
206-
DataFlow::ExprNode getAnInstantiation() { result = this.getInstance().getAnImmediateUse() }
204+
DataFlow::ExprNode getAnInstantiation() { result = this.getInstance().asSource() }
207205

208206
/**
209207
* Gets a node representing a (direct or indirect) subclass of the class represented by this node.

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ private module Config {
6363
)
6464
or
6565
// `Rails.application.config`
66-
this =
67-
API::getTopLevelMember("Rails")
68-
.getReturn("application")
69-
.getReturn("config")
70-
.getAnImmediateUse()
66+
this = API::getTopLevelMember("Rails").getReturn("application").getReturn("config").asSource()
7167
or
7268
// `Rails.application.configure { ... config ... }`
7369
// `Rails::Application.configure { ... config ... }`

ruby/ql/lib/codeql/ruby/frameworks/data/ModelsAsData.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private import codeql.ruby.dataflow.RemoteFlowSources
2525
* A remote flow source originating from a CSV source row.
2626
*/
2727
private class RemoteFlowSourceFromCsv extends RemoteFlowSource::Range {
28-
RemoteFlowSourceFromCsv() { this = ModelOutput::getASourceNode("remote").getAnImmediateUse() }
28+
RemoteFlowSourceFromCsv() { this = ModelOutput::getASourceNode("remote").asSource() }
2929

3030
override string getSourceType() { result = "Remote flow (from model)" }
3131
}

ruby/ql/lib/codeql/ruby/frameworks/http_clients/Excon.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class ExconHttpRequest extends HTTP::Client::Request::Range {
3030
DataFlow::Node connectionUse;
3131

3232
ExconHttpRequest() {
33-
requestUse = requestNode.getAnImmediateUse() and
34-
connectionUse = connectionNode.getAnImmediateUse() and
33+
requestUse = requestNode.asSource() and
34+
connectionUse = connectionNode.asSource() and
3535
connectionNode =
3636
[
3737
// one-off requests

ruby/ql/lib/codeql/ruby/frameworks/http_clients/Faraday.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class FaradayHttpRequest extends HTTP::Client::Request::Range {
3838
] and
3939
requestNode =
4040
connectionNode.getReturn(["get", "head", "delete", "post", "put", "patch", "trace"]) and
41-
requestUse = requestNode.getAnImmediateUse() and
42-
connectionUse = connectionNode.getAnImmediateUse() and
41+
requestUse = requestNode.asSource() and
42+
connectionUse = connectionNode.asSource() and
4343
this = requestUse.asExpr().getExpr()
4444
}
4545

ruby/ql/lib/codeql/ruby/frameworks/http_clients/HttpClient.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class HttpClientRequest extends HTTP::Client::Request::Range {
2929
API::getTopLevelMember("HTTPClient").getInstance()
3030
] and
3131
requestNode = connectionNode.getReturn(method) and
32-
requestUse = requestNode.getAnImmediateUse() and
32+
requestUse = requestNode.asSource() and
3333
method in [
3434
"get", "head", "delete", "options", "post", "put", "trace", "get_content", "post_content"
3535
] and
@@ -52,8 +52,7 @@ class HttpClientRequest extends HTTP::Client::Request::Range {
5252
// Look for calls to set
5353
// `c.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE`
5454
// on an HTTPClient connection object `c`.
55-
disablingNode =
56-
connectionNode.getReturn("ssl_config").getReturn("verify_mode=").getAnImmediateUse() and
55+
disablingNode = connectionNode.getReturn("ssl_config").getReturn("verify_mode=").asSource() and
5756
disablingNode.(DataFlow::CallNode).getArgument(0) =
5857
API::getTopLevelMember("OpenSSL").getMember("SSL").getMember("VERIFY_NONE").getAUse()
5958
}

ruby/ql/lib/codeql/ruby/frameworks/http_clients/Httparty.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HttpartyRequest extends HTTP::Client::Request::Range {
2828
DataFlow::CallNode requestUse;
2929

3030
HttpartyRequest() {
31-
requestUse = requestNode.getAnImmediateUse() and
31+
requestUse = requestNode.asSource() and
3232
requestNode =
3333
API::getTopLevelMember("HTTParty")
3434
.getReturn(["get", "head", "delete", "options", "post", "put", "patch"]) and

ruby/ql/lib/codeql/ruby/frameworks/http_clients/NetHttp.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NetHttpRequest extends HTTP::Client::Request::Range {
2525

2626
NetHttpRequest() {
2727
exists(string method |
28-
request = requestNode.getAnImmediateUse() and
28+
request = requestNode.asSource() and
2929
this = request.asExpr().getExpr()
3030
|
3131
// Net::HTTP.get(...)
@@ -59,7 +59,7 @@ class NetHttpRequest extends HTTP::Client::Request::Range {
5959
new = API::getTopLevelMember("Net").getMember("HTTP").getInstance() and
6060
requestNode = new.getReturn(_)
6161
|
62-
result = new.getAnImmediateUse().(DataFlow::CallNode).getArgument(0)
62+
result = new.asSource().(DataFlow::CallNode).getArgument(0)
6363
)
6464
}
6565

ruby/ql/lib/codeql/ruby/frameworks/http_clients/OpenURI.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class OpenUriRequest extends HTTP::Client::Request::Range {
2828
[API::getTopLevelMember("URI"), API::getTopLevelMember("URI").getReturn("parse")]
2929
.getReturn("open"), API::getTopLevelMember("OpenURI").getReturn("open_uri")
3030
] and
31-
requestUse = requestNode.getAnImmediateUse() and
31+
requestUse = requestNode.asSource() and
3232
this = requestUse.asExpr().getExpr()
3333
}
3434

ruby/ql/lib/codeql/ruby/frameworks/http_clients/RestClient.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RestClientHttpRequest extends HTTP::Client::Request::Range {
2222
API::Node connectionNode;
2323

2424
RestClientHttpRequest() {
25-
requestUse = requestNode.getAnImmediateUse() and
25+
requestUse = requestNode.asSource() and
2626
this = requestUse.asExpr().getExpr() and
2727
(
2828
connectionNode =

0 commit comments

Comments
 (0)