Source code for nvd_api.low_api.api.vulnerabilities_api

"""
    NVD API 2.0 Python API

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: 0.1.0
    Contact: 15080890+kannkyo@users.noreply.github.com
    Generated by: https://openapi-generator.tech
"""


import re  # noqa: F401
import sys  # noqa: F401

from nvd_api.low_api.api_client import ApiClient, Endpoint as _Endpoint
from nvd_api.low_api.model_utils import (  # noqa: F401
    check_allowed_values,
    check_validations,
    date,
    datetime,
    file_type,
    none_type,
    validate_and_convert_types
)
from nvd_api.low_api.model.cve_history_oas import CveHistoryOas
from nvd_api.low_api.model.cve_oas import CveOas


[docs]class VulnerabilitiesApi(object): """NOTE: This class is auto generated by OpenAPI Generator Ref: https://openapi-generator.tech Do not edit the class manually. """ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.get_cve_history_endpoint = _Endpoint( settings={ 'response_type': (CveHistoryOas,), 'auth': [ 'ApiKeyAuth' ], 'endpoint_path': '/cvehistory/2.0/', 'operation_id': 'get_cve_history', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'change_start_date', 'change_end_date', 'cve_id', 'event_name', 'results_per_page', 'start_index', ], 'required': [], 'nullable': [ ], 'enum': [ 'event_name', ], 'validation': [ 'cve_id', 'results_per_page', 'start_index', ] }, root_map={ 'validations': { ('cve_id',): { 'regex': { 'pattern': r'^CVE-[0-9]{4}-[0-9]{4,}$', # noqa: E501 }, }, ('results_per_page',): { 'inclusive_maximum': 5000, 'inclusive_minimum': 0, }, ('start_index',): { 'inclusive_minimum': 0, }, }, 'allowed_values': { ('event_name',): { "INITIAL_ANALYSIS": "Initial Analysis", "REANALYSIS": "Reanalysis", "CVE_MODIFIED": "CVE Modified", "MODIFIED_ANALYSIS": "Modified Analysis", "CVE_TRANSLATED": "CVE Translated", "VENDOR_COMMENT": "Vendor Comment", "CVE_SOURCE_UPDATE": "CVE Source Update", "CPE_DEPRECATION_REMAP": "CPE Deprecation Remap", "CWE_REMAP": "CWE Remap", "CVE_REJECTED": "CVE Rejected", "CVE_UNREJECTED": "CVE Unrejected" }, }, 'openapi_types': { 'change_start_date': (datetime,), 'change_end_date': (datetime,), 'cve_id': (str,), 'event_name': (str,), 'results_per_page': (int,), 'start_index': (int,), }, 'attribute_map': { 'change_start_date': 'changeStartDate', 'change_end_date': 'changeEndDate', 'cve_id': 'cveId', 'event_name': 'eventName', 'results_per_page': 'resultsPerPage', 'start_index': 'startIndex', }, 'location_map': { 'change_start_date': 'query', 'change_end_date': 'query', 'cve_id': 'query', 'event_name': 'query', 'results_per_page': 'query', 'start_index': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [], }, api_client=api_client ) self.get_cves_endpoint = _Endpoint( settings={ 'response_type': (CveOas,), 'auth': [ 'ApiKeyAuth' ], 'endpoint_path': '/cves/2.0/', 'operation_id': 'get_cves', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'cpe_name', 'cve_id', 'cvss_v2_metrics', 'cvss_v2_severity', 'cvss_v3_metrics', 'cvss_v3_severity', 'cwe_id', 'has_cert_alerts', 'has_cert_notes', 'has_kev', 'has_oval', 'is_vulnerable', 'keyword_exact_match', 'keyword_search', 'last_mod_start_date', 'last_mod_end_date', 'no_rejected', 'pub_start_date', 'pub_end_date', 'results_per_page', 'start_index', 'source_identifier', 'version_end', 'version_end_type', 'version_start', 'version_start_type', 'virtual_match_string', ], 'required': [], 'nullable': [ ], 'enum': [ 'cvss_v2_severity', 'cvss_v3_severity', 'version_end_type', 'version_start_type', ], 'validation': [ 'cve_id', 'cwe_id', 'results_per_page', 'start_index', ] }, root_map={ 'validations': { ('cve_id',): { 'regex': { 'pattern': r'^CVE-[0-9]{4}-[0-9]{4,}$', # noqa: E501 }, }, ('cwe_id',): { 'regex': { 'pattern': r'^CWE-\d+$', # noqa: E501 }, }, ('results_per_page',): { 'inclusive_maximum': 2000, 'inclusive_minimum': 0, }, ('start_index',): { 'inclusive_minimum': 0, }, }, 'allowed_values': { ('cvss_v2_severity',): { "LOW": "LOW", "MEDIUM": "MEDIUM", "HIGH": "HIGH" }, ('cvss_v3_severity',): { "LOW": "LOW", "MEDIUM": "MEDIUM", "HIGH": "HIGH", "CRITICAL": "CRITICAL" }, ('version_end_type',): { "INCLUDING": "including", "EXCLUDING": "excluding" }, ('version_start_type',): { "INCLUDING": "including", "EXCLUDING": "excluding" }, }, 'openapi_types': { 'cpe_name': (str,), 'cve_id': (str,), 'cvss_v2_metrics': (str,), 'cvss_v2_severity': (str,), 'cvss_v3_metrics': (str,), 'cvss_v3_severity': (str,), 'cwe_id': (str,), 'has_cert_alerts': (str,), 'has_cert_notes': (str,), 'has_kev': (str,), 'has_oval': (str,), 'is_vulnerable': (str,), 'keyword_exact_match': (str,), 'keyword_search': (str,), 'last_mod_start_date': (datetime,), 'last_mod_end_date': (datetime,), 'no_rejected': (str,), 'pub_start_date': (datetime,), 'pub_end_date': (datetime,), 'results_per_page': (int,), 'start_index': (int,), 'source_identifier': (str,), 'version_end': (str,), 'version_end_type': (str,), 'version_start': (str,), 'version_start_type': (str,), 'virtual_match_string': (str,), }, 'attribute_map': { 'cpe_name': 'cpeName', 'cve_id': 'cveId', 'cvss_v2_metrics': 'cvssV2Metrics', 'cvss_v2_severity': 'cvssV2Severity', 'cvss_v3_metrics': 'cvssV3Metrics', 'cvss_v3_severity': 'cvssV3Severity', 'cwe_id': 'cweId', 'has_cert_alerts': 'hasCertAlerts', 'has_cert_notes': 'hasCertNotes', 'has_kev': 'hasKev', 'has_oval': 'hasOval', 'is_vulnerable': 'isVulnerable', 'keyword_exact_match': 'keywordExactMatch', 'keyword_search': 'keywordSearch', 'last_mod_start_date': 'lastModStartDate', 'last_mod_end_date': 'lastModEndDate', 'no_rejected': 'noRejected', 'pub_start_date': 'pubStartDate', 'pub_end_date': 'pubEndDate', 'results_per_page': 'resultsPerPage', 'start_index': 'startIndex', 'source_identifier': 'sourceIdentifier', 'version_end': 'versionEnd', 'version_end_type': 'versionEndType', 'version_start': 'versionStart', 'version_start_type': 'versionStartType', 'virtual_match_string': 'virtualMatchString', }, 'location_map': { 'cpe_name': 'query', 'cve_id': 'query', 'cvss_v2_metrics': 'query', 'cvss_v2_severity': 'query', 'cvss_v3_metrics': 'query', 'cvss_v3_severity': 'query', 'cwe_id': 'query', 'has_cert_alerts': 'query', 'has_cert_notes': 'query', 'has_kev': 'query', 'has_oval': 'query', 'is_vulnerable': 'query', 'keyword_exact_match': 'query', 'keyword_search': 'query', 'last_mod_start_date': 'query', 'last_mod_end_date': 'query', 'no_rejected': 'query', 'pub_start_date': 'query', 'pub_end_date': 'query', 'results_per_page': 'query', 'start_index': 'query', 'source_identifier': 'query', 'version_end': 'query', 'version_end_type': 'query', 'version_start': 'query', 'version_start_type': 'query', 'virtual_match_string': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [], }, api_client=api_client )
[docs] def get_cve_history( self, **kwargs ): """CVE Change History API # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_cve_history(async_req=True) >>> result = thread.get() Keyword Args: change_start_date (datetime): search by changed date. [optional] change_end_date (datetime): search by changed date. [optional] cve_id (str): CVE ID. [optional] event_name (str): returns all CVE associated with a specific type of change event. [optional] results_per_page (int): max number of records (default is 5000). [optional] start_index (int): the index of the first match string. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _content_type (str/None): force body content-type. Default is None and content-type will be predicted by allowed content-types and body. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. _request_auths (list): set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. Default is None async_req (bool): execute request asynchronously Returns: CveHistoryOas If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_spec_property_naming'] = kwargs.get( '_spec_property_naming', False ) kwargs['_content_type'] = kwargs.get( '_content_type') kwargs['_host_index'] = kwargs.get('_host_index') kwargs['_request_auths'] = kwargs.get('_request_auths', None) return self.get_cve_history_endpoint.call_with_http_info(**kwargs)
[docs] def get_cves( self, **kwargs ): """CVE API # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.get_cves(async_req=True) >>> result = thread.get() Keyword Args: cpe_name (str): CPE Name. [optional] cve_id (str): CVE ID. [optional] cvss_v2_metrics (str): CVSSv2 vector string. [optional] cvss_v2_severity (str): CVSSv2 qualitative severity rating. [optional] cvss_v3_metrics (str): CVSSv3 vector string. [optional] cvss_v3_severity (str): CVSSv3 qualitative severity rating. [optional] cwe_id (str): CWE ID. [optional] has_cert_alerts (str): contain a Technical Alert from US-CERT. [optional] if omitted the server will use the default value of "" has_cert_notes (str): contain a Vulnerability Note from CERT/CC. [optional] if omitted the server will use the default value of "" has_kev (str): appear in CISA's Known Exploited Vulnerabilities (KEV) Catalog. [optional] if omitted the server will use the default value of "" has_oval (str): contain information from MITRE's Open Vulnerability and Assessment Language (OVAL). [optional] if omitted the server will use the default value of "" is_vulnerable (str): returns only CVE associated with a specific CPE. [optional] if omitted the server will use the default value of "" keyword_exact_match (str): returns any CVE where a word or phrase. [optional] if omitted the server will use the default value of "" keyword_search (str): a word or phrase is found in the current description. [optional] last_mod_start_date (datetime): search by modified date. [optional] last_mod_end_date (datetime): search by modified date. [optional] no_rejected (str): return the CVE API includes CVE records with the REJECT or Rejected status. [optional] if omitted the server will use the default value of "" pub_start_date (datetime): search by published date. [optional] pub_end_date (datetime): search by published date. [optional] results_per_page (int): max number of records (default is 2000). [optional] start_index (int): the index of the first match string. [optional] source_identifier (str): returns CVE where the exact value of sourceIdentifier appears. [optional] version_end (str): return only the CVEs associated with CPEs in specific version ranges. [optional] version_end_type (str): return only the CVEs associated with CPEs in specific version ranges. [optional] version_start (str): return only the CVEs associated with CPEs in specific version ranges. [optional] version_start_type (str): return only the CVEs associated with CPEs in specific version ranges. [optional] virtual_match_string (str): CVE more broadly than cpeName. [optional] _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. _request_timeout (int/float/tuple): timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. _check_input_type (bool): specifies if type checking should be done one the data sent to the server. Default is True. _check_return_type (bool): specifies if type checking should be done one the data received from the server. Default is True. _spec_property_naming (bool): True if the variable names in the input data are serialized names, as specified in the OpenAPI document. False if the variable names in the input data are pythonic names, e.g. snake case (default) _content_type (str/None): force body content-type. Default is None and content-type will be predicted by allowed content-types and body. _host_index (int/None): specifies the index of the server that we want to use. Default is read from the configuration. _request_auths (list): set to override the auth_settings for an a single request; this effectively ignores the authentication in the spec for a single request. Default is None async_req (bool): execute request asynchronously Returns: CveOas If the method is called asynchronously, returns the request thread. """ kwargs['async_req'] = kwargs.get( 'async_req', False ) kwargs['_return_http_data_only'] = kwargs.get( '_return_http_data_only', True ) kwargs['_preload_content'] = kwargs.get( '_preload_content', True ) kwargs['_request_timeout'] = kwargs.get( '_request_timeout', None ) kwargs['_check_input_type'] = kwargs.get( '_check_input_type', True ) kwargs['_check_return_type'] = kwargs.get( '_check_return_type', True ) kwargs['_spec_property_naming'] = kwargs.get( '_spec_property_naming', False ) kwargs['_content_type'] = kwargs.get( '_content_type') kwargs['_host_index'] = kwargs.get('_host_index') kwargs['_request_auths'] = kwargs.get('_request_auths', None) return self.get_cves_endpoint.call_with_http_info(**kwargs)