@@ -7,20 +7,26 @@ private import python
77private import semmle.python.dataflow.new.DataFlow
88private import semmle.python.dataflow.new.RemoteFlowSources
99private import semmle.python.Concepts
10+ private import semmle.python.ApiGraphs
1011
11- /** A module implementing PEP 249. Extend this class for implementations. */
12- abstract class PEP249Module extends DataFlow:: Node { }
12+ /**
13+ * A module implementing PEP 249. Extend this class for implementations.
14+ *
15+ * DEPRECATED: Extend `PEP249ModuleApiNode` instead.
16+ */
17+ abstract deprecated class PEP249Module extends DataFlow:: Node { }
1318
14- /** Gets a reference to a connect call. */
15- private DataFlow:: Node connect ( DataFlow:: TypeTracker t ) {
16- t .startInAttr ( "connect" ) and
17- result instanceof PEP249Module
18- or
19- exists ( DataFlow:: TypeTracker t2 | result = connect ( t2 ) .track ( t2 , t ) )
19+ /**
20+ * An abstract class encompassing API graph nodes that implement PEP 249.
21+ * Extend this class for implementations.
22+ */
23+ abstract class PEP249ModuleApiNode extends API:: Node {
24+ /** Gets a string representation of this element. */
25+ override string toString ( ) { result = this .( API:: Node ) .toString ( ) }
2026}
2127
2228/** Gets a reference to a connect call. */
23- DataFlow:: Node connect ( ) { result = connect ( DataFlow :: TypeTracker :: end ( ) ) }
29+ DataFlow:: Node connect ( ) { result = any ( PEP249ModuleApiNode a ) . getMember ( "connect" ) . getAUse ( ) }
2430
2531/**
2632 * Provides models for the `db.Connection` class
@@ -43,10 +49,8 @@ module Connection {
4349 abstract class InstanceSource extends DataFlow:: Node { }
4450
4551 /** A direct instantiation of `db.Connection`. */
46- private class ClassInstantiation extends InstanceSource , DataFlow:: CfgNode {
47- override CallNode node ;
48-
49- ClassInstantiation ( ) { node .getFunction ( ) = connect ( ) .asCfgNode ( ) }
52+ private class ClassInstantiation extends InstanceSource , DataFlow:: CallCfgNode {
53+ ClassInstantiation ( ) { this .getFunction ( ) = connect ( ) }
5054 }
5155
5256 /** Gets a reference to an instance of `db.Connection`. */
@@ -115,10 +119,8 @@ private DataFlow::Node execute(DataFlow::TypeTracker t) {
115119DataFlow:: Node execute ( ) { result = execute ( DataFlow:: TypeTracker:: end ( ) ) }
116120
117121/** A call to the `execute` method on a cursor (or on a connection). */
118- private class ExecuteCall extends SqlExecution:: Range , DataFlow:: CfgNode {
119- override CallNode node ;
120-
121- ExecuteCall ( ) { node .getFunction ( ) = execute ( ) .asCfgNode ( ) }
122+ private class ExecuteCall extends SqlExecution:: Range , DataFlow:: CallCfgNode {
123+ ExecuteCall ( ) { this .getFunction ( ) = execute ( ) }
122124
123125 override DataFlow:: Node getSql ( ) {
124126 result .asCfgNode ( ) in [ node .getArg ( 0 ) , node .getArgByName ( "sql" ) ]
0 commit comments