Skip to content
Back to top
View this page
Edit this page

# pontos.nvd package

## Submodules

- pontos.nvd.cpe package
- pontos.nvd.cve package
- pontos.nvd.models package

pontos.nvd.convert_camel_case(dct)

  Convert camel case keys into snake case keys

  Parameters:

    dct (Dict[str, Any]) – dict to convert

  Returns:

    A dict with key names converted to snake case

  Return type:

    Dict[str, Any]

pontos.nvd.format_date(date, *, fallback_timezone=datetime.timezone.utc, timespec='milliseconds')

  Format date matching to NVD api

  Parameters:

    - date (datetime) – Date to format

    - fallback_timezone (timezone) – The timezone to attach if date is not timezone aware

    - timespec (str) – Timespec to pass to datetime.isoformat

  Returns:

    Formatted date as string

  Return type:

    str

pontos.nvd.now()

  Return current datetime with UTC timezone applied

  Return type:

    datetime

class pontos.nvd.NVDApi(url, *, token=None, timeout=Timeout(timeout=180.0), rate_limit=True, request_attempts=1)

  Abstract base class for querying the NIST NVD API.

  Should be used as an async context manager.

  Create a new instance of the CVE API.

  Parameters:

    - url (str) – The API URL to use.

    - token (str | None) – The API key to use. Using an API key allows to run more requests at the same time.

    - timeout (Timeout | None) – Timeout settings for the HTTP requests

    - rate_limit (bool) – Set to False to ignore rate limits. The public rate limit (without an API key) is 5 requests in a rolling 30 second window. The rate limit with an API key is 50 requests in a rolling 30 second window. See https://nvd.nist.gov/developers/start-here#divRateLimits Default: True.

    - request_attempts (int) – The number of attempts per HTTP request. Defaults to 1.

class pontos.nvd.NVDResults(api, params, result_func, *, request_results=None, results_per_page=None, start_index=0, return_exceptions=False)

  A generic object for accessing the results of a NVD API response

  It implements the pagination and will issue requests against the NVD API.

  async chunks()

    Return the results in chunks

    The size of the chunks is defined by results_per_page.

    Examples

        nvd_results: NVDResults = ...

        async for results in nvd_results.chunks():
            for result in results:
                print(result)

    Return type:

      AsyncIterator[Sequence[T]]

  async items()

    Return the results of the NVD API response

    Examples

        nvd_results: NVDResults = ...

        async for result in nvd_results.items():
            print(result)

    Return type:

      AsyncIterator[T]

  async json()

    Return the result from the NVD API request as JSON

    Examples

        nvd_results: NVDResults = ...
        while data := await nvd_results.json():
            print(data)

    Returns:

      The response data as JSON or None if the response is exhausted.

    Return type:

      dict[str, int | str | dict[str, Any]] | None