From f2cf9dc84c568944acbacf120284b91195424e48 Mon Sep 17 00:00:00 2001 From: Josh Hammer Date: Thu, 4 Jan 2024 14:56:52 -0500 Subject: [PATCH] fix: Fixed edge case in __search_resources_in_root_compartment, added debugging and error output to the case as well --- scripts/cis_reports.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/cis_reports.py b/scripts/cis_reports.py index 1affa4a7..b4ac65cd 100644 --- a/scripts/cis_reports.py +++ b/scripts/cis_reports.py @@ -3375,13 +3375,17 @@ def __search_resources_in_root_compartment(self): for item in structured_search_all_resources: # ignoring global resources like IAM - if item.identifier.split('.')[3]: - record = { - "display_name": item.display_name, - "id": item.identifier, - "region": region_key - } - self.cis_foundations_benchmark_1_2['5.2']['Total'].append(item) + try: + if item.identifier.split('.')[3]: + record = { + "display_name": item.display_name, + "id": item.identifier, + "region": region_key + } + self.cis_foundations_benchmark_1_2['5.2']['Total'].append(item) + except: + self.__errors.append({"id" : "search_resources_in_root_compartment Invalid OCID", "error" : str(item)}) + debug(f'__search_resources_in_root_compartment: Invalid OCID: {str(item)}') except Exception as e: raise RuntimeError(