Skip to content

Commit cec4d55

Browse files
committed
Python points-to: Make sure that vararg tuples are only assigned to vararg parameters.
1 parent 53ddfce commit cec4d55

File tree

4 files changed

+2
-5
lines changed

4 files changed

+2
-5
lines changed

python/ql/src/semmle/python/pointsto/PointsTo.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,7 @@ module InterProceduralPointsTo {
906906
origin = def.getDefiningNode()
907907
or
908908
/* A tuple constructed from positional arguments for a `*` parameter. */
909+
def.isVarargs() and
909910
exists(CallNode call, Function scope, PointsToContext caller, int offset, int length |
910911
varargs_tuple(call, caller, scope, context, offset, length) and
911912
value = TVarargsTuple(call, caller, offset, length) and
@@ -914,6 +915,7 @@ module InterProceduralPointsTo {
914915
origin = def.getDefiningNode()
915916
or
916917
/* A `*` parameter with no surplus positional arguments; an empty tuple */
918+
def.isVarargs() and
917919
exists(Function scope |
918920
varargs_empty_tuple(scope, context) and
919921
value = ObjectInternal::emptyTuple() and

python/ql/test/library-tests/PointsTo/new/PointsToWithContext.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,6 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
612612
| l_calls.py:33 | ControlFlowNode for m | Function m | builtin-class function | 33 | import |
613613
| l_calls.py:34 | ControlFlowNode for self | E() | class E | 38 | code/l_calls.py:38 from import |
614614
| l_calls.py:34 | ControlFlowNode for self | int 3 | builtin-class int | 39 | code/l_calls.py:39 from import |
615-
| l_calls.py:34 | ControlFlowNode for self | self | builtin-class tuple | 33 | code/l_calls.py:38 from import |
616-
| l_calls.py:34 | ControlFlowNode for self | self | builtin-class tuple | 33 | code/l_calls.py:39 from import |
617615
| l_calls.py:34 | ControlFlowNode for self | self | class E | 33 | runtime |
618616
| l_calls.py:35 | ControlFlowNode for args | args | builtin-class tuple | 33 | code/l_calls.py:38 from import |
619617
| l_calls.py:35 | ControlFlowNode for args | args | builtin-class tuple | 33 | code/l_calls.py:39 from import |

python/ql/test/library-tests/PointsTo/new/PointsToWithType.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ WARNING: Predicate points_to has been deprecated and may be removed in future (P
687687
| l_calls.py:33 | ControlFlowNode for m | Function m | builtin-class function | 33 |
688688
| l_calls.py:34 | ControlFlowNode for self | E() | class E | 38 |
689689
| l_calls.py:34 | ControlFlowNode for self | int 3 | builtin-class int | 39 |
690-
| l_calls.py:34 | ControlFlowNode for self | self | builtin-class tuple | 33 |
691690
| l_calls.py:34 | ControlFlowNode for self | self | class E | 33 |
692691
| l_calls.py:35 | ControlFlowNode for args | args | builtin-class tuple | 33 |
693692
| l_calls.py:37 | ControlFlowNode for IntegerLiteral | int 1 | builtin-class int | 37 |

python/ql/test/library-tests/PointsTo/new/Values.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,7 @@
473473
| l_calls.py:32 | ControlFlowNode for ClassExpr | import | class E | builtin-class type |
474474
| l_calls.py:32 | ControlFlowNode for object | import | builtin-class object | builtin-class type |
475475
| l_calls.py:33 | ControlFlowNode for FunctionExpr | import | Function E.m | builtin-class function |
476-
| l_calls.py:34 | ControlFlowNode for self | code/l_calls.py:38 from import | (int 2, int 3, int 4, ) | builtin-class tuple |
477476
| l_calls.py:34 | ControlFlowNode for self | code/l_calls.py:38 from import | E() | class E |
478-
| l_calls.py:34 | ControlFlowNode for self | code/l_calls.py:39 from import | (int 4, int 5, ) | builtin-class tuple |
479477
| l_calls.py:34 | ControlFlowNode for self | code/l_calls.py:39 from import | int 3 | builtin-class int |
480478
| l_calls.py:34 | ControlFlowNode for self | runtime | self instance of E | class E |
481479
| l_calls.py:35 | ControlFlowNode for args | code/l_calls.py:38 from import | (int 2, int 3, int 4, ) | builtin-class tuple |

0 commit comments

Comments
 (0)