Esempio n. 1
0
def find_abuse_escalations(addon_id, **kw):
    weekago = datetime.date.today() - datetime.timedelta(days=7)
    add_to_queue = True

    for abuse in AbuseReport.recent_high_abuse_reports(1, weekago, addon_id):
        if EscalationQueue.objects.filter(addon=abuse.addon).exists():
            # App is already in the queue, no need to re-add it.
            task_log.info(u'[app:%s] High abuse reports, but already '
                          u'escalated' % abuse.addon)
            add_to_queue = False

        # We have an abuse report... has it been detected and dealt with?
        logs = (AppLog.objects.filter(
            activity_log__action=amo.LOG.ESCALATED_HIGH_ABUSE.id,
            addon=abuse.addon).order_by('-created'))
        if logs:
            abuse_since_log = AbuseReport.recent_high_abuse_reports(
                1, logs[0].created, addon_id)
            # If no abuse reports have happened since the last logged abuse
            # report, do not add to queue.
            if not abuse_since_log:
                task_log.info(u'[app:%s] High abuse reports, but none since '
                              u'last escalation' % abuse.addon)
                continue

        # If we haven't bailed out yet, escalate this app.
        msg = u'High number of abuse reports detected'
        if add_to_queue:
            EscalationQueue.objects.create(addon=abuse.addon)
        amo.log(amo.LOG.ESCALATED_HIGH_ABUSE, abuse.addon,
                abuse.addon.current_version, details={'comments': msg})
        task_log.info(u'[app:%s] %s' % (abuse.addon, msg))
Esempio n. 2
0
def find_abuse_escalations(addon_id, **kw):
    weekago = datetime.date.today() - datetime.timedelta(days=7)
    add_to_queue = True

    for abuse in AbuseReport.recent_high_abuse_reports(1, weekago, addon_id):
        if EscalationQueue.objects.filter(addon=abuse.addon).exists():
            # App is already in the queue, no need to re-add it.
            task_log.info(u'[app:%s] High abuse reports, but already '
                          u'escalated' % abuse.addon)
            add_to_queue = False

        # We have an abuse report... has it been detected and dealt with?
        logs = (AppLog.objects.filter(
            activity_log__action=mkt.LOG.ESCALATED_HIGH_ABUSE.id,
            addon=abuse.addon).order_by('-created'))
        if logs:
            abuse_since_log = AbuseReport.recent_high_abuse_reports(
                1, logs[0].created, addon_id)
            # If no abuse reports have happened since the last logged abuse
            # report, do not add to queue.
            if not abuse_since_log:
                task_log.info(u'[app:%s] High abuse reports, but none since '
                              u'last escalation' % abuse.addon)
                continue

        # If we haven't bailed out yet, escalate this app.
        msg = u'High number of abuse reports detected'
        if add_to_queue:
            EscalationQueue.objects.create(addon=abuse.addon)
        mkt.log(mkt.LOG.ESCALATED_HIGH_ABUSE, abuse.addon,
                abuse.addon.current_version, details={'comments': msg})
        task_log.info(u'[app:%s] %s' % (abuse.addon, msg))
Esempio n. 3
0
 def test_website(self):
     website = website_factory()
     AbuseReport(website=website).send()
     assert mail.outbox[0].subject.startswith('[Website]')
     eq_(mail.outbox[0].to, [settings.MKT_FEEDBACK_EMAIL])
Esempio n. 4
0
 def test_extension(self):
     extension = Extension.objects.create(
         name=u'Test Êxtension', slug=u'test-ëxtension')
     AbuseReport(extension=extension).send()
     assert mail.outbox[0].subject.startswith('[FxOS Add-on]')
     eq_(mail.outbox[0].to, [settings.ABUSE_EMAIL])
Esempio n. 5
0
 def test_addon_fr(self):
     with self.activate(locale='fr'):
         AbuseReport(addon=self.app).send()
     assert mail.outbox[0].subject.startswith('[App]')
     eq_(mail.outbox[0].to, [settings.ABUSE_EMAIL])
Esempio n. 6
0
 def test_addon(self):
     AbuseReport(addon=self.app).send()
     assert mail.outbox[0].subject.startswith('[App]')
     eq_(mail.outbox[0].to, [settings.ABUSE_EMAIL])
Esempio n. 7
0
 def test_user(self):
     AbuseReport(user=self.user).send()
     assert mail.outbox[0].subject.startswith('[User]')
     eq_(mail.outbox[0].to, [settings.ABUSE_EMAIL])
Esempio n. 8
0
 def test_addon_fr(self):
     with self.activate(locale='fr'):
         AbuseReport(addon=self.app).send()
     assert mail.outbox[0].subject.startswith('[App]')
Esempio n. 9
0
 def test_addon(self):
     AbuseReport(addon=self.app).send()
     assert mail.outbox[0].subject.startswith('[App]')