@@ -8,119 +8,36 @@ private import semmle.python.dataflow.new.DataFlow
88private import semmle.python.dataflow.new.RemoteFlowSources
99private import semmle.python.Concepts
1010private import semmle.python.ApiGraphs
11+ import semmle.python.frameworks.internal.PEP249Impl
1112
1213/**
1314 * A module implementing PEP 249. Extend this class for implementations.
1415 *
15- * DEPRECATED: Extend `PEP249ModuleApiNode` instead.
16+ * DEPRECATED: Extend `PEP249:: PEP249ModuleApiNode` instead.
1617 */
1718abstract deprecated class PEP249Module extends DataFlow:: Node { }
1819
1920/**
20- * An abstract class encompassing API graph nodes that implement PEP 249.
21- * Extend this class for implementations.
21+ * DEPRECATED: Use `PEP249::PEP249ModuleApiNode` instead.
2222 */
23- abstract class PEP249ModuleApiNode extends API:: Node {
24- /** Gets a string representation of this element. */
25- override string toString ( ) { result = this .( API:: Node ) .toString ( ) }
26- }
27-
28- /** Gets a reference to a connect call. */
29- DataFlow:: Node connect ( ) { result = any ( PEP249ModuleApiNode a ) .getMember ( "connect" ) .getAUse ( ) }
23+ deprecated class PEP249ModuleApiNode = PEP249:: PEP249ModuleApiNode ;
3024
3125/**
32- * Provides models for the `db.Connection` class
33- *
34- * See https://www.python.org/dev/peps/pep-0249/#connection-objects.
26+ * DEPRECATED: Use `PEP249::Connection` instead.
3527 */
36- module Connection {
37- /**
38- * A source of instances of `db.Connection`, extend this class to model new instances.
39- *
40- * This can include instantiations of the class, return values from function
41- * calls, or a special parameter that will be set when functions are called by external
42- * libraries.
43- *
44- * Use the predicate `Connection::instance()` to get references to instances of `db.Connection`.
45- *
46- * Extend this class if the module implementing PEP 249 offers more direct ways to obtain
47- * a connection than going through `connect`.
48- */
49- abstract class InstanceSource extends DataFlow:: Node { }
50-
51- /** A direct instantiation of `db.Connection`. */
52- private class ClassInstantiation extends InstanceSource , DataFlow:: CallCfgNode {
53- ClassInstantiation ( ) { this .getFunction ( ) = connect ( ) }
54- }
55-
56- /** Gets a reference to an instance of `db.Connection`. */
57- private DataFlow:: LocalSourceNode instance ( DataFlow:: TypeTracker t ) {
58- t .start ( ) and
59- result instanceof InstanceSource
60- or
61- exists ( DataFlow:: TypeTracker t2 | result = instance ( t2 ) .track ( t2 , t ) )
62- }
63-
64- /** Gets a reference to an instance of `db.Connection`. */
65- DataFlow:: Node instance ( ) { instance ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
66- }
28+ deprecated module Connection = PEP249:: Connection;
6729
6830/**
69- * Provides models for the `cursor` method on a connection.
70- * See https://www.python.org/dev/peps/pep-0249/#cursor.
31+ * DEPRECATED: Use `PEP249::cursor` instead.
7132 */
72- module cursor {
73- /** Gets a reference to the `cursor` method on a connection. */
74- private DataFlow:: LocalSourceNode methodRef ( DataFlow:: TypeTracker t ) {
75- t .startInAttr ( "cursor" ) and
76- result = Connection:: instance ( )
77- or
78- exists ( DataFlow:: TypeTracker t2 | result = methodRef ( t2 ) .track ( t2 , t ) )
79- }
80-
81- /** Gets a reference to the `cursor` method on a connection. */
82- DataFlow:: Node methodRef ( ) { methodRef ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
83-
84- /** Gets a reference to a result of calling the `cursor` method on a connection. */
85- private DataFlow:: LocalSourceNode methodResult ( DataFlow:: TypeTracker t ) {
86- t .start ( ) and
87- result .asCfgNode ( ) .( CallNode ) .getFunction ( ) = methodRef ( ) .asCfgNode ( )
88- or
89- exists ( DataFlow:: TypeTracker t2 | result = methodResult ( t2 ) .track ( t2 , t ) )
90- }
91-
92- /** Gets a reference to a result of calling the `cursor` method on a connection. */
93- DataFlow:: Node methodResult ( ) { methodResult ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
94- }
33+ deprecated module cursor = PEP249:: cursor;
9534
9635/**
97- * Gets a reference to the `execute` method on a cursor (or on a connection).
98- *
99- * Note: while `execute` method on a connection is not part of PEP249, if it is used, we
100- * recognize it as an alias for constructing a cursor and calling `execute` on it.
101- *
102- * See https://www.python.org/dev/peps/pep-0249/#id15.
36+ * DEPRECATED: Use `PEP249::execute` instead.
10337 */
104- private DataFlow:: LocalSourceNode execute ( DataFlow:: TypeTracker t ) {
105- t .startInAttr ( "execute" ) and
106- result in [ cursor:: methodResult ( ) , Connection:: instance ( ) ]
107- or
108- exists ( DataFlow:: TypeTracker t2 | result = execute ( t2 ) .track ( t2 , t ) )
109- }
38+ deprecated predicate execute = PEP249:: execute / 0 ;
11039
11140/**
112- * Gets a reference to the `execute` method on a cursor (or on a connection).
113- *
114- * Note: while `execute` method on a connection is not part of PEP249, if it is used, we
115- * recognize it as an alias for constructing a cursor and calling `execute` on it.
116- *
117- * See https://www.python.org/dev/peps/pep-0249/#id15.
41+ * DEPRECATED: Use `PEP249::connect` instead.
11842 */
119- DataFlow:: Node execute ( ) { execute ( DataFlow:: TypeTracker:: end ( ) ) .flowsTo ( result ) }
120-
121- /** A call to the `execute` method on a cursor (or on a connection). */
122- private class ExecuteCall extends SqlExecution:: Range , DataFlow:: CallCfgNode {
123- ExecuteCall ( ) { this .getFunction ( ) = execute ( ) }
124-
125- override DataFlow:: Node getSql ( ) { result in [ this .getArg ( 0 ) , this .getArgByName ( "sql" ) ] }
126- }
43+ deprecated predicate connect = PEP249:: connect / 0 ;
0 commit comments