mirror of
https://github.com/github/codeql.git
synced 2025-12-22 03:36:30 +01:00
Initial commit of Python queries and QL libraries.
This commit is contained in:
committed by
Mark Shannon
parent
90c75cd362
commit
5f58824d1b
19
python/ql/src/Expressions/ExpectedMappingForFormatString.ql
Normal file
19
python/ql/src/Expressions/ExpectedMappingForFormatString.ql
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @name Formatted object is not a mapping
|
||||
* @description The formatted object must be a mapping when the format includes a named specifier; otherwise a TypeError will be raised."
|
||||
* @kind problem
|
||||
* @tags reliability
|
||||
* correctness
|
||||
* @problem.severity error
|
||||
* @sub-severity low
|
||||
* @precision high
|
||||
* @id py/percent-format/not-mapping
|
||||
*/
|
||||
|
||||
import python
|
||||
import semmle.python.strings
|
||||
|
||||
from Expr e, ClassObject t
|
||||
where exists(BinaryExpr b | b.getOp() instanceof Mod and format_string(b.getLeft()) and e = b.getRight() and
|
||||
mapping_format(b.getLeft()) and e.refersTo(_, t, _) and not t.isMapping())
|
||||
select e, "Right hand side of a % operator must be a mapping, not class $@.", t, t.getName()
|
||||
Reference in New Issue
Block a user