forked from mtusi2026/mtusi2026lab7
ЛР7: проверять публикацию портов через docker ps
`docker compose ps --format {{.Ports}}` не гарантирует это поле;
docker ps с фильтром проекта даёт стабильный формат.
Co-Authored-By: O3 Agent Claude <noreply@ozon.ru>
This commit is contained in:
@@ -177,7 +177,9 @@ def main():
|
|||||||
wrong_name.startswith("cert_error"), wrong_name)
|
wrong_name.startswith("cert_error"), wrong_name)
|
||||||
|
|
||||||
# 1b. Наружу — только loopback-порты; app-контейнеры hardened.
|
# 1b. Наружу — только loopback-порты; app-контейнеры hardened.
|
||||||
ps_out = compose("ps", "--format", "{{.Service}}|{{.Ports}}").stdout
|
ps_out = run(["docker", "ps",
|
||||||
|
"--filter", "label=com.docker.compose.project=messenger-lab7",
|
||||||
|
"--format", "{{.Names}}|{{.Ports}}"]).stdout
|
||||||
public = [line for line in ps_out.splitlines()
|
public = [line for line in ps_out.splitlines()
|
||||||
if "->" in line and "127.0.0.1:" not in line and "[::1]:" not in line]
|
if "->" in line and "127.0.0.1:" not in line and "[::1]:" not in line]
|
||||||
check("exposure: no service published on all interfaces", not public,
|
check("exposure: no service published on all interfaces", not public,
|
||||||
|
|||||||
Reference in New Issue
Block a user