コード例 #1
0
ファイル: auditor.py プロジェクト: darrow/security_monkey
    def email_report(self, report):
        """
        Given a report, send an email using SES.
        """
        if not report:
            app.logger.info("No Audit issues.  Not sending audit email.")
            return

        subject = "Security Monkey {} Auditor Report".format(self.i_am_singular)
        send_email(subject=subject, recipients=self.emails, html=report)
コード例 #2
0
    def email_report(self, report):
        """
        Given a report, send an email using SES.
        """
        if not report:
            app.logger.info("No Audit issues.  Not sending audit email.")
            return

        subject = "Security Monkey {} Auditor Report".format(self.i_am_singular)
        send_email(subject=subject, recipients=self.emails, html=report)
コード例 #3
0
    def report(self):
        """
        Collect change summaries from watchers defined and send out an email
        """
        changed_watchers = [watcher_auditor[0] for watcher_auditor in self.watchers_auditors if watcher_auditor[0].is_changed()]
        has_issues = has_new_issue = has_unjustified_issue = False
        for watcher in changed_watchers:
            (has_issues, has_new_issue, has_unjustified_issue) = watcher.issues_found()
            if has_issues:
                users = User.query.filter(User.accounts.any(name=self.account)).filter(User.change_reports=='ISSUES').all()
                new_emails = [user.email for user in users]
                self.emails.extend(new_emails)
                break

        watcher_types = [watcher.index for watcher in changed_watchers]
        watcher_str = ', '.join(watcher_types)
        if len(changed_watchers) == 0:
            app.logger.info("Alerter: no changes found")
            return

        app.logger.info("Alerter: Found some changes in {}: {}".format(self.account, watcher_str))

        if app.config.get('SLACK_URL'):
	    url = app.config.get('SLACK_URL')
	    message = "Alerter: Found some changes in {}: {}".format(self.account, watcher_str)
	    username = app.config.get('SLACK_USERNAME')
            message_slack(message, username, url)

        content = {u'watchers': changed_watchers}
        body = report_content(content)
        subject = get_subject(has_issues, has_new_issue, has_unjustified_issue, self.account, watcher_str)
        return send_email(subject=subject, recipients=self.emails, html=body)
コード例 #4
0
    def report(self):
        """
        Collect change summaries from watchers defined and send out an email
        """
        changed_watchers = [watcher_auditor.watcher
                            for watcher_auditor in self.watchers_auditors if watcher_auditor.watcher.is_changed()]
        has_issues = has_new_issue = has_unjustified_issue = False
        for watcher in changed_watchers:
            (has_issues, has_new_issue, has_unjustified_issue) = watcher.issues_found()
            if has_issues:
                users = User.query.filter(
                    User.accounts.any(name=self.account)).filter(User.change_reports == 'ISSUES').filter(User.active == True).all()  # noqa
                new_emails = [user.email for user in users]
                self.emails.extend(new_emails)
                break

        watcher_types = [watcher.index for watcher in changed_watchers]
        watcher_str = ', '.join(watcher_types)
        if len(changed_watchers) == 0:
            app.logger.info("Alerter: no changes found")
            return

        app.logger.info("Alerter: Found some changes in {}: {}".format(self.account, watcher_str))
        content = {'watchers': changed_watchers}
        body = report_content(content)
        subject = get_subject(has_issues, has_new_issue, has_unjustified_issue, self.account, watcher_str)
        return send_email(subject=subject, recipients=self.emails, html=body)
コード例 #5
0
ファイル: alerter.py プロジェクト: jeremy-h/security_monkey
    def report(self):
        """
        Collect change summaries from watchers defined and send out an email
        """
        changed_watchers = [
            watcher_auditor.watcher
            for watcher_auditor in self.watchers_auditors
            if watcher_auditor.watcher.is_changed()
        ]
        has_issues = has_new_issue = has_unjustified_issue = False
        for watcher in changed_watchers:
            (has_issues, has_new_issue, has_unjustified_issue) = watcher.issues_found()
            if has_issues:
                users = (
                    User.query.filter(User.accounts.any(name=self.account))
                    .filter(User.change_reports == "ISSUES")
                    .all()
                )
                new_emails = [user.email for user in users]
                self.emails.extend(new_emails)
                break

        watcher_types = [watcher.index for watcher in changed_watchers]
        watcher_str = ", ".join(watcher_types)
        if len(changed_watchers) == 0:
            app.logger.info("Alerter: no changes found")
            return

        app.logger.info("Alerter: Found some changes in {}: {}".format(self.account, watcher_str))
        content = {u"watchers": changed_watchers}
        body = report_content(content)
        subject = get_subject(has_issues, has_new_issue, has_unjustified_issue, self.account, watcher_str)
        return send_email(subject=subject, recipients=self.emails, html=body)