Skip to content

Commit bcfe209

Browse files
committed
Python points-to: Fix up some oddities with nested from ... import *.
1 parent c4a79c2 commit bcfe209

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

python/ql/src/semmle/python/objects/Modules.qll

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,9 @@ class PackageObjectInternal extends ModuleObjectInternal, TPackageObject {
175175
pragma [noinline] override predicate attribute(string name, ObjectInternal value, CfgOrigin origin) {
176176
this.getInitModule().attribute(name, value, origin)
177177
or
178-
exists(Module init |
179-
init = this.getSourceModule() and
180-
(
181-
/* There is no variable shadowing the name of the child module */
182-
not exists(EssaVariable var | var.getAUse() = init.getANormalExit() and var.getSourceVariable().getName() = name)
183-
or
184-
/* The variable shadowing the name of the child module is undefined at exit */
185-
ModuleAttributes::pointsToAtExit(init, name, ObjectInternal::undefined(), _)
186-
) and
178+
exists(ModuleObjectInternal init |
179+
init = this.getInitModule() and
180+
InterModulePointsTo::moduleExportsBoolean(init, name) = false and
187181
not name = "__init__" and
188182
value = this.submodule(name) and
189183
origin = CfgOrigin::fromObject(value)
@@ -249,6 +243,7 @@ class PythonModuleObjectInternal extends ModuleObjectInternal, TPythonModule {
249243
}
250244

251245
pragma [noinline] override predicate attribute(string name, ObjectInternal value, CfgOrigin origin) {
246+
value != ObjectInternal::undefined() and
252247
ModuleAttributes::pointsToAtExit(this.getSourceModule(), name, value, origin)
253248
}
254249

python/ql/src/semmle/python/pointsto/PointsTo.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ cached module PointsToInternal {
594594

595595
}
596596

597-
private module InterModulePointsTo {
597+
module InterModulePointsTo {
598598

599599
pragma [noinline]
600600
predicate import_points_to(ControlFlowNode f, PointsToContext context, ObjectInternal value, ControlFlowNode origin) {

0 commit comments

Comments
 (0)