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): Handle new resource type for CKV_GCP_73 #7023

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tsmithv11
Copy link
Collaborator

@tsmithv11 tsmithv11 commented Feb 22, 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

Handles google_compute_security_policy_rule

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:

Enhances the CloudArmorWAFACLCVE202144228 check to handle the new google_compute_security_policy_rule resource type. Modifies the check method in the CloudArmorWAFACLCVE202144228 class to evaluate connected security policy rules. Updates test files to include new test cases for separate security policy and rule resources.

TopicDetails
Test Updates Updates test files with new cases for separate security policy and rule resources
Modified files (2)
  • tests/terraform/checks/resource/gcp/example_CloudArmorWAFACLCVE202144228/main.tf
  • tests/terraform/checks/resource/gcp/test_CloudArmorWAFACLCVE202144228.py
Latest Contributors(2)
UserCommitDate
naveednawazkhanfeat-terraform-Update-...May 01, 2024
gruebeladd-CKV_GCP_73-to-chec...December 22, 2021
Check Enhancement Enhances the CloudArmorWAFACLCVE202144228 check to support the new google_compute_security_policy_rule resource type
Modified files (1)
  • checkov/terraform/checks/resource/gcp/CloudArmorWAFACLCVE202144228.py
Latest Contributors(2)
UserCommitDate
naveednawazkhanfeat-terraform-Update-...May 01, 2024
ChanochShaynerfix-terraform-Terrafor...January 29, 2023
This pull request is reviewed by Baz. Join @tsmithv11 and the rest of your team on (Baz).

@@ -38,6 +39,32 @@ def scan_resource_conf(self, conf: Dict[str, List[Any]]) -> CheckResult:
if rule.get("preview") == [True]:
return CheckResult.FAILED
return CheckResult.PASSED

resource_name = conf.get("name")[0]
Copy link
Contributor

@maxamel maxamel Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will we always have a name? I know the name attribute can be omitted from the resource but I am not sure if we populate this field in a default way in this case. I also saw in other locations we check if conf["name"] is null.

if expr.get("expression") == "evaluatePreconfiguredExpr('cve-canary')":
if rule.get("action") == "allow":
return CheckResult.FAILED
if rule.get("preview"):
Copy link
Contributor

@maxamel maxamel Feb 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I saw if preview=True we do not enforce the action, so why are we failing here?
Also, perhaps before the action check we need to first check the preview since in case it's True the action won't kick in.

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.

2 participants