@@ -45,16 +45,22 @@ def run(self, results):
45
45
bucket_name = self .options .get ("bucket_name" )
46
46
if not bucket_name :
47
47
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
+ )
48
61
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 )
58
64
59
65
# Read the exclusion lists, defaulting to empty strings
60
66
exclude_dirs_str = self .options .get ("exclude_dirs" , "" )
@@ -73,8 +79,6 @@ def run(self, results):
73
79
try :
74
80
# --- Authentication ---
75
81
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 )
78
82
bucket = storage_client .bucket (bucket_name )
79
83
80
84
# Check if the bucket exists and is accessible
0 commit comments