Skip to content

Commit

Permalink
Merge pull request #160 from nccgroup/feature/5-ebs-findings-prop
Browse files Browse the repository at this point in the history
Feature/5 ebs findings prop
  • Loading branch information
Aboisier committed Feb 9, 2019
2 parents f1f4776 + 6b3f9e6 commit 907c8ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ <h4 class="list-group-item-heading">{{name}}</h4>
<h4 class="list-group-item-heading">Information</h4>
<ul>
<li class="list-group-item-text">Id: {{id}}</li>
<li class="list-group-item-text">Description: {{Description}}</li>
<li class="list-group-item-text">Date: <span id="ec2.regions.{{region}}.snapshots.{{id}}.old_snapshot">{{StartTime}}</span></li>
<li class="list-group-item-text">Description:{{Description}}</li>
<li class="list-group-item-text">State: <span id="ec2.regions.{{region}}.snapshots.{{id}}.snapshot_errored">{{State}}</span></li>
<li class="list-group-item-text">Encrypted: {{Encrypted}}</li>
<li class="list-group-item-text">Is encrypted: {{Encrypted}}</li>
<li class="list-group-item-text">Volume: {{> resource_link resource_path = (concat 'services.ec2.regions' region 'volumes' VolumeId )}}</li>
Expand Down
8 changes: 8 additions & 0 deletions ScoutSuite/providers/aws/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def preprocessing(self, ip_ranges=None, ip_ranges_name_key=None):

# Various data processing calls
self._add_security_group_name_to_ec2_grants()
self._add_last_snapshot_date_to_ec2_volumes()
self._process_cloudtrail_trails(self.services['cloudtrail'])
self._add_cidr_display_name(ip_ranges, ip_ranges_name_key)
self._merge_route53_and_route53domains()
Expand Down Expand Up @@ -114,6 +115,13 @@ def _add_security_group_name_to_ec2_grants(self):
self.add_security_group_name_to_ec2_grants_callback,
{'AWSAccountId': self.aws_account_id})

def _add_last_snapshot_date_to_ec2_volumes(self):
for region in self.services['ec2']['regions'].values():
for volumeId, volume in region.get('volumes').items():
completed_snapshots = [s for s in region['snapshots'].values() if s['VolumeId'] == volumeId and s['State'] == 'completed']
mostRecent = sorted(completed_snapshots, key=lambda s: s['StartTime'], reverse=True)[0]
volume['LastSnapshotDate'] = mostRecent['StartTime']

def add_security_group_name_to_ec2_grants_callback(self, current_config, path, current_path, ec2_grant, callback_args):
sg_id = ec2_grant['GroupId']
if sg_id in current_path:
Expand Down

0 comments on commit 907c8ba

Please sign in to comment.