mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: minor rewrite of from <pkg> import * handling
This commit is contained in:
@@ -86,7 +86,7 @@ module ImportResolution {
|
||||
predicate module_export(Module m, string name, DataFlow::CfgNode defn) {
|
||||
exists(EssaVariable v, EssaDefinition essaDef |
|
||||
v.getName() = name and
|
||||
v.getAUse() = ImportStar::getStarImported*(m).getANormalExit() and
|
||||
v.getAUse() = m.getANormalExit() and
|
||||
allowedEssaImportStep*(essaDef, v.getDefinition())
|
||||
|
|
||||
defn.getNode() = essaDef.(AssignmentDefinition).getValue()
|
||||
@@ -94,6 +94,10 @@ module ImportResolution {
|
||||
defn.getNode() = essaDef.(ArgumentRefinement).getArgument()
|
||||
)
|
||||
or
|
||||
// `from <pkg> import *`
|
||||
module_export(ImportStar::getStarImported+(m), name, defn)
|
||||
or
|
||||
// `import <pkg>` or `from <pkg> import <stuff>`
|
||||
exists(Alias a |
|
||||
defn.asExpr() = a.getValue() and
|
||||
a.getAsname().(Name).getId() = name and
|
||||
|
||||
Reference in New Issue
Block a user