swh.vulns.api.client module#

class swh.vulns.api.client.RemoteVulnerabilitiesStorage(url: str, timeout: None | Tuple[float, float] | List[float] | float = None, chunk_size: int = 4096, max_retries: int = 3, pool_connections: int = 20, pool_maxsize: int = 100, adapter_kwargs: Dict[str, Any] | None = None, api_exception: Type[Exception] | None = None, reraise_exceptions: List[Type[Exception]] | None = None, enable_requests_retry: bool | None = None, session_kwargs: Dict[str, Any] | None = None, **kwargs)[source]#

Bases: RPCClient

Proxy to a remote OSV vulnerabilities API

backend_class#

alias of VulnerabilitiesStorageInterface

extra_type_decoders: Dict[str, Callable] = {'core_swhid': <bound method _BaseSWHID.from_string of <class 'swh.model.swhids.CoreSWHID'>>, 'osv_vulnerabilities_model': <function _decode_model_object>}#

Value of extra_decoders passed to json_loads or msgpack_loads to be able to deserialize more object types.

extra_type_encoders: List[Tuple[type, str, Callable]] = [(<class 'swh.vulns.osv.model.BaseModel'>, 'osv_vulnerabilities_model', <function _encode_model_object>), (<class 'swh.model.swhids.CoreSWHID'>, 'core_swhid', <class 'str'>)]#

Value of extra_encoders passed to json_dumps or msgpack_dumps to be able to serialize more object types.

enable_requests_retry: bool = True#

If set to True, requests sent by the client will be retried when encountering specific errors. Default policy is to retry when connection errors or transient remote exceptions are raised. Subclasses can change that policy by overriding the retry_policy() method.

osv_vulnerability_event_add(vulnerabilities_events: List[OSVVulnerabilityEvent])#

Add OSV vulnerability events in storage.

osv_vulnerability_event_get_by_id(vulnerabilities_ids: List[str]) List[OSVVulnerabilityEvent]#

Get vulnerability events for a given OSV vulnerability.

osv_vulnerability_event_get_by_origin_url(origin_urls: List[str]) List[OSVVulnerabilityEvent]#

Get OSV vulnerability events related to a list of origin URLs.

osv_vulnerability_event_get_by_swhid(swhids: List[CoreSWHID]) List[OSVVulnerabilityEvent]#

Get OSV vulnerability events related to a list of SWHIDs.

osv_vulnerability_report_add(vulnerability_id: str, processing_date: datetime, json_report: Dict[str, Any])#

Add last processing date for an OSV vulnerability report and the full JSON report.

osv_vulnerability_report_get(vulnerability_id: str) Dict[str, Any] | None#

Get full JSON report of an OSV vulnerability event.

osv_vulnerability_report_last_processing_date(vulnerability_id: str) datetime | None#

Get the last processing data for an OSV vulnerability report.