File tree Expand file tree Collapse file tree
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,7 +9,19 @@ private import semmle.python.dataflow.new.DataFlow
99private import semmle.python.dataflow.new.internal.ImportStar
1010private import semmle.python.dataflow.new.TypeTracking
1111private import semmle.python.dataflow.new.internal.DataFlowPrivate
12- private import semmle.python.essa.SsaDefinitions
12+
13+ /**
14+ * Holds if `init` is a package's `__init__.py` and `var` is a global variable in
15+ * `init` whose name matches a submodule of the package.
16+ *
17+ * Inlined from `SsaSource::init_module_submodule_defn` to avoid pulling
18+ * `semmle.python.essa.SsaDefinitions` into the new dataflow stack.
19+ */
20+ private predicate initModuleSubmoduleDefn ( GlobalVariable var , Module init ) {
21+ init .isPackageInit ( ) and
22+ exists ( init .getPackage ( ) .getSubModule ( var .getId ( ) ) ) and
23+ var .getScope ( ) = init
24+ }
1325
1426/**
1527 * Python modules and the way imports are resolved are... complicated. Here's a crash course in how
@@ -326,7 +338,7 @@ module ImportResolution {
326338 // imported yet.
327339 exists ( string submodule , Module package , EssaVariable var |
328340 submodule = var .getName ( ) and
329- SsaSource :: init_module_submodule_defn ( var .getSourceVariable ( ) , package . getEntryNode ( ) ) and
341+ initModuleSubmoduleDefn ( var .getSourceVariable ( ) , package ) and
330342 m = getModuleFromName ( package .getPackageName ( ) + "." + submodule ) and
331343 result .asCfgNode ( ) = var .getDefinition ( ) .( EssaNodeDefinition ) .getDefiningNode ( )
332344 )
You can’t perform that action at this time.
0 commit comments