88#
99import json
1010import logging
11- from io import BytesIO
1211from pathlib import Path
1312from typing import Iterable
14- from zipfile import ZipFile
15-
16- import requests
1713
1814from vulnerabilities .importer import AdvisoryData
1915from vulnerabilities .importer import Importer
2016from vulnerabilities .importers .osv import parse_advisory_data
17+ from vulnerabilities .utils import get_advisory_url
2118
2219logger = logging .getLogger (__name__ )
2320
@@ -26,6 +23,7 @@ class GithubOSVImporter(Importer):
2623 license_url = "https://github.com/github/advisory-database/blob/main/LICENSE.md"
2724 spdx_license_expression = "CC-BY-4.0"
2825 repo_url = "git+https://github.com/github/advisory-database/"
26+ importer_name = "GithubOSV Importer"
2927
3028 def advisory_data (self ) -> Iterable [AdvisoryData ]:
3129 supported_ecosystems = [
@@ -41,13 +39,19 @@ def advisory_data(self) -> Iterable[AdvisoryData]:
4139 ]
4240 try :
4341 self .clone (repo_url = self .repo_url )
44- path = Path (self .vcs_response .dest_dir )
42+ base_path = Path (self .vcs_response .dest_dir )
4543 # filter out non-github-reviewed files and only keep the files end-with .json
46- advisory_dirs = path / "advisories/github-reviewed"
44+ advisory_dirs = base_path / "advisories/github-reviewed"
4745 for file in advisory_dirs .glob ("**/*.json" ):
46+ advisory_url = get_advisory_url (
47+ file = file ,
48+ base_path = base_path ,
49+ url = "https://github.com/github/advisory-database/blob/main/" ,
50+ )
4851 with open (file ) as f :
4952 raw_data = json .load (f )
50- yield parse_advisory_data (raw_data , supported_ecosystems )
53+ print (advisory_url )
54+ yield parse_advisory_data (raw_data , supported_ecosystems , advisory_url )
5155 finally :
5256 if self .vcs_response :
5357 self .vcs_response .delete ()
0 commit comments