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 @@ -224,10 +224,23 @@ private module Sqlite {
224224 result = sqlite ( ) .getAConstructorInvocation ( "Database" )
225225 }
226226
227- /** A call to a Sqlite query method. */
228- private class QueryCall extends DatabaseAccess , DataFlow:: ValueNode {
229- override MethodCallExpr astNode ;
227+ /** Gets a data flow node referring to a Sqlite database instance. */
228+ private DataFlow:: SourceNode db ( DataFlow:: TypeTracker t ) {
229+ t .start ( ) and
230+ result = newDb ( )
231+ or
232+ exists ( DataFlow:: TypeTracker t2 |
233+ result = db ( t2 ) .track ( t2 , t )
234+ )
235+ }
236+
237+ /** Gets a data flow node referring to a Sqlite database instance. */
238+ DataFlow:: SourceNode db ( ) {
239+ result = db ( DataFlow:: TypeTracker:: end ( ) )
240+ }
230241
242+ /** A call to a Sqlite query method. */
243+ private class QueryCall extends DatabaseAccess , DataFlow:: MethodCallNode {
231244 QueryCall ( ) {
232245 exists ( string meth |
233246 meth = "all" or
@@ -237,12 +250,12 @@ private module Sqlite {
237250 meth = "prepare" or
238251 meth = "run"
239252 |
240- this = newDb ( ) .getAMethodCall ( meth )
253+ this = db ( ) .getAMethodCall ( meth )
241254 )
242255 }
243256
244257 override DataFlow:: Node getAQueryArgument ( ) {
245- result = DataFlow :: valueNode ( astNode . getArgument ( 0 ) )
258+ result = getArgument ( 0 )
246259 }
247260 }
248261
Original file line number Diff line number Diff line change 3939| spanner.js:19:16:19:34 | { sql: "SQL code" } |
4040| spanner.js:19:23:19:32 | "SQL code" |
4141| sqlite.js:7:8:7:45 | "UPDATE ... id = ?" |
42+ | sqliteImport.js:2:8:2:44 | "UPDATE ... id = ?" |
Original file line number Diff line number Diff line change @@ -5,3 +5,5 @@ var sqlite = require('sqlite3');
55
66var db = new sqlite . Database ( ":memory:" ) ;
77db . run ( "UPDATE tbl SET name = ? WHERE id = ?" , "bar" , 2 ) ;
8+
9+ exports . db = db ;
Original file line number Diff line number Diff line change 1+ const { db } = require ( './sqlite' ) ;
2+ db . run ( "UPDATE foo SET bar = ? WHERE id = ?" , "bar" , 2 ) ;
You can’t perform that action at this time.
0 commit comments