Пример #1
0
def annotate_legacy_addon_restrictions(path, results, parsed_data, error=True):
    """
    Annotate validation results to restrict uploads of legacy
    (non-webextension) add-ons.
    """
    # We can be broad here. Search plugins are not validated through this
    # path and as of right now (Jan 2019) there aren't any legacy type
    # add-ons allowed to submit anymore.
    msg = ugettext(
        u'Legacy extensions are no longer supported in Firefox.')

    description = ugettext(
        u'Add-ons for Thunderbird and SeaMonkey are now listed and '
        u'maintained on addons.thunderbird.net. You can use the same '
        u'account to update your add-ons on the new site.')

    # `parsed_data` only contains the most minimal amount of data because
    # we aren't in the right context. Let's explicitly fetch the add-ons
    # apps so that we can adjust the messaging to the user.
    xpi = get_file(path)
    extractor = RDFExtractor(SafeZip(xpi))

    targets_thunderbird_or_seamonkey = False
    thunderbird_or_seamonkey = {amo.THUNDERBIRD.guid, amo.SEAMONKEY.guid}

    for ctx in extractor.rdf.objects(None, extractor.uri('targetApplication')):
        if extractor.find('id', ctx) in thunderbird_or_seamonkey:
            targets_thunderbird_or_seamonkey = True

    description = description if targets_thunderbird_or_seamonkey else []

    insert_validation_message(
        results, type_='error' if error else 'warning',
        message=msg, description=description,
        msg_id='legacy_addons_unsupported')
Пример #2
0
def extract_strict_compatibility_value_for_addon(addon):
    strict_compatibility = None  # We don't know yet.
    try:
        # We take a shortcut here and only look at the first file we
        # find...
        # Note that we can't use parse_addon() wrapper because it no longer
        # exposes the real value of `strictCompatibility`...
        path = addon.current_version.all_files[0].file_path
        zip_file = SafeZip(get_file(path))
        parser = RDFExtractor(zip_file)
        strict_compatibility = parser.find('strictCompatibility') == 'true'
    except Exception as exc:
        # A number of things can go wrong: missing file, path somehow not
        # existing, etc. In any case, that means the add-on is in a weird
        # state and should be ignored (this is a one off task).
        log.exception(u'bump_appver_for_legacy_addons: ignoring addon %d, '
                      u'received %s when extracting.', addon.pk, unicode(exc))
    return strict_compatibility
Пример #3
0
def extract_strict_compatibility_value_for_addon(addon):
    strict_compatibility = None  # We don't know yet.
    try:
        # We take a shortcut here and only look at the first file we
        # find...
        # Note that we can't use parse_addon() wrapper because it no longer
        # exposes the real value of `strictCompatibility`...
        path = addon.current_version.all_files[0].file_path
        zip_file = SafeZip(get_file(path))
        parser = RDFExtractor(zip_file)
        strict_compatibility = parser.find('strictCompatibility') == 'true'
    except Exception as exc:
        # A number of things can go wrong: missing file, path somehow not
        # existing, etc. In any case, that means the add-on is in a weird
        # state and should be ignored (this is a one off task).
        log.exception(u'bump_appver_for_legacy_addons: ignoring addon %d, '
                      u'received %s when extracting.', addon.pk, unicode(exc))
    return strict_compatibility
Пример #4
0
def annotate_legacy_addon_restrictions(path, results, parsed_data, error=True):
    """
    Annotate validation results to restrict uploads of legacy
    (non-webextension) add-ons.
    """
    # We can be broad here. Search plugins are not validated through this
    # path and as of right now (Jan 2019) there aren't any legacy type
    # add-ons allowed to submit anymore.
    msg = gettext('Legacy extensions are no longer supported in Firefox.')

    description = gettext(
        'Add-ons for Thunderbird and SeaMonkey are now listed and '
        'maintained on addons.thunderbird.net. You can use the same '
        'account to update your add-ons on the new site.'
    )

    # `parsed_data` only contains the most minimal amount of data because
    # we aren't in the right context. Let's explicitly fetch the add-ons
    # apps so that we can adjust the messaging to the user.
    xpi = get_file(path)
    extractor = RDFExtractor(SafeZip(xpi))

    targets_thunderbird_or_seamonkey = False
    thunderbird_or_seamonkey = {amo.THUNDERBIRD.guid, amo.SEAMONKEY.guid}

    for ctx in extractor.rdf.objects(None, extractor.uri('targetApplication')):
        if extractor.find('id', ctx) in thunderbird_or_seamonkey:
            targets_thunderbird_or_seamonkey = True

    description = description if targets_thunderbird_or_seamonkey else []

    insert_validation_message(
        results,
        type_='error' if error else 'warning',
        message=msg,
        description=description,
        msg_id='legacy_addons_unsupported',
    )