8000 1309 AWS Role RoleLastUsed information by paigebelliveau · Pull Request #1345 · nccgroup/ScoutSuite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

1309 AWS Role RoleLastUsed information #1345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Fronted Build CI (dummy version)

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ v6-master ]

jobs:
test:
runs-on: ubuntu-18.04
steps:
- name: Show environment v1
run: env | grep ^GITHUB
- name: Show ref v1
run: echo "===============> Version from $GITHUB_REF"
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ <h4 class="list-group-item-heading">Information</h4>
<div class="list-group-item-text item-margin">Creation Date: <span id="iam.roles.{{@key}}.create_date">{{format_date create_date}}</span></div>
<div class="list-group-item-text item-margin">Path: <span id="iam.roles.{{@key}}.path"><samp>{{value_or_none path}}</samp></span></div>
<div class="list-group-item-text item-margin">Max Session Duration: <span id="iam.roles.{{@key}}.max_session_duration"><samp>{{value_or_none max_session_duration}}</samp></span></div>
<div class="list-group-item-text item-margin">Last Used Date: <span id="iam.roles.{{@key}}.last_used_date"><samp>{{value_or_none last_used_date}}</samp></span></div>
<div class="list-group-item-text item-margin">Last Used Region: <span id="iam.roles.{{@key}}.last_used_region"><samp>{{value_or_none last_used_region}}</samp></span></div>
</div>
<div class="list-group-item">
{{> accordion_policy name = 'Role Trust Policy' policy_path = (concat 'iam.roles' @key 'assume_role_policy.PolicyDocument') document = assume_role_policy.PolicyDocument}}
Expand Down
13 changes: 12 additions & 1 deletion ScoutSuite/providers/aws/facade/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ async def get_roles(self):
await get_and_set_concurrently(
[functools.partial(self._get_and_set_inline_policies, iam_resource_type='role'),
self._get_and_set_role_profiles,
self._get_and_set_role_tags], roles)
self._get_and_set_role_tags,
self._get_and_set_role_last_used_info], roles)

return roles

Expand All @@ -160,6 +161,16 @@ async def _get_and_set_role_profiles(self, role: {}):
'arn', profile['Arn'])
role['instance_profiles'][profile_id].setdefault(
'name', profile['InstanceProfileName'])

async def _get_and_set_role_last_used_info(self, role: {}):
client = AWSFacadeUtils.get_client('iam', self.session)
try:
role_description = client.get_role(RoleName=role['RoleName'])['Role']
last_used_info = role_description.get('RoleLastUsed', {})
role['last_used_date'] = last_used_info.get('LastUsedDate', None)
role['last_used_region'] = last_used_info.get('Region', None)
except Exception as e:
print_exception(f'Failed to describe role {e}')

async def get_password_policy(self):
client = AWSFacadeUtils.get_client('iam', self.session)
Expand Down
2 changes: 2 additions & 0 deletions ScoutSuite/providers/aws/resources/iam/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ def _parse_role(self, raw_role):
role_dict['inline_policies'] = raw_role.get('inline_policies')
role_dict['inline_policies_count'] = raw_role.get('inline_policies_count')
role_dict['assume_role_policy'] = raw_role.get('assume_role_policy')
role_dict['last_used_date'] = raw_role.get('last_used_date')
role_dict['last_used_region'] = raw_role.get('last_used_region')
if (len(raw_role['tags']['Tags']) > 0):
role_dict['Tags'] = raw_role['tags']['Tags']
return role_dict['id'], role_dict
0