Skip to content

Commit

Permalink
Merge pull request androguard#352 from reox/fix-analysis
Browse files Browse the repository at this point in the history
make Analysis callable without an inital object
  • Loading branch information
reox authored Nov 24, 2017
2 parents 0c77b4b + 2f343de commit fe82cf1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
33 changes: 23 additions & 10 deletions androguard/core/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,33 @@ def __str__(self):


class Analysis(object):
def __init__(self, vm):
self.vms = [vm]
def __init__(self, vm=None):
"""
Analysis Object
The Analysis contains a lot of information about (multiple) DalvikVMFormat objects
Features are for example XREFs between Classes, Methods, Fields and Strings.
Multiple DalvikVMFormat Objects can be added using the function `add`
:param vm: inital DalvikVMFormat object.
"""
self.vms = []
self.classes = {}
self.strings = {}
self.methods = {}

if vm:
self.add(vm)

def add(self, vm):
"""
Add a DalvikVMFormat to this Analysis
:param vm:
:return:
"""
self.vms.append(vm)
for current_class in vm.get_classes():
self.classes[current_class.get_name()] = ClassAnalysis(
current_class, True)
Expand Down Expand Up @@ -958,14 +979,6 @@ def get_external_classes(self):
def get_strings_analysis(self):
return self.strings

def add(self, vm):
self.vms.append(vm)

for current_class in vm.get_classes():
if current_class.get_name() not in self.classes:
self.classes[current_class.get_name()] = ClassAnalysis(
current_class, True)


def is_ascii_obfuscation(vm):
"""
Expand Down
8 changes: 8 additions & 0 deletions androguard/core/bytecodes/apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,14 @@ def get_all_dex(self):
except FileNotPresent:
pass

def is_multidex(self):
"""
Test if the APK has multiple DEX files
:return: True if multiple dex found, otherwise False
"""
return "classes1.dex" in self.get_files()

def get_elements(self, tag_name, attribute):
"""
Return elements in xml files which match with the tag name and the specific attribute
Expand Down

0 comments on commit fe82cf1

Please sign in to comment.