Beispiel #1
0
 def read_previous_items(self):
     """
     Pulls the last-recorded configuration from the database.
     :return: List of all items for the given technology and the given account.
     """
     prev_list = []
     for account in self.accounts:
         prev = self.datastore.get_all_ctype_filtered(tech=self.index, account=account, include_inactive=False)
         # Returns a map of {Item: ItemRevision}
         for item in prev:
             item_revision = prev[item]
             new_item = ChangeItem(index=self.index,
                                   region=item.region,
                                   account=item.account.name,
                                   name=item.name,
                                   new_config=item_revision.config)
             new_item.audit_issues = []
             new_item.db_item = item
             prev_list.append(new_item)
     return prev_list
Beispiel #2
0
 def read_previous_items(self):
     """
     Pulls the last-recorded configuration from the database.
     :return: List of all items for the given technology and the given account.
     """
     prev_list = []
     for account in self.accounts:
         prev = self.datastore.get_all_ctype_filtered(tech=self.index, account=account, include_inactive=False)
         # Returns a map of {Item: ItemRevision}
         for item in prev:
             item_revision = prev[item]
             new_item = ChangeItem(index=self.index,
                                   region=item.region,
                                   account=item.account.name,
                                   name=item.name,
                                   new_config=item_revision.config)
             new_item.audit_issues = []
             new_item.db_item = item
             prev_list.append(new_item)
     return prev_list
def _delete_issues(settings):
    account = Account.query.filter(Account.id == settings.account_id).first()
    tech = Technology.query.filter(Technology.id == settings.tech_id).first()
    if account and tech:
        # Report issues as fixed
        db_items = Datastore().get_all_ctype_filtered(tech=tech.name, account=account.name, include_inactive=False)
        items = []
        for item in db_items:
            new_item = ChangeItem(index=tech.name,
                                  region=item.region,
                                  account=account.name,
                                  name=item.name,
                                  arn=item.arn)
            new_item.audit_issues = []
            new_item.db_item = item
            items.append(new_item)

        for item in items:
            for issue in item.db_item.issues:
                if issue.auditor_setting_id == settings.id:
                    item.confirmed_fixed_issues.append(issue)

    db.session.delete(settings)