pontos.nvd package

Submodules

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)

Format date matching to NVD api

Parameters:

date (datetime) – Date to format

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)

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.

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

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