mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
Python: Adds modernized predicate and moves queries over to it
This commit is contained in:
@@ -16,6 +16,6 @@ import Raising
|
||||
import Exceptions.NotImplemented
|
||||
|
||||
from Raise r, ClassObject t
|
||||
where type_or_typeof(r, t, _) and not t.isLegalExceptionType() and not t.failedInference() and not use_of_not_implemented_in_raise_objectapi(r, _)
|
||||
where type_or_typeof(r, t, _) and not t.isLegalExceptionType() and not t.failedInference() and not use_of_not_implemented_in_raise(r, _)
|
||||
select r, "Illegal class '" + t.getName() + "' raised; will result in a TypeError being raised instead."
|
||||
|
||||
|
||||
@@ -9,3 +9,12 @@ predicate use_of_not_implemented_in_raise_objectapi(Raise raise, Expr notimpl) {
|
||||
notimpl = raise.getException().(Call).getFunc()
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `notimpl` refers to `NotImplemented` or `NotImplemented()` in the `raise` statement */
|
||||
predicate use_of_not_implemented_in_raise(Raise raise, Expr notimpl) {
|
||||
notimpl.pointsTo(Value::named("NotImplemented")) and
|
||||
(
|
||||
notimpl = raise.getException() or
|
||||
notimpl = raise.getException().(Call).getFunc()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ import python
|
||||
import Exceptions.NotImplemented
|
||||
|
||||
from Expr notimpl
|
||||
where use_of_not_implemented_in_raise_objectapi(_, notimpl)
|
||||
where use_of_not_implemented_in_raise(_, notimpl)
|
||||
|
||||
select notimpl, "NotImplemented is not an Exception. Did you mean NotImplementedError?"
|
||||
|
||||
Reference in New Issue
Block a user