Skip to content
This repository has been archived by the owner on Sep 17, 2021. It is now read-only.

Commit

Permalink
Further fixing the IAM User auditor to work with the new IAM User for…
Browse files Browse the repository at this point in the history
…mat.
  • Loading branch information
scriptsrc committed Dec 7, 2016
1 parent 31de86f commit 2330520
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions security_monkey/auditors/iam/iam_user.py
Expand Up @@ -51,22 +51,22 @@ def check_access_keys(self, iamuser_item):
alert when an IAM User has an active access key.
"""
akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys.keys():
if 'Status' in akeys[akey]:
if akeys[akey]['Status'] == 'Active':
self.add_issue(1, 'User has active accesskey.', iamuser_item, notes=akey)
for akey in akeys:
if 'Status' in akey:
if akey['Status'] == 'Active':
self.add_issue(1, 'User has active accesskey.', iamuser_item, notes=akey['AccessKeyId'])
else:
self.add_issue(0, 'User has an inactive accesskey.', iamuser_item, notes=akey)
self.add_issue(0, 'User has an inactive accesskey.', iamuser_item, notes=akey['AccessKeyId'])

def check_access_key_rotation(self, iamuser_item):
"""
alert when an IAM User has an active access key created more than 90 days go.
"""
akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys.keys():
if 'Status' in akeys[akey]:
if akeys[akey]['Status'] == 'Active':
create_date = akeys[akey]['CreateDate']
for akey in akeys:
if 'Status' in akey:
if akey['Status'] == 'Active':
create_date = akey['CreateDate']
create_date = parser.parse(create_date)
if create_date < self.ninety_days_ago:
notes = "> 90 days ago"
Expand All @@ -77,10 +77,10 @@ def check_access_key_last_used(self, iamuser_item):
alert if an active access key hasn't been used in 90 days
"""
akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys.keys():
if 'Status' in akeys[akey]:
if akeys[akey]['Status'] == 'Active':
last_used_str = akeys[akey].get('LastUsedDate')
for akey in akeys:
if 'Status' in akey:
if akey['Status'] == 'Active':
last_used_str = akey.get('LastUsedDate')
if not last_used_str:
continue
last_used_date = parser.parse(last_used_str)
Expand Down Expand Up @@ -152,8 +152,8 @@ def check_loginprofile_plus_akeys(self, iamuser_item):
return

akeys = iamuser_item.config.get('AccessKeys', {})
for akey in akeys.keys():
if 'Status' in akeys[akey] and akeys[akey]['Status'] == 'Active':
for akey in akeys:
if 'Status' in akey and akey['Status'] == 'Active':
self.add_issue(1, 'User with password login and API access.', iamuser_item)
return

Expand Down

0 comments on commit 2330520

Please sign in to comment.