@@ -28,33 +28,23 @@ module SQL {
28
28
* Provides classes modelling the (API compatible) `mysql` and `mysql2` packages.
29
29
*/
30
30
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" ] ) }
34
32
35
- private DataFlow:: CallNode createPool ( ) {
36
- result = mysql ( ) .getAMemberCall ( "createPool" )
37
- }
33
+ private DataFlow:: CallNode createPool ( ) { result = mysql ( ) .getAMemberCall ( "createPool" ) }
38
34
39
35
/** Gets a call to `mysql.createPool`. */
40
36
private DataFlow:: SourceNode pool ( DataFlow:: TypeTracker t ) {
41
37
t .start ( ) and
42
38
result = createPool ( )
43
39
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 ) )
47
41
}
48
42
49
43
/** 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 ( ) ) }
53
45
54
46
/** Gets a call to `mysql.createConnection`. */
55
- DataFlow:: CallNode createConnection ( ) {
56
- result = mysql ( ) .getAMemberCall ( "createConnection" )
57
- }
47
+ DataFlow:: CallNode createConnection ( ) { result = mysql ( ) .getAMemberCall ( "createConnection" ) }
58
48
59
49
/** Gets a data flow node that contains a freshly created MySQL connection instance. */
60
50
private DataFlow:: SourceNode connection ( DataFlow:: TypeTracker t ) {
@@ -65,25 +55,17 @@ private module MySql {
65
55
result = pool ( ) .getAMethodCall ( "getConnection" ) .getABoundCallbackParameter ( 0 , 1 )
66
56
)
67
57
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 ) )
71
59
}
72
60
73
61
/** 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 ( ) ) }
77
63
78
64
/** A call to the MySql `query` method. */
79
65
private class QueryCall extends DatabaseAccess , DataFlow:: MethodCallNode {
80
- QueryCall ( ) {
81
- this = [ pool ( ) , connection ( ) ] .getAMethodCall ( "query" )
82
- }
66
+ QueryCall ( ) { this = [ pool ( ) , connection ( ) ] .getAMethodCall ( "query" ) }
83
67
84
- override DataFlow:: Node getAQueryArgument ( ) {
85
- result = getArgument ( 0 )
86
- }
68
+ override DataFlow:: Node getAQueryArgument ( ) { result = getArgument ( 0 ) }
87
69
}
88
70
89
71
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -137,15 +119,11 @@ private module Postgres {
137
119
t .start ( ) and
138
120
result = newPool ( )
139
121
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 ) )
143
123
}
144
-
124
+
145
125
/** 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 ( ) ) }
149
127
150
128
/** Gets a creation of a Postgres client. */
151
129
DataFlow:: InvokeNode newClient ( ) {
@@ -161,27 +139,19 @@ private module Postgres {
161
139
result = pool ( ) .getAMethodCall ( "connect" ) .getABoundCallbackParameter ( 0 , 1 )
162
140
)
163
141
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 ) )
167
143
}
168
-
144
+
169
145
/** 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 ( ) ) }
173
147
174
- private DataFlow:: SourceNode clientOrPool ( ) {
175
- result = client ( ) or result = pool ( )
176
- }
148
+ private DataFlow:: SourceNode clientOrPool ( ) { result = client ( ) or result = pool ( ) }
177
149
178
150
/** A call to the Postgres `query` method. */
179
151
private class QueryCall extends DatabaseAccess , DataFlow:: MethodCallNode {
180
152
QueryCall ( ) { this = clientOrPool ( ) .getAMethodCall ( "query" ) }
181
153
182
- override DataFlow:: Node getAQueryArgument ( ) {
183
- result = getArgument ( 0 )
184
- }
154
+ override DataFlow:: Node getAQueryArgument ( ) { result = getArgument ( 0 ) }
185
155
}
186
156
187
157
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -194,9 +164,7 @@ private module Postgres {
194
164
string kind ;
195
165
196
166
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 ( ) |
200
168
prop = "user" and kind = "user name"
201
169
or
202
170
prop = "password" and kind = prop
@@ -229,15 +197,11 @@ private module Sqlite {
229
197
t .start ( ) and
230
198
result = newDb ( )
231
199
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 ) )
235
201
}
236
202
237
203
/** 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 ( ) ) }
241
205
242
206
/** A call to a Sqlite query method. */
243
207
private class QueryCall extends DatabaseAccess , DataFlow:: MethodCallNode {
@@ -254,9 +218,7 @@ private module Sqlite {
254
218
)
255
219
}
256
220
257
- override DataFlow:: Node getAQueryArgument ( ) {
258
- result = getArgument ( 0 )
259
- }
221
+ override DataFlow:: Node getAQueryArgument ( ) { result = getArgument ( 0 ) }
260
222
}
261
223
262
224
/** An expression that is passed to the `query` method and hence interpreted as SQL. */
@@ -283,15 +245,11 @@ private module MsSql {
283
245
result = request ( ) .getAMethodCall ( "input" )
284
246
)
285
247
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 ) )
289
249
}
290
-
250
+
291
251
/** 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 ( ) ) }
295
253
296
254
/** A tagged template evaluated as a query. */
297
255
private class QueryTemplateExpr extends DatabaseAccess , DataFlow:: ValueNode {
@@ -306,13 +264,9 @@ private module MsSql {
306
264
307
265
/** A call to a MsSql query method. */
308
266
private class QueryCall extends DatabaseAccess , DataFlow:: MethodCallNode {
309
- QueryCall ( ) {
310
- this = request ( ) .getAMethodCall ( [ "query" , "batch" ] )
311
- }
267
+ QueryCall ( ) { this = request ( ) .getAMethodCall ( [ "query" , "batch" ] ) }
312
268
313
- override DataFlow:: Node getAQueryArgument ( ) {
314
- result = getArgument ( 0 )
315
- }
269
+ override DataFlow:: Node getAQueryArgument ( ) { result = getArgument ( 0 ) }
316
270
}
317
271
318
272
/** An expression that is passed to a method that interprets it as SQL. */
@@ -369,15 +323,11 @@ private module Sequelize {
369
323
t .start ( ) and
370
324
result = sequelize ( ) .getAnInstantiation ( )
371
325
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 ) )
375
327
}
376
328
377
329
/** 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 ( ) ) }
381
331
382
332
/** A call to `Sequelize.query`. */
383
333
private class QueryCall extends DatabaseAccess , DataFlow:: ValueNode {
@@ -444,75 +394,55 @@ private module Spanner {
444
394
t .start ( ) and
445
395
result = spanner ( ) .getAnInvocation ( )
446
396
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 ) )
450
398
}
451
399
452
400
/** 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 ( ) ) }
456
402
457
403
/** Gets a data flow node referring to the result of `.instance()`. */
458
404
private DataFlow:: SourceNode instance ( DataFlow:: TypeTracker t ) {
459
405
t .start ( ) and
460
406
result = spannerNew ( ) .getAMethodCall ( "instance" )
461
407
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 ) )
465
409
}
466
410
467
411
/** 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 ( ) ) }
471
413
472
414
/** Gets a node that refers to an instance of the `Database` class. */
473
415
private DataFlow:: SourceNode database ( DataFlow:: TypeTracker t ) {
474
416
t .start ( ) and
475
417
result = instance ( ) .getAMethodCall ( "database" )
476
418
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 ) )
480
420
}
481
421
482
422
/** 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 ( ) ) }
486
424
487
425
/** Gets a node that refers to an instance of the `v1.SpannerClient` class. */
488
426
private DataFlow:: SourceNode v1SpannerClient ( DataFlow:: TypeTracker t ) {
489
427
t .start ( ) and
490
428
result = spanner ( ) .getAPropertyRead ( "v1" ) .getAPropertyRead ( "SpannerClient" ) .getAnInstantiation ( )
491
429
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 ) )
495
431
}
496
432
497
433
/** 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 ( ) ) }
501
435
502
436
/** Gets a node that refers to a transaction object. */
503
437
private DataFlow:: SourceNode transaction ( DataFlow:: TypeTracker t ) {
504
438
t .start ( ) and
505
439
result = database ( ) .getAMethodCall ( "runTransaction" ) .getABoundCallbackParameter ( 0 , 1 )
506
440
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 ) )
510
442
}
511
443
512
444
/** 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 ( ) ) }
516
446
517
447
/**
518
448
* A call to a Spanner method that executes a SQL query.
@@ -543,9 +473,7 @@ private module Spanner {
543
473
* A call to `Transaction.run`, `Transaction.runStream` or `Transaction.runUpdate`.
544
474
*/
545
475
class TransactionRunCall extends SqlExecution {
546
- TransactionRunCall ( ) {
547
- this = transaction ( ) .getAMethodCall ( [ "run" , "runStream" , "runUpdate" ] )
548
- }
476
+ TransactionRunCall ( ) { this = transaction ( ) .getAMethodCall ( [ "run" , "runStream" , "runUpdate" ] ) }
549
477
}
550
478
551
479
/**
0 commit comments