Skip to content

Commit 897a3e3

Browse files
committed
JS: Autoformat
1 parent 435f9ea commit 897a3e3

File tree

1 file changed

+39
-111
lines changed
  • javascript/ql/src/semmle/javascript/frameworks

1 file changed

+39
-111
lines changed

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

Lines changed: 39 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,23 @@ module SQL {
2828
* Provides classes modelling the (API compatible) `mysql` and `mysql2` packages.
2929
*/
3030
private module MySql {
31-
private DataFlow::SourceNode mysql() {
32-
result = DataFlow::moduleImport(["mysql", "mysql2"])
33-
}
31+
private DataFlow::SourceNode mysql() { result = DataFlow::moduleImport(["mysql", "mysql2"]) }
3432

35-
private DataFlow::CallNode createPool() {
36-
result = mysql().getAMemberCall("createPool")
37-
}
33+
private DataFlow::CallNode createPool() { result = mysql().getAMemberCall("createPool") }
3834

3935
/** Gets a call to `mysql.createPool`. */
4036
private DataFlow::SourceNode pool(DataFlow::TypeTracker t) {
4137
t.start() and
4238
result = createPool()
4339
or
44-
exists(DataFlow::TypeTracker t2 |
45-
result = pool(t2).track(t2, t)
46-
)
40+
exists(DataFlow::TypeTracker t2 | result = pool(t2).track(t2, t))
4741
}
4842

4943
/** Gets a call to `mysql.createPool`. */
50-
private DataFlow::SourceNode pool() {
51-
result = pool(DataFlow::TypeTracker::end())
52-
}
44+
private DataFlow::SourceNode pool() { result = pool(DataFlow::TypeTracker::end()) }
5345

5446
/** Gets a call to `mysql.createConnection`. */
55-
DataFlow::CallNode createConnection() {
56-
result = mysql().getAMemberCall("createConnection")
57-
}
47+
DataFlow::CallNode createConnection() { result = mysql().getAMemberCall("createConnection") }
5848

5949
/** Gets a data flow node that contains a freshly created MySQL connection instance. */
6050
private DataFlow::SourceNode connection(DataFlow::TypeTracker t) {
@@ -65,25 +55,17 @@ private module MySql {
6555
result = pool().getAMethodCall("getConnection").getABoundCallbackParameter(0, 1)
6656
)
6757
or
68-
exists(DataFlow::TypeTracker t2 |
69-
result = connection(t2).track(t2, t)
70-
)
58+
exists(DataFlow::TypeTracker t2 | result = connection(t2).track(t2, t))
7159
}
7260

7361
/** Gets a data flow node that contains a freshly created MySQL connection instance. */
74-
DataFlow::SourceNode connection() {
75-
result = connection(DataFlow::TypeTracker::end())
76-
}
62+
DataFlow::SourceNode connection() { result = connection(DataFlow::TypeTracker::end()) }
7763

7864
/** A call to the MySql `query` method. */
7965
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
80-
QueryCall() {
81-
this = [pool(), connection()].getAMethodCall("query")
82-
}
66+
QueryCall() { this = [pool(), connection()].getAMethodCall("query") }
8367

84-
override DataFlow::Node getAQueryArgument() {
85-
result = getArgument(0)
86-
}
68+
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
8769
}
8870

8971
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -137,15 +119,11 @@ private module Postgres {
137119
t.start() and
138120
result = newPool()
139121
or
140-
exists(DataFlow::TypeTracker t2 |
141-
result = pool(t2).track(t2, t)
142-
)
122+
exists(DataFlow::TypeTracker t2 | result = pool(t2).track(t2, t))
143123
}
144-
124+
145125
/** Gets a data flow node referring to a connection pool. */
146-
DataFlow::SourceNode pool() {
147-
result = pool(DataFlow::TypeTracker::end())
148-
}
126+
DataFlow::SourceNode pool() { result = pool(DataFlow::TypeTracker::end()) }
149127

150128
/** Gets a creation of a Postgres client. */
151129
DataFlow::InvokeNode newClient() {
@@ -161,27 +139,19 @@ private module Postgres {
161139
result = pool().getAMethodCall("connect").getABoundCallbackParameter(0, 1)
162140
)
163141
or
164-
exists(DataFlow::TypeTracker t2 |
165-
result = client(t2).track(t2, t)
166-
)
142+
exists(DataFlow::TypeTracker t2 | result = client(t2).track(t2, t))
167143
}
168-
144+
169145
/** Gets a data flow node referring to a Postgres client. */
170-
DataFlow::SourceNode client() {
171-
result = client(DataFlow::TypeTracker::end())
172-
}
146+
DataFlow::SourceNode client() { result = client(DataFlow::TypeTracker::end()) }
173147

174-
private DataFlow::SourceNode clientOrPool() {
175-
result = client() or result = pool()
176-
}
148+
private DataFlow::SourceNode clientOrPool() { result = client() or result = pool() }
177149

178150
/** A call to the Postgres `query` method. */
179151
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
180152
QueryCall() { this = clientOrPool().getAMethodCall("query") }
181153

182-
override DataFlow::Node getAQueryArgument() {
183-
result = getArgument(0)
184-
}
154+
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
185155
}
186156

187157
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -194,9 +164,7 @@ private module Postgres {
194164
string kind;
195165

196166
Credentials() {
197-
exists(string prop |
198-
this = [newClient(), newPool()].getOptionArgument(0, prop).asExpr()
199-
|
167+
exists(string prop | this = [newClient(), newPool()].getOptionArgument(0, prop).asExpr() |
200168
prop = "user" and kind = "user name"
201169
or
202170
prop = "password" and kind = prop
@@ -229,15 +197,11 @@ private module Sqlite {
229197
t.start() and
230198
result = newDb()
231199
or
232-
exists(DataFlow::TypeTracker t2 |
233-
result = db(t2).track(t2, t)
234-
)
200+
exists(DataFlow::TypeTracker t2 | result = db(t2).track(t2, t))
235201
}
236202

237203
/** Gets a data flow node referring to a Sqlite database instance. */
238-
DataFlow::SourceNode db() {
239-
result = db(DataFlow::TypeTracker::end())
240-
}
204+
DataFlow::SourceNode db() { result = db(DataFlow::TypeTracker::end()) }
241205

242206
/** A call to a Sqlite query method. */
243207
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
@@ -254,9 +218,7 @@ private module Sqlite {
254218
)
255219
}
256220

257-
override DataFlow::Node getAQueryArgument() {
258-
result = getArgument(0)
259-
}
221+
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
260222
}
261223

262224
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -283,15 +245,11 @@ private module MsSql {
283245
result = request().getAMethodCall("input")
284246
)
285247
or
286-
exists(DataFlow::TypeTracker t2 |
287-
result = request(t2).track(t2, t)
288-
)
248+
exists(DataFlow::TypeTracker t2 | result = request(t2).track(t2, t))
289249
}
290-
250+
291251
/** Gets a data flow node referring to a request object. */
292-
DataFlow::SourceNode request() {
293-
result = request(DataFlow::TypeTracker::end())
294-
}
252+
DataFlow::SourceNode request() { result = request(DataFlow::TypeTracker::end()) }
295253

296254
/** A tagged template evaluated as a query. */
297255
private class QueryTemplateExpr extends DatabaseAccess, DataFlow::ValueNode {
@@ -306,13 +264,9 @@ private module MsSql {
306264

307265
/** A call to a MsSql query method. */
308266
private class QueryCall extends DatabaseAccess, DataFlow::MethodCallNode {
309-
QueryCall() {
310-
this = request().getAMethodCall(["query", "batch"])
311-
}
267+
QueryCall() { this = request().getAMethodCall(["query", "batch"]) }
312268

313-
override DataFlow::Node getAQueryArgument() {
314-
result = getArgument(0)
315-
}
269+
override DataFlow::Node getAQueryArgument() { result = getArgument(0) }
316270
}
317271

318272
/** An expression that is passed to a method that interprets it as SQL. */
@@ -369,15 +323,11 @@ private module Sequelize {
369323
t.start() and
370324
result = sequelize().getAnInstantiation()
371325
or
372-
exists(DataFlow::TypeTracker t2 |
373-
result = newSequelize(t2).track(t2, t)
374-
)
326+
exists(DataFlow::TypeTracker t2 | result = newSequelize(t2).track(t2, t))
375327
}
376328

377329
/** Gets an expression that creates an instance of the `Sequelize` class. */
378-
DataFlow::SourceNode newSequelize() {
379-
result = newSequelize(DataFlow::TypeTracker::end())
380-
}
330+
DataFlow::SourceNode newSequelize() { result = newSequelize(DataFlow::TypeTracker::end()) }
381331

382332
/** A call to `Sequelize.query`. */
383333
private class QueryCall extends DatabaseAccess, DataFlow::ValueNode {
@@ -444,75 +394,55 @@ private module Spanner {
444394
t.start() and
445395
result = spanner().getAnInvocation()
446396
or
447-
exists(DataFlow::TypeTracker t2 |
448-
result = spannerNew(t2).track(t2, t)
449-
)
397+
exists(DataFlow::TypeTracker t2 | result = spannerNew(t2).track(t2, t))
450398
}
451399

452400
/** Gets a data flow node referring to the result of `Spanner()` or `new Spanner()`. */
453-
DataFlow::SourceNode spannerNew() {
454-
result = spannerNew(DataFlow::TypeTracker::end())
455-
}
401+
DataFlow::SourceNode spannerNew() { result = spannerNew(DataFlow::TypeTracker::end()) }
456402

457403
/** Gets a data flow node referring to the result of `.instance()`. */
458404
private DataFlow::SourceNode instance(DataFlow::TypeTracker t) {
459405
t.start() and
460406
result = spannerNew().getAMethodCall("instance")
461407
or
462-
exists(DataFlow::TypeTracker t2 |
463-
result = instance(t2).track(t2, t)
464-
)
408+
exists(DataFlow::TypeTracker t2 | result = instance(t2).track(t2, t))
465409
}
466410

467411
/** Gets a data flow node referring to the result of `.instance()`. */
468-
DataFlow::SourceNode instance() {
469-
result = instance(DataFlow::TypeTracker::end())
470-
}
412+
DataFlow::SourceNode instance() { result = instance(DataFlow::TypeTracker::end()) }
471413

472414
/** Gets a node that refers to an instance of the `Database` class. */
473415
private DataFlow::SourceNode database(DataFlow::TypeTracker t) {
474416
t.start() and
475417
result = instance().getAMethodCall("database")
476418
or
477-
exists(DataFlow::TypeTracker t2 |
478-
result = database(t2).track(t2, t)
479-
)
419+
exists(DataFlow::TypeTracker t2 | result = database(t2).track(t2, t))
480420
}
481421

482422
/** Gets a node that refers to an instance of the `Database` class. */
483-
DataFlow::SourceNode database() {
484-
result = database(DataFlow::TypeTracker::end())
485-
}
423+
DataFlow::SourceNode database() { result = database(DataFlow::TypeTracker::end()) }
486424

487425
/** Gets a node that refers to an instance of the `v1.SpannerClient` class. */
488426
private DataFlow::SourceNode v1SpannerClient(DataFlow::TypeTracker t) {
489427
t.start() and
490428
result = spanner().getAPropertyRead("v1").getAPropertyRead("SpannerClient").getAnInstantiation()
491429
or
492-
exists(DataFlow::TypeTracker t2 |
493-
result = v1SpannerClient(t2).track(t2, t)
494-
)
430+
exists(DataFlow::TypeTracker t2 | result = v1SpannerClient(t2).track(t2, t))
495431
}
496432

497433
/** Gets a node that refers to an instance of the `v1.SpannerClient` class. */
498-
DataFlow::SourceNode v1SpannerClient() {
499-
result = v1SpannerClient(DataFlow::TypeTracker::end())
500-
}
434+
DataFlow::SourceNode v1SpannerClient() { result = v1SpannerClient(DataFlow::TypeTracker::end()) }
501435

502436
/** Gets a node that refers to a transaction object. */
503437
private DataFlow::SourceNode transaction(DataFlow::TypeTracker t) {
504438
t.start() and
505439
result = database().getAMethodCall("runTransaction").getABoundCallbackParameter(0, 1)
506440
or
507-
exists(DataFlow::TypeTracker t2 |
508-
result = transaction(t2).track(t2, t)
509-
)
441+
exists(DataFlow::TypeTracker t2 | result = transaction(t2).track(t2, t))
510442
}
511443

512444
/** Gets a node that refers to a transaction object. */
513-
DataFlow::SourceNode transaction() {
514-
result = transaction(DataFlow::TypeTracker::end())
515-
}
445+
DataFlow::SourceNode transaction() { result = transaction(DataFlow::TypeTracker::end()) }
516446

517447
/**
518448
* A call to a Spanner method that executes a SQL query.
@@ -543,9 +473,7 @@ private module Spanner {
543473
* A call to `Transaction.run`, `Transaction.runStream` or `Transaction.runUpdate`.
544474
*/
545475
class TransactionRunCall extends SqlExecution {
546-
TransactionRunCall() {
547-
this = transaction().getAMethodCall(["run", "runStream", "runUpdate"])
548-
}
476+
TransactionRunCall() { this = transaction().getAMethodCall(["run", "runStream", "runUpdate"]) }
549477
}
550478

551479
/**

0 commit comments

Comments
 (0)