From 4ad8e9b2828bdcb1177ef7386f20f565382c4efb Mon Sep 17 00:00:00 2001 From: Will Bengtson Date: Tue, 24 Jul 2018 16:07:28 -0700 Subject: [PATCH] Bump cloudaux and move IAM User and Role to new CloudAux orchestration --- requirements.txt | 2 +- security_monkey/watchers/iam/iam_role.py | 20 +++++--------------- security_monkey/watchers/iam/iam_user.py | 6 +++--- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/requirements.txt b/requirements.txt index 68ff64886..9d5f10288 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ six>=1.11.0 -cloudaux==1.4.13 +cloudaux>=1.4.19 celery==4.2.0 celery[redis]==4.2.0 redis==2.10.6 diff --git a/security_monkey/watchers/iam/iam_role.py b/security_monkey/watchers/iam/iam_role.py index 0f9cfbd95..56f16ef53 100644 --- a/security_monkey/watchers/iam/iam_role.py +++ b/security_monkey/watchers/iam/iam_role.py @@ -1,10 +1,10 @@ from security_monkey.cloudaux_batched_watcher import CloudAuxBatchedWatcher from cloudaux.aws.iam import list_roles -from cloudaux.orchestration.aws.iam.role import get_role +from cloudaux.orchestration.aws.iam.role import get_all_roles from security_monkey import AWS_DEFAULT_REGION -class IAMRole(CloudAuxBatchedWatcher): +class IAMRole(CloudAuxWatcher): index = 'iamrole' i_am_singular = 'IAM Role' i_am_plural = 'IAM Roles' @@ -17,22 +17,12 @@ def __init__(self, **kwargs): def _get_regions(self): return [AWS_DEFAULT_REGION] - + def get_name_from_list_output(self, item): return item['RoleName'] def list_method(self, **kwargs): - all_roles = list_roles(**kwargs) - items = [] - - for role in all_roles: - role["Region"] = "us-east-1" # IAM is global - items.append(role) - - return items + return get_all_roles(**kwargs) def get_method(self, item, **kwargs): - # This is not needed for IAM Role: - item.pop("Region") - - return get_role(dict(item), **kwargs) + return item diff --git a/security_monkey/watchers/iam/iam_user.py b/security_monkey/watchers/iam/iam_user.py index e2981d03d..2f2dc8af3 100644 --- a/security_monkey/watchers/iam/iam_user.py +++ b/security_monkey/watchers/iam/iam_user.py @@ -1,7 +1,7 @@ from security_monkey.cloudaux_watcher import CloudAuxWatcher from security_monkey import AWS_DEFAULT_REGION from cloudaux.aws.iam import list_users -from cloudaux.orchestration.aws.iam.user import get_user +from cloudaux.orchestration.aws.iam.user import get_all_users class IAMUser(CloudAuxWatcher): @@ -27,7 +27,7 @@ def _get_regions(self): return [AWS_DEFAULT_REGION] def list_method(self, **kwargs): - return list_users(**kwargs) + return get_all_users(**kwargs) def get_method(self, item, **kwargs): - return get_user(item, **kwargs) + return item