|
14 | 14 |
|
15 | 15 | import dateparser |
16 | 16 | from fetchcode.vcs import fetch_via_vcs |
| 17 | +from packageurl.contrib.purl2url import get_repo_url |
17 | 18 | from packageurl.contrib.url2purl import url2purl |
18 | 19 |
|
19 | 20 | from aboutcode.hashid import get_core_purl |
| 21 | +from vulnerabilities.importer import VCS_URLS_SUPPORTED_TYPES |
20 | 22 | from vulnerabilities.importer import AdvisoryData |
21 | 23 | from vulnerabilities.importer import AffectedPackageV2 |
22 | 24 | from vulnerabilities.importer import CodePatchData |
23 | 25 | from vulnerabilities.importer import ReferenceV2 |
24 | 26 | from vulnerabilities.importer import VulnerabilitySeverity |
25 | 27 | from vulnerabilities.pipelines import VulnerableCodeBaseImporterPipelineV2 |
26 | 28 | from vulnerabilities.severity_systems import GENERIC |
27 | | -from vulnerabilities.utils import VCS_URLS_SUPPORTED_TYPES |
28 | | -from vulnerabilities.utils import parse_commit_url |
29 | 29 |
|
30 | 30 |
|
31 | 31 | class AospImporterPipeline(VulnerableCodeBaseImporterPipelineV2): |
@@ -96,24 +96,29 @@ def collect_advisories(self): |
96 | 96 | purl = url2purl(commit_url) |
97 | 97 | base_purl = get_core_purl(purl) |
98 | 98 |
|
99 | | - if base_purl and base_purl.type in VCS_URLS_SUPPORTED_TYPES: |
100 | | - vcs_url, commit_hash = parse_commit_url(url=commit_url) |
| 99 | + purl_string = base_purl.to_string() |
| 100 | + vcs_url = get_repo_url(purl_string) |
101 | 101 |
|
102 | | - fixed_commit = CodePatchData( |
103 | | - commit_hash=commit_hash, |
104 | | - vcs_url=vcs_url, |
| 102 | + if not base_purl or base_purl.type not in VCS_URLS_SUPPORTED_TYPES: |
| 103 | + references.append( |
| 104 | + ReferenceV2( |
| 105 | + reference_id=commit_id, |
| 106 | + reference_type="commit", |
| 107 | + url=commit_url, |
| 108 | + ) |
105 | 109 | ) |
| 110 | + continue |
106 | 111 |
|
107 | | - affected_package = AffectedPackageV2( |
108 | | - package=base_purl, |
109 | | - fixed_by_commits=[fixed_commit], |
110 | | - ) |
111 | | - affected_packages.append(affected_package) |
112 | | - else: |
113 | | - ref = ReferenceV2( |
114 | | - reference_id=commit_id, reference_type="commit", url=commit_url |
115 | | - ) |
116 | | - references.append(ref) |
| 112 | + fixed_commit = CodePatchData( |
| 113 | + commit_hash=purl.version, |
| 114 | + vcs_url=vcs_url, |
| 115 | + ) |
| 116 | + |
| 117 | + affected_package = AffectedPackageV2( |
| 118 | + package=base_purl, |
| 119 | + fixed_by_commits=[fixed_commit], |
| 120 | + ) |
| 121 | + affected_packages.append(affected_package) |
117 | 122 |
|
118 | 123 | url = ( |
119 | 124 | "https://raw.githubusercontent.com/quarkslab/aosp_dataset/refs/heads/master/cves/" |
|
0 commit comments