import re


def parse_one_cve_commit(commit_str):
    """
    Parse a single CVE commit.
    :param commit_str: the commit message
    returns the commit ID and all the matched CVEs in a list.
    """
    result = re.findall(r'CVE-\d{4}-\d+', commit_str)
    #print(result)
    result = list(set(result))
    if commit_str[:7] == 'commit ':  # the first commit message contains the 'commit ' leading string
        commit_id = commit_str[7:47]
    else:  # all other commit messages starts with the 40-digit SHA1 checksum, which is the git commit ID.
        commit_id = commit_str[:40]
    #print(commit_id, result)
    return (commit_id, result)