Merge pull request #2827 from BekaValentine/objectapi-to-valueapi-expectedmappingforformatstring

Python: ObjectAPI to ValueAPI: ExpectedMappingForFormatString
This commit is contained in:
Rasmus Wriedt Larsen
2020-03-11 10:52:48 +01:00
committed by GitHub
3 changed files with 51 additions and 5 deletions

View File

@@ -13,7 +13,14 @@
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())
from Expr e, ClassValue 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.pointsTo().getClass() = t and
not t.isMapping()
)
select e, "Right hand side of a % operator must be a mapping, not class $@.", t, t.getName()