@@ -18,7 +18,7 @@ private module Asyncpg {
1818 /**
1919 * A `Connection` is created when
2020 * - the result of `asyncpg.connect()` is awaited.
21- * - the result of calling `aquire` on a c= `ConnectionPool` is awaited.
21+ * - the result of calling `aquire` on a `ConnectionPool` is awaited.
2222 */
2323 API:: Node connection ( ) {
2424 result = API:: moduleImport ( "asyncpg" ) .getMember ( "connect" ) .getReturn ( ) .getAwaited ( )
@@ -112,15 +112,17 @@ private module Asyncpg {
112112 * TODO: Rewrite this, once we have `API::CallNode` available.
113113 */
114114 module PreparedStatement {
115+ class PreparedStatementConstruction extends SqlConstruction:: Range , DataFlow:: CallCfgNode {
116+ PreparedStatementConstruction ( ) { this = connection ( ) .getMember ( "prepare" ) .getACall ( ) }
117+
118+ override DataFlow:: Node getSql ( ) { result in [ this .getArg ( 0 ) , this .getArgByName ( "query" ) ] }
119+ }
120+
115121 private DataFlow:: TypeTrackingNode preparedStatementFactory (
116122 DataFlow:: TypeTracker t , DataFlow:: Node sql
117123 ) {
118124 t .start ( ) and
119- result = connection ( ) .getMember ( "prepare" ) .getACall ( ) and
120- sql in [
121- result .( DataFlow:: CallCfgNode ) .getArg ( 0 ) ,
122- result .( DataFlow:: CallCfgNode ) .getArgByName ( "query" )
123- ]
125+ sql = result .( PreparedStatementConstruction ) .getSql ( )
124126 or
125127 exists ( DataFlow:: TypeTracker t2 | result = preparedStatementFactory ( t2 , sql ) .track ( t2 , t ) )
126128 }
@@ -163,14 +165,16 @@ private module Asyncpg {
163165 * TODO: Rewrite this, once we have `API::CallNode` available.
164166 */
165167 module Cursor {
168+ class CursorConstruction extends SqlConstruction:: Range , DataFlow:: CallCfgNode {
169+ CursorConstruction ( ) { this = connection ( ) .getMember ( "cursor" ) .getACall ( ) }
170+
171+ override DataFlow:: Node getSql ( ) { result in [ this .getArg ( 0 ) , this .getArgByName ( "query" ) ] }
172+ }
173+
166174 private DataFlow:: TypeTrackingNode cursorFactory ( DataFlow:: TypeTracker t , DataFlow:: Node sql ) {
167175 // cursor created from connection
168176 t .start ( ) and
169- result = connection ( ) .getMember ( "cursor" ) .getACall ( ) and
170- sql in [
171- result .( DataFlow:: CallCfgNode ) .getArg ( 0 ) ,
172- result .( DataFlow:: CallCfgNode ) .getArgByName ( "query" )
173- ]
177+ sql = result .( CursorConstruction ) .getSql ( )
174178 or
175179 // cursor created from prepared statement
176180 t .start ( ) and
0 commit comments