diff --git a/checkov/common/bridgecrew/wrapper.py b/checkov/common/bridgecrew/wrapper.py index 4f25bd7234c..0e630732e18 100644 --- a/checkov/common/bridgecrew/wrapper.py +++ b/checkov/common/bridgecrew/wrapper.py @@ -206,6 +206,7 @@ def _upload_resource_subgraph_map(check_type: str, resource_subgraph_map: dict[s except Exception: logging.error(f'failed to upload resource_subgraph_map from framework {check_type} to platform', exc_info=True) + # removing '/src' with [:-4] graphs_repo_object_key = full_repo_object_key.replace('checkov', 'graphs')[:-4] with futures.ThreadPoolExecutor() as executor: futures.wait( @@ -214,4 +215,4 @@ def _upload_resource_subgraph_map(check_type: str, resource_subgraph_map: dict[s return_when=futures.FIRST_EXCEPTION, timeout=timeout ) - logging.info(f"Done persisting {len(resource_subgraph_maps)} resource_subgraph_maps") + logging.info(f"Done persisting resource_subgraph_maps for frameworks - {', '.join(resource_subgraph_maps.keys())}") diff --git a/checkov/common/runners/base_runner.py b/checkov/common/runners/base_runner.py index 3ce6de5dc5a..2449baf3b36 100644 --- a/checkov/common/runners/base_runner.py +++ b/checkov/common/runners/base_runner.py @@ -6,7 +6,7 @@ import re from abc import ABC, abstractmethod from collections.abc import Iterable -from typing import List, Any, TYPE_CHECKING, TypeVar, Generic, Dict +from typing import List, Any, TYPE_CHECKING, TypeVar, Generic, Dict, Optional from checkov.common.graph.db_connectors.igraph.igraph_db_connector import IgraphConnector from checkov.common.graph.graph_builder import CustomAttributes @@ -62,6 +62,7 @@ class BaseRunner(ABC, Generic[_Definitions, _Context, _GraphManager]): graph_manager: _GraphManager | None = None graph_registry: Registry | None = None db_connector: LibraryGraphConnector + resource_subgraph_map: Optional[dict[str, str]] = None def __init__(self, file_extensions: Iterable[str] | None = None, file_names: Iterable[str] | None = None): self.file_extensions = file_extensions or [] diff --git a/checkov/common/runners/runner_registry.py b/checkov/common/runners/runner_registry.py index 6b1d81708a9..b095c3e524e 100644 --- a/checkov/common/runners/runner_registry.py +++ b/checkov/common/runners/runner_registry.py @@ -140,7 +140,7 @@ def _parallel_run(runner: _BaseRunner) -> tuple[Report | list[Report], str | Non if runner.graph_manager: return report, runner.check_type, self.extract_graphs_from_runner(runner), \ - self.extract_resource_subgraph_map_from_runner(runner) + runner.resource_subgraph_map return report, None, None, None valid_runners = [] @@ -200,11 +200,8 @@ def _parallel_run(runner: _BaseRunner) -> tuple[Report | list[Report], str | Non self.check_type_to_graph = {runner.check_type: self.extract_graphs_from_runner(runner) for runner in self.runners if runner.graph_manager} if not self.check_type_to_resource_subgraph_map: - self.check_type_to_resource_subgraph_map = {} - for runner in self.runners: - resource_subgraph_map = self.extract_resource_subgraph_map_from_runner(runner) - if resource_subgraph_map is not None: - self.check_type_to_resource_subgraph_map[runner.check_type] = resource_subgraph_map + self.check_type_to_resource_subgraph_map = {runner.check_type: runner.resource_subgraph_map for runner in + self.runners if runner.resource_subgraph_map is not None} return self.scan_reports def _merge_reports(self, reports: Iterable[Report | list[Report]]) -> list[Report]: @@ -771,8 +768,3 @@ def extract_graphs_from_runner(runner: _BaseRunner) -> list[tuple[LibraryGraph, elif runner.graph_manager: return [(runner.graph_manager.get_reader_endpoint(), None)] return [] - - @staticmethod - def extract_resource_subgraph_map_from_runner(runner: _BaseRunner) -> Optional[dict[str, str]]: - # exist only for terraform - return getattr(runner, 'resource_subgraph_map', None) diff --git a/checkov/terraform/runner.py b/checkov/terraform/runner.py index fb1e50ac2f5..bf234129ea3 100644 --- a/checkov/terraform/runner.py +++ b/checkov/terraform/runner.py @@ -57,7 +57,6 @@ def __init__( ) -> None: super().__init__(parser, db_connector, external_registries, source, graph_class, graph_manager) self.all_graphs: list[tuple[LibraryGraph, Optional[str]]] = [] - self.resource_subgraph_map: Optional[dict[str, str]] = None def run( self,