def reserve_cve_id()

in foundation_security_advisories/common_cve.py [0:0]


def reserve_cve_id(year: str):
    """CVE Servies: Reserve a new CVE-ID for a given year and return that new id."""
    print(f"Reserving CVE-ID for year {year}")
    try:
        response = cve_api.reserve(1, False, year)
    except HTTPError as e:
        raise Exception(f"Failed to reserve CVE-ID, {e.response.text}")
    if (
        "cve_ids" not in response
        or len(response["cve_ids"]) != 1
        or "cve_id" not in response["cve_ids"][0]
    ):
        raise ValueError(f"API did not respond with valid CVE-ID")
    return response["cve_ids"][0]["cve_id"]