Skip to content

Commit

Permalink
fix(terraform): Update CKV2_AWS_12 for the new defaults (#5203)
Browse files Browse the repository at this point in the history
* Update CKV2_AWS_12 for the new defaults

* fix test data
  • Loading branch information
JamesWoolfenden committed Jul 13, 2023
1 parent 86db3ac commit 72bca73
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
12 changes: 12 additions & 0 deletions checkov/terraform/checks/graph_checks/aws/VPCHasRestrictedSG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ definition:
- "aws_default_security_group"
connected_resource_types:
- "aws_security_group_rule"
operator: "not_exists"
- cond_type: "connection"
resource_types:
- "aws_default_security_group"
connected_resource_types:
- "aws_vpc_security_group_egress_rule"
operator: "not_exists"
- cond_type: "connection"
resource_types:
- "aws_default_security_group"
connected_resource_types:
- "aws_vpc_security_group_ingress_rule"
operator: "not_exists"
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ fail:
- "aws_vpc.not_ok_vpc"
- "aws_vpc.not_ok_vpc_2"
- "aws_vpc.not_ok_vpc_3"
- "aws_vpc.not_ok_vpc_4"
- "aws_vpc.not_ok_vpc_5"
35 changes: 35 additions & 0 deletions tests/terraform/graph/checks/resources/VPCHasRestrictedSG/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,38 @@ resource "aws_security_group_rule" "default_sg_rule" {
type = "-1"
security_group_id = aws_default_security_group.default_3.id
}

resource "aws_vpc_security_group_ingress_rule" "pike" {
security_group_id = aws_default_security_group.default_4.id

cidr_ipv4 = "10.0.0.0/8"
from_port = 80
ip_protocol = "tcp"
to_port = 8080
}


resource "aws_vpc_security_group_egress_rule" "pike" {
security_group_id = aws_default_security_group.default_5.id

cidr_ipv4 = "10.0.0.0/8"
from_port = 80
ip_protocol = "tcp"
to_port = 8080
}

resource "aws_vpc" "not_ok_vpc_4" {
cidr_block = "10.0.0.0/16"
}

resource "aws_vpc" "not_ok_vpc_5" {
cidr_block = "10.0.0.0/16"
}

resource "aws_default_security_group" "default_4" {
vpc_id = aws_vpc.not_ok_vpc_4.id
}

resource "aws_default_security_group" "default_5" {
vpc_id = aws_vpc.not_ok_vpc_5.id
}

0 comments on commit 72bca73

Please sign in to comment.