mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
Python points-to: Make sure that builtin-classes inherit attributes.
This commit is contained in:
@@ -212,6 +212,15 @@ predicate file_sanity(string clsname, string problem, string what) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
predicate class_value_sanity(string clsname, string problem, string what) {
|
||||||
|
exists(ClassValue value |
|
||||||
|
exists(value.getASuperType().lookup(what)) and
|
||||||
|
not exists(value.lookup(what)) and
|
||||||
|
clsname = value.getAQlClass() and
|
||||||
|
problem = "is missing attribute that superclass has"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
from string clsname, string problem, string what
|
from string clsname, string problem, string what
|
||||||
where
|
where
|
||||||
ast_sanity(clsname, problem, what) or
|
ast_sanity(clsname, problem, what) or
|
||||||
@@ -224,5 +233,6 @@ source_object_sanity(clsname, problem, what) or
|
|||||||
function_object_sanity(clsname, problem, what) or
|
function_object_sanity(clsname, problem, what) or
|
||||||
points_to_sanity(clsname, problem, what) or
|
points_to_sanity(clsname, problem, what) or
|
||||||
jump_to_definition_sanity(clsname, problem, what) or
|
jump_to_definition_sanity(clsname, problem, what) or
|
||||||
file_sanity(clsname, problem, what)
|
file_sanity(clsname, problem, what) or
|
||||||
|
class_value_sanity(clsname, problem, what)
|
||||||
select clsname + " " + what + " has " + problem
|
select clsname + " " + what + " has " + problem
|
||||||
|
|||||||
@@ -191,8 +191,7 @@ class BuiltinClassObjectInternal extends ClassObjectInternal, TBuiltinClassObjec
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate lookup(string name, ObjectInternal value, CfgOrigin origin) {
|
override predicate lookup(string name, ObjectInternal value, CfgOrigin origin) {
|
||||||
value = ObjectInternal::fromBuiltin(this.getBuiltin().getMember(name)) and
|
Types::getMro(this).lookup(name, value, origin)
|
||||||
origin = CfgOrigin::unknown()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pragma [noinline] override predicate attributesUnknown() { none() }
|
pragma [noinline] override predicate attributesUnknown() { none() }
|
||||||
@@ -301,8 +300,7 @@ class TypeInternal extends ClassObjectInternal, TType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override predicate lookup(string name, ObjectInternal value, CfgOrigin origin) {
|
override predicate lookup(string name, ObjectInternal value, CfgOrigin origin) {
|
||||||
value = ObjectInternal::fromBuiltin(Builtin::special("type").getMember(name)) and
|
Types::getMro(this).lookup(name, value, origin)
|
||||||
origin = CfgOrigin::unknown()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pragma [noinline] override predicate attributesUnknown() { any() }
|
pragma [noinline] override predicate attributesUnknown() { any() }
|
||||||
|
|||||||
Reference in New Issue
Block a user