-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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): Nested source_module_objects with missing foreach key #5580
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ies all foreach indices
…check for them all
bo156
had a problem deploying
to
scan-security
September 20, 2023 10:40 — with
GitHub Actions
Failure
…foreach key exists always
gruebel
reviewed
Sep 20, 2023
SteveVaknin
approved these changes
Sep 20, 2023
bo156
had a problem deploying
to
scan-security
September 20, 2023 13:45 — with
GitHub Actions
Failure
… this is the only place where it's used
bo156
force-pushed
the
bugfix/no-mutable-dict-keys
branch
from
September 20, 2023 13:55
fa0ad45
to
1181e88
Compare
bo156
had a problem deploying
to
scan-security
September 20, 2023 13:56 — with
GitHub Actions
Failure
gruebel
approved these changes
Sep 20, 2023
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.
🏖️
pull bot
pushed a commit
to Julian-Louis/checkov
that referenced
this pull request
Sep 20, 2023
…bridgecrewio#5580) * made TFModule a frozen immutable dataclass, didn't update all usages yet * replaced one mutable location with a function that recursively nullifies all foreach indices * Updated second todo area to use recursion with immutable objects instead of mutable * Also made TFDefinitionKey immutable * Fixed insertion of foreach keys for all vertices and updated test to check for them all * middle of final debug - fixed foreach key for 12/16 resources in test * Fixed creation of foreach indices for all resources of all types * flake8 * Added another tf_definitions check for the new test to make sure all foreach key exists always * moved _get_module_with_only_relevant_foreach_idx to module_handler as this is the only place where it's used * empty commit to retrigger checks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
A bug was found where the
source_module_object
ofTerraformLocalGraph.vertices
might had missing/unassigned foreach_idx in cases with nested foreach terraform objects (see changed test for example).To solve it I:
TFModule
andTFDefinitionKey
immutable objects (as we use them as dictionary keys, which is extremely bad with mutable objects and caused bugs while debugging).ForeachModuleHandler._update_children_foreach_index
Checklist: