Files
codeql/python/ql/src/Statements/AssertOnTuple.ql
Taus Brock-Nannestad f07a7bf8cf Python: Autoformat everything using qlformat.
Will need subsequent PRs fixing up test failures (due to deprecated
methods moving around), but other than that everything should be
straight-forward.
2020-07-07 15:43:52 +02:00

28 lines
624 B
Plaintext

/**
* @name Asserting a tuple
* @description Using an assert statement to test a tuple provides no validity checking.
* @kind problem
* @tags reliability
* maintainability
* external/cwe/cwe-670
* @problem.severity error
* @sub-severity low
* @precision very-high
* @id py/asserts-tuple
*/
import python
from Assert a, string b, string non
where
a.getTest() instanceof Tuple and
(
if exists(a.getTest().(Tuple).getAnElt())
then (
b = "True" and non = "non-"
) else (
b = "False" and non = ""
)
)
select a, "Assertion of " + non + "empty tuple is always " + b + "."