From 3251062028c482c7fa3d1a9dd38e55efec92c8ad Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 28 Oct 2025 14:37:50 +0100 Subject: [PATCH 1/2] json und metadata logging for background commands --- src/attackmate/executors/features/background.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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: From 4cf3e26400a695a62601bc86c19b308178c9157f Mon Sep 17 00:00:00 2001 From: kali Date: Tue, 28 Oct 2025 14:42:08 +0100 Subject: [PATCH 2/2] json und metadata logging for background commands --- src/attackmate/executors/baseexecutor.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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}'")