Skip to content

Commit 839232b

Browse files
committed
Change advisory ID for pypa importer
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
1 parent 261c0f4 commit 839232b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

vulnerabilities/pipelines/v2_importers/pypa_importer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,14 @@ def collect_advisories(self) -> Iterable[AdvisoryDataV2]:
5959
)
6060
advisory_text = advisory.read_text()
6161
advisory_dict = saneyaml.load(advisory_text)
62+
advisory_path = advisory.relative_to(base_directory)
63+
advisory_id = advisory_path.parent.stem + "/" + advisory_path.stem
6264
yield parse_advisory_data_v3(
6365
raw_data=advisory_dict,
6466
supported_ecosystems=["pypi"],
6567
advisory_url=advisory_url,
6668
advisory_text=advisory_text,
69+
advisory_id=advisory_id,
6770
)
6871

6972
def clean_downloads(self):

vulnerabilities/pipes/osv_v2.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,18 @@
5959

6060

6161
def parse_advisory_data_v3(
62-
raw_data: dict, supported_ecosystems, advisory_url: str, advisory_text: str
62+
raw_data: dict,
63+
supported_ecosystems,
64+
advisory_url: str,
65+
advisory_text: str,
66+
advisory_id: Optional[str] = None,
6367
) -> Optional[AdvisoryDataV2]:
6468
"""
6569
Return an AdvisoryData build from a ``raw_data`` mapping of OSV advisory and
6670
a ``supported_ecosystem`` string.
6771
"""
68-
advisory_id = raw_data.get("id") or ""
72+
if not advisory_id:
73+
advisory_id = raw_data.get("id") or ""
6974
if not advisory_id:
7075
logger.error(f"Missing advisory id in OSV data: {raw_data}")
7176
return None

0 commit comments

Comments
 (0)