From 949b81b07cfbadf21137869410cc838ae8d9a582 Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Thu, 10 Sep 2020 13:42:10 +0200 Subject: [PATCH] Python: Add dataflow tests for dynamic tuple creation Inspired by the FP-report in https://github.com/github/codeql/issues/4239 --- .../experimental/dataflow/coverage/test.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/python/ql/test/experimental/dataflow/coverage/test.py b/python/ql/test/experimental/dataflow/coverage/test.py index 05d3711b99fd..32e303e3652c 100644 --- a/python/ql/test/experimental/dataflow/coverage/test.py +++ b/python/ql/test/experimental/dataflow/coverage/test.py @@ -534,3 +534,40 @@ def f6(arg): x = f6(SOURCE) SINK(x) # Flow missing + + +def test_dynamic_tuple_creation_1(): + tup = tuple() + tup += (SOURCE,) + tup += (NONSOURCE,) + + SINK(tup[0]) # Flow missing + SINK_F(tup[1]) + + +def test_dynamic_tuple_creation_2(): + tup = () + tup += (SOURCE,) + tup += (NONSOURCE,) + + SINK(tup[0]) # Flow missing + SINK_F(tup[1]) + + +def test_dynamic_tuple_creation_3(): + tup1 = (SOURCE,) + tup2 = (NONSOURCE,) + tup = tup1 + tup2 + + SINK(tup[0]) # Flow missing + SINK_F(tup[1]) + + +# Inspired by FP-report https://github.com/github/codeql/issues/4239 +def test_dynamic_tuple_creation_4(): + tup = () + for item in [SOURCE, NONSOURCE]: + tup += (item,) + + SINK(tup[0]) # Flow missing + SINK_F(tup[1])