diff options
| author | J08nY | 2025-02-14 14:22:47 +0100 |
|---|---|---|
| committer | J08nY | 2025-02-14 14:22:47 +0100 |
| commit | d5d8838c8b883e5b8aebcde81ea1089757dcfb4f (patch) | |
| tree | f91ddffd09b425036b97b99b141bcc07ad6c5d9a /src | |
| parent | 175165e34c07b17f3ee734b0d089322dd82e07b8 (diff) | |
| download | sec-certs-d5d8838c8b883e5b8aebcde81ea1089757dcfb4f.tar.gz sec-certs-d5d8838c8b883e5b8aebcde81ea1089757dcfb4f.tar.zst sec-certs-d5d8838c8b883e5b8aebcde81ea1089757dcfb4f.zip | |
Unify CVE and CPEDataset from_web with the rest.
Diffstat (limited to 'src')
| -rw-r--r-- | src/sec_certs/dataset/cpe.py | 9 | ||||
| -rw-r--r-- | src/sec_certs/dataset/cve.py | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/sec_certs/dataset/cpe.py b/src/sec_certs/dataset/cpe.py index c93ddd71..56e6ac5d 100644 --- a/src/sec_certs/dataset/cpe.py +++ b/src/sec_certs/dataset/cpe.py @@ -71,7 +71,7 @@ class CPEDataset(JSONPathDataset, ComplexSerializableType): return cls(**dct) @classmethod - def from_web(cls, json_path: str | Path = constants.DUMMY_NONEXISTING_PATH) -> CPEDataset: + def from_web(cls, json_path: str | Path | None = None) -> CPEDataset: """ Creates CPEDataset from NIST resources published on-line @@ -91,8 +91,11 @@ class CPEDataset(JSONPathDataset, ComplexSerializableType): raise RuntimeError(f"Could not download CPEDataset from {config.cpe_latest_snapshot}.") dset = cls.from_json(dset_path, is_compressed=True) - dset.json_path = json_path - dset.to_json() + if json_path: + dset.json_path = json_path + dset.to_json() + else: + dset.json_path = constants.DUMMY_NONEXISTING_PATH return dset def enhance_with_nvd_data(self, nvd_data: dict[Any, Any]) -> None: diff --git a/src/sec_certs/dataset/cve.py b/src/sec_certs/dataset/cve.py index 52d988b1..6314040c 100644 --- a/src/sec_certs/dataset/cve.py +++ b/src/sec_certs/dataset/cve.py @@ -67,7 +67,7 @@ class CVEDataset(JSONPathDataset, ComplexSerializableType): return bool(self._cpe_uri_to_cve_ids_lookup) @classmethod - def from_web(cls, json_path: str | Path = constants.DUMMY_NONEXISTING_PATH) -> CVEDataset: + def from_web(cls, json_path: str | Path | None = None) -> CVEDataset: """ Creates CVEDataset from NIST resources published on-line @@ -87,8 +87,11 @@ class CVEDataset(JSONPathDataset, ComplexSerializableType): raise RuntimeError(f"Could not download CVEDataset from {config_module.config.cve_latest_snapshot}.") dset = cls.from_json(dset_path, is_compressed=True) - dset.json_path = json_path - dset.to_json() + if json_path: + dset.json_path = json_path + dset.to_json() + else: + dset.json_path = constants.DUMMY_NONEXISTING_PATH return dset def _get_cves_with_criteria_configurations(self) -> None: |
