def check_ranges(cpe_item, version):
    """
    According to the specification, CPE uses also ranges with the keywords
    'version[Start|End][Including|Excluding]'. This way it specifies ranges of versions
    which are affected by the CVE, for example versions from 4.0.0 to 4.5.0.

    :param cpe_item: cpe data
    :param version: version to be checked
    :return: True if the version is in the specified range
    """
    if "versionStartIncluding" in cpe_item and \
            version < cpe_item['versionStartIncluding']:
        return False
    if "versionStartExcluding" in cpe_item and \
            version <= cpe_item['versionStartExcluding']:
        return False
    if "versionEndIncluding" in cpe_item and \
            version > cpe_item["versionEndIncluding"]:
        return False
    if "versionEndExcluding" in cpe_item and \
            version >= cpe_item["versionEndExcluding"]:
        return False
    return True