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
5058 while True :
5159 current_url = f"https://access.redhat.com/hydra/rest/securitydata/cve.json?per_page=10000&page={ page_no } " # nopep8
5260 try :
53- response = requests_session . get (current_url )
61+ response = get_response (current_url )
5462 if response .status_code != requests .codes .ok :
5563 logger .error (f"Failed to fetch results from { current_url } " )
5664 break
@@ -65,11 +73,11 @@ def fetch_list_of_cves() -> Iterable[List[Dict]]:
6573
6674
6775def get_bugzilla_data (bugzilla ):
68- return requests_session . get (f"https://bugzilla.redhat.com/rest/bug/{ bugzilla } " ).json ()
76+ return get_response (f"https://bugzilla.redhat.com/rest/bug/{ bugzilla } " ).json ()
6977
7078
7179def get_rhsa_data (rh_adv ):
72- return requests_session . get (
80+ return get_response (
7381 f"https://access.redhat.com/hydra/rest/securitydata/cvrf/{ rh_adv } .json"
7482 ).json ()
7583
@@ -114,6 +122,7 @@ def to_advisory(advisory_data):
114122 url = "https://bugzilla.redhat.com/show_bug.cgi?id={}" .format (bugzilla )
115123 bugzilla_data = get_bugzilla_data (bugzilla )
116124 if (
125+ bugzilla_data and
117126 bugzilla_data .get ("bugs" )
118127 and len (bugzilla_data ["bugs" ])
119128 and bugzilla_data ["bugs" ][0 ].get ("severity" )
@@ -142,7 +151,8 @@ def to_advisory(advisory_data):
142151
143152 if "RHSA" in rh_adv .upper ():
144153 rhsa_data = get_rhsa_data (rh_adv )
145-
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