fix(vpc): ignore com.amazonaws.vpce endpoints (#2929)

This commit is contained in:
Sergio Garcia
2023-10-17 11:14:12 +02:00
committed by GitHub
parent 3739801ed4
commit 92547bfdb6
3 changed files with 46 additions and 2 deletions

View File

@@ -71,6 +71,45 @@ class Test_vpc_endpoint_connections_trust_boundaries:
assert len(result) == 0
@mock_ec2
def test_vpc_aws_endpoint(self):
# Create VPC Mocked Resources
ec2_client = client("ec2", region_name=AWS_REGION)
vpc = ec2_client.create_vpc(CidrBlock="10.0.0.0/16")["Vpc"]
route_table = ec2_client.create_route_table(VpcId=vpc["VpcId"])["RouteTable"]
ec2_client.create_vpc_endpoint(
VpcId=vpc["VpcId"],
ServiceName="com.amazonaws.vpce.us-east-1.s3",
RouteTableIds=[route_table["RouteTableId"]],
VpcEndpointType="Interface",
)
from prowler.providers.aws.services.vpc.vpc_service import VPC
current_audit_info = self.set_mocked_audit_info()
# Set config variable
current_audit_info.audit_config = {"trusted_account_ids": []}
with mock.patch(
"prowler.providers.aws.lib.audit_info.audit_info.current_audit_info",
new=current_audit_info,
):
with mock.patch(
"prowler.providers.aws.services.vpc.vpc_endpoint_connections_trust_boundaries.vpc_endpoint_connections_trust_boundaries.vpc_client",
new=VPC(current_audit_info),
):
# Test Check
from prowler.providers.aws.services.vpc.vpc_endpoint_connections_trust_boundaries.vpc_endpoint_connections_trust_boundaries import (
vpc_endpoint_connections_trust_boundaries,
)
check = vpc_endpoint_connections_trust_boundaries()
result = check.execute()
assert len(result) == 0
@mock_ec2
def test_vpc_endpoint_with_full_access(self):
# Create VPC Mocked Resources