@@ -2,6 +2,7 @@ private import python
22private import DataFlowPublic
33private import semmle.python.essa.SsaCompute
44private import semmle.python.dataflow.new.internal.ImportStar
5+ private import semmle.python.dataflow.new.internal.ImportResolution
56// Since we allow extra data-flow steps from modeled frameworks, we import these
67// up-front, to ensure these are included. This provides a more seamless experience from
78// a user point of view, since they don't need to know they need to import a specific
@@ -419,9 +420,9 @@ predicate jumpStepSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
419420 runtimeJumpStep ( nodeFrom , nodeTo )
420421 or
421422 // Read of module attribute:
422- exists ( AttrRead r , ModuleValue mv |
423- r .getObject ( ) . asCfgNode ( ) . pointsTo ( mv ) and
424- module_export ( mv . getScope ( ) , r .getAttributeName ( ) , nodeFrom ) and
423+ exists ( AttrRead r |
424+ ImportResolution :: module_export ( ImportResolution :: getModule ( r .getObject ( ) ) ,
425+ r .getAttributeName ( ) , nodeFrom ) and
425426 nodeTo = r
426427 )
427428 or
@@ -445,22 +446,6 @@ predicate jumpStepNotSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
445446 any ( Orm:: AdditionalOrmSteps es ) .jumpStep ( nodeFrom , nodeTo )
446447}
447448
448- /**
449- * Holds if the module `m` defines a name `name` by assigning `defn` to it. This is an
450- * overapproximation, as `name` may not in fact be exported (e.g. by defining an `__all__` that does
451- * not include `name`).
452- */
453- private predicate module_export ( Module m , string name , CfgNode defn ) {
454- exists ( EssaVariable v |
455- v .getName ( ) = name and
456- v .getAUse ( ) = ImportStar:: getStarImported * ( m ) .getANormalExit ( )
457- |
458- defn .getNode ( ) = v .getDefinition ( ) .( AssignmentDefinition ) .getValue ( )
459- or
460- defn .getNode ( ) = v .getDefinition ( ) .( ArgumentRefinement ) .getArgument ( )
461- )
462- }
463-
464449//--------
465450// Field flow
466451//--------
0 commit comments