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

fix(terraform_plan): Fix parsing other types of provisioners #6606

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
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
28 changes: 21 additions & 7 deletions checkov/terraform/plan_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,13 +439,27 @@ def _clean_simple_type_list(value_list: List[Any]) -> List[Any]:
return value_list


def _get_provisioner(input_data: List[Any]) -> List[Any]:
def _get_provisioner(input_data: List[Dict[str, Any]]) -> List[Dict[str, Dict[str, Any]]]:
result = []
for item in input_data:
key = item['type']
command_value = item['expressions']['command']
if not isinstance(command_value, list):
command_value = [command_value]
transformed_item = {key: {'command': command_value}}
result.append(transformed_item)
if 'type' in item and 'expressions' in item:
key = item['type']
expressions = item['expressions']
transformed_expressions = {}

if key == 'local-exec':
if 'command' in expressions:
command_value = expressions['command']
if not isinstance(command_value, list):
command_value = [command_value]
transformed_expressions['command'] = command_value

for field, value in expressions.items():
if field != 'command':
transformed_expressions[field] = value
else:
transformed_expressions = expressions

transformed_item = {key: transformed_expressions}
result.append(transformed_item)
return result
Loading
Loading