Skip to content

Commit 4b423fe

Browse files
authored
Merge pull request #4245 from RasmusWL/python-dataflow-dynamic-tuple-tests
Python: Add dataflow tests for dynamic tuple creation
2 parents c2175b6 + 949b81b commit 4b423fe

File tree

1 file changed

+37
-0
lines changed
  • python/ql/test/experimental/dataflow/coverage

1 file changed

+37
-0
lines changed

python/ql/test/experimental/dataflow/coverage/test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,3 +534,40 @@ def f6(arg):
534534

535535
x = f6(SOURCE)
536536
SINK(x) # Flow missing
537+
538+
539+
def test_dynamic_tuple_creation_1():
540+
tup = tuple()
541+
tup += (SOURCE,)
542+
tup += (NONSOURCE,)
543+
544+
SINK(tup[0]) # Flow missing
545+
SINK_F(tup[1])
546+
547+
548+
def test_dynamic_tuple_creation_2():
549+
tup = ()
550+
tup += (SOURCE,)
551+
tup += (NONSOURCE,)
552+
553+
SINK(tup[0]) # Flow missing
554+
SINK_F(tup[1])
555+
556+
557+
def test_dynamic_tuple_creation_3():
558+
tup1 = (SOURCE,)
559+
tup2 = (NONSOURCE,)
560+
tup = tup1 + tup2
561+
562+
SINK(tup[0]) # Flow missing
563+
SINK_F(tup[1])
564+
565+
566+
# Inspired by FP-report https://github.com/github/codeql/issues/4239
567+
def test_dynamic_tuple_creation_4():
568+
tup = ()
569+
for item in [SOURCE, NONSOURCE]:
570+
tup += (item,)
571+
572+
SINK(tup[0]) # Flow missing
573+
SINK_F(tup[1])

0 commit comments

Comments
 (0)