diff options
| author | Adam Janovsky | 2021-04-19 11:05:08 +0200 |
|---|---|---|
| committer | Adam Janovsky | 2021-04-19 11:05:08 +0200 |
| commit | a51a0095b1a6f27fbf7488b11ef052e967fee55a (patch) | |
| tree | 44ee43e98c7df03a5dcc2907a02710cd125d11b6 | |
| parent | 0846d0bdd1aadac9f42a72899a56f1f27b9a308c (diff) | |
| download | sec-certs-a51a0095b1a6f27fbf7488b11ef052e967fee55a.tar.gz sec-certs-a51a0095b1a6f27fbf7488b11ef052e967fee55a.tar.zst sec-certs-a51a0095b1a6f27fbf7488b11ef052e967fee55a.zip | |
introduce ClassVar in CVEDataset
| -rw-r--r-- | sec_certs/cve.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sec_certs/cve.py b/sec_certs/cve.py index 4b8c0912..8415728d 100644 --- a/sec_certs/cve.py +++ b/sec_certs/cve.py @@ -1,5 +1,5 @@ from dataclasses import dataclass, field -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, Union, ClassVar import copy import datetime from pathlib import Path @@ -99,6 +99,8 @@ class CVEDataset(ComplexSerializableType): cves: Dict[str, CVE] cpes_to_cve_lookup: Dict[str, List[str]] = field(init=False) + cve_url: ClassVar[str] = 'https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-' + def to_dict(self): return copy.deepcopy({'cves': self.cves}) @@ -127,14 +129,12 @@ class CVEDataset(ComplexSerializableType): def __len__(self) -> int: return len(self.cves) - @staticmethod - def download_cves(output_path: str, start_year: int, end_year: int): + def download_cves(self, output_path: str, start_year: int, end_year: int): output_path = Path(output_path) if not output_path.exists: output_path.mkdir() - base_url = 'https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-' - urls = [base_url + str(x) + '.json.zip' for x in range(start_year, end_year + 1)] + urls = [self.cve_url + str(x) + '.json.zip' for x in range(start_year, end_year + 1)] logger.info(f'Identified {len(urls)} CVE files to fetch from nist.gov. Downloading them into {output_path}') with tempfile.TemporaryDirectory() as tmp_dir: |
