mirror of
https://github.com/github/codeql.git
synced 2026-07-12 23:15:40 +02:00
Python: Adds modernized predicates
This commit is contained in:
@@ -269,6 +269,18 @@ class ExceptFlowNode extends ControlFlowNode {
|
||||
)
|
||||
}
|
||||
|
||||
private predicate handledObject(Value val, ClassValue cls, ControlFlowNode origin) {
|
||||
val.getClass() = cls and
|
||||
(
|
||||
this.getType().pointsTo(val, origin)
|
||||
or
|
||||
exists(TupleValue tup |
|
||||
this.handledObject(tup, ClassValue::tuple(), _) |
|
||||
val = tup.getItem(_) and origin.pointsTo(val)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
|
||||
pragma [noinline]
|
||||
predicate handledException_objectapi(Object obj, ClassObject cls, ControlFlowNode origin) {
|
||||
@@ -278,6 +290,15 @@ class ExceptFlowNode extends ControlFlowNode {
|
||||
origin = this
|
||||
}
|
||||
|
||||
/** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
|
||||
pragma [noinline]
|
||||
predicate handledException(Value val, ClassValue cls, ControlFlowNode origin) {
|
||||
this.handledObject(val, cls, origin) and not cls = ClassValue::tuple()
|
||||
or
|
||||
not exists(this.getNode().(ExceptStmt).getType()) and val = ClassValue::baseException() and cls = ClassValue::type() and
|
||||
origin = this
|
||||
}
|
||||
|
||||
/** Whether this `except` handles `cls` */
|
||||
predicate handles(ClassObject cls) {
|
||||
exists(ClassObject handled |
|
||||
|
||||
Reference in New Issue
Block a user