@@ -26,24 +26,22 @@ private module Asyncpg {
2626 result = connectionPool ( ) .getMember ( "acquire" ) .getReturn ( ) .getAwaited ( )
2727 }
2828
29- /** Reverse lookup of the query argument name for a query method. */
30- private string queryMethodName ( string queryArg ) {
31- result in [ "copy_from_query" , "execute" , "fetch" , "fetchrow" , "fetchval" ] and
32- queryArg = "query"
33- or
34- result = "executemany" and
35- queryArg = "command"
36- }
37-
3829 /** `Connection`s and `ConnectionPool`s provide some methods that execute SQL. */
3930 class SqlExecutionOnConnection extends SqlExecution:: Range , DataFlow:: MethodCallNode {
40- string queryArg ;
31+ string methodName ;
4132
4233 SqlExecutionOnConnection ( ) {
43- this .calls ( [ connectionPool ( ) .getAUse ( ) , connection ( ) .getAUse ( ) ] , queryMethodName ( queryArg ) )
34+ methodName in [ "copy_from_query" , "execute" , "fetch" , "fetchrow" , "fetchval" , "executemany" ] and
35+ this .calls ( [ connectionPool ( ) .getAUse ( ) , connection ( ) .getAUse ( ) ] , methodName )
4436 }
4537
46- override DataFlow:: Node getSql ( ) { result in [ this .getArg ( 0 ) , this .getArgByName ( queryArg ) ] }
38+ override DataFlow:: Node getSql ( ) {
39+ methodName in [ "copy_from_query" , "execute" , "fetch" , "fetchrow" , "fetchval" ] and
40+ result in [ this .getArg ( 0 ) , this .getArgByName ( "query" ) ]
41+ or
42+ methodName = "executemany" and
43+ result in [ this .getArg ( 0 ) , this .getArgByName ( "command" ) ]
44+ }
4745 }
4846
4947 /** Reverse lokup of the path argument name for a method accessing the file system. */
@@ -57,14 +55,21 @@ private module Asyncpg {
5755
5856 /** `Connection`s and `ConnectionPool`s provide some methods that access the file system. */
5957 class FileAccessOnConnection extends FileSystemAccess:: Range , DataFlow:: MethodCallNode {
60- string pathArg ;
58+ string methodName ;
6159
6260 FileAccessOnConnection ( ) {
63- this .calls ( [ connectionPool ( ) .getAUse ( ) , connection ( ) .getAUse ( ) ] , fileAccessMethodName ( pathArg ) )
61+ methodName in [ "copy_from_query" , "copy_from_table" , "copy_to_table" ] and
62+ this .calls ( [ connectionPool ( ) .getAUse ( ) , connection ( ) .getAUse ( ) ] , methodName )
6463 }
6564
6665 // The path argument is keyword only.
67- override DataFlow:: Node getAPathArgument ( ) { result in [ this .getArgByName ( pathArg ) ] }
66+ override DataFlow:: Node getAPathArgument ( ) {
67+ methodName in [ "copy_from_query" , "copy_from_table" ] and
68+ result = this .getArgByName ( "output" )
69+ or
70+ methodName = "copy_to_table" and
71+ result = this .getArgByName ( "source" )
72+ }
6873 }
6974
7075 /**
0 commit comments