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 4242 - [ ncp] ( https://www.npmjs.com/package/ncp )
4343 - [ node-dir] ( https://www.npmjs.com/package/node-dir )
4444 - [ path-exists] ( https://www.npmjs.com/package/path-exists )
45+ - [ pg] ( https://www.npmjs.com/package/pg )
4546 - [ react] ( https://www.npmjs.com/package/react )
4647 - [ recursive-readdir] ( https://www.npmjs.com/package/recursive-readdir )
4748 - [ request] ( https://www.npmjs.com/package/request )
Original file line number Diff line number Diff line change @@ -132,15 +132,22 @@ private module Postgres {
132132 result = DataFlow:: moduleImport ( "pg-pool" ) .getAnInstantiation ( )
133133 }
134134
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+
135146 /** A call to the Postgres `query` method. */
136147 private class QueryCall extends DatabaseAccess , DataFlow:: ValueNode {
137148 override MethodCallExpr astNode ;
138149
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" ) }
144151
145152 override DataFlow:: Node getAQueryArgument ( ) {
146153 result = DataFlow:: valueNode ( astNode .getArgument ( 0 ) )
Original file line number Diff line number Diff line change 1212| postgres1.js:37:21:37:24 | text |
1313| postgres2.js:30:16:30:41 | 'SELECT ... number' |
1414| postgres3.js:15:16:15:40 | 'SELECT ... s name' |
15+ | postgres5.js:8:21:8:25 | query |
1516| sequelize2.js:10:17:10:118 | 'SELECT ... Y name' |
1617| sequelize.js:8:17:8:118 | 'SELECT ... Y name' |
1718| 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