fix(Terraform): Failing checks due to parsing error CKV_GCP_54 & CKV_GCP_57 Issue 7033 #7036
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.
User description
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
CKV_GCP_54 & CKV_GCP_57 checks are failing with TypeError: 'int' object is not subscriptable on flags = [{key: flag[key][0] for key in flag} for flag in flags]
failing with a cdk.tf.json file
We are not parsing the
databse_flags
object properly. This just grabs the name and value of each flag and appends to a new array which then we set flags to. This is te format checkov expects. I believe the errors comes from__startswith
and__endswith
being part of the flags list in the dict.Ran unit tests for both the checks and they still pass and ran locally with a cdk.tf.json file to make sure databse_flags is parsed properly.
Fixes # 7033
Fix
How does someone fix the issue in code and/or in runtime?
Running checkov on a file that contains google_sql_database_instance leads to these errors I just went to the file where it errored and added the code in the pr.
Checklist:
Generated description
Below is a concise technical summary of the changes proposed in this PR:
Modifies the parsing of database flags in Google Cloud PostgreSQL checks to handle different data structures. Updates the
GoogleCloudPostgreSqlLogLockWaits
andGoogleCloudPostgreSqlLogMinDuration
classes to correctly process thedatabase_flags
object, addressing a TypeError issue with CDK-generated Terraform JSON files.Latest Contributors(2)