Skip to content

Commit 9d4b168

Browse files
committed
Python: Added extra test for global variable nested attribute reads/writes.
1 parent 6c779c7 commit 9d4b168

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

python/ql/test/library-tests/dataflow/fieldflow/test_global.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ def fields_with_local_flow(x):
146146
class NestedObj(object):
147147
def __init__(self):
148148
self.obj = MyObj("OK")
149+
self.obj.foo = "default"
149150

150151
def getObj(self):
151152
return self.obj
@@ -163,6 +164,20 @@ def getObj(self):
163164
a2 = NestedObj()
164165
a2.getObj().foo = x2
165166
SINK(a2.obj.foo) # $ flow="SOURCE, l:-3 -> a2.obj.foo"
167+
168+
# Global variable
169+
app = NestedObj()
170+
171+
def init_global():
172+
app.obj.foo = SOURCE
173+
174+
def read_global():
175+
return app.obj.foo
176+
177+
def test_global_nested_attributes():
178+
init_global()
179+
result = read_global()
180+
SINK(result) # $ MISSING: flow="SOURCE, l:-8 -> result"
166181

167182
# ------------------------------------------------------------------------------
168183
# Global scope interaction

0 commit comments

Comments
 (0)