Пример #1
0
    def __init__(self, accounts=None, debug=False):
        """Initializes the Watcher"""
        self.datastore = datastore.Datastore()
        if not accounts:
            accounts = Account.query.filter(
                Account.third_party == False).filter(
                    Account.active == True).all()
        else:
            accounts = Account.query.filter(
                Account.third_party == False).filter(
                    Account.active == True).filter(
                        Account.name.in_(accounts)).all()
        if not accounts:
            raise ValueError('Watcher needs a valid account')
        self.accounts = [account.name for account in accounts]
        self.account_identifiers = [account.identifier for account in accounts]
        self.debug = debug
        self.created_items = []
        self.deleted_items = []
        self.changed_items = []
        self.ephemeral_items = []
        # TODO: grab these from DB, keyed on account
        self.rate_limit_delay = 0
        self.honor_ephemerals = False
        self.ephemeral_paths = []

        # Batching attributes:
        self.batched_size = 0  # Don't batch anything by default
        self.done_slurping = True  # Don't batch anything by default
        self.total_list = [
        ]  # This will hold the full list of items to batch over
        self.batch_counter = 0  # Keeps track of the batch we are on -- can be used for retry logic
        self.current_account = None  # Tuple that holds the current account and account index we are on.
        self.technology = None
Пример #2
0
    def __init__(self, accounts=None, debug=False):
        self.datastore = datastore.Datastore()
        self.accounts = accounts
        self.debug = debug
        self.items = []
        self.team_emails = app.config.get('SECURITY_TEAM_EMAIL', [])
        self.emails = []
        self.current_support_items = {}
        self.override_scores = None
        self.current_method_name = None

        if type(self.team_emails) in string_types:
            self.emails.append(self.team_emails)
        elif type(self.team_emails) in (list, tuple):
            self.emails.extend(self.team_emails)
        else:
            app.logger.info("Auditor: SECURITY_TEAM_EMAIL contains an invalid type")

        for account in self.accounts:
            users = User.query.filter(User.daily_audit_email==True).filter(User.accounts.any(name=account)).all()
            self.emails.extend([user.email for user in users])