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(query): vcp peering route table should restrict cidr query with fp results #7067

Merged
merged 6 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CxPolicy[result] {
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("aws_route[%s] restricts CIDR", [name]),
"keyActualValue": sprintf("aws_route[%s] does not restrict CIDR", [name]),
"searchLine": common_lib.build_search_line(["resource", "aws_route", name], []),
}
}

Expand All @@ -30,10 +31,11 @@ CxPolicy[result] {
"documentId": input.document[i].id,
"resourceType": "aws_route",
"resourceName": tf_lib.get_resource_name(resource, name),
"searchKey": sprintf("aws_route[%s].route", [name]),
"searchKey": sprintf("aws_route_table[%s].route", [name]),
"issueType": "IncorrectValue",
"keyExpectedValue": sprintf("aws_route[%s].route restricts CIDR", [name]),
"keyActualValue": sprintf("aws_route[%s].route does not restrict CIDR", [name]),
"keyExpectedValue": sprintf("aws_route_table[%s].route restricts CIDR", [name]),
"keyActualValue": sprintf("aws_route_table[%s].route does not restrict CIDR", [name]),
"searchLine": common_lib.build_search_line(["resource", "aws_route_table", name, "route"], []),
}
}

Expand All @@ -59,7 +61,7 @@ unrestricted(route) {
route_table_open_cidr(route) {
is_array(route)
common_lib.valid_key(route[r], "vpc_peering_connection_id")
unrestricted(route)
unrestricted(route[r])
} else {
is_object(route)
common_lib.valid_key(route, "vpc_peering_connection_id")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "aws_route_table" "art_nat_gw_out" {
vpc_id = aws_vpc.av_xxx.id

route {
nat_gateway_id = aws_nat_gateway.ngw01.id
cidr_block = "0.0.0.0/0"
}

route {
vpc_peering_connection_id = aws_vpc_peering_connection.avpv.id
cidr_block = "10.0.0.0/24"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "aws_route_table" "art_nat_gw_out" {
vpc_id = aws_vpc.av_xxx.id

route {
nat_gateway_id = aws_nat_gateway.ngw01.id
cidr_block = "10.0.0.0/24"
}

route {
vpc_peering_connection_id = aws_vpc_peering_connection.avpv.id
cidr_block = "0.0.0.0/0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
"severity": "HIGH",
"line": 118,
"fileName": "positive3.tf"
},
{
"queryName": "VPC Peering Route Table with Unrestricted CIDR",
"severity": "HIGH",
"line": 9,
"fileName": "positive4.tf"
}
]
Loading