Publish curated ITWorx-ModelForge source from 990401737f96c8d46a9f7b0d84994516cadcb6a0

This commit is contained in:
Public Source Publisher committed 2026-09-30 09:23:17 +00:00
1 parent 7082ab955a
commit 848f0d8f8a
434 files changed
+67298 -4315

No files matched your search

+63 -14
View File
@@ -264,6 +264,7 @@ _PUBLISHED_PORT = re.compile(r'^\s*-\s*"(?P<mapping>[^"]*:\d+)"\s*$')
# The API is published deliberately: every admin route is operator-authenticated and the console has
# to reach it. Everything else defaults to loopback.
_DELIBERATELY_PUBLISHED = ("MODELFORGE_API_BIND",)
_VALIDATION_TLS_PUBLIC_MAPPING = "0.0.0.0:18444:8443"
def _published_mappings(path: Path) -> list[str]:
@@ -331,7 +332,16 @@ def test_every_compose_projection_binds_its_ports_to_loopback(compose: Path) ->
written for cannot find the next occurrence, so this one reads every projection.
"""
for mapping in _published_mappings(compose):
mappings = _published_mappings(compose)
if compose.name == "docker-compose.validation-tls.yml":
# This overlay is the one explicitly isolated candidate ingress. Its rendered service,
# project and network are independently checked by rc_isolation_preflight.py.
assert mappings.count(_VALIDATION_TLS_PUBLIC_MAPPING) == 1
assert "\n tls:\n" in compose.read_text("utf-8")
for mapping in mappings:
if compose.name == "docker-compose.validation-tls.yml" and mapping == _VALIDATION_TLS_PUBLIC_MAPPING:
continue
if any(name in mapping for name in _DELIBERATELY_PUBLISHED):
continue
assert _binds_to_loopback(mapping), (
@@ -379,6 +389,11 @@ def test_the_console_sets_its_security_headers_in_every_location() -> None:
):
assert header in headers
assert "location = /.well-known/modelforge-build-provenance.json" in config
assert config.index("location = /.well-known/modelforge-build-provenance.json") < config.index(
"location ~ /\\."
)
def test_no_dependency_is_declared_as_a_floating_latest() -> None:
"""`latest` makes a build unrepeatable and pulls a compromised release automatically."""
@@ -395,9 +410,21 @@ def test_no_dependency_is_declared_as_a_floating_latest() -> None:
assert floating == [], f"floating dependency specifiers: {floating}"
def test_the_release_images_upgrade_their_installer() -> None:
for dockerfile in (ROOT / "backend" / "Dockerfile", ROOT / "node-agent" / "Dockerfile"):
assert "--upgrade pip" in dockerfile.read_text("utf-8"), dockerfile
def test_python_release_images_use_the_hash_locked_build_toolchain() -> None:
for dockerfile in (
ROOT / "backend" / "Dockerfile",
ROOT / "node-agent" / "Dockerfile",
ROOT / "runtime-worker" / "Dockerfile",
):
text = dockerfile.read_text("utf-8")
assert "COPY config/security/build-toolchain.lock /tmp/modelforge-build-toolchain.lock" in text
assert "--require-hashes" in text
assert "--only-binary=:all:" in text
assert "--index-url https://pypi.org/simple" in text
assert "--no-build-isolation" in text
assert "--upgrade pip" not in text
if dockerfile.parent.name == "node-agent":
assert "--ignore-installed" in text
def test_every_release_base_image_is_digest_pinned_and_security_updated() -> None:
@@ -410,29 +437,49 @@ def test_every_release_base_image_is_digest_pinned_and_security_updated() -> Non
text = dockerfile.read_text("utf-8")
from_lines = [line for line in text.splitlines() if line.startswith("FROM ")]
assert from_lines
assert all("@sha256:" in line for line in from_lines), dockerfile
assert (
"apk upgrade --no-cache" in text
or "apt-get upgrade --yes" in text
stages = {
line.split(" AS ", 1)[1].strip()
for line in from_lines
if " AS " in line
}
assert all(
"@sha256:" in line or line.split()[1] in stages
for line in from_lines
), dockerfile
if dockerfile.parent.name == "node-agent":
# The Node Agent final stage is Canonical's glibc-compatible chiseled runtime. It has
# no package manager by design; patch currency is supplied by the exact immutable
# runtime digest and the managed exact-image Trivy gate. Its builder installs the
# hash-locked toolchain and is excluded from the shipped image.
assert "ubuntu/python:3.12-24.04@sha256:" in text, dockerfile
else:
assert (
"apk upgrade --no-cache" in text
or "apt-get upgrade --yes" in text
), dockerfile
for dockerfile in (dockerfiles[0], dockerfiles[2]):
text = dockerfile.read_text("utf-8")
assert '"setuptools>=78.1.1"' in text, dockerfile
assert '"msgpack>=1.2.1"' in text, dockerfile
assert "--require-hashes" in text, dockerfile
assert "--no-build-isolation" in text, dockerfile
assert "pip check" in text, dockerfile
assert "python -m pip uninstall --yes pip setuptools" in text, dockerfile
assert "-m pip uninstall --yes pip setuptools wheel" in text, dockerfile
def test_node_agent_runtime_is_glibc_multistage_and_keeps_nvidia_hardening() -> None:
dockerfile = (ROOT / "node-agent" / "Dockerfile").read_text("utf-8")
compose = (ROOT / "docker-compose.node-agent.yml").read_text("utf-8")
assert dockerfile.count("FROM python:3.12-slim-trixie@sha256:") == 2
assert dockerfile.count("FROM python:3.12-slim-trixie@sha256:") == 1
assert "FROM ubuntu/python:3.12-24.04@sha256:" in dockerfile
assert " AS runtime-base" in dockerfile
assert " AS builder" in dockerfile
assert "alpine" not in dockerfile.lower()
assert "USER modelforge-agent" in dockerfile
assert "--uid 100" in dockerfile and "--gid 101" in dockerfile
assert "USER 100:101" in dockerfile
assert "modelforge-agent:x:100:101" in dockerfile
assert "modelforge-agent:x:101:" in dockerfile
assert "COPY --from=builder /runtime/etc/passwd /etc/passwd" in dockerfile
assert "COPY --from=builder /runtime/etc/group /etc/group" in dockerfile
assert (
"MODELFORGE_AGENT_ACCELERATOR_MODE: ${MODELFORGE_AGENT_ACCELERATOR_MODE:-nvidia}"
in compose
@@ -468,6 +515,8 @@ def test_release_builder_uses_reproducible_image_exports() -> None:
script = (ROOT / "scripts" / "release_build.py").read_text("utf-8")
assert '"--provenance=false"' in script
assert '"--sbom=false"' in script
assert '"--pull"' in script
assert '"--no-cache"' in script
assert "SOURCE_DATE_EPOCH" in script