Exemple #1
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
        issue_only_emails = []
        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()
                issue_only_emails = [user.email for user in users]
                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)
        issue_only_body = report_content(content, issues_only=True)
        subject = get_subject(has_issues, has_new_issue, has_unjustified_issue, self.account, watcher_str)
        if issue_only_emails:
            res = send_email(subject=subject, recipients=issue_only_emails, html=issue_only_body)
        return send_email(subject=subject, recipients=self.emails, html=body)
Exemple #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)
    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)
Exemple #4
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))
        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)
Exemple #5
0
 def mail(self, body, watcher_type):
     subject = "[{}] Changes in {}".format(self.account, watcher_type)
     send_email(subject=subject, recipients=self.emails, html=body)
Exemple #6
0
 def mail(self, body, watcher_type):
     subject = "[{}] Changes in {}".format(self.account, watcher_type)
     send_email(subject=subject, recipients=self.emails, html=body)