Skip to content

Commit

Permalink
fix linting and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gruebel committed Sep 24, 2023
1 parent 50d691b commit 82384a8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
9 changes: 5 additions & 4 deletions checkov/cloudformation/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,10 @@ def get_graph_checks_report(self, root_folder: str | None, runner_filter: Runner
entity_file_abs_path = entity[CustomAttributes.FILE_PATH]
entity_file_path = f"/{os.path.relpath(entity_file_abs_path, root_folder)}"
entity_name = entity[CustomAttributes.BLOCK_NAME].split(".")[-1]
entity_context = self.context[entity_file_abs_path][TemplateSections.RESOURCES][
entity_name
]
if entity_file_abs_path in self.context:
entity_context = self.context[entity_file_abs_path][TemplateSections.RESOURCES][entity_name]
else:
entity_context = {}

skipped_check = next(
(
Expand All @@ -243,7 +244,7 @@ def get_graph_checks_report(self, root_folder: str | None, runner_filter: Runner
check_result=check_result,
code_block=entity_context.get("code_lines"),
file_path=entity_file_path,
file_line_range=[entity_context.get("start_line"), entity_context.get("end_line")],
file_line_range=[entity_context.get("start_line", 1), entity_context.get("end_line", 1)],
resource=entity[CustomAttributes.ID],
evaluations={},
check_class=check.__class__.__module__,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from __future__ import annotations

from typing import Any
from typing import Any, TYPE_CHECKING

from policy_sentry.analysis.expand import expand # type:ignore[import] # will be fixed with the next version
from typing_extensions import Self

from checkov.common.graph.checks_infra.extensions.base_extension import BaseGraphCheckExtension
from checkov.common.graph.graph_builder.graph_components.attribute_names import CustomAttributes
from checkov.common.models.enums import GraphCheckExtension
from checkov.common.util.data_structures_utils import pickle_deepcopy
from checkov.common.util.type_forcers import force_list

if TYPE_CHECKING:
from typing_extensions import Self

SUPPORTED_IAM_BLOCKS = {
"aws_iam_group_policy",
"aws_iam_policy",
Expand Down
7 changes: 4 additions & 3 deletions checkov/common/checks_infra/extensions_registry.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from __future__ import annotations

import logging
from typing import Any

from typing_extensions import Self
from typing import Any, TYPE_CHECKING

from checkov.common.checks_infra.extensions.iam_action_expansion import IamActionExpansion
from checkov.common.models.enums import GraphCheckExtension

if TYPE_CHECKING:
from typing_extensions import Self

logger = logging.getLogger(__name__)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class BaseGraphCheckExtension(ABC):
name: GraphCheckExtension
name: GraphCheckExtension # noqa: CCE003 # a static attribute

@abstractmethod
def extend(self, vertex_data: dict[str, Any]) -> dict[str, Any]:
Expand Down

0 comments on commit 82384a8

Please sign in to comment.