Files
codeql/python/ql/src/Exceptions/Raising.qll
2025-10-30 13:58:59 +00:00

14 lines
529 B
Plaintext

import python
private import LegacyPointsTo
/** Whether the raise statement 'r' raises 'type' from origin 'orig' */
predicate type_or_typeof(Raise r, ClassValue type, AstNode orig) {
exists(ExprWithPointsTo exception | exception = r.getRaised() |
exception.pointsTo(type, orig)
or
not exists(ClassValue exc_type | exception.pointsTo(exc_type)) and
not type = ClassValue::type() and // First value is an unknown exception type
exists(Value val | exception.pointsTo(val, orig) | val.getClass() = type)
)
}