mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
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.
This commit is contained in:
@@ -276,6 +276,17 @@ class ModuleVariable extends SsaSourceVariable instanceof GlobalVariable {
|
|||||||
override CallNode redefinedAtCallSite() { none() }
|
override CallNode redefinedAtCallSite() { none() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Holds if `f` is an import of the form `from .[...] import ...` and the enclosing scope is an __init__ module */
|
||||||
|
private predicate import_from_dot_in_init(ImportExprNode f) {
|
||||||
|
f.getScope() = any(Module m).getInitModule() and
|
||||||
|
(
|
||||||
|
f.getNode().getLevel() = 1 and
|
||||||
|
not exists(f.getNode().getName())
|
||||||
|
or
|
||||||
|
f.getNode().getImportedModuleName() = f.getEnclosingModule().getPackage().getName()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
class NonEscapingGlobalVariable extends ModuleVariable {
|
class NonEscapingGlobalVariable extends ModuleVariable {
|
||||||
NonEscapingGlobalVariable() {
|
NonEscapingGlobalVariable() {
|
||||||
this instanceof GlobalVariable and
|
this instanceof GlobalVariable and
|
||||||
|
|||||||
@@ -7,6 +7,13 @@ import python
|
|||||||
private import semmle.python.internal.CachedStages
|
private import semmle.python.internal.CachedStages
|
||||||
private import LegacyPointsTo
|
private import LegacyPointsTo
|
||||||
|
|
||||||
|
/** Hold if `expr` is a test (a branch) and `use` is within that test */
|
||||||
|
predicate test_contains(ControlFlowNode expr, ControlFlowNode use) {
|
||||||
|
expr.getNode() instanceof Expr and
|
||||||
|
expr.isBranch() and
|
||||||
|
expr.getAChild*() = use
|
||||||
|
}
|
||||||
|
|
||||||
cached
|
cached
|
||||||
module SsaSource {
|
module SsaSource {
|
||||||
/** Holds if `v` is used as the receiver in a method call. */
|
/** Holds if `v` is used as the receiver in a method call. */
|
||||||
|
|||||||
@@ -44,24 +44,6 @@ private predicate class_defines_name(Class cls, string name) {
|
|||||||
exists(SsaVariable var | name = var.getId() and var.getAUse() = cls.getANormalExit())
|
exists(SsaVariable var | name = var.getId() and var.getAUse() = cls.getANormalExit())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hold if `expr` is a test (a branch) and `use` is within that test */
|
|
||||||
predicate test_contains(ControlFlowNode expr, ControlFlowNode use) {
|
|
||||||
expr.getNode() instanceof Expr and
|
|
||||||
expr.isBranch() and
|
|
||||||
expr.getAChild*() = use
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Holds if `f` is an import of the form `from .[...] import ...` and the enclosing scope is an __init__ module */
|
|
||||||
predicate import_from_dot_in_init(ImportExprNode f) {
|
|
||||||
f.getScope() = any(Module m).getInitModule() and
|
|
||||||
(
|
|
||||||
f.getNode().getLevel() = 1 and
|
|
||||||
not exists(f.getNode().getName())
|
|
||||||
or
|
|
||||||
f.getNode().getImportedModuleName() = f.getEnclosingModule().getPackage().getName()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gets the pseudo-object representing the value referred to by an undefined variable */
|
/** Gets the pseudo-object representing the value referred to by an undefined variable */
|
||||||
Object undefinedVariable() { py_special_objects(result, "_semmle_undefined_value") }
|
Object undefinedVariable() { py_special_objects(result, "_semmle_undefined_value") }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user