11/** Provides predicates for reasoning about uses of `import *` in Python. */
2+ overlay [ local]
3+ module ;
24
35private import python
46private import semmle.python.dataflow.new.internal.Builtins
@@ -11,6 +13,7 @@ module ImportStar {
1113 * Holds if `n` is an access of a variable called `name` (which is _not_ the name of a
1214 * built-in, and which is _not_ a global defined in the enclosing module) inside the scope `s`.
1315 */
16+ overlay [ local]
1417 cached
1518 predicate namePossiblyDefinedInImportStar ( NameNode n , string name , Scope s ) {
1619 n .isLoad ( ) and
@@ -61,6 +64,7 @@ module ImportStar {
6164 * Holds if `n` may refer to a global variable of the same name in the module `m`, accessible
6265 * from the scope of `n` by a chain of `import *` imports.
6366 */
67+ overlay [ global]
6468 cached
6569 predicate importStarResolvesTo ( NameNode n , Module m ) {
6670 m = getStarImported + ( n .getEnclosingModule ( ) ) and
@@ -71,6 +75,7 @@ module ImportStar {
7175 /**
7276 * Gets a module that is imported from `m` via `import *`.
7377 */
78+ overlay [ global]
7479 cached
7580 Module getStarImported ( Module m ) {
7681 exists ( ImportStar i , DataFlow:: CfgNode imported_module |
@@ -92,6 +97,7 @@ module ImportStar {
9297 *
9398 * this would return the data-flow nodes corresponding to `foo.bar` and `quux`.
9499 */
100+ overlay [ local]
95101 cached
96102 ControlFlowNode potentialImportStarBase ( Scope s ) {
97103 result = any ( ImportStarNode n | n .getScope ( ) = s ) .getModule ( )
0 commit comments