forked from mtusi2026/mtusi2026lab7
Prepare verified laboratory 7 implementation and evidence
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { requireThat, project } from "./runtime";
|
||||
export function publicLBEndpoint(inspection: any): {
|
||||
host: string;
|
||||
port: number;
|
||||
servername: string;
|
||||
} {
|
||||
requireThat(
|
||||
inspection?.Config?.Labels?.["com.docker.compose.project"] === project &&
|
||||
inspection?.Config?.Labels?.["com.docker.compose.service"] === "lb" &&
|
||||
inspection?.State?.Running === true,
|
||||
"LB_RESOURCE_GUARD_FAILED",
|
||||
);
|
||||
const bindings = inspection?.NetworkSettings?.Ports?.["8443/tcp"];
|
||||
requireThat(
|
||||
Array.isArray(bindings) && bindings.length === 1,
|
||||
"LB_PUBLIC_TLS_BINDING_MISSING",
|
||||
);
|
||||
const binding = bindings[0];
|
||||
requireThat(
|
||||
binding.HostIp === "127.0.0.1" &&
|
||||
typeof binding.HostPort === "string" &&
|
||||
/^[0-9]{1,5}$/.test(binding.HostPort),
|
||||
"LB_PUBLIC_TLS_BINDING_UNSAFE",
|
||||
);
|
||||
const port = Number(binding.HostPort);
|
||||
requireThat(port >= 1 && port <= 65535, "LB_PUBLIC_TLS_PORT_INVALID");
|
||||
return { host: "127.0.0.1", port, servername: "localhost" };
|
||||
}
|
||||
Reference in New Issue
Block a user