File tree Expand file tree Collapse file tree 4 files changed +23
-5
lines changed
src/semmle/javascript/frameworks
test/library-tests/frameworks/SQL Expand file tree Collapse file tree 4 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 42
42
- [ ncp] ( https://www.npmjs.com/package/ncp )
43
43
- [ node-dir] ( https://www.npmjs.com/package/node-dir )
44
44
- [ path-exists] ( https://www.npmjs.com/package/path-exists )
45
+ - [ pg] ( https://www.npmjs.com/package/pg )
45
46
- [ react] ( https://www.npmjs.com/package/react )
46
47
- [ recursive-readdir] ( https://www.npmjs.com/package/recursive-readdir )
47
48
- [ request] ( https://www.npmjs.com/package/request )
Original file line number Diff line number Diff line change @@ -132,15 +132,22 @@ private module Postgres {
132
132
result = DataFlow:: moduleImport ( "pg-pool" ) .getAnInstantiation ( )
133
133
}
134
134
135
+ private DataFlow:: SourceNode clientOrPool ( DataFlow:: TypeTracker t ) {
136
+ t .start ( ) and
137
+ ( result = client ( ) or result = newPool ( ) )
138
+ or
139
+ exists ( DataFlow:: TypeTracker t2 | result = clientOrPool ( t2 ) .track ( t2 , t ) )
140
+ }
141
+
142
+ private DataFlow:: SourceNode clientOrPool ( ) {
143
+ result = clientOrPool ( DataFlow:: TypeTracker:: end ( ) )
144
+ }
145
+
135
146
/** A call to the Postgres `query` method. */
136
147
private class QueryCall extends DatabaseAccess , DataFlow:: ValueNode {
137
148
override MethodCallExpr astNode ;
138
149
139
- QueryCall ( ) {
140
- exists ( DataFlow:: SourceNode recv | recv = client ( ) or recv = newPool ( ) |
141
- this = recv .getAMethodCall ( "query" )
142
- )
143
- }
150
+ QueryCall ( ) { this = clientOrPool ( ) .getAMethodCall ( "query" ) }
144
151
145
152
override DataFlow:: Node getAQueryArgument ( ) {
146
153
result = DataFlow:: valueNode ( astNode .getArgument ( 0 ) )
Original file line number Diff line number Diff line change 12
12
| postgres1.js:37:21:37:24 | text |
13
13
| postgres2.js:30:16:30:41 | 'SELECT ... number' |
14
14
| postgres3.js:15:16:15:40 | 'SELECT ... s name' |
15
+ | postgres5.js:8:21:8:25 | query |
15
16
| sequelize2.js:10:17:10:118 | 'SELECT ... Y name' |
16
17
| sequelize.js:8:17:8:118 | 'SELECT ... Y name' |
17
18
| spanner2.js:5:26:5:35 | "SQL code" |
Original file line number Diff line number Diff line change
1
+ const pg = require ( 'pg' ) ;
2
+
3
+ function PgWrapper ( ) {
4
+ this . pool = new pg . Pool ( { } ) ;
5
+ }
6
+
7
+ PgWrapper . prototype . query = function ( query , params , cb ) {
8
+ this . pool . query ( query , params || [ ] , cb ) ;
9
+ } ;
You can’t perform that action at this time.
0 commit comments