4444requests_session = requests_with_5xx_retry (max_retries = 5 , backoff_factor = 1 )
4545
4646
47+ def get_response (url ):
48+ try :
49+ return requests_session .get (url )
50+ except Exception as e :
51+ logger .error (f"Failed to fetch results from { url } { e } " )
52+ return None
53+
54+
4755def fetch_list_of_cves () -> Iterable [List [Dict ]]:
4856 page_no = 1
4957 cve_data = None
@@ -64,14 +72,12 @@ def fetch_list_of_cves() -> Iterable[List[Dict]]:
6472 yield cve_data
6573
6674
67- def get_bugzilla_data (bugzilla ):
68- return requests_session .get (f"https://bugzilla.redhat.com/rest/bug/{ bugzilla } " ).json ()
69-
70-
71- def get_rhsa_data (rh_adv ):
72- return requests_session .get (
73- f"https://access.redhat.com/hydra/rest/securitydata/cvrf/{ rh_adv } .json"
74- ).json ()
75+ def get_data_from_url (url ):
76+ try :
77+ return requests_session .get (url ).json ()
78+ except Exception as e :
79+ logger .error (f"Failed to fetch results from { url } { e !r} " )
80+ return
7581
7682
7783class RedhatImporter (Importer ):
@@ -112,9 +118,11 @@ def to_advisory(advisory_data):
112118 bugzilla = advisory_data .get ("bugzilla" )
113119 if bugzilla :
114120 url = "https://bugzilla.redhat.com/show_bug.cgi?id={}" .format (bugzilla )
115- bugzilla_data = get_bugzilla_data (bugzilla )
121+ bugzilla_url = f"https://bugzilla.redhat.com/rest/bug/{ bugzilla } "
122+ bugzilla_data = get_data_from_url (bugzilla_url )
116123 if (
117- bugzilla_data .get ("bugs" )
124+ bugzilla_data
125+ and bugzilla_data .get ("bugs" )
118126 and len (bugzilla_data ["bugs" ])
119127 and bugzilla_data ["bugs" ][0 ].get ("severity" )
120128 ):
@@ -141,8 +149,10 @@ def to_advisory(advisory_data):
141149 continue
142150
143151 if "RHSA" in rh_adv .upper ():
144- rhsa_data = get_rhsa_data (rh_adv )
145-
152+ rhsa_url = f"https://access.redhat.com/hydra/rest/securitydata/cvrf/{ rh_adv } .json"
153+ rhsa_data = get_data_from_url (rhsa_url )
154+ if not rhsa_data :
155+ continue
146156 rhsa_aggregate_severities = []
147157 if rhsa_data .get ("cvrfdoc" ):
148158 # not all RHSA errata have a corresponding CVRF document
0 commit comments