@@ -9,11 +9,10 @@ private import python
99private import semmle.python.dataflow.new.DataFlow
1010private import semmle.python.Concepts
1111private import semmle.python.ApiGraphs
12+ private import semmle.python.frameworks.PEP249
1213
1314/** Provides models for the `aiomysql` PyPI package. */
1415private module Aiomysql {
15- private import semmle.python.internal.Awaited
16-
1716 /**
1817 * Gets a `ConnectionPool` that is created when the result of `aiomysql.create_pool()` is awaited.
1918 * See https://aiomysql.readthedocs.io/en/stable/pool.html
@@ -23,49 +22,29 @@ private module Aiomysql {
2322 }
2423
2524 /**
26- * Gets a ` Connection` that is created when
25+ * A Connection that is created when
2726 * - the result of `aiomysql.connect()` is awaited.
2827 * - the result of calling `acquire` on a `ConnectionPool` is awaited.
29- * See https://aiomysql.readthedocs.io/en/stable/connection.html#connection
28+ * See
29+ * - https://aiomysql.readthedocs.io/en/stable/connection.html#connection
30+ * - https://aiomysql.readthedocs.io/en/stable/pool.html#Pool.acquire
3031 */
31- API:: Node connection ( ) {
32- result = API:: moduleImport ( "aiomysql" ) .getMember ( "connect" ) .getReturn ( ) .getAwaited ( )
33- or
34- result = connectionPool ( ) .getMember ( "acquire" ) .getReturn ( ) .getAwaited ( )
32+ class AiomysqlConnection extends PEP249:: AsyncDatabaseConnection {
33+ AiomysqlConnection ( ) {
34+ this = API:: moduleImport ( "aiomysql" ) .getMember ( "connect" ) .getReturn ( ) .getAwaited ( )
35+ or
36+ this = connectionPool ( ) .getMember ( "acquire" ) .getReturn ( ) .getAwaited ( )
37+ }
3538 }
3639
3740 /**
38- * Gets a `Cursor` that is created when
41+ * An additional cursor, that is created when
3942 * - the result of calling `cursor` on a `ConnectionPool` is awaited.
40- * - the result of calling `cursor` on a `Connection` is awaited.
41- * See https://aiomysql.readthedocs.io/en/stable/cursors .html
43+ * See
44+ * - https://aiomysql.readthedocs.io/en/stable/pool .html##Pool.cursor
4245 */
43- API:: Node cursor ( ) {
44- result = connectionPool ( ) .getMember ( "cursor" ) .getReturn ( ) .getAwaited ( )
45- or
46- result = connection ( ) .getMember ( "cursor" ) .getReturn ( ) .getAwaited ( )
47- }
48-
49- /**
50- * A query. Calling `execute` on a `Cursor` constructs a query.
51- * See https://aiomysql.readthedocs.io/en/stable/cursors.html#Cursor.execute
52- */
53- class CursorExecuteCall extends SqlConstruction:: Range , API:: CallNode {
54- CursorExecuteCall ( ) { this = cursor ( ) .getMember ( "execute" ) .getACall ( ) }
55-
56- override DataFlow:: Node getSql ( ) { result = this .getParameter ( 0 , "operation" ) .asSink ( ) }
57- }
58-
59- /**
60- * An awaited query. Awaiting the result of calling `execute` executes the query.
61- * See https://aiomysql.readthedocs.io/en/stable/cursors.html#Cursor.execute
62- */
63- class AwaitedCursorExecuteCall extends SqlExecution:: Range {
64- CursorExecuteCall executeCall ;
65-
66- AwaitedCursorExecuteCall ( ) { this = executeCall .getReturn ( ) .getAwaited ( ) .asSource ( ) }
67-
68- override DataFlow:: Node getSql ( ) { result = executeCall .getSql ( ) }
46+ class AiomysqlCursor extends PEP249:: AsyncDatabaseCursor {
47+ AiomysqlCursor ( ) { this = connectionPool ( ) .getMember ( "cursor" ) .getReturn ( ) .getAwaited ( ) }
6948 }
7049
7150 /**
0 commit comments