File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
python/ql/test/experimental/dataflow/fieldflow Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,40 @@ def test_nested_obj_method():
160
160
a .getObj ().foo = x
161
161
SINK (a .obj .foo ) # $ flow="SOURCE, l:-3 -> a.obj.foo"
162
162
163
+ # ------------------------------------------------------------------------------
164
+ # Bound Method calls
165
+ # ------------------------------------------------------------------------------
166
+
167
+ class Foo :
168
+ def __init__ (self , x ):
169
+ self .x = x
170
+
171
+ def update_x (self , x ):
172
+ self .x = x
173
+
174
+ @expects (7 ) # $ unresolved_call=expects(..) unresolved_call=expects(..)(..)
175
+ def test_bound_method_call ():
176
+ # direct assignment
177
+ foo = Foo (None )
178
+ SINK_F (foo .x )
179
+ foo .x = SOURCE
180
+ SINK (foo .x ) # $ flow="SOURCE, l:-1 -> foo.x"
181
+ foo .x = None
182
+ SINK_F (foo .x )
183
+
184
+ # assignment through function
185
+ foo = Foo (SOURCE )
186
+ SINK (foo .x ) # $ flow="SOURCE, l:-1 -> foo.x"
187
+ foo .update_x (None )
188
+ SINK_F (foo .x ) # $ flow="SOURCE, l:-3 -> foo.x"
189
+
190
+ # assignment through bound-method calls
191
+ foo = Foo (SOURCE )
192
+ ux = foo .update_x
193
+ SINK (foo .x ) # $ flow="SOURCE, l:-2 -> foo.x"
194
+ ux (None )
195
+ SINK_F (foo .x ) # $ SPURIOUS: flow="SOURCE, l:-4 -> foo.x"
196
+
163
197
# ------------------------------------------------------------------------------
164
198
# Global scope
165
199
# ------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments