mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
Python: Add funky call-graph regression
I don't even know how to phrase this :D
This commit is contained in:
@@ -17,6 +17,7 @@ pointsTo_found_typeTracker_notFound
|
||||
| code/func_defined_outside_class.py:39:11:39:21 | ControlFlowNode for _gen() | B._gen |
|
||||
| code/func_defined_outside_class.py:42:1:42:7 | ControlFlowNode for Attribute() | B._gen.func |
|
||||
| code/func_defined_outside_class.py:43:1:43:7 | ControlFlowNode for Attribute() | B._gen.func |
|
||||
| code/funky_regression.py:15:9:15:17 | ControlFlowNode for Attribute() | Wat.f2 |
|
||||
| code/type_tracking_limitation.py:8:1:8:3 | ControlFlowNode for x() | my_func |
|
||||
typeTracker_found_pointsTo_notFound
|
||||
| code/callable_as_argument.py:29:5:29:12 | ControlFlowNode for Attribute() | test_class.InsideTestFunc.sm |
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
# When this regression was discovered, we did not resolve the `self.f2()` call after the
|
||||
# try-except block, but ONLY when passing an attribute to a method, as indicated in the
|
||||
# other tests below.
|
||||
|
||||
class Wat(object):
|
||||
def f1(self, arg): pass
|
||||
def f2(self): pass
|
||||
|
||||
def func(self, foo):
|
||||
try:
|
||||
self.f1(foo.bar) # $ pt,tt=Wat.f1
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
self.f2() # $ pt=Wat.f2 MISSING: tt=Wat.f2
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# variants that we are able to handle
|
||||
# ==============================================================================
|
||||
|
||||
|
||||
class Works(object):
|
||||
"not using attribute"
|
||||
def f1(self, arg): pass
|
||||
def f2(self): pass
|
||||
|
||||
def func(self, foo):
|
||||
try:
|
||||
self.f1(foo) # $ pt,tt=Works.f1
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
self.f2() # $ pt,tt=Works.f2
|
||||
|
||||
|
||||
class AlsoWorks(object):
|
||||
"no exception"
|
||||
def f1(self, arg): pass
|
||||
def f2(self): pass
|
||||
|
||||
def func(self, foo):
|
||||
self.f1(foo.bar) # $ pt,tt=AlsoWorks.f1
|
||||
|
||||
self.f2() # $ pt,tt=AlsoWorks.f2
|
||||
|
||||
|
||||
def safe_func(arg):
|
||||
pass
|
||||
|
||||
|
||||
class Works3(object):
|
||||
"call to non-self function"
|
||||
def f1(self, arg): pass
|
||||
def f2(self): pass
|
||||
|
||||
def func(self, foo):
|
||||
try:
|
||||
safe_func(foo.bar) # $ pt,tt=safe_func
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
self.f2() # $ pt,tt=Works3.f2
|
||||
Reference in New Issue
Block a user