Python: minor rewrite of from <pkg> import * handling

This commit is contained in:
Rasmus Wriedt Larsen
2023-02-22 15:00:55 +01:00
parent 4df7dfbff6
commit d77ce4f3d7

View File

@@ -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