Skip to content

Commit

Permalink
#26 - Fix IAM sync crash due to "Action" not being defined on a polic…
Browse files Browse the repository at this point in the history
…y Statement (#27)

* #26 - Fix IAM sync crash due to "Action" not being defined on a policy Statement

* Pre-release version to 0.2.2rc1
  • Loading branch information
achantavy authored Mar 28, 2019
1 parent 3ba71b0 commit a4e8a61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
35 changes: 18 additions & 17 deletions cartography/intel/aws/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,29 +275,30 @@ def load_group_policies(session, group_policies, aws_update_tag):
for group_name, policies in group_policies.items():
for policy_name, policy_data in policies.items():
for statement in policy_data["PolicyDocument"]["Statement"]:
action = statement["Action"]

# TODO improve this
if action == "sts:AssumeRole":
if statement["Effect"] == "Allow":
roles_arn = statement["Resource"]

if type(roles_arn) == str:
session.run(
ingest_policies_assume_role,
GroupName=group_name,
RoleArn=roles_arn,
aws_update_tag=aws_update_tag
)
else:
# TODO the code below probably contains a bug -- why is role_arn not used in the loop?
for role_arn in roles_arn:
if "Action" in statement:
action = statement["Action"]

# TODO improve this
if action == "sts:AssumeRole":
if statement["Effect"] == "Allow":
roles_arn = statement["Resource"]

if type(roles_arn) == str:
session.run(
ingest_policies_assume_role,
GroupName=group_name,
RoleArn=roles_arn,
aws_update_tag=aws_update_tag
)
else:
# TODO the code below probably contains a bug -- why is role_arn not used in the loop?
for role_arn in roles_arn:
session.run(
ingest_policies_assume_role,
GroupName=group_name,
RoleArn=roles_arn,
aws_update_tag=aws_update_tag
)


def load_user_access_keys(session, user_access_keys, aws_update_tag):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

__version__ = '0.2.1'
__version__ = '0.2.2rc1'


setup(
Expand Down

0 comments on commit a4e8a61

Please sign in to comment.