'alert when an IAM item (group, user or role) is attached to a managed policy with issues'

def library_check_attached_managed_policies(self, iam_item, iam_type):

    mp_items = self.get_auditor_support_items(ManagedPolicy.index, iam_item.account)
    managed_policies = iam_item.config.get('managed_policies', iam_item.config.get('ManagedPolicies'))
    for item_mp in (managed_policies or []):
        found = False
        item_mp_arn = item_mp.get('arn', item_mp.get('Arn'))
        for mp_item in (mp_items or ([] and (not found))):
            mp_arn = mp_item.config.get('arn', mp_item.config.get('Arn'))
            if (mp_arn == item_mp_arn):
                found = True
                self.link_to_support_item_issues(iam_item, mp_item.db_item, None, 'Found    issue(s)    in    attached    Managed    Policy')
        if (not found):
            app.logger.error('IAM    Managed    Policy    defined    but    not    found    for    {}-{}'.format(iam_item.index, iam_item.name))
