Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Resolve various parsing issues #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions smalisca/core/smalisca_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from smalisca.core.smalisca_config import JSON_SETTINGS
from smalisca.core.smalisca_logging import log


class App:
"""Provides information about an application

Expand Down Expand Up @@ -167,7 +166,8 @@ def get_classes(self):
'name': c['name'],
'type': c['type'],
'package': c['package'],
'parent': c['parent'],
# Some classes are orphans?
'parent': c.get('parent'),
'path': c['path'],
'depth': c['depth']
})
Expand Down
17 changes: 13 additions & 4 deletions smalisca/modules/module_smali_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def is_class_property(self, line):
otherwise False

"""
match = re.search("\.field\s+(?P<property>.*);", line)
match = re.search("\.field\s+(?P<property>.*)", line)
if match:
log.debug("\t\tFound property: %s" % match.group('property'))
return match.group('property')
Expand All @@ -205,7 +205,7 @@ def is_const_string(self, line):
otherwise False

"""
match = re.search("const-string\s+(?P<const>.*)", line)
match = re.search("const-string/?[^\s]*\s+(?P<const>.*)", line)
if match:
log.debug("\t\tFound const-string: %s" % match.group('const'))
return match.group('const')
Expand Down Expand Up @@ -296,7 +296,13 @@ def extract_class_property(self, data):
dict: Returns a property object, otherwise None

"""
prop_info = data.split(" ")

key_val = data.split(' = ')
prop_info = key_val[0].split(' ')
val = None

if len(key_val) > 1:
val = key_val[1]

# A field/property is usually saved in this form
# <name>:<type>
Expand All @@ -310,7 +316,10 @@ def extract_class_property(self, data):
'type': prop_name_split[1] if len(prop_name_split) > 1 else '',

# Additional info (e.g. public static etc.)
'info': " ".join(prop_info[:-1])
'info': " ".join(prop_info[:-1]),

# Value
'value': val
}

return p
Expand Down