Skip to content

Commit e6319e5

Browse files
committed
Python: Rewrite StringConstCompare to use IterableNode
1 parent 098f8c4 commit e6319e5

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

python/ql/src/semmle/python/dataflow/new/BarrierGuards.qll

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,15 @@ class StringConstCompare extends DataFlow::BarrierGuard, CompareNode {
1919
this.operands(checked_node, op, str_const.getAFlowNode())
2020
)
2121
or
22-
exists(ControlFlowNode str_const_iterable, Cmpop op |
22+
exists(IterableNode str_const_iterable, Cmpop op |
2323
op = any(In in_) and safe_branch = true
2424
or
2525
op = any(NotIn ni) and safe_branch = false
2626
|
27-
this.operands(checked_node, op, str_const_iterable) and
28-
(
29-
str_const_iterable instanceof SequenceNode
30-
or
31-
str_const_iterable instanceof SetNode
32-
) and
33-
forall(ControlFlowNode elem |
34-
elem = str_const_iterable.(SequenceNode).getAnElement()
35-
or
36-
elem = str_const_iterable.(SetNode).getAnElement()
37-
|
27+
forall(ControlFlowNode elem | elem = str_const_iterable.getAnElement() |
3828
elem.getNode() instanceof StrConst
39-
)
29+
) and
30+
this.operands(checked_node, op, str_const_iterable)
4031
)
4132
}
4233

0 commit comments

Comments
 (0)