11private import python
22private import DataFlowPublic
33private import semmle.python.essa.SsaCompute
4- private import semmle.python.dataflow.new.internal.ImportStar
4+ private import semmle.python.dataflow.new.internal.ImportResolution
55// Since we allow extra data-flow steps from modeled frameworks, we import these
66// up-front, to ensure these are included. This provides a more seamless experience from
77// a user point of view, since they don't need to know they need to import a specific
@@ -335,11 +335,7 @@ predicate runtimeJumpStep(Node nodeFrom, Node nodeTo) {
335335 nodeFrom = nodeTo .( ModuleVariableNode ) .getAWrite ( )
336336 or
337337 // Setting the possible values of the variable at the end of import time
338- exists ( SsaVariable def |
339- def = any ( SsaVariable var ) .getAnUltimateDefinition ( ) and
340- def .getDefinition ( ) = nodeFrom .asCfgNode ( ) and
341- def .getVariable ( ) = nodeTo .( ModuleVariableNode ) .getVariable ( )
342- )
338+ nodeFrom = nodeTo .( ModuleVariableNode ) .getADefiningWrite ( )
343339}
344340
345341/**
@@ -423,9 +419,9 @@ predicate jumpStepSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
423419 runtimeJumpStep ( nodeFrom , nodeTo )
424420 or
425421 // Read of module attribute:
426- exists ( AttrRead r , ModuleValue mv |
427- r .getObject ( ) . asCfgNode ( ) . pointsTo ( mv ) and
428- module_export ( mv . getScope ( ) , r .getAttributeName ( ) , nodeFrom ) and
422+ exists ( AttrRead r |
423+ ImportResolution :: module_export ( ImportResolution :: getModule ( r .getObject ( ) ) ,
424+ r .getAttributeName ( ) , nodeFrom ) and
429425 nodeTo = r
430426 )
431427 or
@@ -449,22 +445,6 @@ predicate jumpStepNotSharedWithTypeTracker(Node nodeFrom, Node nodeTo) {
449445 any ( Orm:: AdditionalOrmSteps es ) .jumpStep ( nodeFrom , nodeTo )
450446}
451447
452- /**
453- * Holds if the module `m` defines a name `name` by assigning `defn` to it. This is an
454- * overapproximation, as `name` may not in fact be exported (e.g. by defining an `__all__` that does
455- * not include `name`).
456- */
457- private predicate module_export ( Module m , string name , CfgNode defn ) {
458- exists ( EssaVariable v |
459- v .getName ( ) = name and
460- v .getAUse ( ) = ImportStar:: getStarImported * ( m ) .getANormalExit ( )
461- |
462- defn .getNode ( ) = v .getDefinition ( ) .( AssignmentDefinition ) .getValue ( )
463- or
464- defn .getNode ( ) = v .getDefinition ( ) .( ArgumentRefinement ) .getArgument ( )
465- )
466- }
467-
468448//--------
469449// Field flow
470450//--------
0 commit comments