Skip to content

Commit

Permalink
platform(terraform): fix in subgraphs uploads (#5610)
Browse files Browse the repository at this point in the history
* convert subgraph path to None if not exist

* revert changes in wrapper

* fix mypy

* fix mypy
  • Loading branch information
YaaraVerner authored Oct 2, 2023
1 parent 026f933 commit f19727c
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit f19727c

Please sign in to comment.