Skip to content

Commit 65cba82

Browse files
committed
Fixes bug w/ use of pointsTo
1 parent bfb720c commit 65cba82

File tree

1 file changed

+2
-32
lines changed

1 file changed

+2
-32
lines changed

python/ql/src/Expressions/ExpectedMappingForFormatString.ql

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,7 @@
1313
import python
1414
import semmle.python.strings
1515

16-
/* modernized query
1716
from Expr e, ClassValue t
1817
where exists(BinaryExpr b | b.getOp() instanceof Mod and format_string(b.getLeft()) and e = b.getRight() and
19-
mapping_format(b.getLeft()) and e.pointsTo(_, t, _) and not t.isMapping())
20-
select e, "Right hand side of a % operator must be a mapping, not class $@.", t, t.getName()
21-
//*/
22-
23-
/* original query
24-
from Expr e, ClassObject t
25-
where exists(BinaryExpr b | b.getOp() instanceof Mod and format_string(b.getLeft()) and e = b.getRight() and
26-
mapping_format(b.getLeft()) and e.refersTo(_, t, _) and not t.isMapping())
27-
select e, "Right hand side of a % operator must be a mapping, not class $@.", t, t.getName()
28-
//*/
29-
30-
//* debug query
31-
from Expr e, ClassValue t, string s
32-
where any()
33-
and exists(BinaryExpr b | any()
34-
and b.getOp() instanceof Mod
35-
and format_string(b.getLeft())
36-
and e = b.getRight()
37-
and mapping_format(b.getLeft())
38-
and e.pointsTo().getClass() = t
39-
//and not t.isMapping()
40-
)
41-
and if t.hasAttribute("__getitem__") then s = "yes" else s = "no"
42-
select
43-
e
44-
, "Right hand side of a % operator must be a mapping, not class $@."
45-
, t
46-
, t.getName()
47-
, s
48-
, s
49-
//*/
18+
mapping_format(b.getLeft()) and e.pointsTo().getClass() = t and not t.isMapping())
19+
select e, "Right hand side of a % operator must be a mapping, not class $@.", t, t.getName()

0 commit comments

Comments
 (0)