Skip to content

Commit 2da4b39

Browse files
committed
Python: Add global field-flow tests
I thought it was interesting that it did not propagate flow to the uses inside the functions :O
1 parent d2cd77a commit 2da4b39

File tree

1 file changed

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

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,22 @@ def test_nested_obj_method():
159159
a = NestedObj()
160160
a.getObj().foo = x
161161
SINK(a.obj.foo) # $ MISSING: flow
162+
163+
# ------------------------------------------------------------------------------
164+
# In global scope
165+
# ------------------------------------------------------------------------------
166+
167+
def func_defined_before():
168+
SINK(global_obj.foo) # $ MISSING: flow="SOURCE, l:+3 -> global_obj.foo"
169+
170+
global_obj = MyObj(NONSOURCE)
171+
global_obj.foo = SOURCE
172+
SINK(global_obj.foo) # $ flow="SOURCE, l:-1 -> global_obj.foo"
173+
174+
def func_defined_after():
175+
SINK(global_obj.foo) # $ MISSING: flow="SOURCE, l:-4 -> global_obj.foo"
176+
177+
@expects(2)
178+
def test_global_funcs():
179+
func_defined_before()
180+
func_defined_after()

0 commit comments

Comments
 (0)