Skip to content

Commit d77ce4f

Browse files
committed
Python: minor rewrite of from <pkg> import * handling
1 parent 4df7dfb commit d77ce4f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/ImportResolution.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,18 @@ module ImportResolution {
8686
predicate module_export(Module m, string name, DataFlow::CfgNode defn) {
8787
exists(EssaVariable v, EssaDefinition essaDef |
8888
v.getName() = name and
89-
v.getAUse() = ImportStar::getStarImported*(m).getANormalExit() and
89+
v.getAUse() = m.getANormalExit() and
9090
allowedEssaImportStep*(essaDef, v.getDefinition())
9191
|
9292
defn.getNode() = essaDef.(AssignmentDefinition).getValue()
9393
or
9494
defn.getNode() = essaDef.(ArgumentRefinement).getArgument()
9595
)
9696
or
97+
// `from <pkg> import *`
98+
module_export(ImportStar::getStarImported+(m), name, defn)
99+
or
100+
// `import <pkg>` or `from <pkg> import <stuff>`
97101
exists(Alias a |
98102
defn.asExpr() = a.getValue() and
99103
a.getAsname().(Name).getId() = name and

0 commit comments

Comments
 (0)