@@ -84,6 +84,7 @@ library class CfgOrigin extends TCfgOrigin {
8484 this = TFlowNodeOrigin ( result )
8585 }
8686
87+ pragma [ inline]
8788 CfgOrigin fix ( ControlFlowNode here ) {
8889 this = TUnknownOrigin ( ) and result = TFlowNodeOrigin ( here )
8990 or
@@ -128,7 +129,7 @@ module PointsTo {
128129 pointsToValue ( f , context , value , origin ) and
129130 cls = value .getClass ( ) .getSource ( ) |
130131 obj = value .getSource ( ) or
131- not exists ( value .getSource ( ) ) and obj = origin
132+ not exists ( value .getSource ( ) ) and obj = origin and not cls = theBoundMethodType ( )
132133 )
133134 or
134135 /* Backwards compatibility for *args and **kwargs */
@@ -663,22 +664,20 @@ module InterModulePointsTo {
663664
664665 /** Points-to for `from ... import *`. */
665666 predicate import_star_points_to ( ImportStarRefinement def , PointsToContext context , ObjectInternal value , CfgOrigin origin ) {
666- exists ( CfgOrigin orig |
667- origin = orig .fix ( def .getDefiningNode ( ) )
668- |
669- exists ( ModuleObjectInternal mod , string name |
670- PointsToInternal:: pointsTo ( def .getDefiningNode ( ) .( ImportStarNode ) .getModule ( ) , context , mod , _) and
671- name = def .getSourceVariable ( ) .getName ( ) |
672- /* Attribute from imported module */
673- module_exports_boolean ( mod , name ) = true and
674- mod .attribute ( name , value , origin )
675- )
676- or
677- exists ( EssaVariable var |
678- /* Retain value held before import */
679- variable_not_redefined_by_import_star ( var , context , def ) and
680- PointsToInternal:: variablePointsTo ( var , context , value , orig )
681- )
667+ /* Attribute from imported module */
668+ exists ( CfgOrigin orig , ImportStarNode imp , ModuleObjectInternal mod , string name |
669+ imp = def .getDefiningNode ( ) and
670+ PointsToInternal:: pointsTo ( imp .getModule ( ) , context , mod , _) and
671+ name = def .getSourceVariable ( ) .getName ( ) and
672+ module_exports_boolean ( mod , name ) = true and
673+ mod .attribute ( name , value , orig ) and
674+ origin = orig .fix ( imp )
675+ )
676+ or
677+ /* Retain value held before import */
678+ exists ( EssaVariable var |
679+ variable_not_redefined_by_import_star ( var , context , def ) and
680+ PointsToInternal:: variablePointsTo ( var , context , value , origin )
682681 )
683682 }
684683
@@ -751,6 +750,8 @@ module InterModulePointsTo {
751750 )
752751 or
753752 name = "__name__" and result = true
753+ or
754+ exists ( mod .( BuiltinModuleObjectInternal ) .getBuiltin ( ) .getMember ( name ) ) and result = true
754755 }
755756
756757}
@@ -1650,14 +1651,18 @@ cached module Types {
16501651module AttributePointsTo {
16511652
16521653 predicate attributePointsTo ( ControlFlowNode f , Context context , string name , ObjectInternal value , ControlFlowNode origin ) {
1653- exists ( ObjectInternal obj , Context prev , AttributeAssignment def |
1654- PointsToInternal:: pointsTo ( f , context , obj , _) and
1655- PointsToInternal:: variablePointsTo ( def .getInput ( ) , prev , obj , _) and
1654+ exists ( ObjectInternal defobj , Context prev , AttributeAssignment def , ObjectInternal useobj |
1655+ PointsToInternal:: pointsTo ( f , context , useobj , _) and
1656+ PointsToInternal:: variablePointsTo ( def .getInput ( ) , prev , defobj , _) and
16561657 PointsToInternal:: pointsTo ( def .getValue ( ) , prev , value , origin ) and name = def .getName ( )
16571658 |
1658- prev .getOuter * ( ) .getCall ( ) .getBasicBlock ( ) .reaches ( context .getOuter * ( ) .getCall ( ) .getBasicBlock ( ) )
1659+ prev .getOuter * ( ) .getCall ( ) .getBasicBlock ( ) .reaches ( context .getOuter * ( ) .getCall ( ) .getBasicBlock ( ) ) and
1660+ useobj .( SelfInstanceInternal ) .getClass ( ) = defobj .( SelfInstanceInternal ) .getClass ( )
1661+ or
1662+ def .getScope ( ) .getScope * ( ) .precedes ( f .getScope ( ) .getScope * ( ) ) and
1663+ useobj .( SelfInstanceInternal ) .getClass ( ) = defobj .( SelfInstanceInternal ) .getClass ( )
16591664 or
1660- def .getScope ( ) .getScope * ( ) .precedes ( f .getScope ( ) . getScope * ( ) )
1665+ def .getDefiningNode ( ) .getBasicBlock ( ) .dominates ( f .getBasicBlock ( ) ) and defobj = useobj
16611666 )
16621667 }
16631668
@@ -1697,8 +1702,9 @@ module ModuleAttributes {
16971702 private predicate importStarPointsTo ( ImportStarRefinement def , string name , ObjectInternal value , CfgOrigin origin ) {
16981703 def .getVariable ( ) .getName ( ) = "$" and
16991704 exists ( ImportStarNode imp , ModuleObjectInternal mod , CfgOrigin orig |
1705+ imp = def .getDefiningNode ( ) and
17001706 origin = orig .fix ( imp ) and
1701- PointsToInternal:: pointsTo ( def . getDefiningNode ( ) . ( ImportStarNode ) .getModule ( ) , any ( Context ctx | ctx .isImport ( ) ) , mod , _) |
1707+ PointsToInternal:: pointsTo ( imp .getModule ( ) , any ( Context ctx | ctx .isImport ( ) ) , mod , _) |
17021708 /* Attribute from imported module */
17031709 InterModulePointsTo:: module_exports_boolean ( mod , name ) = true and
17041710 mod .attribute ( name , value , orig ) and
0 commit comments