Skip to content

Commit bcf67a5

Browse files
committed
Python: Move some non-points-to methods out of points-to
These methods were in `pointsto.Base` but did not actually interact with the points-to machinery directly, so they were easy to move out.
1 parent b3d51bf commit bcf67a5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

python/ql/lib/semmle/python/essa/Definitions.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,17 @@ class ModuleVariable extends SsaSourceVariable instanceof GlobalVariable {
276276
override CallNode redefinedAtCallSite() { none() }
277277
}
278278

279+
/** Holds if `f` is an import of the form `from .[...] import ...` and the enclosing scope is an __init__ module */
280+
private predicate import_from_dot_in_init(ImportExprNode f) {
281+
f.getScope() = any(Module m).getInitModule() and
282+
(
283+
f.getNode().getLevel() = 1 and
284+
not exists(f.getNode().getName())
285+
or
286+
f.getNode().getImportedModuleName() = f.getEnclosingModule().getPackage().getName()
287+
)
288+
}
289+
279290
class NonEscapingGlobalVariable extends ModuleVariable {
280291
NonEscapingGlobalVariable() {
281292
this instanceof GlobalVariable and

python/ql/lib/semmle/python/essa/SsaDefinitions.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ import python
77
private import semmle.python.internal.CachedStages
88
private import LegacyPointsTo
99

10+
/** Hold if `expr` is a test (a branch) and `use` is within that test */
11+
predicate test_contains(ControlFlowNode expr, ControlFlowNode use) {
12+
expr.getNode() instanceof Expr and
13+
expr.isBranch() and
14+
expr.getAChild*() = use
15+
}
16+
1017
cached
1118
module SsaSource {
1219
/** Holds if `v` is used as the receiver in a method call. */

0 commit comments

Comments
 (0)