Skip to content

Commit 2d0034c

Browse files
committed
Python: Replicate global field-flow failures
1 parent faaa63a commit 2d0034c

File tree

1 file changed

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

1 file changed

+52
-0
lines changed

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,55 @@ def test_global_scope():
179179

180180
fieldflow.test_global.func_defined_before()
181181
fieldflow.test_global.func_defined_after()
182+
183+
# ------------------------------------------------------------------------------
184+
# Global flow cases that doesn't work in this file, but works in test_global.py
185+
# ------------------------------------------------------------------------------
186+
187+
# --------------------------------------
188+
# using constructor
189+
# --------------------------------------
190+
191+
# def test_constructor_assign():
192+
obj2 = MyObj(SOURCE)
193+
SINK(obj2.foo) # $ flow="SOURCE, l:-1 -> obj2.foo"
194+
195+
# apparently these if statements below makes a difference :O
196+
# but one is not enough
197+
cond = os.urandom(1)[0] > 128
198+
199+
if cond:
200+
pass
201+
202+
# def test_constructor_assign():
203+
obj2 = MyObj(SOURCE)
204+
SINK(obj2.foo) # $ MISSING: flow="SOURCE, l:-1 -> obj2.foo"
205+
206+
if cond:
207+
pass
208+
209+
# def test_constructor_assign():
210+
obj2 = MyObj(SOURCE)
211+
SINK(obj2.foo) # $ MISSING: flow="SOURCE, l:-1 -> obj2.foo"
212+
213+
# def test_constructor_assign_kw():
214+
obj3 = MyObj(foo=SOURCE)
215+
SINK(obj3.foo) # $ MISSING: flow="SOURCE, l:-1 -> obj3.foo"
216+
217+
# def test_fields():
218+
SINK(fields_with_local_flow(SOURCE)) # $ MISSING: flow="SOURCE -> fields_with_local_flow(..)"
219+
220+
# --------------------------------------
221+
# method calls
222+
# --------------------------------------
223+
224+
# def test_indirect_assign_method():
225+
myobj2 = MyObj("OK")
226+
myobj2.setFoo(SOURCE)
227+
SINK(myobj2.foo) # $ MISSING: flow="SOURCE, l:-1 -> myobj2.foo"
228+
229+
# def test_nested_obj_method():
230+
x2 = SOURCE
231+
a2 = NestedObj()
232+
a2.getObj().foo = x2
233+
SINK(a2.obj.foo) # $ MISSING: flow="SOURCE, l:-3 -> a2.obj.foo"

0 commit comments

Comments
 (0)