Skip to content

Commit fb6955e

Browse files
committed
Python: Add tests of methods in summaries
1 parent afafaac commit fb6955e

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,21 @@ def explicit_identity(x):
6666
from json import loads as json_loads
6767
tainted_resultlist = json_loads(SOURCE)
6868
SINK(tainted_resultlist[0]) # $ flow="SOURCE, l:-1 -> tainted_resultlist[0]"
69+
70+
71+
# Class methods are not handled right now
72+
73+
class MyClass:
74+
@staticmethod
75+
def foo(x):
76+
return x
77+
78+
def bar(self, x):
79+
return x
80+
81+
through_staticmethod = apply_lambda(MyClass.foo, SOURCE)
82+
through_staticmethod # $ MISSING: flow
83+
84+
mc = MyClass()
85+
through_method = apply_lambda(mc.bar, SOURCE)
86+
through_method # $ MISSING: flow

python/ql/test/experimental/dataflow/typetracking-summaries/summaries.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,20 @@ def explicit_identity(x):
5959
y # $ tracked=secret
6060
TTS_set_secret(y, tracked) # $ tracked tracked=secret
6161
y.secret # $ tracked tracked=secret
62+
63+
# Class methods are not handled right now
64+
65+
class MyClass:
66+
@staticmethod
67+
def foo(x):
68+
return x
69+
70+
def bar(self, x):
71+
return x
72+
73+
through_staticmethod = TTS_apply_lambda(MyClass.foo, tracked) # $ tracked
74+
through_staticmethod # $ MISSING: tracked
75+
76+
mc = MyClass()
77+
through_method = TTS_apply_lambda(mc.bar, tracked) # $ tracked
78+
through_method # $ MISSING: tracked

0 commit comments

Comments
 (0)