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

feat(terraform): add expanded actions to Terraform AWS IAM resources #5590

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
142 changes: 71 additions & 71 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
13 changes: 11 additions & 2 deletions checkov/common/checks_infra/checks_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def parse_raw_check(self, raw_check: Dict[str, Dict[str, Any]], **kwargs: Any) -
check.frameworks = raw_check.get("metadata", {}).get("frameworks", [])
check.guideline = raw_check.get("metadata", {}).get("guideline")
check.check_path = kwargs.get("check_path", "")
extensions = raw_check.get("metadata", {}).get("extensions", None)
if extensions is not None:
check.extensions = extensions
solver = self.get_check_solver(check)
check.set_solver(solver)

Expand Down Expand Up @@ -282,9 +285,11 @@ def get_check_solver(self, check: BaseGraphCheck) -> BaseSolver:
if check.sub_checks:
sub_solvers = []
for sub_solver in check.sub_checks:
# set extensions
sub_solver.extensions = check.extensions
sub_solvers.append(self.get_check_solver(sub_solver))

type_to_solver = {
type_to_solver: dict[SolverType | None, BaseSolver | None] = {
SolverType.COMPLEX_CONNECTION: operator_to_complex_connection_solver_classes.get(
check.operator, lambda *args: None
)(sub_solvers, check.operator),
Expand All @@ -300,9 +305,13 @@ def get_check_solver(self, check: BaseGraphCheck) -> BaseSolver:
),
}

solver = type_to_solver.get(check.type) # type:ignore[arg-type] # if not str will return None
solver = type_to_solver.get(check.type)
if not solver:
raise NotImplementedError(f"solver type {check.type} with operator {check.operator} is not supported")

# set extensions
solver.extensions = check.extensions

return solver


Expand Down
Empty file.
Loading