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): Failing checks due to parsing error CKV_GCP_54 & CKV_GCP_57 Issue 7033 #7036

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewkaldani30
Copy link

@andrewkaldani30 andrewkaldani30 commented Mar 4, 2025

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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • [] I have made corresponding changes to the documentation
  • I have added tests that prove my feature, policy, or fix is effective and works
  • New and existing tests pass locally with my changes

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 and GoogleCloudPostgreSqlLogMinDuration classes to correctly process the database_flags object, addressing a TypeError issue with CDK-generated Terraform JSON files.

Latest Contributors(2)
UserCommitDate
rotemavnifix-terraform-Handle-m...September 28, 2022
losisinfix-terraform-gcp-post...September 05, 2022
This pull request is reviewed by Baz. Join @andrewkaldani30 and the rest of your team on (Baz).

@andrewkaldani30 andrewkaldani30 changed the title fix: Terraform CKV_GCP_54 & CKV_GCP_57 Issue 7033 fix(Terraform): CKV_GCP_54 & CKV_GCP_57 Issue 7033 Mar 4, 2025
@andrewkaldani30 andrewkaldani30 changed the title fix(Terraform): CKV_GCP_54 & CKV_GCP_57 Issue 7033 fix(Terraform): Failing checks due to parsing error CKV_GCP_54 & CKV_GCP_57 Issue 7033 Mar 4, 2025
@andrewkaldani30
Copy link
Author

bump on this -- we would like to use google sql checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant