Skip to content

Commit bab6ecf

Browse files
committed
Python: test the MaD path for constructor calls
1 parent e44d4c4 commit bab6ecf

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

python/ql/test/library-tests/dataflow/model-summaries/NormalDataflowTest.ext.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ extensions:
1818
- ["foo", "Member[MS_spread]", "Argument[0]", "ReturnValue.TupleElement[0]", "value"]
1919
- ["foo", "Member[MS_spread]", "Argument[1]", "ReturnValue.TupleElement[1]", "value"]
2020
- ["foo", "Member[MS_spread_all]", "Argument[0]", "ReturnValue.TupleElement[0,1]", "value"]
21+
- ["foo", "Member[MS_Class].Call", "Argument[0, x:]", "ReturnValue", "value"]
22+
- ["foo", "Member[MS_Class_transitive].Subclass.Call", "Argument[0, x:]", "ReturnValue", "value"]
2123
- ["json", "Member[MS_loads]", "Argument[0]", "ReturnValue", "taint"]

python/ql/test/library-tests/dataflow/model-summaries/model_summaries.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,24 @@ def explicit_identity(x):
122122
SINK(a) # $ flow="SOURCE, l:-1 -> a"
123123
SINK(b) # $ flow="SOURCE, l:-2 -> b"
124124

125+
from foo import MS_Class, MS_Class_transitive
126+
127+
# Class summaries
128+
class_via_positional = MS_Class(SOURCE)
129+
SINK(class_via_positional) # $ flow="SOURCE, l:-1 -> class_via_positional"
130+
131+
class_via_kw = MS_Class(x = SOURCE)
132+
SINK(class_via_kw) # $ flow="SOURCE, l:-1 -> class_via_kw"
133+
134+
class C(MS_Class_transitive):
135+
pass
136+
137+
subclass_via_positional = C(SOURCE)
138+
SINK(subclass_via_positional) # $ flow="SOURCE, l:-1 -> subclass_via_positional"
139+
140+
subclass_via_kw = C(x = SOURCE)
141+
SINK(subclass_via_kw) # $ flow="SOURCE, l:-1 -> subclass_via_kw"
142+
125143
# Modeled flow-summary is not value preserving
126144
from json import MS_loads as json_loads
127145

0 commit comments

Comments
 (0)