Skip to content

fix(docker): reduce runtime CVE exposure, fix e2e tests - #1210

Merged
mckornfield merged 9 commits into
mainfrom
cve-pass-08-10/mck
Aug 12, 2026
Merged

fix(docker): reduce runtime CVE exposure, fix e2e tests#1210
mckornfield merged 9 commits into
mainfrom
cve-pass-08-10/mck

Conversation

@mckornfield

@mckornfield mckornfield commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

This reduces non-Automodel CVE exposure in Docker runtime images while keeping nmp-api on the shell-compatible Python base by default. Platform-Deploy E2E showed the distroless API runtime breaks the local subprocess job backend because commands such as echo and sh are not present; NMP_API_RUNTIME_BASE remains available for explicit distroless experiments.

Changes

  • Keep the default nmp-api final runtime base as nmp-python-base so Docker/local subprocess jobs retain shell/coreutils compatibility.
  • Keep NMP_API_RUNTIME_BASE as a bake override for testing alternate API runtime bases, including NVIDIA distroless Python.
  • Preserve the previous root runtime UID for nmp-api; Platform-Deploy E2E showed non-root UID 1000 cannot access existing root-owned /data/files_storage mounts.
  • Raise aiohttp runtime remediation floors to >=3.14.3,<4 for Auditor, Safe Synthesizer, and Unsloth images.
  • Remove stale inherited system GitPython and jupyterlab copies from the Unsloth image.
  • Wire the Docker E2E harness to start a ClickHouse sidecar for the API container.
  • Remove the draft CVE_SUMMARY.md file.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification:

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

  • uv run --frozen pytest packages/nmp_testing/tests/unit/test_e2e_docker_backend.py -v - passed.
  • docker buildx bake --print nmp-api-docker | rg -n 'NMP_API_RUNTIME_BASE|nmp-python-base|distroless|dockerfile|target' - passed; confirmed NMP_API_RUNTIME_BASE=nmp-python-base.
  • git diff --check - passed.
  • git diff --check origin/main...HEAD && git diff --check && git diff --cached --check - passed earlier in this PR.
  • docker buildx bake --print nmp-api-docker - passed bake parse after the runtime UID compatibility fix.
  • docker buildx bake --print nmp-api-docker auditor-tasks-docker safe-synthesizer-tasks-docker nmp-unsloth-training - passed bake parse before the follow-up UID/runtime-default fixes.
  • make docker-print TARGET=docker-cpu - passed bake parse.
  • make docker-print TARGET=docker-gpu - passed bake parse.
  • make docker-print TARGET=docker-auditor - passed bake parse.
  • make docker-print TARGET=docker-python-base - passed bake parse.
  • make docker-print TARGET=nmp-unsloth - passed bake parse.
  • make docker-print TARGET=nmp-automodel - passed bake parse.
  • docker run --rm --platform linux/amd64 --entrypoint python nvcr.io/nvidia/distroless/python:3.13-v4.0.9 -c '...' - confirmed Python 3.13.14, UID/GID 1000 by default, /home/nvs, and writable /tmp.
  • docker run --rm --user 1000:1000 -v <root-owned-dir>:/data --entrypoint python nvcr.io/nvidia/distroless/python:3.13-v4.0.9 -c 'pathlib.Path("/data/files_storage").stat()' - reproduced the Platform-Deploy PermissionError; the same command with --user 0:0 passed.
  • Platform-Deploy run 31440874724 against 58c0f52e showed nmp-api distroless failures in Docker E2E: subprocess jobs could not start echo or sh.
  • uv run pre-commit run -a - blocked before hooks ran because fetching https://github.com/norwoodj/helm-docs/ returned HTTP 503 on repeated attempts.
  • BUILD_ARCH=linux/amd64 docker buildx bake --load nmp-api-docker - attempted before this push and blocked before project layers because this environment cannot pull ghcr.io/astral-sh/uv:0.9.14 (failed to fetch oauth token: denied).

Follow-up validation in progress:

Summary by CodeRabbit

  • New Features

    • Added support for Python 3.13 distroless runtime images.
    • Added configurable ClickHouse support for Docker-based end-to-end testing, including readiness checks and image selection.
    • Improved local Nemo command execution with automatic environment detection and telemetry disabled by default.
  • Bug Fixes

    • Updated aiohttp requirements to supported 3.14.3-or-newer versions across services.
    • Improved runtime compatibility and reduced unnecessary container setup.
  • Tests

    • Added coverage for ClickHouse startup, networking, cleanup, configuration overrides, and local Nemo execution.

@github-actions github-actions Bot added the fix label Aug 10, 2026
Comment thread CVE_SUMMARY.md Outdated
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 32013/40717 78.6% 63.4%
Integration Tests 18566/38643 48.0% 20.8%

Comment thread packages/nmp_testing/src/nmp/testing/e2e/docker.py
@mckornfield
mckornfield marked this pull request as ready for review August 11, 2026 04:07
@mckornfield
mckornfield requested review from a team as code owners August 11, 2026 04:07
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR adds Python 3.13 distroless runtime support, updates aiohttp remediation constraints and package cleanup, adds ClickHouse sidecar orchestration to Docker E2E runs, and updates local Nemo command execution.

Changes

Runtime and E2E container updates

Layer / File(s) Summary
Python 3.13 distroless runtime images
docker-bake.hcl, docker/Dockerfile.bake, docker/Dockerfile.nmp-api, docker/Dockerfile.nmp-core
API and core builds select Python 3.13 distroless runtime bases. The runtime images copy BusyBox utilities, use numeric ownership, and set PYTHONPATH.
Container dependency and package cleanup
docker/Dockerfile.auditor-tasks, docker/Dockerfile.nmp-unsloth-training, docker/Dockerfile.safe-synthesizer-tasks
The Dockerfiles require aiohttp>=3.14.3,<4. Training-image cleanup removes GitPython, Git, and JupyterLab packages.
ClickHouse E2E sidecar orchestration
e2e/k8s/values/kind.yaml, packages/nmp_testing/src/nmp/testing/e2e/docker.py
Kind runs configure ClickHouse resources. The Docker E2E backend starts ClickHouse, waits for readiness, configures API networking, collects logs, and performs cleanup.
ClickHouse E2E validation
packages/nmp_testing/tests/unit/test_e2e_docker_backend.py
Unit tests verify fake-container behavior, sidecar configuration, startup ordering, cleanup, API networking, and image overrides.
Local Nemo command resolution
packages/nmp_testing/src/nmp/testing/utils.py, packages/nmp_testing/tests/unit/test_utils.py
Local Nemo execution uses a repository virtual-environment executable when available and falls back to frozen uv run. Tests verify command selection and telemetry overrides.

Sequence Diagram(s)

sequenceDiagram
  participant DockerE2EBackend
  participant ClickHouseContainer
  participant APIContainer
  DockerE2EBackend->>ClickHouseContainer: create and start sidecar
  DockerE2EBackend->>ClickHouseContainer: poll health endpoint
  DockerE2EBackend->>APIContainer: configure intake with ClickHouse network URL
  DockerE2EBackend->>APIContainer: start API container
Loading

Suggested reviewers: ironcommit

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: reducing Docker runtime CVE exposure and fixing E2E tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cve-pass-08-10/mck

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/nmp_testing/tests/unit/test_e2e_docker_backend.py (1)

14-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Replace quoted FakeDockerContainer annotations.

Add from __future__ import annotations and remove the quotes from all listed annotations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/nmp_testing/tests/unit/test_e2e_docker_backend.py` at line 14, Add
from __future__ import annotations at the top of the module, then update the
FakeDockerContainer annotations, including the instances declaration, to use
unquoted type references throughout the file.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/nmp_testing/tests/unit/test_e2e_docker_backend.py`:
- Line 14: Add from __future__ import annotations at the top of the module, then
update the FakeDockerContainer annotations, including the instances declaration,
to use unquoted type references throughout the file.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8e819b07-43c9-409c-8af7-f1dd63ea819e

📥 Commits

Reviewing files that changed from the base of the PR and between 33cecaf and fc2bda9.

📒 Files selected for processing (8)
  • docker-bake.hcl
  • docker/Dockerfile.auditor-tasks
  • docker/Dockerfile.nmp-api
  • docker/Dockerfile.nmp-unsloth-training
  • docker/Dockerfile.safe-synthesizer-tasks
  • e2e/k8s/values/kind.yaml
  • packages/nmp_testing/src/nmp/testing/e2e/docker.py
  • packages/nmp_testing/tests/unit/test_e2e_docker_backend.py

@mckornfield
mckornfield requested a review from ironcommit August 11, 2026 18:31
@mckornfield
mckornfield added this pull request to the merge queue Aug 11, 2026
@mckornfield
mckornfield removed this pull request from the merge queue due to a manual request Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docker-bake.hcl`:
- Around line 39-41: Update the NMP_API_RUNTIME_BASE variable default from
root-distroless-base-3-13 to nmp-python-base so nmp-api-docker uses the
shell-compatible base by default, while preserving support for explicitly
selecting the distroless base.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6370d5a8-3c31-4e79-b13d-faf3ff79c1a0

📥 Commits

Reviewing files that changed from the base of the PR and between fc2bda9 and bc25971.

📒 Files selected for processing (4)
  • docker-bake.hcl
  • docker/Dockerfile.bake
  • docker/Dockerfile.nmp-api
  • docker/Dockerfile.nmp-core
🚧 Files skipped from review as they are similar to previous changes (1)
  • docker/Dockerfile.nmp-api

Comment thread docker-bake.hcl
@mckornfield mckornfield changed the title fix(docker): reduce runtime CVE exposure fix(docker): reduce runtime CVE exposure, fix e2e tests Aug 11, 2026
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nmp_testing/src/nmp/testing/e2e/docker.py`:
- Around line 331-337: Update the existing ClickHouse cleanup block around
self.clickhouse_container.stop() to invoke the container’s force-removal
fallback when graceful stopping raises, using the same removal behavior as
stop(). Only clear self.clickhouse_container after the fallback attempt,
preserving cleanup of the attached sidecar before subsequent network removal.
- Around line 277-303: Update ClickHouse startup around
clickhouse_container.with_exposed_ports and _wait_for_clickhouse_healthy so the
exposed host port is bound only to loopback, or replace the host-based health
probe with an internal-network probe using the ClickHouse network alias.
Preserve the existing health-check behavior while preventing unauthenticated
ClickHouse access from all host interfaces.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 408d01a4-5b20-429b-bc8c-94ab3a331bec

📥 Commits

Reviewing files that changed from the base of the PR and between d5e9e4e and 8284c0f.

📒 Files selected for processing (10)
  • docker-bake.hcl
  • docker/Dockerfile.auditor-tasks
  • docker/Dockerfile.bake
  • docker/Dockerfile.nmp-api
  • docker/Dockerfile.nmp-core
  • docker/Dockerfile.nmp-unsloth-training
  • docker/Dockerfile.safe-synthesizer-tasks
  • e2e/k8s/values/kind.yaml
  • packages/nmp_testing/src/nmp/testing/e2e/docker.py
  • packages/nmp_testing/tests/unit/test_e2e_docker_backend.py
🚧 Files skipped from review as they are similar to previous changes (9)
  • docker/Dockerfile.safe-synthesizer-tasks
  • e2e/k8s/values/kind.yaml
  • docker/Dockerfile.nmp-api
  • docker/Dockerfile.auditor-tasks
  • docker/Dockerfile.nmp-unsloth-training
  • docker/Dockerfile.nmp-core
  • docker-bake.hcl
  • docker/Dockerfile.bake
  • packages/nmp_testing/tests/unit/test_e2e_docker_backend.py

Comment thread packages/nmp_testing/src/nmp/testing/e2e/docker.py
Comment thread packages/nmp_testing/src/nmp/testing/e2e/docker.py
@mckornfield
mckornfield added this pull request to the merge queue Aug 12, 2026
Signed-off-by: Matt Kornfield <mkornfield@nvidia.com>
@mckornfield
mckornfield removed this pull request from the merge queue due to a manual request Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/nmp_testing/src/nmp/testing/utils.py`:
- Around line 42-49: Update the local CLI resolution in
packages/nmp_testing/src/nmp/testing/utils.py:42-49 to select a candidate only
when it is a regular executable file, while preserving the repository-boundary
validation. In packages/nmp_testing/tests/unit/test_utils.py:52-72, mark the
valid fixture executable and add coverage verifying that a non-executable
candidate is skipped in favor of the fallback.

In `@packages/nmp_testing/tests/unit/test_utils.py`:
- Around line 74-90: Update
test_falls_back_to_uv_when_not_running_from_repo_virtualenv to set VIRTUAL_ENV
to an external virtualenv path containing the nemo executable instead of
deleting the variable, so run_nemo_local exercises the relative_to rejection
branch. Keep the existing uv command assertion unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 2f16739c-6081-4d47-ad3c-dd15cf615014

📥 Commits

Reviewing files that changed from the base of the PR and between 8284c0f and a3a7e9b.

📒 Files selected for processing (2)
  • packages/nmp_testing/src/nmp/testing/utils.py
  • packages/nmp_testing/tests/unit/test_utils.py

Comment thread packages/nmp_testing/src/nmp/testing/utils.py
Comment thread packages/nmp_testing/tests/unit/test_utils.py
@mckornfield
mckornfield added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit a8bd92b Aug 12, 2026
57 checks passed
@mckornfield
mckornfield deleted the cve-pass-08-10/mck branch August 12, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants