Skip to content

Commit ae7abde

Browse files
author
doomedraven
committed
GCS
1 parent ce0fff2 commit ae7abde

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

modules/reporting/gcs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run(self, results):
5353
credentials_path = os.path.join(CUCKOO_ROOT, credentials_path_str)
5454
if not os.path.isfile(credentials_path):
5555
raise CuckooReportError(
56-
f"GCS credentials_path '{credentials_path}' is invalid or file does not exist in reporting.conf -> gcs"
56+
"GCS credentials_path '%s' is invalid or file does not exist in reporting.conf -> gcs", credentials_path
5757
)
5858

5959
# Read the exclusion lists, defaulting to empty strings
@@ -66,9 +66,9 @@ def run(self, results):
6666
exclude_files = {item.strip() for item in exclude_files_str.split(",") if item.strip()}
6767

6868
if exclude_dirs:
69-
log.debug(f"GCS reporting will exclude directories: {exclude_dirs}")
69+
log.debug("GCS reporting will exclude directories: %s", exclude_dirs)
7070
if exclude_files:
71-
log.debug(f"GCS reporting will exclude files: {exclude_files}")
71+
log.debug("GCS reporting will exclude files: %s", exclude_files)
7272

7373
try:
7474
# --- Authentication ---
@@ -80,7 +80,7 @@ def run(self, results):
8080
# Check if the bucket exists and is accessible
8181
if not bucket.exists():
8282
raise CuckooReportError(
83-
f"The specified GCS bucket '{bucket_name}' does not exist or you don't have permission to access it."
83+
"The specified GCS bucket '%s' does not exist or you don't have permission to access it.", bucket_name
8484
)
8585

8686
# --- File Upload ---
@@ -89,7 +89,7 @@ def run(self, results):
8989
if not analysis_id:
9090
raise CuckooReportError("Could not get analysis ID from results.")
9191

92-
log.debug(f"Uploading files for analysis ID {analysis_id} to GCS bucket '{bucket_name}'")
92+
log.debug("Uploading files for analysis ID %d to GCS bucket '%s'", analysis_id, bucket_name)
9393

9494
# self.analysis_path is the path to the analysis results directory
9595
# e.g., /opt/cape/storage/analyses/123/
@@ -103,19 +103,19 @@ def run(self, results):
103103
for filename in files:
104104
# --- NEW: File Exclusion Logic ---
105105
if filename in exclude_files:
106-
log.debug(f"Skipping excluded file: {os.path.join(root, filename)}")
106+
log.debug("Skipping excluded file: %s", os.path.join(root, filename))
107107
continue # Skip to the next file
108108

109109
local_path = os.path.join(root, filename)
110110
relative_path = os.path.relpath(local_path, source_directory)
111111
blob_name = f"{analysis_id}/{relative_path}"
112112

113-
log.debug(f"Uploading '{local_path}' to '{blob_name}'")
113+
log.debug("Uploading '%s' to '%s'", local_path, blob_name)
114114

115115
blob = bucket.blob(blob_name)
116116
blob.upload_from_filename(local_path)
117117

118-
log.info(f"Successfully uploaded files for analysis {analysis_id} to GCS.")
118+
log.info("Successfully uploaded files for analysis %d to GCS.", analysis_id)
119119

120120
except Exception as e:
121-
raise CuckooReportError(f"Failed to upload report to GCS: {e}")
121+
raise CuckooReportError("Failed to upload report to GCS: %s", str(e))

0 commit comments

Comments
 (0)