in filter_aws.py [0:0]
def execute(self, listing, response):
"""Apply filter.
Args:
listing: data returned from aws api.
response: relevant data returned to caller.
"""
if listing.service == 'kms' and listing.operation == 'ListKeys':
aliases_file = '{}_{}_{}_{}.json'.format(listing.service, 'ListAliases',
listing.region, listing.profile)
aliases_file = self.directory + aliases_file
aliases_listing = listing.from_json(json.load(open(aliases_file, 'rb')))
list_aliases = aliases_listing.response
service_key_ids = [
k.get('TargetKeyId') for k in list_aliases.get('Aliases', [])
if k.get('AliasName').lower().startswith('alias/aws')
]
response['Keys'] = [k for k in response.get('Keys', [])
if k.get('KeyId') not in service_key_ids]