Пример #1
0
def new_erratum(et_data, errata_type=None, kind=None, release_date=None, create=False,
                assigned_to=None, manager=None, package_owner=None, impact=None, cve=None):
    """5.2.1.1. POST /api/v1/erratum

    Create a new advisory.
    Takes an unrealized advisory object and related attributes using the following format:

    https://errata.devel.redhat.com/developer-guide/api-http-api.html#api-post-apiv1erratum

    :param et_data: The ET data dump we got from our erratatool.yaml file
    :param errata_type: The type of advisory to create (RHBA, RHSA, or RHEA)
    :param string kind: One of 'rpm' or 'image', effects boilerplate text
    :param string release_date: A date in the form YYYY-MM-DD
    :param bool create: If true, create the erratum in the Errata
        tool, by default just the DATA we would have POSTed is
        returned
    :param string assigned_to: The email address of the group responsible for
        examining and approving the advisory entries
    :param string manager: The email address of the manager responsible for
        managing the contents and status of this advisory
    :param string package_owner: The email address of the person who is handling
        the details and status of this advisory
    :param impact: The security impact. Only applies to RHSA
    :param cve: The CVE to attach to the advisory. Only applies to RHSA

    :return: An Erratum object
    :raises: exceptions.ErrataToolUnauthenticatedException if the user is not authenticated to make the request
    """
    if release_date is None:
        release_date = datetime.datetime.now() + datetime.timedelta(days=21)

    if kind is None:
        kind = 'rpm'

    e = Erratum(
            product = et_data['product'],
            release = et_data['release'],
            errata_type = errata_type,
            synopsis = et_data['synopsis'][kind],
            topic = et_data['topic'],
            description = et_data['description'],
            solution = et_data['solution'],
            qe_email = assigned_to,
            qe_group = et_data['quality_responsibility_name'],
            owner_email = package_owner,
            manager_email = manager,
            date = release_date
        )

    if errata_type == 'RHSA':
        e.security_impact = impact
        e.cve_names = cve

    if create:
        # THIS IS NOT A DRILL
        e.commit()
        return e
    else:
        return e
Пример #2
0
def new_erratum(et_data,
                errata_type=None,
                boilerplate_name=None,
                kind=None,
                release_date=None,
                create=False,
                assigned_to=None,
                manager=None,
                package_owner=None,
                impact=None,
                cves=None):
    """5.2.1.1. POST /api/v1/erratum

    Create a new advisory.
    Takes an unrealized advisory object and related attributes using the following format:

    https://errata.devel.redhat.com/developer-guide/api-http-api.html#api-post-apiv1erratum

    :param et_data: The ET data dump we got from our erratatool.yaml file
    :param errata_type: The type of advisory to create (RHBA, RHSA, or RHEA)
    :param string kind: One of [rpm, image].
        Only used for backward compatibility.
    :param string boilerplate_name: One of [rpm, image, extras, metadata, cve].
        The name of boilerplate for creating this advisory
    :param string release_date: A date in the form YYYY-Mon-DD
    :param bool create: If true, create the erratum in the Errata
        tool, by default just the DATA we would have POSTed is
        returned
    :param string assigned_to: The email address of the group responsible for
        examining and approving the advisory entries
    :param string manager: The email address of the manager responsible for
        managing the contents and status of this advisory
    :param string package_owner: The email address of the person who is handling
        the details and status of this advisory
    :param impact: The security impact. Only applies to RHSA
    :param cves: The CVE(s) to attach to the advisory. Separate multiple CVEs with a space. Only applies to RHSA

    :return: An Erratum object
    :raises: exceptions.ErrataToolUnauthenticatedException if the user is not authenticated to make the request
    """
    if not release_date:
        release_date = datetime.datetime.now() + datetime.timedelta(days=21)

    if not kind:
        kind = 'rpm'

    if not boilerplate_name:
        boilerplate_name = kind

    if "boilerplates" in et_data:
        boilerplate = et_data['boilerplates'][boilerplate_name]
    else:  # FIXME: For backward compatibility.
        boilerplate = {
            "synopsis":
            (et_data['synopsis'][boilerplate_name]
             if boilerplate_name != "cve" else et_data['synopsis'][kind]),
            "topic":
            et_data["topic"],
            "description":
            et_data["description"],
            "solution":
            et_data["solution"],
        }

    e = Erratum(product=et_data['product'],
                release=et_data['release'],
                errata_type=errata_type,
                synopsis=boilerplate['synopsis'],
                topic=boilerplate['topic'],
                description=boilerplate['description'],
                solution=boilerplate['solution'],
                qe_email=assigned_to,
                qe_group=et_data['quality_responsibility_name'],
                owner_email=package_owner,
                manager_email=manager,
                date=release_date)

    if errata_type == 'RHSA':
        e.security_impact = impact
        e.cve_names = cves

    if create:
        # THIS IS NOT A DRILL
        e.commit()
        return e
    else:
        return e