def publish_cve()

in foundation_security_advisories/common_cve.py [0:0]


def publish_cve(cve_id: str, cve_json: dict):
    """
    CVE Services: Publish the content for a already existing and given
    CVE-ID with the given data in CVE JSON format.
    """
    cve_json["containers"]["cna"]["references"].sort(
        key=lambda reference: reference["url"]
    )
    diff = difflib.unified_diff(
        "",
        dumps(cve_json, indent=2, sort_keys=True).split("\n"),
        lineterm="",
        fromfile=f"Remote (not yet published)",
        tofile=f"Local",
    )
    for line in diff:
        print(line)
    if not prompt_yes_no(f"\nShould this content be published for {cve_id}?"):
        print(f"Skipping {cve_id}")
        return False
    print(f"Publishing {cve_id}")
    try:
        cve_api.publish(cve_id, cve_json)
        # The timestamp on the API needs to be younger than the commit timestamp so that
        # the file does not get registered as modified.
        touch_cve_id(cve_id)
    except HTTPError as e:
        raise Exception(f"Failed to publish {cve_id}, {e.response.text}")