From a281adaa35b3ed068918ad5e2e9c3683d90f7752 Mon Sep 17 00:00:00 2001 From: Mike Urbanski Date: Fri, 8 Mar 2024 09:32:08 -0600 Subject: [PATCH] platform(general): improve upload failure logging and log size of failed files (#6076) * improve upload failure logging and log size of failed files * remove debugging test --- checkov/common/bridgecrew/platform_integration.py | 5 +++-- checkov/common/bridgecrew/wrapper.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/checkov/common/bridgecrew/platform_integration.py b/checkov/common/bridgecrew/platform_integration.py index 336026d20f6..60211e26c54 100644 --- a/checkov/common/bridgecrew/platform_integration.py +++ b/checkov/common/bridgecrew/platform_integration.py @@ -902,11 +902,12 @@ def _persist_file(self, full_file_path: str, s3_file_key: str) -> None: sleep(SLEEP_SECONDS) curr_try += 1 else: - logging.error(f"failed to persist file {full_file_path} into S3 bucket {self.bucket}", - exc_info=True) + logging.error(f"failed to persist file {full_file_path} into S3 bucket {self.bucket}", exc_info=True) + logging.debug(f"file size of {full_file_path} is {os.stat(full_file_path).st_size} bytes") raise except Exception: logging.error(f"failed to persist file {full_file_path} into S3 bucket {self.bucket}", exc_info=True) + logging.debug(f"file size of {full_file_path} is {os.stat(full_file_path).st_size} bytes") raise if curr_try == tries: logging.error( diff --git a/checkov/common/bridgecrew/wrapper.py b/checkov/common/bridgecrew/wrapper.py index c69de1fa9e8..361d361969a 100644 --- a/checkov/common/bridgecrew/wrapper.py +++ b/checkov/common/bridgecrew/wrapper.py @@ -51,7 +51,7 @@ def _put_json_object(s3_client: S3Client, json_obj: Any, bucket: str, object_pat try: s3_client.put_object(Bucket=bucket, Key=object_path, Body=json.dumps(json_obj, cls=CustomJSONEncoder)) except Exception: - logging.error(f"failed to persist object into S3 bucket {bucket}", exc_info=log_stack_trace_on_error) + logging.error(f"failed to persist object into S3 bucket {bucket} - {object_path}", exc_info=log_stack_trace_on_error) raise