From 2a58e9ddc0c48ff22462b7166d94eb930c560fb5 Mon Sep 17 00:00:00 2001 From: Shay Nehmad Date: Tue, 23 Apr 2019 19:04:39 +0300 Subject: [PATCH] Improved the error messages of AWS remote run So the users will have a better chance of understanding the situation and deal with it --- monkey/monkey_island/cc/resources/remote_run.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/resources/remote_run.py b/monkey/monkey_island/cc/resources/remote_run.py index e2a2ae91f..675c292c1 100644 --- a/monkey/monkey_island/cc/resources/remote_run.py +++ b/monkey/monkey_island/cc/resources/remote_run.py @@ -8,6 +8,11 @@ from monkey_island.cc.auth import jwt_required from monkey_island.cc.services.remote_run_aws import RemoteRunAwsService from common.cloud.aws_service import AwsService +CLIENT_ERROR_FORMAT = "ClientError, error message: '{}'. Probably, the IAM role that has been associated with the " \ + "instance doesn't permit SSM calls. " +NO_CREDS_ERROR_FORMAT = "NoCredentialsError, error message: '{}'. Probably, no IAM role has been associated with the " \ + "instance. " + class RemoteRun(flask_restful.Resource): def __init__(self): @@ -29,12 +34,10 @@ class RemoteRun(flask_restful.Resource): try: resp['instances'] = AwsService.get_instances() except NoCredentialsError as e: - # Probably, role hasn't been defined. - resp['error'] = e.message + resp['error'] = NO_CREDS_ERROR_FORMAT.format(e.message) return jsonify(resp) except ClientError as e: - # Probably, role doesn't allow SSM. - resp['error'] = e.message + resp['error'] = CLIENT_ERROR_FORMAT.format(e.message) return jsonify(resp) return jsonify(resp)