nvd_client.utils¶
Helpers for CVE ids and NVD timestamps. They are not re-exported from
nvd_client. NvdApi calls them before it sends a request.
Parameter checks and NVD timestamp formatting.
NVD date parameters use extended ISO-8601 with milliseconds
(YYYY-MM-DDTHH:MM:SS.sss) and an optional UTC offset. A positive offset
must be sent as %2B rather than a raw +. This module formats the
timestamp; requests percent-encodes it when the value is passed as a
query parameter.
Functions:
-
format_nvd_datetime–Format
valueas an NVD timestamp in UTC. -
validate_and_convert_dates–Validate a date pair and return NVD timestamp strings.
-
validate_cve_id–Return
Truewhencve_idmatchesCVE-YYYY-NNNN.
Attributes:
format_nvd_datetime
¶
Format value as an NVD timestamp in UTC.
Naive values are treated as UTC. Aware values, including those built
with zoneinfo, are converted to UTC. The +00:00 suffix is
intentional: callers must not paste it into a URL by hand.
validate_and_convert_dates
¶
validate_and_convert_dates(start_date: datetime | None, end_date: datetime | None, param_names: list[str]) -> tuple[str | None, str | None]
Validate a date pair and return NVD timestamp strings.
Both ends are required when either one is set. The span cannot exceed 120 days, which is NVD's maximum for every date-range parameter.
validate_cve_id
¶
Return True when cve_id matches CVE-YYYY-NNNN.
Raises InvalidCVEIDError otherwise.