diff --git a/checkov/common/bridgecrew/platform_integration.py b/checkov/common/bridgecrew/platform_integration.py index 7114443d558..8febb525cdb 100644 --- a/checkov/common/bridgecrew/platform_integration.py +++ b/checkov/common/bridgecrew/platform_integration.py @@ -316,7 +316,7 @@ def set_s3_integration(self) -> None: try: self.skip_fixes = True # no need to run fixes on CI integration repo_full_path, support_path, response = self.get_s3_role(self.repo_id) # type: ignore - if not repo_full_path: + if not repo_full_path: # happens if the setup fails with something other than an auth error - we continue locally return self.bucket, self.repo_path = repo_full_path.split("/", 1) @@ -363,7 +363,7 @@ def set_s3_integration(self) -> None: logging.error("Received an error response during authentication") raise - def get_s3_role(self, repo_id: str) -> tuple[str | None, str | None, dict[str, Any]]: + def get_s3_role(self, repo_id: str) -> tuple[str, str, dict[str, Any]] | tuple[None, None, dict[str, Any]]: token = self.get_auth_token() if not self.http: @@ -385,8 +385,8 @@ def get_s3_role(self, repo_id: str) -> tuple[str | None, str | None, dict[str, A tries += 1 response = self._get_s3_creds(repo_id, token) else: - logging.error(f'Checkov got an unexpected error that may be due to backend issues. The scan will continue, ' - f'but results will not be sent to the platform. Please contact support for assistance.') + logging.error('Checkov got an unexpected error that may be due to backend issues. The scan will continue, ' + 'but results will not be sent to the platform. Please contact support for assistance.') logging.error(f'Error from platform: {response.get("message") or response.get("Message")}') self.s3_setup_failed = True return None, None, response @@ -661,7 +661,7 @@ def commit_repository(self, branch: str) -> str | None: self.s3_setup_failed = True except JSONDecodeError: if request: - logging.warning(f"Response (status: {request.status}) of {self.integrations_api_url}: {request.data.decode('utf8')}") + logging.warning(f"Response (status: {request.status}) of {self.integrations_api_url}: {request.data.decode('utf8')}") # nosec logging.error(f"Response of {self.integrations_api_url} is not a valid JSON", exc_info=True) self.s3_setup_failed = True finally: diff --git a/checkov/main.py b/checkov/main.py index 56d5423b41a..8dfa606edf2 100755 --- a/checkov/main.py +++ b/checkov/main.py @@ -611,6 +611,7 @@ def run(self, banner: str = checkov_banner, tool: str = checkov_tool, source_typ self.url = self.commit_repository() except Exception: logging.error('An error occurred while uploading scan results to the platform', exc_info=True) + bc_integration.s3_setup_failed = True should_run_contributor_metrics = bc_integration.bc_api_key and self.config.repo_id and self.config.prisma_api_url logger.debug(f"Should run contributor metrics report: {should_run_contributor_metrics}") @@ -689,7 +690,7 @@ def run(self, banner: str = checkov_banner, tool: str = checkov_tool, source_typ if bc_integration.support_flag_enabled: if bc_integration.s3_setup_failed: print_to_stderr = os.getenv('CKV_STDERR_DEBUG', 'FALSE').upper() == 'TRUE' - log_level = os.getenv('LOG_LEVEL', '').upper() + log_level = os.getenv('LOG_LEVEL', '') if log_level == 'DEBUG': print('Unable to upload support logs. However, LOG_LEVEL is already set to DEBUG, so debug logs are available locally.') elif print_to_stderr: