Reviewer · Networking
Avoid hardcoded network assumptions
Network configuration (IP addresses, CIDR ranges, and ports) should never be hardcoded with assumptions about a specific topology or IP version. This leads to brittle, insecure, or incomplete test coverage.
Network configuration (IP addresses, CIDR ranges, and ports) should never be hardcoded with assumptions about a specific topology or IP version. This leads to brittle, insecure, or incomplete test coverage.
- Support dual-stack (IPv4/IPv6) explicitly: don’t assume an address is IPv4 (e.g. relying solely on
public_ip). Instead pass around bothhostsandip_version(or equivalent) so callers can select the correct address family, and where feasible randomize between IPv4 and IPv6 test values to exercise both code paths. - Don’t hardcode CIDR ranges or IPs that implicitly depend on a particular VPC/subnet layout (e.g.
exclude_cidr_list = "10.0.0.0/8"). Instead expose a variable for the network CIDR or derive it dynamically from the relevant host’s address. - Apply least-privilege when opening network access: don’t add ports to a shared/global ingress list for all targets. Instead, inject the extra ports only for the specific step/module that needs them, e.g.:
step "..." {
variables {
ports_ingress = concat(values(globals.ports), [{
description = "LDAP"
port = 389
protocol = "tcp"
}])
}
}
This keeps modules portable across network environments and IP versions, and avoids unnecessarily widening the attack surface.