Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1596436

Browse files
committed
rename getASourceUse to getAReference
1 parent adc0502 commit 1596436

2 files changed

Lines changed: 21 additions & 22 deletions

File tree

javascript/ql/src/semmle/javascript/ApiGraphs.qll

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,29 @@ module API {
2121
*/
2222
class Node extends Impl::TApiNode {
2323
/**
24-
* Gets a data-flow node corresponding to a use of the API component represented by this node.
24+
* Gets a `SourceNode` corresponding to a use of the API component represented by this node.
2525
*
2626
* For example, `require('fs').readFileSync` is a use of the function `readFileSync` from the
2727
* `fs` module, and `require('fs').readFileSync(file)` is a use of the result of that function.
2828
*
2929
* As another example, in the assignment `exports.plusOne = (x) => x+1` the two references to
3030
* `x` are uses of the first parameter of `plusOne`.
31+
*
32+
* Note: The result from this predicate is always a `DataFlow::SourceǸode`, use `getAUse()` if
33+
* you want to follow purely local data-flow and get all `DataFlow::Node`s that corrospond to a
34+
* use of this API node.
3135
*/
32-
DataFlow::Node getAUse() {
33-
exists(DataFlow::SourceNode src | Impl::use(this, src) |
34-
Impl::trackUseNode(src).flowsTo(result)
35-
)
36+
DataFlow::SourceNode getAReference() {
37+
exists(DataFlow::SourceNode src | Impl::use(this, src) | result = Impl::trackUseNode(src))
3638
}
3739

3840
/**
39-
* Gets a source-node corresponding to a use of the API component represented by this node.
40-
*
41-
* For example, `require('fs').readFileSync` is a use of the function `readFileSync` from the
42-
* `fs` module, and `require('fs').readFileSync(file)` is a use of the result of that function.
41+
* Gets a data-flow node corresponding to a use of the API component represented by this node.
4342
*
44-
* As another example, in the assignment `exports.plusOne = (x) => x+1` the two references to
45-
* `x` are uses of the first parameter of `plusOne`.
43+
* This predicate is similar to `getAReference`, except this prediate also follows purely local
44+
* data-flow.
4645
*/
47-
DataFlow::SourceNode getASourceUse() { Impl::use(this, result) }
46+
DataFlow::Node getAUse() { getAReference().flowsTo(result) }
4847

4948
/**
5049
* Gets a data-flow node corresponding to the right-hand side of a definition of the API

javascript/ql/src/semmle/javascript/frameworks/SQL.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private module MySql {
5454
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
5555
QueryCall() {
5656
exists(API::Node recv | recv = createPool() or recv = connection() |
57-
this = recv.getMember("query").getASourceUse().getACall()
57+
this = recv.getMember("query").getAReference().getACall()
5858
)
5959
}
6060

@@ -72,7 +72,7 @@ private module MySql {
7272
this =
7373
[mysql(), createPool(), connection()]
7474
.getMember(["escape", "escapeId"])
75-
.getASourceUse()
75+
.getAReference()
7676
.getACall()
7777
.asExpr() and
7878
input = this.getArgument(0) and
@@ -132,7 +132,7 @@ private module Postgres {
132132

133133
/** A call to the Postgres `query` method. */
134134
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
135-
QueryCall() { this = [client(), newPool()].getMember("query").getASourceUse().getACall() }
135+
QueryCall() { this = [client(), newPool()].getMember("query").getAReference().getACall() }
136136

137137
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
138138
}
@@ -190,7 +190,7 @@ private module Sqlite {
190190
meth = "prepare" or
191191
meth = "run"
192192
|
193-
this = newDb().getMember(meth).getASourceUse().getACall()
193+
this = newDb().getMember(meth).getAReference().getACall()
194194
)
195195
}
196196

@@ -234,7 +234,7 @@ private module MsSql {
234234

235235
/** A call to a MsSql query method. */
236236
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
237-
QueryCall() { this = request().getMember(["query", "batch"]).getASourceUse().getACall() }
237+
QueryCall() { this = request().getMember(["query", "batch"]).getAReference().getACall() }
238238

239239
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
240240
}
@@ -293,7 +293,7 @@ private module Sequelize {
293293

294294
/** A call to `Sequelize.query`. */
295295
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
296-
QueryCall() { this = newSequelize().getMember("query").getASourceUse().getACall() }
296+
QueryCall() { this = newSequelize().getMember("query").getAReference().getACall() }
297297

298298
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
299299
}
@@ -312,7 +312,7 @@ private module Sequelize {
312312

313313
Credentials() {
314314
exists(NewExpr ne, string prop |
315-
ne = sequelize().getASourceUse().getAnInstantiation().asExpr() and
315+
ne = sequelize().getAReference().getAnInstantiation().asExpr() and
316316
(
317317
this = ne.getArgument(1) and prop = "username"
318318
or
@@ -393,7 +393,7 @@ private module Spanner {
393393
this =
394394
database()
395395
.getMember(["run", "runPartitionedUpdate", "runStream"])
396-
.getASourceUse()
396+
.getAReference()
397397
.getACall()
398398
}
399399
}
@@ -403,7 +403,7 @@ private module Spanner {
403403
*/
404404
class TransactionRunCall extends SqlExecution {
405405
TransactionRunCall() {
406-
this = transaction().getMember(["run", "runStream", "runUpdate"]).getASourceUse().getACall()
406+
this = transaction().getMember(["run", "runStream", "runUpdate"]).getAReference().getACall()
407407
}
408408
}
409409

@@ -415,7 +415,7 @@ private module Spanner {
415415
this =
416416
v1SpannerClient()
417417
.getMember(["executeSql", "executeStreamingSql"])
418-
.getASourceUse()
418+
.getAReference()
419419
.getACall()
420420
}
421421

0 commit comments

Comments
 (0)