Files
codeql/python/ql/src/Classes/WrongNameForArgumentInClassInstantiation.ql
Taus 5b63b4957c Python: Fix query tests
Mostly just adding `private import LegacyPointsTo`. Sometimes getting
rid of other imports that are superceded by that module.
2025-11-26 12:30:30 +00:00

27 lines
857 B
Plaintext

/**
* @name Wrong name for an argument in a class instantiation
* @description Using a named argument whose name does not correspond to a
* parameter of the __init__ method of the class being
* instantiated, will result in a TypeError at runtime.
* @kind problem
* @tags quality
* reliability
* correctness
* external/cwe/cwe-628
* @problem.severity error
* @sub-severity low
* @precision very-high
* @id py/call/wrong-named-class-argument
*/
import python
import Expressions.CallArgs
private import LegacyPointsTo
from Call call, ClassValue cls, string name, FunctionValue init
where
illegally_named_parameter(call, cls, name) and
init = get_function_or_initializer(cls)
select call, "Keyword argument '" + name + "' is not a supported parameter name of $@.", init,
init.getQualifiedName()