Skip to content

fix(terraform): CKV_AWS_382 false positive on aws_vpc_security_group_egress_rule with ip_protocol=-1#7513

Open
jathinsn27 wants to merge 3 commits intobridgecrewio:mainfrom
jathinsn27:fix/ckv-aws-382-ip-protocol-false-positive
Open

fix(terraform): CKV_AWS_382 false positive on aws_vpc_security_group_egress_rule with ip_protocol=-1#7513
jathinsn27 wants to merge 3 commits intobridgecrewio:mainfrom
jathinsn27:fix/ckv-aws-382-ip-protocol-false-positive

Conversation

@jathinsn27
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

CKV_AWS_382 was silently passing wide-open egress rules written against the newer aws_vpc_security_group_egress_rule resource whenever ip_protocol was set to -1 and the from_port or to_port arguments were omitted.

Fixes #7372

Fix

  • Always evaluate contains_violation on the new-resource branch.
  • Read protocol from either protocol or ip_protocol.
  • Normalize ip_protocol="-1" with no ports to the full 0-65535 range.
  • Mirror the cidr_ipv4 list-unwrapping pattern for cidr_ipv6.

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.

terraform: CKV_AWS_382 false positive for aws_vpc_security_group_egress_rule with ip_protocol=-1

1 participant