mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Python: factor out helper predicate to prevent bad join-order.
This commit is contained in:
@@ -752,12 +752,6 @@ module PointsTo {
|
||||
origin = orig.asCfgNodeOrHere(f)
|
||||
|
|
||||
mod.getSourceModule() = f.getEnclosingModule() and
|
||||
exists(EssaVariable var |
|
||||
var.getSourceVariable().getName() = name and var.getAUse() = f and
|
||||
ssa_variable_points_to(var, context, value, cls, orig)
|
||||
)
|
||||
or
|
||||
mod.getSourceModule() = f.getEnclosingModule() and
|
||||
not exists(EssaVariable var | var.getSourceVariable().getName() = name and var.getAUse() = f) and
|
||||
exists(EssaVariable dollar |
|
||||
isModuleStateVariable(dollar) and dollar.getAUse() = f and
|
||||
@@ -767,6 +761,20 @@ module PointsTo {
|
||||
not mod.getSourceModule() = f.getEnclosingModule() and
|
||||
Layer::module_attribute_points_to(mod, name, value, cls, orig)
|
||||
)
|
||||
or
|
||||
exists(EssaVariable var, CfgOrigin orig |
|
||||
var = ssa_variable_for_module_attribute(f, context) and
|
||||
ssa_variable_points_to(var, context, value, cls, orig) and
|
||||
origin = orig.asCfgNodeOrHere(f)
|
||||
)
|
||||
}
|
||||
|
||||
private EssaVariable ssa_variable_for_module_attribute(ImportMemberNode f, PointsToContext context) {
|
||||
exists(string name, ModuleObject mod, Module m |
|
||||
mod.getSourceModule() = m and m = f.getEnclosingModule() and m = result.getScope() and
|
||||
points_to(f.getModule(name), context, mod, _, _) and
|
||||
result.getSourceVariable().getName() = name and result.getAUse() = f
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `f` is of the form `getattr(x, "name")` and x.name points to `(value, cls, origin)`. */
|
||||
|
||||
Reference in New Issue
Block a user