From 0b5a507f386535b5371bd45c2a6ee2f29cd20aea Mon Sep 17 00:00:00 2001 From: vakarisz Date: Wed, 11 May 2022 11:46:13 +0300 Subject: [PATCH] Island: Make AWSCommandStatus enum json serializable --- monkey/monkey_island/cc/resources/remote_run.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/monkey/monkey_island/cc/resources/remote_run.py b/monkey/monkey_island/cc/resources/remote_run.py index f872fc07b..8f02ee066 100644 --- a/monkey/monkey_island/cc/resources/remote_run.py +++ b/monkey/monkey_island/cc/resources/remote_run.py @@ -54,8 +54,20 @@ class RemoteRun(flask_restful.Resource): resp = {} if body.get("type") == "aws": result = self.run_aws_monkeys(body) + result = self._get_encodable_results(result) resp["result"] = result return jsonify(resp) # default action return make_response({"error": "Invalid action"}, 500) + + @staticmethod + def _get_encodable_results(results: Sequence[AWSCommandResults]) -> str: + results_copy = [] + for result in results: + results_copy.append( + AWSCommandResults( + result.response_code, result.stdout, result.stderr, result.status.name.lower() + ) + ) + return results_copy