Skip to content

Commit

Permalink
chore: reinitialize platform integration in SAST runner (#5749)
Browse files Browse the repository at this point in the history
reinitialize platform integration in SAST runner
  • Loading branch information
gruebel authored Nov 12, 2023
1 parent c339655 commit 0250d08
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions checkov/common/bridgecrew/platform_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,13 @@ def __init__(self) -> None:
self.ca_certificate: str | None = None
self.no_cert_verify: bool = False
self.on_prem: bool = False
self.daemon_process = False # set to 'True' when running in multiprocessing 'spawn' mode

def init_instance(self, platform_integration_data: dict[str, Any]) -> None:
"""This is mainly used for recreating the instance without interacting with the platform again"""

self.daemon_process = True

self.bc_api_url = platform_integration_data["bc_api_url"]
self.bc_api_key = platform_integration_data["bc_api_key"]
self.bc_source = platform_integration_data["bc_source"]
Expand Down Expand Up @@ -377,6 +380,7 @@ def set_s3_integration(self) -> None:
self.support_bucket, self.support_repo_path = cast(str, support_path).split("/", 1)

self.use_s3_integration = True
self.platform_integration_configured = True
except MaxRetryError:
logging.error("An SSL error occurred connecting to the platform. If you are on a VPN, please try "
"disabling it and re-running the command.", exc_info=True)
Expand Down
6 changes: 6 additions & 0 deletions checkov/sast/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys

from checkov.common.bridgecrew.check_type import CheckType
from checkov.common.bridgecrew.platform_integration import bc_integration
from checkov.common.output.report import Report
from checkov.common.runners.base_runner import BaseRunner
from checkov.common.sast.consts import SUPPORT_FILE_EXT, FILE_EXT_TO_SAST_LANG
Expand Down Expand Up @@ -46,6 +47,11 @@ def run(self, root_folder: Optional[str],
logger.warning('no runner filter')
return [Report(self.check_type)]

if bc_integration.daemon_process:
# only happens for 'ParallelizationType.SPAWN'
bc_integration.setup_http_manager()
bc_integration.set_s3_integration()

# registry get all the paths
self.registry.set_runner_filter(runner_filter)
self.registry.add_external_dirs(external_checks_dir)
Expand Down
2 changes: 1 addition & 1 deletion checkov/sca_package_2/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def prepare_and_scan(

if not bc_integration.timestamp and bc_integration.bc_source and not bc_integration.bc_source.upload_results:
bc_integration.set_s3_integration()
if not bc_integration.credentials:
if bc_integration.daemon_process:
# only happens for 'ParallelizationType.SPAWN'
bc_integration.setup_http_manager()
bc_integration.set_s3_integration()
Expand Down

0 comments on commit 0250d08

Please sign in to comment.