Skip to content

fix(terraform): prevent crash in S3AllowsAnyPrincipal with unparsed v…#7581

Open
marcoHosseini wants to merge 1 commit into
bridgecrewio:mainfrom
marcoHosseini:fix/issue-7571
Open

fix(terraform): prevent crash in S3AllowsAnyPrincipal with unparsed v…#7581
marcoHosseini wants to merge 1 commit into
bridgecrewio:mainfrom
marcoHosseini:fix/issue-7571

Conversation

@marcoHosseini

Copy link
Copy Markdown

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Description

This PR fixes a parser crash in the CKV_AWS_70 (S3AllowsAnyPrincipal) check when it encounters an unparsed Terraform variable within a concat statement for an S3 Bucket Policy.

A TypeError was previously thrown when the parser expected a dictionary but received a string (the unparsed variable placeholder). I added an isinstance guard inside the loop to safely skip non-dictionary elements, along with a corresponding Terraform test fixture to prevent regression.

Fixes #7571

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

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.

CKV_AWS_70 crashes on mixed concat([dict], var.list) Statement shape — PR #7097 only covers all-strings case

1 participant