def __store_results(self, results): ''' Store the results and increase the analyzed apks counter. Parameters ---------- results : list<FastApk, AndroScript> ''' for res in results: # unpack results fastapk, script_results = res for script in script_results: try: storage_result = AnalyzeUtil.store_script_res(self.storage, script, fastapk) self.add_storage_result(storage_result) except StorageException as e: log.warn(e) self.add_analyzed_apks_sm(1)
def __store_results(self, results): ''' Store the results and increase the analyzed apks counter. Parameters ---------- results : list<FastApk, AndroScript> ''' for res in results: # unpack results fastapk, script_results = res for script in script_results: try: storage_result = AnalyzeUtil.store_script_res( self.storage, script, fastapk) self.add_storage_result(storage_result) except StorageException as e: log.warn(e) self.add_analyzed_apks_sm(1)
def _analyze(self, test = False): ''' Start the analysis and store the results in the predefined place. Parameters ---------- test : bool, optional (default is False) Use for testing. Will not store any result ! Returns ------- int Number of analyzed apks list<ResultObject> List of the results (only if `test`) ''' androscripts = self.script_list # collect results for test mode test_results = [] # get minimum options for all scripts -> boost performance # use only as much options as needed! # run over apks for apk_path, _apk, _ in apk_gen(self.apks_or_paths): eandro_apk = open_apk(apk_path, apk=_apk) # if is None error happened and has been logged # otherwise proceed with analysis if eandro_apk is not None: # tuple<FastApk, AndroScript> res = AnalyzeUtil.analyze_apk(eandro_apk, androscripts, self.min_script_needs, reset_scripts = True) if res: # unpack results fastapk, script_results = res # store results if not in test mode if not test: for script in script_results: try: storage_result = AnalyzeUtil.store_script_res(self.storage, script, fastapk) # keep storage results self.add_storage_result(storage_result) except StorageException as e: log.warn(e) else: # deliver result object in testing mode test_results += [s.res for s in script_results] clilog.info("analyzed %s", fastapk.short_description()) # increment counter, no lock needed, nobody else is writing to this value self.cnt_analyzed_apks.value += 1 if test: return test_results return self.cnt_analyzed_apks.value
def _analyze(self, test=False): ''' Start the analysis and store the results in the predefined place. Parameters ---------- test : bool, optional (default is False) Use for testing. Will not store any result ! Returns ------- int Number of analyzed apks list<ResultObject> List of the results (only if `test`) ''' androscripts = self.script_list # collect results for test mode test_results = [] # get minimum options for all scripts -> boost performance # use only as much options as needed! # run over apks for apk_path, _apk, _ in apk_gen(self.apks_or_paths): eandro_apk = open_apk(apk_path, apk=_apk) # if is None error happened and has been logged # otherwise proceed with analysis if eandro_apk is not None: # tuple<FastApk, AndroScript> res = AnalyzeUtil.analyze_apk(eandro_apk, androscripts, self.min_script_needs, reset_scripts=True) if res: # unpack results fastapk, script_results = res # store results if not in test mode if not test: for script in script_results: try: storage_result = AnalyzeUtil.store_script_res( self.storage, script, fastapk) # keep storage results self.add_storage_result(storage_result) except StorageException as e: log.warn(e) else: # deliver result object in testing mode test_results += [s.res for s in script_results] clilog.info("analyzed %s", fastapk.short_description()) # increment counter, no lock needed, nobody else is writing to this value self.cnt_analyzed_apks.value += 1 if test: return test_results return self.cnt_analyzed_apks.value