Skip to content

Commit 2face94

Browse files
committed
Python: Mitigate CP in nested_sequence_assign.
The problem here was that in the base case, there was no relationship between `left_parent` and `right_parent`. These could be any two tuples or lists, even if they were not part of an assignment statement. To fix this, we add a bit of manual "magic", requiring that both of these arguments must belong to the left and right-hand sides of the same assignment statement. (Note that this is in principle _still_ a gross overapproximation, but since assignment statements are usually quite restricted in size, I don't expect this to be a major problem.)
1 parent 0da554c commit 2face94

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

python/ql/src/semmle/python/Flow.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ private AstNode assigned_value(Expr lhs) {
910910

911911
predicate nested_sequence_assign(Expr left_parent, Expr right_parent,
912912
Expr left_result, Expr right_result) {
913+
exists(Assign a |
914+
a.getATarget().getASubExpression*() = left_parent and
915+
a.getValue().getASubExpression*() = right_parent
916+
) and
913917
exists(int i, Expr left_elem, Expr right_elem
914918
|
915919
(

0 commit comments

Comments
 (0)