@@ -48,7 +48,7 @@ def fetch_list_of_cves() -> Iterable[List[Dict]]:
4848 page_no = 1
4949 cve_data = None
5050 while True :
51- current_url = f"https://access.redhat.com/hydra/rest/securitydata/cve.json?per_page=10000 &page={ page_no } " # nopep8
51+ current_url = f"https://access.redhat.com/hydra/rest/securitydata/cve.json?per_page=1000 &page={ page_no } " # nopep8
5252 try :
5353 response = requests_session .get (current_url )
5454 if response .status_code != requests .codes .ok :
@@ -69,7 +69,7 @@ def get_data_from_url(url):
6969 return requests_session .get (url ).json ()
7070 except Exception as e :
7171 logger .error (f"Failed to fetch results from { url } { e !r} " )
72- return
72+ return {}
7373
7474
7575class RedhatImporter (Importer ):
@@ -112,25 +112,22 @@ def to_advisory(advisory_data):
112112 url = "https://bugzilla.redhat.com/show_bug.cgi?id={}" .format (bugzilla )
113113 bugzilla_url = f"https://bugzilla.redhat.com/rest/bug/{ bugzilla } "
114114 bugzilla_data = get_data_from_url (bugzilla_url )
115- if (
116- bugzilla_data
117- and bugzilla_data .get ("bugs" )
118- and len (bugzilla_data ["bugs" ])
119- and bugzilla_data ["bugs" ][0 ].get ("severity" )
120- ):
121- bugzilla_severity_val = bugzilla_data ["bugs" ][0 ]["severity" ]
122- bugzilla_severity = VulnerabilitySeverity (
123- system = severity_systems .REDHAT_BUGZILLA ,
124- value = bugzilla_severity_val ,
125- )
126-
127- references .append (
128- Reference (
129- severities = [bugzilla_severity ],
130- url = url ,
131- reference_id = bugzilla ,
115+ bugs = bugzilla_data .get ("bugs" ) or []
116+ if bugs :
117+ # why [0] only here?
118+ severity = bugs [0 ].get ("severity" )
119+ if severity :
120+ bugzilla_severity = VulnerabilitySeverity (
121+ system = severity_systems .REDHAT_BUGZILLA ,
122+ value = severity ,
123+ )
124+ references .append (
125+ Reference (
126+ severities = [bugzilla_severity ],
127+ url = url ,
128+ reference_id = bugzilla ,
129+ )
132130 )
133- )
134131
135132 for rh_adv in advisory_data .get ("advisories" ) or []:
136133 # RH provides 3 types of advisories RHSA, RHBA, RHEA. Only RHSA's contain severity score.
@@ -191,7 +188,9 @@ def to_advisory(advisory_data):
191188 alias = advisory_data .get ("CVE" )
192189 if alias :
193190 aliases .append (alias )
194- references .append (Reference (severities = redhat_scores , url = advisory_data ["resource_url" ]))
191+ resource_url = advisory_data .get ("resource_url" )
192+ if resource_url :
193+ references .append (Reference (severities = redhat_scores , url = resource_url ))
195194 return AdvisoryData (
196195 aliases = aliases ,
197196 summary = advisory_data .get ("bugzilla_description" ) or "" ,
0 commit comments