Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Add dataflow tests for dynamic tuple creation #4245

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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])