-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(terraform_plan): Don't add values to empty list values in after_unknown #7319
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
Conversation
…ing after_unknown
checkov/terraform/plan_parser.py
Outdated
| resource_conf[k][0][inner_key] = _clean_simple_type_list([TRUE_AFTER_UNKNOWN]) | ||
| elif isinstance(resource_conf[k][0], list) and isinstance(resource_conf[k][0][0], dict): | ||
| resource_conf[k][0][0][inner_key] = _clean_simple_type_list([TRUE_AFTER_UNKNOWN]) | ||
| if _validate_after_unknown_list_not_empty(inner_key, k, resource_conf): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we really invoke the same condition in both cases?
I would expect the second condition to be invoked with k[0], since the second one is operating at a deeper level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, fixing
| } | ||
| ]} | ||
| key: str = 'network_configuration' | ||
| value: list = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have more than one item in this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the function to handle case where there are more than 1 by going in for loop
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
Fixes a bug in which empty lists in after_unknown section were inserted a new value, now the value stays an empty list.
Checklist: