@@ -45,16 +45,22 @@ def run(self, results):
4545 bucket_name = self .options .get ("bucket_name" )
4646 if not bucket_name :
4747 raise CuckooReportError ("GCS bucket_name is not configured in reporting.conf -> gcs" )
48+ auth_by = self .options .get ("auth_by" )
49+ if auth_by == "vm" :
50+ storage_client = storage .Client ()
51+ else :
52+ credentials_path_str = self .options .get ("credentials_path" )
53+ if not credentials_path_str :
54+ raise CuckooReportError ("GCS credentials_path is not configured in reporting.conf -> gcs" )
55+
56+ credentials_path = os .path .join (CUCKOO_ROOT , credentials_path_str )
57+ if not os .path .isfile (credentials_path ):
58+ raise CuckooReportError (
59+ "GCS credentials_path '%s' is invalid or file does not exist in reporting.conf -> gcs" , credentials_path
60+ )
4861
49- credentials_path_str = self .options .get ("credentials_path" )
50- if not credentials_path_str :
51- raise CuckooReportError ("GCS credentials_path is not configured in reporting.conf -> gcs" )
52-
53- credentials_path = os .path .join (CUCKOO_ROOT , credentials_path_str )
54- if not os .path .isfile (credentials_path ):
55- raise CuckooReportError (
56- "GCS credentials_path '%s' is invalid or file does not exist in reporting.conf -> gcs" , credentials_path
57- )
62+ credentials = service_account .Credentials .from_service_account_file (credentials_path )
63+ storage_client = storage .Client (credentials = credentials )
5864
5965 # Read the exclusion lists, defaulting to empty strings
6066 exclude_dirs_str = self .options .get ("exclude_dirs" , "" )
@@ -73,8 +79,6 @@ def run(self, results):
7379 try :
7480 # --- Authentication ---
7581 log .debug ("Authenticating with Google Cloud Storage..." )
76- credentials = service_account .Credentials .from_service_account_file (credentials_path )
77- storage_client = storage .Client (credentials = credentials )
7882 bucket = storage_client .bucket (bucket_name )
7983
8084 # Check if the bucket exists and is accessible
0 commit comments