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

    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.
            # TODO: If not in queue b/c of abuse reports, add an
            #       amo.LOG.ESCALATED_HIGH_ABUSE for reviewers.
            log.info(u'[addon:%s] High abuse reports, but already escalated' %
                     (abuse.addon,))
            continue

        # We have an abuse report and this add-on isn't currently in the
        # escalated queue... let's see if it has been detected and dealt with
        # already.
        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:
                log.info(u'[addon:%s] High abuse reports, but none since last '
                          'escalation' % abuse.addon)
                continue

        # If we haven't bailed out yet, escalate this app.
        msg = u'High number of abuse reports detected'
        EscalationQueue.objects.create(addon=abuse.addon)
        amo.log(amo.LOG.ESCALATED_HIGH_ABUSE, abuse.addon,
                abuse.addon.current_version, details={'comments': msg})
        log.info(u'[addon:%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.
            log.info(u'[addon:%s] High abuse reports, but already 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:
                log.info(u'[addon:%s] High abuse reports, but none since last '
                         u'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})
        log.info(u'[addon:%s] %s' % (abuse.addon, msg))
Esempio n. 3
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.
            log.info(u"[addon:%s] High abuse reports, but already 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:
                log.info(u"[addon:%s] High abuse reports, but none since last " u"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})
        log.info(u"[addon:%s] %s" % (abuse.addon, msg))
Esempio n. 4
0
 def test_addon_fr(self):
     with self.activate(locale='fr'):
         AbuseReport(addon_id=3615).send()
     assert mail.outbox[0].subject.startswith('[Extension]')
Esempio n. 5
0
 def test_addon(self):
     AbuseReport(addon_id=3615).send()
     assert mail.outbox[0].subject.startswith('[Extension]')
Esempio n. 6
0
 def test_user(self):
     AbuseReport(user_id=999).send()
     assert mail.outbox[0].subject.startswith('[User]')
     eq_(mail.outbox[0].to, [settings.ABUSE_EMAIL])