Skip to content

Commit 84faf49

Browse files
committed
Python: Add tests for compound arguments field flow
1 parent d876acd commit 84faf49

File tree

1 file changed

+33
-0
lines changed
  • python/ql/test/experimental/dataflow/fieldflow

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,39 @@ def test_nested_obj_method():
193193
SINK(a.obj.foo) # $ flow="SOURCE, l:-3 -> a.obj.foo"
194194

195195

196+
# ------------------------------------------------------------------------------
197+
# Field access on compound arguments
198+
# ------------------------------------------------------------------------------
199+
200+
# TODO: Add support for this, see https://github.com/github/codeql/pull/10444
201+
202+
@expects(5) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
203+
def test_field_on_compound_arg(cond_true=True, cond_false=False):
204+
class Ex:
205+
def __init__(self):
206+
self.attr = None
207+
208+
def set_attr(obj):
209+
obj.attr = SOURCE
210+
211+
x = Ex()
212+
y = Ex()
213+
set_attr(x if cond_true else y)
214+
SINK(x.attr) # $ MISSING: flow
215+
216+
x = Ex()
217+
y = Ex()
218+
set_attr(x if cond_false else y)
219+
SINK(y.attr) # $ MISSING: flow
220+
221+
x = Ex()
222+
y = Ex()
223+
z = Ex()
224+
set_attr(x if cond_false else (y if cond_true else z))
225+
SINK_F(x.attr) # $ MISSING: flow
226+
SINK(y.attr) # $ MISSING: flow
227+
SINK_F(z.attr) # $ MISSING: flow
228+
196229
# ------------------------------------------------------------------------------
197230
# Crosstalk test -- using different function based on conditional
198231
# ------------------------------------------------------------------------------

0 commit comments

Comments
 (0)