From 157bca59597969a0b504b36cb9d0931c968974c0 Mon Sep 17 00:00:00 2001 From: Antoine Boisier-Michaud Date: Thu, 7 Feb 2019 16:25:16 -0500 Subject: [PATCH 1/2] Implemented processing method which finds the most recent ebs snapshots for each volume --- ScoutSuite/providers/aws/provider.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ScoutSuite/providers/aws/provider.py b/ScoutSuite/providers/aws/provider.py index 8a688e16d..06168617a 100644 --- a/ScoutSuite/providers/aws/provider.py +++ b/ScoutSuite/providers/aws/provider.py @@ -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() @@ -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: From 6b3f9e6e092c4d7fbaef6628b25429b73a90107f Mon Sep 17 00:00:00 2001 From: Antoine Boisier-Michaud Date: Thu, 7 Feb 2019 16:25:24 -0500 Subject: [PATCH 2/2] Added info in the snapshots dashboard --- .../html/partials/aws/services.ec2.regions.id.snapshots.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ScoutSuite/output/data/html/partials/aws/services.ec2.regions.id.snapshots.html b/ScoutSuite/output/data/html/partials/aws/services.ec2.regions.id.snapshots.html index 19e46be31..3dc32e97e 100644 --- a/ScoutSuite/output/data/html/partials/aws/services.ec2.regions.id.snapshots.html +++ b/ScoutSuite/output/data/html/partials/aws/services.ec2.regions.id.snapshots.html @@ -8,7 +8,9 @@

{{name}}

Information