示例#1
0
 def _handle_failed_analysis(self, fw_object, process, worker_id,
                             cause: str):
     terminate_process_and_childs(process)
     fw_object.analysis_exception = (
         self.NAME, '{} occurred during analysis'.format(cause))
     logging.error('Worker {}: {} during analysis {} on {}'.format(
         worker_id, cause, self.NAME, fw_object.uid))
     self.out_queue.put(fw_object)
示例#2
0
 def check_exceptions(self):
     return_value = False
     if self.worker.exception:
         logging.error("{}Worker Exception Found!!{}".format(
             bcolors.FAIL, bcolors.ENDC))
         logging.error(self.worker.exception[1])
         if self.config.getboolean('ExpertSettings', 'throw_exceptions'):
             return_value = True
             terminate_process_and_childs(self.worker)
     return return_value
示例#3
0
 def check_exceptions(self):
     for _, plugin in self.analysis_plugins.items():
         if plugin.check_exceptions():
             return True
     for process in [self.schedule_process, self.result_collector_process]:
         if process.exception:
             logging.error("{}Exception in scheduler process {}{}".format(bcolors.FAIL, bcolors.ENDC, process.name))
             logging.error(process.exception[1])
             terminate_process_and_childs(process)
             return True  # Error here means nothing will ever get scheduled again. Thing should just break !
     return False
示例#4
0
 def check_exceptions(self):
     return_value = False
     for worker in self.workers:
         if worker.exception:
             logging.error('{}Analysis worker {} caused exception{}'.format(bcolors.FAIL, worker.name, bcolors.ENDC))
             logging.error(worker.exception[1])
             terminate_process_and_childs(worker)
             self.workers.remove(worker)
             if self.config.getboolean('ExpertSettings', 'throw_exceptions'):
                 return_value = True
             else:
                 process_index = worker.name.split('-')[2]
                 self._start_single_worker_process(process_index)
     return return_value
示例#5
0
 def worker_processing_with_timeout(self, worker_id, next_task):
     manager = Manager()
     result = manager.list()
     process = ExceptionSafeProcess(target=self.process_next_object, args=(next_task, result))
     process.start()
     process.join(timeout=self.timeout)
     if self.timeout_happened(process):
         terminate_process_and_childs(process)
         self.out_queue.put(next_task)
         logging.warning('Worker {}: Timeout {} analysis on {}'.format(worker_id, self.NAME, next_task.uid))
     elif process.exception:
         terminate_process_and_childs(process)
         raise process.exception[0]
     else:
         self.out_queue.put(result.pop())
         logging.debug('Worker {}: Finished {} analysis on {}'.format(worker_id, self.NAME, next_task.uid))