Skip to content

Commit

Permalink
Merge pull request #4245 from RasmusWL/python-dataflow-dynamic-tuple-…
Browse files Browse the repository at this point in the history
…tests

Python: Add dataflow tests for dynamic tuple creation
  • Loading branch information
tausbn authored Sep 16, 2020
2 parents c2175b6 + 949b81b commit 4b423fe
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions python/ql/test/experimental/dataflow/coverage/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

0 comments on commit 4b423fe

Please sign in to comment.