pontos.nvd.cpe package#

class pontos.nvd.cpe.CPEApi(*, token=None, timeout=Timeout(timeout=180.0), rate_limit=True)#

API for querying the NIST NVD CPE information.

Should be used as an async context manager.

Example

from pontos.nvd.cpe import CPEApi

async with CPEApi() as api:
    cpe = await api.cpe(...)

Create a new instance of the CPE API.

Parameters:
  • 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.

async cpe(cpe_name_id)#

Query for a CPE matching the CPE UUID.

Parameters:

cpe_name_id (str | UUID) – Returns a specific CPE record identified by a Universal Unique Identifier (UUID).

Return type:

CPE

Example

from pontos.nvd.cpe import CPEApi

async with CPEApi() as api:
    cpe = await api.cpe("87316812-5F2C-4286-94FE-CC98B9EAEF53")
    print(cpe)
Returns:

A single CPE matching the CPE UUID

Raises:

PontosError – If a CPE with the CPE UUID couldn’t be found.

Return type:

CPE

async cpes(*, last_modified_start_date=None, last_modified_end_date=None, cpe_match_string=None, keywords=None, match_criteria_id=None, request_results=None)#

Get all CPEs for the provided arguments

https://nvd.nist.gov/developers/products

Parameters:
  • last_modified_start_date (datetime | None) – Return all CPEs modified after this date.

  • last_modified_end_date (datetime | None) – Return all CPEs modified before this date. If last_modified_start_date is set but no last_modified_end_date is passed it is set to now.

  • cpe_match_string (str | None) – Returns all CPE names that exist in the Official CPE Dictionary.

  • keywords (List[str] | str | None) – Returns only the CPEs where a word or phrase is found in the metadata title or reference links.

  • match_criteria_id (str | None) – Returns all CPE records associated with a match string identified by its UUID.

  • request_results (int | None) – Number of CPEs to download. Set to None (default) to download all available CPEs.

Returns:

An async iterator of CPE model instances.

Return type:

AsyncIterator[CPE]

Example

from pontos.nvd.cpe import CPEApi

async with CPEApi() as api:
    async for cpe in api.cpes(keywords=["Mac OS X"]):
        print(cpe.cpe_name, cpe.cpe_name_id)