Skip to content

Commit 4c0f123

Browse files
committed
Python: switch from '*' to '$' pseudo variable to track module state.
1 parent 9820249 commit 4c0f123

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

python/ql/src/semmle/python/dataflow/SsaDefinitions.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private predicate class_with_global_metaclass(Class cls, GlobalVariable metaclas
337337

338338
/** Holds if this variable is implicitly defined */
339339
private predicate implicit_definition(Variable v) {
340-
v.getId() = "*"
340+
v.getId() = "*" or v.getId() = "$"
341341
or
342342
exists(ImportStar is | is.getScope() = v.getScope())
343343
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ module PointsTo {
119119
or
120120
exists(Module init |
121121
init = package.getInitModule().getModule() |
122-
not exists(PythonSsaSourceVariable v | v.getScope() = init | v.getName() = name or v.getName() = "*")
122+
not exists(PythonSsaSourceVariable v | v.getScope() = init | v.getName() = name or v.getName() = "$")
123123
or
124124
exists(EssaVariable v, PointsToContext imp |
125-
v.getScope() = init and v.getName() = "*" and v.getAUse() = init.getANormalExit() |
125+
v.getScope() = init and v.getName() = "$" and v.getAUse() = init.getANormalExit() |
126126
SSA::ssa_variable_named_attribute_points_to(v, imp, name, undefinedVariable(), _, _) and
127127
imp.isImport()
128128
)
@@ -145,7 +145,7 @@ module PointsTo {
145145
or
146146
not exists(EssaVariable var | var.getAUse() = m.getANormalExit() and var.getSourceVariable().getName() = name) and
147147
exists(EssaVariable var, PointsToContext imp |
148-
var.getAUse() = m.getANormalExit() and var.getName() = "*" |
148+
var.getAUse() = m.getANormalExit() and var.getName() = "$" |
149149
SSA::ssa_variable_named_attribute_points_to(var, imp, name, obj, cls, origin) and
150150
imp.isImport() and obj != undefinedVariable()
151151
)
@@ -1680,7 +1680,7 @@ module PointsTo {
16801680
/* Undefined variable */
16811681
exists(Scope scope |
16821682
not def.getVariable().getName() = "__name__" and
1683-
not def.getVariable().getName() = "*" and
1683+
not def.getVariable().getName() = "$" and
16841684
def.getScope() = scope and context.appliesToScope(scope) |
16851685
def.getSourceVariable() instanceof GlobalVariable and scope instanceof Module
16861686
or
@@ -1853,7 +1853,7 @@ module PointsTo {
18531853
)
18541854
or
18551855
origin = def.getDefiningNode() and
1856-
def.getSourceVariable().getName() = "*" and
1856+
def.getSourceVariable().getName() = "$" and
18571857
context.isImport() and
18581858
exists(PackageObject package |
18591859
package.getInitModule().getModule() = def.getScope() |
@@ -1964,7 +1964,7 @@ module PointsTo {
19641964
/* Helper for import_star_named_attribute_points_to */
19651965
pragma [noinline]
19661966
private predicate star_variable_import_star_module(ImportStarRefinement def, ImportStarNode imp, PointsToContext context, ModuleObject mod) {
1967-
def.getSourceVariable().getName() = "*" and
1967+
def.getSourceVariable().getName() = "$" and
19681968
exists(ControlFlowNode fmod |
19691969
fmod = imp.getModule() and
19701970
imp = def.getDefiningNode() and
@@ -1984,7 +1984,7 @@ module PointsTo {
19841984
/* Helper for ssa_star_variable_input_points_to */
19851985
pragma [noinline]
19861986
private predicate ssa_star_import_star_input(ImportStarRefinement def, EssaVariable var) {
1987-
def.getSourceVariable().getName() = "*" and var = def.getInput()
1987+
def.getSourceVariable().getName() = "$" and var = def.getInput()
19881988
}
19891989

19901990
pragma [noinline]

0 commit comments

Comments
 (0)