@@ -4,7 +4,7 @@ import python
44private import semmle.python.objects.TObject
55private import semmle.python.objects.ObjectInternal
66private import semmle.python.pointsto.PointsTo2
7- private import semmle.python.pointsto.PointsToContext2
7+ private import semmle.python.pointsto.PointsToContext
88private import semmle.python.pointsto.MRO2
99private import semmle.python.types.Builtins
1010
@@ -54,7 +54,7 @@ class PythonFunctionObjectInternal extends CallableObjectInternal, TPythonFuncti
5454 result = this .getScope ( ) .toString ( )
5555 }
5656
57- override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
57+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
5858 this = TPythonFunctionObject ( node ) and context .appliesTo ( node )
5959 }
6060
@@ -72,7 +72,7 @@ class PythonFunctionObjectInternal extends CallableObjectInternal, TPythonFuncti
7272 this = TPythonFunctionObject ( result )
7373 }
7474
75- override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
75+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) {
7676 exists ( Function func , ControlFlowNode rval |
7777 func = this .getScope ( ) and
7878 callee .appliesToScope ( func ) and
@@ -105,7 +105,7 @@ class BuiltinFunctionObjectInternal extends CallableObjectInternal, TBuiltinFunc
105105 result = "Builtin-function " + this .getBuiltin ( ) .getName ( )
106106 }
107107
108- override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
108+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
109109 none ( )
110110 }
111111
@@ -115,7 +115,7 @@ class BuiltinFunctionObjectInternal extends CallableObjectInternal, TBuiltinFunc
115115
116116 override boolean isComparable ( ) { result = true }
117117
118- override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
118+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) {
119119 none ( )
120120 }
121121
@@ -185,13 +185,13 @@ class BuiltinMethodObjectInternal extends CallableObjectInternal, TBuiltinMethod
185185 result = TBuiltinClassObject ( this .getBuiltin ( ) .getClass ( ) )
186186 }
187187
188- override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
188+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
189189 none ( )
190190 }
191191
192192 override boolean isComparable ( ) { result = true }
193193
194- override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
194+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) {
195195 none ( )
196196 }
197197
@@ -236,13 +236,13 @@ class BoundMethodObjectInternal extends CallableObjectInternal, TBoundMethod {
236236 result = TBuiltinClassObject ( Builtin:: special ( "MethodType" ) )
237237 }
238238
239- override predicate introduced ( ControlFlowNode node , PointsToContext2 context ) {
239+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
240240 this = TBoundMethod ( node , _, _, context )
241241 }
242242
243243 override boolean isComparable ( ) { result = false }
244244
245- override predicate callResult ( PointsToContext2 callee , ObjectInternal obj , CfgOrigin origin ) {
245+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) {
246246 this .getFunction ( ) .callResult ( callee , obj , origin )
247247 }
248248
@@ -264,6 +264,103 @@ class BoundMethodObjectInternal extends CallableObjectInternal, TBoundMethod {
264264
265265}
266266
267+ class ClassMethodObjectInternal extends ObjectInternal , TClassMethod {
268+
269+ override string toString ( ) {
270+ result = "classmethod()"
271+ }
272+
273+ override boolean booleanValue ( ) { result = true }
274+
275+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
276+ exists ( CallableObjectInternal function |
277+ this = TClassMethod ( node , function ) and
278+ class_method ( node , function , context )
279+ )
280+ }
281+
282+ CallableObjectInternal getFunction ( ) {
283+ this = TClassMethod ( _, result )
284+ }
285+
286+ override ClassDecl getClassDeclaration ( ) { none ( ) }
287+
288+ override boolean isClass ( ) { result = false }
289+
290+ override ObjectInternal getClass ( ) { result = ObjectInternal:: builtin ( "classmethod" ) }
291+
292+ override boolean isComparable ( ) { none ( ) }
293+
294+ override Builtin getBuiltin ( ) { none ( ) }
295+
296+ override ControlFlowNode getOrigin ( ) { this = TClassMethod ( result , _) }
297+
298+ override predicate callResult ( ObjectInternal obj , CfgOrigin origin ) { none ( ) }
299+
300+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) { none ( ) }
301+
302+ override int intValue ( ) { none ( ) }
303+
304+ override string strValue ( ) { none ( ) }
305+
306+ override predicate calleeAndOffset ( Function scope , int paramOffset ) {
307+ this .getFunction ( ) .calleeAndOffset ( scope , paramOffset )
308+ }
309+
310+ override predicate attribute ( string name , ObjectInternal value , CfgOrigin origin ) { none ( ) }
311+
312+ override predicate attributesUnknown ( ) { none ( ) }
313+
314+ }
315+
316+ class StaticMethodObjectInternal extends ObjectInternal , TStaticMethod {
317+
318+ override string toString ( ) {
319+ result = "staticmethod()"
320+ }
321+
322+ override boolean booleanValue ( ) { result = true }
323+
324+ override predicate introduced ( ControlFlowNode node , PointsToContext context ) {
325+ exists ( CallableObjectInternal function |
326+ this = TStaticMethod ( node , function ) and
327+ static_method ( node , function , context )
328+ )
329+ }
330+
331+ CallableObjectInternal getFunction ( ) {
332+ this = TStaticMethod ( _, result )
333+ }
334+
335+ override ClassDecl getClassDeclaration ( ) { none ( ) }
336+
337+ override boolean isClass ( ) { result = false }
338+
339+ override ObjectInternal getClass ( ) { result = ObjectInternal:: builtin ( "staticmethod" ) }
340+
341+ override boolean isComparable ( ) { none ( ) }
342+
343+ override Builtin getBuiltin ( ) { none ( ) }
344+
345+ override ControlFlowNode getOrigin ( ) { this = TStaticMethod ( result , _) }
346+
347+ override predicate callResult ( ObjectInternal obj , CfgOrigin origin ) { none ( ) }
348+
349+ override predicate callResult ( PointsToContext callee , ObjectInternal obj , CfgOrigin origin ) { none ( ) }
350+
351+ override int intValue ( ) { none ( ) }
352+
353+ override string strValue ( ) { none ( ) }
354+
355+ override predicate calleeAndOffset ( Function scope , int paramOffset ) {
356+ this .getFunction ( ) .calleeAndOffset ( scope , paramOffset )
357+ }
358+
359+ override predicate attribute ( string name , ObjectInternal value , CfgOrigin origin ) { none ( ) }
360+
361+ override predicate attributesUnknown ( ) { none ( ) }
362+
363+ }
267364
268365
269366
0 commit comments