1111from typing import Iterable
1212
1313from fetchcode .vcs import fetch_via_vcs
14- from packageurl import PackageURL
15- from packageurl .contrib .purl2url import get_commit_url
1614from packageurl .contrib .url2purl import url2purl
1715
1816from vulnerabilities .importer import AdvisoryDataV2
1917from vulnerabilities .importer import AffectedPackageV2
2018from vulnerabilities .importer import PackageCommitPatchData
2119from vulnerabilities .importer import ReferenceV2
22- from vulnerabilities .models import AdvisoryReference
2320from vulnerabilities .pipelines import VulnerableCodeBaseImporterPipelineV2
21+ from vulnerabilities .pipes .advisory import VCS_URLS_SUPPORTED_TYPES
22+ from vulnerabilities .pipes .advisory import classify_patch_source
2423from vulnerabilities .utils import get_advisory_url
2524
2625
@@ -59,6 +58,9 @@ def collect_advisories_fix_commits(self):
5958 raw_data = json .load (f )
6059 vcs_url = raw_data ["vcs_url" ]
6160 purl = url2purl (vcs_url )
61+ if not purl or (purl .type not in VCS_URLS_SUPPORTED_TYPES ):
62+ self .log (f"Unsupported url2purl for git repo url: { vcs_url } " )
63+ continue
6264 vulnerabilities = raw_data .get ("vulnerabilities" , {})
6365 advisory_url = get_advisory_url (
6466 file = file ,
@@ -84,26 +86,6 @@ def collect_advisories_fix_commits(self):
8486 )
8587 affected_packages .append (affected_package )
8688
87- purl_with_commit_hash = PackageURL (
88- type = purl .type ,
89- namespace = purl .namespace ,
90- name = purl .name ,
91- version = commit_hash ,
92- qualifiers = purl .qualifiers ,
93- )
94-
95- ref_url = get_commit_url (purl = str (purl_with_commit_hash ))
96- if not ref_url :
97- continue
98-
99- references .append (
100- ReferenceV2 (
101- reference_id = commit_hash ,
102- reference_type = AdvisoryReference .COMMIT ,
103- url = ref_url ,
104- )
105- )
106-
10789 yield AdvisoryDataV2 (
10890 advisory_id = vuln_id ,
10991 summary = summary ,
0 commit comments