mirror of
https://github.com/github/codeql.git
synced 2026-02-13 13:41:08 +01:00
29 lines
780 B
Plaintext
29 lines
780 B
Plaintext
/**
|
|
* @name Non-callable called
|
|
* @description A call to an object which is not a callable will raise a TypeError at runtime.
|
|
* @kind problem
|
|
* @tags quality
|
|
* reliability
|
|
* correctness
|
|
* @problem.severity error
|
|
* @sub-severity high
|
|
* @precision high
|
|
* @id py/call-to-non-callable
|
|
*/
|
|
|
|
import python
|
|
private import LegacyPointsTo
|
|
import Exceptions.NotImplemented
|
|
|
|
from Call c, Value v, ClassValue t, ExprWithPointsTo f, AstNode origin
|
|
where
|
|
f = c.getFunc() and
|
|
f.pointsTo(v, origin) and
|
|
t = v.getClass() and
|
|
not t.isCallable() and
|
|
not t.failedInference(_) and
|
|
not t.hasAttribute("__get__") and
|
|
not v = Value::named("None") and
|
|
not use_of_not_implemented_in_raise(_, f)
|
|
select c, "Call to a $@ of $@.", origin, "non-callable", t, t.toString()
|