forked from p15670423/monkey
Agent: Remove unused file post_breach_handler.py
This commit is contained in:
parent
99b621f2c8
commit
296a91a458
|
@ -1,39 +0,0 @@
|
|||
import logging
|
||||
from multiprocessing.dummy import Pool
|
||||
from typing import Sequence
|
||||
|
||||
from infection_monkey.post_breach.pba import PBA
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PostBreach(object):
|
||||
"""
|
||||
This class handles post breach actions execution
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.pba_list = self.config_to_pba_list()
|
||||
|
||||
def execute_all_configured(self):
|
||||
"""
|
||||
Executes all post breach actions.
|
||||
"""
|
||||
with Pool(5) as pool:
|
||||
pool.map(self.run_pba, self.pba_list)
|
||||
logger.info("All PBAs executed. Total {} executed.".format(len(self.pba_list)))
|
||||
|
||||
@staticmethod
|
||||
def config_to_pba_list() -> Sequence[PBA]:
|
||||
"""
|
||||
:return: A list of PBA objects.
|
||||
"""
|
||||
return PBA.get_instances()
|
||||
|
||||
def run_pba(self, pba):
|
||||
try:
|
||||
logger.debug("Executing PBA: '{}'".format(pba.name))
|
||||
pba.run()
|
||||
logger.debug(f"Execution of {pba.name} finished")
|
||||
except Exception as e:
|
||||
logger.error("PBA {} failed. Error info: {}".format(pba.name, e))
|
Loading…
Reference in New Issue