diff --git a/src/attackmate/executors/baseexecutor.py b/src/attackmate/executors/baseexecutor.py index 1e33ee08..4f71d71d 100644 --- a/src/attackmate/executors/baseexecutor.py +++ b/src/attackmate/executors/baseexecutor.py @@ -81,13 +81,14 @@ def run(self, command: BaseCommand) -> Result: self.logger.debug(f"Template-Command: '{command.cmd}'") if command.background: # Background commands always return Result(None,None) + time_of_execution = datetime.now().isoformat() + self.log_json(self.json_logger, command, time_of_execution) result = self.exec_background(self.substitute_template_vars(command, self.substitute_cmd_vars)) else: result = self.exec(self.substitute_template_vars(command, self.substitute_cmd_vars)) return result - def log_command(self, command): """Log starting-status of the command""" self.logger.info(f"Executing '{command}'") diff --git a/src/attackmate/executors/features/background.py b/src/attackmate/executors/features/background.py index c2a9cb68..988b1240 100644 --- a/src/attackmate/executors/features/background.py +++ b/src/attackmate/executors/features/background.py @@ -1,3 +1,4 @@ +import json from attackmate.schemas.base import BaseCommand from attackmate.processmanager import ProcessManager from attackmate.result import Result @@ -30,7 +31,8 @@ def _create_queue(self) -> Optional[Queue]: def exec_background(self, command: BaseCommand) -> Result: self.logger.info(f'Run in background: {getattr(command, "type", "")}({command.cmd})') - + if command.metadata: + self.logger.info(f'Metadata: {json.dumps(command.metadata)}') queue = self._create_queue() if queue: