Skip to content

Commit 631527f

Browse files
committed
JS: Rename Node.{getASource -> asSource, getASink -> asSink}
1 parent bc60126 commit 631527f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+197
-198
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ module API {
2828
* The most basic use of API graphs is typically as follows:
2929
* 1. Start with `API::moduleImport` for the relevant library.
3030
* 2. Follow up with a chain of accessors such as `getMember` describing how to get to the relevant API function.
31-
* 3. Map the resulting API graph nodes to data-flow nodes, using `getASource` or `getASink`.
31+
* 3. Map the resulting API graph nodes to data-flow nodes, using `asSource` or `asSink`.
3232
*
3333
* For example, a simplified way to get arguments to `underscore.extend` would be
3434
* ```ql
35-
* API::moduleImport("underscore").getMember("extend").getParameter(0).getASink()
35+
* API::moduleImport("underscore").getMember("extend").getParameter(0).asSink()
3636
* ```
3737
*
3838
* The most commonly used accessors are `getMember`, `getParameter`, and `getReturn`.
@@ -121,48 +121,48 @@ module API {
121121
/**
122122
* Get a data-flow node where this value may flow after entering the current codebase.
123123
*
124-
* This is similar to `getASource()` but additionally includes nodes that are transitively reachable by data flow.
125-
* See `getASource()` for examples.
124+
* This is similar to `asSource()` but additionally includes nodes that are transitively reachable by data flow.
125+
* See `asSource()` for examples.
126126
*/
127127
pragma[inline]
128128
DataFlow::Node getAValueReachableFromSource() {
129-
Impl::trackUseNode(this.getASource()).flowsTo(result)
129+
Impl::trackUseNode(this.asSource()).flowsTo(result)
130130
}
131131

132132
/**
133133
* Get a data-flow node where this value enters the current codebase.
134134
*
135135
* For example:
136136
* ```js
137-
* // API::moduleImport("fs").getASource()
137+
* // API::moduleImport("fs").asSource()
138138
* require('fs');
139139
*
140-
* // API::moduleImport("fs").getMember("readFile").getASource()
140+
* // API::moduleImport("fs").getMember("readFile").asSource()
141141
* require('fs').readFile;
142142
*
143-
* // API::moduleImport("fs").getMember("readFile").getReturn().getASource()
143+
* // API::moduleImport("fs").getMember("readFile").getReturn().asSource()
144144
* require('fs').readFile();
145145
*
146146
* require('fs').readFile(
147147
* filename,
148-
* // 'y' matched by API::moduleImport("fs").getMember("readFile").getParameter(1).getParameter(0).getASource()
148+
* // 'y' matched by API::moduleImport("fs").getMember("readFile").getParameter(1).getParameter(0).asSource()
149149
* y => {
150150
* ...
151151
* });
152152
* ```
153153
*/
154-
DataFlow::SourceNode getASource() { Impl::use(this, result) }
154+
DataFlow::SourceNode asSource() { Impl::use(this, result) }
155155

156-
/** DEPRECATED. This predicate has been renamed to `getASource`. */
157-
deprecated DataFlow::SourceNode getAnImmediateUse() { result = this.getASource() }
156+
/** DEPRECATED. This predicate has been renamed to `asSource`. */
157+
deprecated DataFlow::SourceNode getAnImmediateUse() { result = this.asSource() }
158158

159159
/** DEPRECATED. This predicate has been renamed to `getAValueReachableFromSource`. */
160160
deprecated DataFlow::Node getAUse() { result = this.getAValueReachableFromSource() }
161161

162162
/**
163163
* Gets a call to the function represented by this API component.
164164
*/
165-
CallNode getACall() { result = this.getReturn().getASource() }
165+
CallNode getACall() { result = this.getReturn().asSource() }
166166

167167
/**
168168
* Gets a call to the function represented by this API component,
@@ -177,7 +177,7 @@ module API {
177177
/**
178178
* Gets a `new` call to the function represented by this API component.
179179
*/
180-
NewNode getAnInstantiation() { result = this.getInstance().getASource() }
180+
NewNode getAnInstantiation() { result = this.getInstance().asSource() }
181181

182182
/**
183183
* Gets an invocation (with our without `new`) to the function represented by this API component.
@@ -193,27 +193,27 @@ module API {
193193
*
194194
* For example:
195195
* ```js
196-
* // 'x' is matched by API::moduleImport("foo").getParameter(0).getASink()
196+
* // 'x' is matched by API::moduleImport("foo").getParameter(0).asSink()
197197
* require('foo')(x);
198198
*
199-
* // 'x' is matched by API::moduleImport("foo").getParameter(0).getMember("prop").getASink()
199+
* // 'x' is matched by API::moduleImport("foo").getParameter(0).getMember("prop").asSink()
200200
* require('foo')({
201201
* prop: x
202202
* });
203203
* ```
204204
*/
205-
DataFlow::Node getASink() { Impl::rhs(this, result) }
205+
DataFlow::Node asSink() { Impl::rhs(this, result) }
206206

207207
/**
208208
* Get a data-flow node that transitively flows to an external library (or in general, any external codebase).
209209
*
210-
* This is similar to `getASink()` but additionally includes nodes that transitively reach a sink by data flow.
211-
* See `getASink()` for examples.
210+
* This is similar to `asSink()` but additionally includes nodes that transitively reach a sink by data flow.
211+
* See `asSink()` for examples.
212212
*/
213-
DataFlow::Node getAValueReachingSink() { result = Impl::trackDefNode(this.getASink()) }
213+
DataFlow::Node getAValueReachingSink() { result = Impl::trackDefNode(this.asSink()) }
214214

215-
/** DEPRECATED. This predicate has been renamed to `getASink`. */
216-
deprecated DataFlow::Node getARhs() { result = this.getASink() }
215+
/** DEPRECATED. This predicate has been renamed to `asSink`. */
216+
deprecated DataFlow::Node getARhs() { result = this.asSink() }
217217

218218
/** DEPRECATED. This predicate has been renamed to `getAValueReachingSink`. */
219219
deprecated DataFlow::Node getAValueReachingRhs() { result = this.getAValueReachingSink() }
@@ -451,7 +451,7 @@ module API {
451451
* In other words, the value of a use of `that` may flow into the right-hand side of a
452452
* definition of this node.
453453
*/
454-
predicate refersTo(Node that) { this.getASink() = that.getAValueReachableFromSource() }
454+
predicate refersTo(Node that) { this.asSink() = that.getAValueReachableFromSource() }
455455

456456
/**
457457
* Gets the data-flow node that gives rise to this node, if any.
@@ -1301,8 +1301,8 @@ module API {
13011301
API::Node callee;
13021302

13031303
InvokeNode() {
1304-
this = callee.getReturn().getASource() or
1305-
this = callee.getInstance().getASource() or
1304+
this = callee.getReturn().asSource() or
1305+
this = callee.getInstance().asSource() or
13061306
this = Impl::getAPromisifiedInvocation(callee, _, _)
13071307
}
13081308

@@ -1317,7 +1317,7 @@ module API {
13171317
* Gets an API node where a RHS of the node is the `i`th argument to this call.
13181318
*/
13191319
pragma[noinline]
1320-
private Node getAParameterCandidate(int i) { result.getASink() = this.getArgument(i) }
1320+
private Node getAParameterCandidate(int i) { result.asSink() = this.getArgument(i) }
13211321

13221322
/** Gets the API node for a parameter of this invocation. */
13231323
Node getAParameter() { result = this.getParameter(_) }
@@ -1328,13 +1328,13 @@ module API {
13281328
/** Gets the API node for the return value of this call. */
13291329
Node getReturn() {
13301330
result = callee.getReturn() and
1331-
result.getASource() = this
1331+
result.asSource() = this
13321332
}
13331333

13341334
/** Gets the API node for the object constructed by this invocation. */
13351335
Node getInstance() {
13361336
result = callee.getInstance() and
1337-
result.getASource() = this
1337+
result.asSource() = this
13381338
}
13391339
}
13401340

javascript/ql/lib/semmle/javascript/JsonParsers.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private class PlainJsonParserCall extends JsonParserCall {
2929
callee =
3030
DataFlow::moduleMember(["json3", "json5", "flatted", "teleport-javascript", "json-cycle"],
3131
"parse") or
32-
callee = API::moduleImport("replicator").getInstance().getMember("decode").getASource() or
32+
callee = API::moduleImport("replicator").getInstance().getMember("decode").asSource() or
3333
callee = DataFlow::moduleImport("parse-json") or
3434
callee = DataFlow::moduleImport("json-parse-better-errors") or
3535
callee = DataFlow::moduleImport("json-safe-parse") or

javascript/ql/lib/semmle/javascript/JsonSchema.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ module JsonSchema {
134134
.ref()
135135
.getMember(["addSchema", "validate", "compile", "compileAsync"])
136136
.getParameter(0)
137-
.getASink()
137+
.asSink()
138138
}
139139
}
140140
}
@@ -184,7 +184,7 @@ module JsonSchema {
184184
override boolean getPolarity() { none() }
185185

186186
override DataFlow::Node getAValidationResultAccess(boolean polarity) {
187-
result = this.getReturn().getMember("error").getASource() and
187+
result = this.getReturn().getMember("error").asSource() and
188188
polarity = false
189189
}
190190
}

javascript/ql/lib/semmle/javascript/JsonStringifiers.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class JsonStringifyCall extends DataFlow::CallNode {
1414
callee =
1515
DataFlow::moduleMember(["json3", "json5", "flatted", "teleport-javascript", "json-cycle"],
1616
"stringify") or
17-
callee = API::moduleImport("replicator").getInstance().getMember("encode").getASource() or
17+
callee = API::moduleImport("replicator").getInstance().getMember("encode").asSource() or
1818
callee =
1919
DataFlow::moduleImport([
2020
"json-stringify-safe", "json-stable-stringify", "stringify-object",

javascript/ql/lib/semmle/javascript/frameworks/Babel.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ module Babel {
198198
.getMember(["transform", "transformSync", "transformAsync"])
199199
.getACall() and
200200
pred = call.getArgument(0) and
201-
succ = [call, call.getParameter(2).getParameter(0).getASource()]
201+
succ = [call, call.getParameter(2).getParameter(0).asSource()]
202202
)
203203
}
204204
}

javascript/ql/lib/semmle/javascript/frameworks/ClientRequests.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ module ClientRequest {
265265
or
266266
responseType = this.getResponseType() and
267267
promise = false and
268-
result = this.getReturn().getPromisedError().getMember("response").getASource()
268+
result = this.getReturn().getPromisedError().getMember("response").asSource()
269269
}
270270
}
271271

@@ -463,7 +463,7 @@ module ClientRequest {
463463
*/
464464
private API::Node netSocketInstantiation(DataFlow::NewNode socket) {
465465
result = API::moduleImport("net").getMember("Socket").getInstance() and
466-
socket = result.getASource()
466+
socket = result.asSource()
467467
}
468468

469469
/**
@@ -827,7 +827,7 @@ module ClientRequest {
827827
class ApolloClientRequest extends ClientRequest::Range, API::InvokeNode {
828828
ApolloClientRequest() { this = apolloUriCallee().getAnInvocation() }
829829

830-
override DataFlow::Node getUrl() { result = this.getParameter(0).getMember("uri").getASink() }
830+
override DataFlow::Node getUrl() { result = this.getParameter(0).getMember("uri").asSink() }
831831

832832
override DataFlow::Node getHost() { none() }
833833

@@ -848,10 +848,10 @@ module ClientRequest {
848848

849849
override DataFlow::Node getUrl() { result = this.getArgument(0) }
850850

851-
override DataFlow::Node getHost() { result = this.getParameter(0).getMember("host").getASink() }
851+
override DataFlow::Node getHost() { result = this.getParameter(0).getMember("host").asSink() }
852852

853853
override DataFlow::Node getADataNode() {
854-
result = form.getMember("append").getACall().getParameter(1).getASink()
854+
result = form.getMember("append").getACall().getParameter(1).asSink()
855855
}
856856
}
857857
}

javascript/ql/lib/semmle/javascript/frameworks/Credentials.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ private class CredentialsFromModel extends CredentialsExpr {
2121
string kind;
2222

2323
CredentialsFromModel() {
24-
this = ModelOutput::getASinkNode("credentials[" + kind + "]").getASink().asExpr()
24+
this = ModelOutput::getASinkNode("credentials[" + kind + "]").asSink().asExpr()
2525
}
2626

2727
override string getCredentialsKind() { result = kind }

javascript/ql/lib/semmle/javascript/frameworks/D3.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ module D3 {
6969
D3XssSink() {
7070
exists(API::Node htmlArg |
7171
htmlArg = d3Selection().getMember("html").getParameter(0) and
72-
this = [htmlArg, htmlArg.getReturn()].getASink()
72+
this = [htmlArg, htmlArg.getReturn()].asSink()
7373
)
7474
}
7575
}
7676

7777
private class D3DomValueSource extends DOM::DomValueSource::Range {
7878
D3DomValueSource() {
79-
this = d3Selection().getMember("each").getReceiver().getASource()
79+
this = d3Selection().getMember("each").getReceiver().asSource()
8080
or
81-
this = d3Selection().getMember("node").getReturn().getASource()
81+
this = d3Selection().getMember("node").getReturn().asSource()
8282
or
83-
this = d3Selection().getMember("nodes").getReturn().getUnknownMember().getASource()
83+
this = d3Selection().getMember("nodes").getReturn().getUnknownMember().asSource()
8484
}
8585
}
8686

javascript/ql/lib/semmle/javascript/frameworks/Electron.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ module Electron {
5656
}
5757
}
5858

59-
private API::Node browserObject() { result.getASource() instanceof NewBrowserObject }
59+
private API::Node browserObject() { result.asSource() instanceof NewBrowserObject }
6060

6161
/**
6262
* A data flow node whose value may originate from a browser object instantiation.

javascript/ql/lib/semmle/javascript/frameworks/Files.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private API::Node globbyFileNameSource() {
8989
* A file name or an array of file names from the `globby` library.
9090
*/
9191
private class GlobbyFileNameSource extends FileNameSource {
92-
GlobbyFileNameSource() { this = globbyFileNameSource().getASource() }
92+
GlobbyFileNameSource() { this = globbyFileNameSource().asSource() }
9393
}
9494

9595
/** Gets a file name or an array of file names from the `fast-glob` library. */
@@ -116,7 +116,7 @@ private API::Node fastGlobFileName() {
116116
* A file name or an array of file names from the `fast-glob` library.
117117
*/
118118
private class FastGlobFileNameSource extends FileNameSource {
119-
FastGlobFileNameSource() { this = fastGlobFileName().getASource() }
119+
FastGlobFileNameSource() { this = fastGlobFileName().asSource() }
120120
}
121121

122122
/**
@@ -200,7 +200,7 @@ private class RecursiveReadDir extends FileSystemAccess, FileNameProducer, API::
200200

201201
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
202202

203-
override DataFlow::Node getAFileName() { result = this.trackFileSource().getASource() }
203+
override DataFlow::Node getAFileName() { result = this.trackFileSource().asSource() }
204204

205205
private API::Node trackFileSource() {
206206
result = this.getParameter([1 .. 2]).getParameter(1)
@@ -223,7 +223,7 @@ private module JsonFile {
223223

224224
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
225225

226-
override DataFlow::Node getADataNode() { result = this.trackRead().getASource() }
226+
override DataFlow::Node getADataNode() { result = this.trackRead().asSource() }
227227

228228
private API::Node trackRead() {
229229
this.getCalleeName() = "readFile" and
@@ -272,7 +272,7 @@ private class LoadJsonFile extends FileSystemReadAccess, API::CallNode {
272272

273273
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
274274

275-
override DataFlow::Node getADataNode() { result = this.trackRead().getASource() }
275+
override DataFlow::Node getADataNode() { result = this.trackRead().asSource() }
276276

277277
private API::Node trackRead() {
278278
this.getCalleeName() = "sync" and result = this.getReturn()
@@ -310,7 +310,7 @@ private class WalkDir extends FileNameProducer, FileSystemAccess, API::CallNode
310310

311311
override DataFlow::Node getAPathArgument() { result = this.getArgument(0) }
312312

313-
override DataFlow::Node getAFileName() { result = this.trackFileSource().getASource() }
313+
override DataFlow::Node getAFileName() { result = this.trackFileSource().asSource() }
314314

315315
private API::Node trackFileSource() {
316316
not this.getCalleeName() = ["sync", "async"] and

0 commit comments

Comments
 (0)