mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Python: Fix queries and tests
This commit is contained in:
@@ -36,7 +36,7 @@ predicate same_value(Expr left, Expr right) {
|
||||
}
|
||||
|
||||
predicate maybe_defined_in_outer_scope(Name n) {
|
||||
exists(SsaVariable v | v.getAUse().getNode() = n | v.maybeUndefined())
|
||||
exists(SsaVariableWithPointsTo v | v.getAUse().getNode() = n | v.maybeUndefined())
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -62,7 +62,7 @@ predicate undefined_use_in_function(Name u) {
|
||||
not u.getEnclosingModule().(ImportTimeScope).definesName(u.getId()) and
|
||||
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId())) and
|
||||
not globallyDefinedName(u.getId()) and
|
||||
not exists(SsaVariable var | var.getAUse().getNode() = u and not var.maybeUndefined()) and
|
||||
not exists(SsaVariableWithPointsTo var | var.getAUse().getNode() = u and not var.maybeUndefined()) and
|
||||
not guarded_against_name_error(u) and
|
||||
not (u.getEnclosingModule().isPackageInit() and u.getId() = "__path__")
|
||||
}
|
||||
@@ -70,7 +70,7 @@ predicate undefined_use_in_function(Name u) {
|
||||
predicate undefined_use_in_class_or_module(Name u) {
|
||||
exists(GlobalVariable v | u.uses(v)) and
|
||||
not u.getScope().getScope*() instanceof Function and
|
||||
exists(SsaVariable var | var.getAUse().getNode() = u | var.maybeUndefined()) and
|
||||
exists(SsaVariableWithPointsTo var | var.getAUse().getNode() = u | var.maybeUndefined()) and
|
||||
not guarded_against_name_error(u) and
|
||||
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId())) and
|
||||
not (u.getEnclosingModule().isPackageInit() and u.getId() = "__path__") and
|
||||
|
||||
@@ -18,7 +18,9 @@ private import semmle.python.types.ImportTime
|
||||
|
||||
/* Local variable part */
|
||||
predicate initialized_as_local(PlaceHolder use) {
|
||||
exists(SsaVariable l, Function f | f = use.getScope() and l.getAUse() = use.getAFlowNode() |
|
||||
exists(SsaVariableWithPointsTo l, Function f |
|
||||
f = use.getScope() and l.getAUse() = use.getAFlowNode()
|
||||
|
|
||||
l.getVariable() instanceof LocalVariable and
|
||||
not l.maybeUndefined()
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import python
|
||||
private import LegacyPointsTo
|
||||
|
||||
from SsaVariable var
|
||||
from SsaVariableWithPointsTo var
|
||||
where var.maybeUndefined()
|
||||
select var.getDefinition().getLocation().getStartLine(), var.toString()
|
||||
|
||||
Reference in New Issue
Block a user