Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

platform(terraform): fix in subgraphs uploads #5610

Merged
merged 4 commits into from
Oct 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions checkov/terraform/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import dataclasses
import logging
import os
from typing import Any, TYPE_CHECKING
from typing import Any, TYPE_CHECKING, Optional

from typing_extensions import TypeAlias # noqa[TC002]

Expand Down Expand Up @@ -56,7 +56,7 @@ def __init__(
graph_manager: TerraformGraphManager | None = None,
) -> None:
super().__init__(parser, db_connector, external_registries, source, graph_class, graph_manager)
self.all_graphs: list[tuple[LibraryGraph, str]] = []
self.all_graphs: list[tuple[LibraryGraph, Optional[str]]] = []

def run(
self,
Expand All @@ -73,7 +73,7 @@ def run(
report = Report(self.check_type)
parsing_errors: dict[str, Exception] = {}
self.load_external_checks(external_checks_dir)
local_graphs = None
local_graphs: Optional[list[tuple[Optional[str], Optional[TerraformLocalGraph]]]] = None
if self.context is None or self.definitions is None or self.breadcrumbs is None:
self.definitions = {}
logging.info("Scanning root folder and producing fresh tf_definitions and context")
Expand Down Expand Up @@ -108,7 +108,7 @@ def run(
create_graph=CHECKOV_CREATE_GRAPH,
)
# Make graph a list to allow single processing method for all cases
local_graphs = [('', single_graph)]
local_graphs = [(None, single_graph)]
elif files:
files = [os.path.abspath(file) for file in files]
root_folder = os.path.split(os.path.commonprefix(files))[0]
Expand All @@ -121,7 +121,7 @@ def run(
)
else:
# local_graph needs to be a list to allow supporting multi graph
local_graphs = [('', self.graph_manager.build_graph_from_definitions(self.definitions))]
local_graphs = [(None, self.graph_manager.build_graph_from_definitions(self.definitions))]
else:
raise Exception("Root directory was not specified, files were not specified")

Expand Down Expand Up @@ -190,7 +190,7 @@ def parse_file(file: str) -> tuple[str, dict[str, Any] | None, dict[str, Excepti
parsing_errors.update(file_parsing_errors)

def _update_definitions_and_breadcrumbs(
self, local_graphs: list[tuple[str, TerraformLocalGraph]], report: Report, root_folder: str
self, local_graphs: list[tuple[Optional[str], TerraformLocalGraph]], report: Report, root_folder: str
) -> None:
self.definitions = {}
self.breadcrumbs = {}
Expand Down