Skip to content

Commit f988e1f

Browse files
committed
Python: Improve field-flow by removing import *
Since that apparently impacts call graph resolution with points-to :O Also interesting that global flow was only not working for those cases because of the tricky ifs... still need to 100% figure out how those ifs are messing up the analysis :|
1 parent 999af15 commit f988e1f

File tree

1 file changed

+22
-6
lines changed
  • python/ql/test/experimental/dataflow/fieldflow

1 file changed

+22
-6
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
sys.path.append(os.path.dirname(os.path.dirname((__file__)))) # $ unresolved_call=os.path.dirname(..) unresolved_call=sys.path.append(..)
5-
from testlib import *
5+
from testlib import expects
66

77
# These are defined so that we can evaluate the test code.
88
NONSOURCE = "not a source"
@@ -53,8 +53,8 @@ def test_indirect_assign():
5353
def test_indirect_assign_method():
5454
myobj = MyObj("OK")
5555

56-
myobj.setFoo(SOURCE) # $ unresolved_call=myobj.setFoo(..)
57-
SINK(myobj.foo) # $ MISSING: flow
56+
myobj.setFoo(SOURCE)
57+
SINK(myobj.foo) # $ flow="SOURCE, l:-1 -> myobj.foo"
5858

5959

6060
def test_direct_assign():
@@ -157,8 +157,8 @@ def test_nested_obj():
157157
def test_nested_obj_method():
158158
x = SOURCE
159159
a = NestedObj()
160-
a.getObj().foo = x # $ unresolved_call=a.getObj()
161-
SINK(a.obj.foo) # $ MISSING: flow
160+
a.getObj().foo = x
161+
SINK(a.obj.foo) # $ flow="SOURCE, l:-3 -> a.obj.foo"
162162

163163
# ------------------------------------------------------------------------------
164164
# Global scope
@@ -184,6 +184,22 @@ def test_global_scope():
184184
# Global flow cases that doesn't work in this file, but works in test_global.py
185185
# ------------------------------------------------------------------------------
186186

187+
# --------------------------------------
188+
# method calls _before_ those ifs
189+
# --------------------------------------
190+
191+
# def test_indirect_assign_method():
192+
myobj2 = MyObj("OK")
193+
myobj2.setFoo(SOURCE)
194+
SINK(myobj2.foo) # $ flow="SOURCE, l:-1 -> myobj2.foo"
195+
196+
# def test_nested_obj_method():
197+
x2 = SOURCE
198+
a2 = NestedObj()
199+
a2.getObj().foo = x2
200+
SINK(a2.obj.foo) # $ flow="SOURCE, l:-3 -> a2.obj.foo"
201+
202+
187203
# --------------------------------------
188204
# using constructor
189205
# --------------------------------------
@@ -218,7 +234,7 @@ def test_global_scope():
218234
SINK(fields_with_local_flow(SOURCE)) # $ unresolved_call=fields_with_local_flow(..) unresolved_call=SINK(..) MISSING: flow="SOURCE -> fields_with_local_flow(..)"
219235

220236
# --------------------------------------
221-
# method calls
237+
# method calls _after_ those ifs
222238
# --------------------------------------
223239

224240
# def test_indirect_assign_method():

0 commit comments

Comments
 (0)