From 6d8d106d91f78e1c33552c7f65e81ac3cf0aae8d Mon Sep 17 00:00:00 2001 From: Rasmus Lerchedahl Petersen Date: Fri, 8 Mar 2024 11:18:51 +0100 Subject: [PATCH] Python: add test for `ReturnValue.TupleElement[n]` --- .../dataflow/model-summaries/InlineTaintTest.ext.yml | 2 ++ .../dataflow/model-summaries/NormalDataflowTest.ext.yml | 2 ++ .../dataflow/model-summaries/model_summaries.py | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml b/python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml index 3e14c56d7351..e3a7e059401e 100644 --- a/python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml +++ b/python/ql/test/experimental/dataflow/model-summaries/InlineTaintTest.ext.yml @@ -15,4 +15,6 @@ extensions: - ["foo", "Member[MS_append_to_list]", "Argument[1]", "ReturnValue.ListElement", "value"] - ["foo", "Member[MS_append_to_list]", "Argument[0]", "ReturnValue", "taint"] - ["foo", "Member[MS_append_to_list]", "Argument[1]", "ReturnValue", "taint"] + - ["foo", "Member[MS_spread]", "Argument[0]", "ReturnValue.TupleElement[0]", "value"] + - ["foo", "Member[MS_spread]", "Argument[1]", "ReturnValue.TupleElement[1]", "value"] - ["json", "Member[MS_loads]", "Argument[0]", "ReturnValue", "taint"] diff --git a/python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml b/python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml index 3e14c56d7351..e3a7e059401e 100644 --- a/python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml +++ b/python/ql/test/experimental/dataflow/model-summaries/NormalDataflowTest.ext.yml @@ -15,4 +15,6 @@ extensions: - ["foo", "Member[MS_append_to_list]", "Argument[1]", "ReturnValue.ListElement", "value"] - ["foo", "Member[MS_append_to_list]", "Argument[0]", "ReturnValue", "taint"] - ["foo", "Member[MS_append_to_list]", "Argument[1]", "ReturnValue", "taint"] + - ["foo", "Member[MS_spread]", "Argument[0]", "ReturnValue.TupleElement[0]", "value"] + - ["foo", "Member[MS_spread]", "Argument[1]", "ReturnValue.TupleElement[1]", "value"] - ["json", "Member[MS_loads]", "Argument[0]", "ReturnValue", "taint"] diff --git a/python/ql/test/experimental/dataflow/model-summaries/model_summaries.py b/python/ql/test/experimental/dataflow/model-summaries/model_summaries.py index ee02918b0798..c8c5ac0a8882 100644 --- a/python/ql/test/experimental/dataflow/model-summaries/model_summaries.py +++ b/python/ql/test/experimental/dataflow/model-summaries/model_summaries.py @@ -30,7 +30,7 @@ def SINK_F(x): ensure_tainted = ensure_not_tainted = print TAINTED_STRING = "TAINTED_STRING" -from foo import MS_identity, MS_apply_lambda, MS_reversed, MS_list_map, MS_append_to_list +from foo import MS_identity, MS_apply_lambda, MS_reversed, MS_list_map, MS_append_to_list, MS_spread # Simple summary via_identity = MS_identity(SOURCE) @@ -107,6 +107,13 @@ def explicit_identity(x): tainted_list[0], # $ tainted ) +a, b = MS_spread(SOURCE, NONSOURCE) +SINK(a) # $ flow="SOURCE, l:-1 -> a" +SINK_F(b) +x, y = MS_spread(NONSOURCE, SOURCE) +SINK_F(x) +SINK(y) # $ flow="SOURCE, l:-2 -> y" + # Modeled flow-summary is not value preserving from json import MS_loads as json_loads