mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Python: Add tests for compound arguments field flow
This commit is contained in:
@@ -193,6 +193,39 @@ def test_nested_obj_method():
|
||||
SINK(a.obj.foo) # $ flow="SOURCE, l:-3 -> a.obj.foo"
|
||||
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Field access on compound arguments
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# TODO: Add support for this, see https://github.com/github/codeql/pull/10444
|
||||
|
||||
@expects(5) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
|
||||
def test_field_on_compound_arg(cond_true=True, cond_false=False):
|
||||
class Ex:
|
||||
def __init__(self):
|
||||
self.attr = None
|
||||
|
||||
def set_attr(obj):
|
||||
obj.attr = SOURCE
|
||||
|
||||
x = Ex()
|
||||
y = Ex()
|
||||
set_attr(x if cond_true else y)
|
||||
SINK(x.attr) # $ MISSING: flow
|
||||
|
||||
x = Ex()
|
||||
y = Ex()
|
||||
set_attr(x if cond_false else y)
|
||||
SINK(y.attr) # $ MISSING: flow
|
||||
|
||||
x = Ex()
|
||||
y = Ex()
|
||||
z = Ex()
|
||||
set_attr(x if cond_false else (y if cond_true else z))
|
||||
SINK_F(x.attr) # $ MISSING: flow
|
||||
SINK(y.attr) # $ MISSING: flow
|
||||
SINK_F(z.attr) # $ MISSING: flow
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Crosstalk test -- using different function based on conditional
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user