MethodAnalysis descriptor type inconsistency
ehrenb opened this issue · comments
Please remove this template if you only have a question or do not want to create a new issue.
Describe what you wanted to do
I expect to get the same type for descriptors in MethodAnalysis. However, when I look deeper, I see that ExternalMethods are using lists/tuples for descriptors, and regular internal methods are using strings. I expect these types to be the same so we can reason over their descriptors generically when iterating. I expect this to cause some issues with any regex pattern matching (e.g. in find_fields()), e.g. attempting to match a pattern against a list type. If we go with lists, find_fields() and find_methods() will need to adjust how they pattern match on descriptors.
Test like this using 'tests/data/APK/TestActivity.apk' :
c = some class
for m in c.get_methods():
z = m.get_method()
if isinstance(z, ExternalMethod):
print('external method')
print(f'is list: {isinstance(z.get_descriptor(), list)}')
else:
print('internal method')
print(f'is str: {isinstance(z.get_descriptor(), str)}')
output snippet:
onPageSelected
internal method
is str: True
<init>
internal method
is str: True
setSingleLineAllCaps
internal method
is str: True
<init>
internal method
is str: True
...
runQuery
external method
is list: True
query
external method
is list: True
<init>
external method
is list: True
setColor
external method
is list: True
setImageResource
external method
is list: True
setImageURI
external method
is list: True
- is this error specific to a single file?
- if possible give a minimal working example where the error happens
Describe what you expected
Describe what actually happened
System Information
- Androguard Version: master
- Python Version: 3.10
- Operating System
Further Log Files and Output
- please report logs, tracebacks and other useful information
- if possible report the files you tried to analyze!