#NEWLINE# def slurp( self ) : #NEWLINE# #INDENT# '\n        :returns: item_list - list of Managed Policies.\n        :returns: exception_map - A dict where the keys are a tuple containing the\n            location of the exception and the value is the actual exception\n        ' #NEWLINE# self . prep_for_slurp ( ) #NEWLINE# item_list = [ ] #NEWLINE# exception_map = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# from security_monkey.common.sts_connect import connect #NEWLINE# for account in self . accounts : #NEWLINE# #INDENT# all_policies = [ ] #NEWLINE# try : #NEWLINE# #INDENT# iam = connect ( account , 'iam_boto3' ) #NEWLINE# for policy in iam . policies . all ( ) : #NEWLINE# #INDENT# all_policies . append ( policy ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# exc = BotoConnectionIssue ( str ( e ) , 'iamuser' , account , None ) #NEWLINE# self . slurp_exception ( ( self . index , account , 'universal' ) , exc , exception_map ) #NEWLINE# continue #NEWLINE# #UNINDENT# for policy in all_policies : #NEWLINE# #INDENT# if self . check_ignore_list ( policy . policy_name ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if self . check_ignore_list ( policy . arn ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# item_config = { #NEWLINE# #INDENT# 'name' : policy . policy_name , #NEWLINE# 'arn' : policy . arn , #NEWLINE# 'create_date' : str ( policy . create_date ) , #NEWLINE# 'update_date' : str ( policy . update_date ) , #NEWLINE# 'default_version_id' : policy . default_version_id , #NEWLINE# 'attachment_count' : policy . attachment_count , #NEWLINE# 'attached_users' : [ a . arn for a in policy . attached_users . all ( ) ] , #NEWLINE# 'attached_groups' : [ a . arn for a in policy . attached_groups . all ( ) ] , #NEWLINE# 'attached_roles' : [ a . arn for a in policy . attached_roles . all ( ) ] , #NEWLINE# 'policy' : policy . default_version . document , #NEWLINE# #UNINDENT# } #NEWLINE# app . logger . debug ( ( 'Slurping %s (%s) from %s' % ( self . i_am_singular , policy . policy_name , account ) ) ) #NEWLINE# item_list . append ( ManagedPolicyItem ( account = account , name = policy . policy_name , config = item_config ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ( item_list , exception_map )