@@ -27,6 +27,7 @@ import python
2727private import PointsToContext
2828private import Base
2929private import semmle.python.types.Extensions
30+ private import semmle.python.types.Builtins
3031private import Filters as BaseFilters
3132import semmle.dataflow.SSA
3233private import MRO
@@ -311,7 +312,7 @@ module PointsTo {
311312 exists ( SubscriptNode sub , Object sys_modules |
312313 sub .getValue ( ) = sys_modules_flow and
313314 points_to ( sys_modules_flow , _, sys_modules , _, _) and
314- builtin_module_attribute ( theSysModuleObject ( ) , " modules", sys_modules , _ ) and
315+ sys_modules . asBuiltin ( ) = Builtin :: special ( "sys" ) . getMember ( " modules") and
315316 sub .getIndex ( ) = n and
316317 n .getNode ( ) .( StrConst ) .getText ( ) = name and
317318 sub .( DefinitionNode ) .getValue ( ) = mod and
@@ -435,7 +436,7 @@ module PointsTo {
435436 }
436437
437438 private boolean module_exports_boolean ( ModuleObject mod , string name ) {
438- py_cmembers_versioned ( mod , name , _ , major_version ( ) .toString ( ) ) and
439+ exists ( mod . asBuiltin ( ) .getMember ( name ) ) and
439440 name .charAt ( 0 ) != "_" and result = true
440441 or
441442 result = package_exports_boolean ( mod , name )
@@ -494,7 +495,8 @@ module PointsTo {
494495 or
495496 package_attribute_points_to ( mod , name , value , cls , origin )
496497 or
497- builtin_module_attribute ( mod , name , value , cls ) and origin = CfgOrigin:: unknown ( )
498+ value .asBuiltin ( ) = mod .asBuiltin ( ) .getMember ( name ) and
499+ cls .asBuiltin ( ) = value .asBuiltin ( ) .getClass ( ) and origin = CfgOrigin:: unknown ( )
498500 }
499501
500502 }
@@ -2458,7 +2460,7 @@ module PointsTo {
24582460 is_new_style ( cls ) and not exists ( cls_expr .getBase ( 0 ) ) and result = theObjectType ( ) and n = 0
24592461 )
24602462 or
2461- result = builtin_base_type ( cls ) and n = 0
2463+ result . asBuiltin ( ) = cls . asBuiltin ( ) . getBaseClass ( ) and n = 0
24622464 or
24632465 cls = theUnknownType ( ) and result = theObjectType ( ) and n = 0
24642466 }
@@ -2482,7 +2484,7 @@ module PointsTo {
24822484 or
24832485 cls = theObjectType ( ) and result = 0
24842486 or
2485- exists ( builtin_base_type ( cls ) ) and cls != theObjectType ( ) and result = 1
2487+ exists ( cls . asBuiltin ( ) . getBaseClass ( ) ) and cls != theObjectType ( ) and result = 1
24862488 or
24872489 cls = theUnknownType ( ) and result = 1
24882490 }
@@ -2646,8 +2648,8 @@ module PointsTo {
26462648 ssa_variable_points_to ( var , _, value , vcls , origin )
26472649 )
26482650 or
2649- value = builtin_class_attribute ( owner , name ) and class_declares_attribute ( owner , name ) and
2650- origin = CfgOrigin:: unknown ( ) and vcls = builtin_object_type ( value )
2651+ value . asBuiltin ( ) = owner . asBuiltin ( ) . getMember ( name ) and class_declares_attribute ( owner , name ) and
2652+ origin = CfgOrigin:: unknown ( ) and vcls . asBuiltin ( ) = value . asBuiltin ( ) . getClass ( )
26512653 }
26522654
26532655 private predicate interesting_class_attribute ( ClassList mro , string name ) {
@@ -2754,7 +2756,11 @@ module PointsTo {
27542756 obj = unknownValue ( ) and result = theUnknownType ( )
27552757 )
27562758 or
2757- py_cobjecttypes ( cls , result ) and is_c_metaclass ( result )
2759+ exists ( Builtin meta |
2760+ result .asBuiltin ( ) = meta and
2761+ meta = cls .asBuiltin ( ) .getClass ( ) and
2762+ meta .inheritsFromType ( )
2763+ )
27582764 or
27592765 exists ( ControlFlowNode meta |
27602766 Types:: six_add_metaclass ( _, cls , meta ) and
@@ -2777,7 +2783,7 @@ module PointsTo {
27772783 }
27782784
27792785 private boolean has_declared_metaclass ( ClassObject cls ) {
2780- py_cobjecttypes ( cls , _ ) and result = true
2786+ exists ( cls . asBuiltin ( ) . getClass ( ) ) and result = true
27812787 or
27822788 result = has_six_add_metaclass ( cls ) .booleanOr ( has_metaclass_var_metaclass ( cls ) )
27832789 }
0 commit comments