Skip to content

fix: harden docker cloud workspaces - #122

Merged
delete-cloud merged 2 commits into
mainfrom
feat/adr-0019-docker-hardening
May 9, 2026
Merged

delete-cloud merged 2 commits into
mainfrom
feat/adr-0019-docker-hardening

Conversation

@delete-cloud

@delete-cloud delete-cloud commented May 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • update ADR-0019 status, implementation notes, and acceptance criteria to match current main
  • harden Docker cloud workspace containers with no network, dropped capabilities, no-new-privileges, pids/cpu/memory limits, and configured exec user
  • require configured Docker workspace images to be included in an explicit allowlist

Verification

  • uv run pytest tests/coding_agent/environment/test_docker_workspace_provider.py::test_docker_workspace_provider_provisions_runnable_container tests/coding_agent/environment/test_docker_workspace_provider.py::test_docker_workspace_provider_applies_configured_container_hardening tests/coding_agent/environment/test_docker_workspace_provider.py::test_docker_workspace_provider_rejects_image_outside_allowlist -q
  • uv run pytest tests/coding_agent/environment/test_docker_workspace_provider.py tests/coding_agent/environment/test_docker_workspace_provider_transfer.py tests/coding_agent/environment/test_workspace_archive.py -q
  • uv run basedpyright src/coding_agent/environment/docker_workspace_provider.py tests/coding_agent/environment/test_docker_workspace_provider.py
  • uv run pytest tests/coding_agent/environment/ tests/ui/test_execution_binding.py tests/ui/test_http_server.py tests/ui/test_session_manager_runtime.py -k "cloud or workspace or binding" -v
  • uv run pytest tests/cli/ -k "remote or attach" -v
  • git diff --check

Summary by CodeRabbit

  • New Features
    • Added support for remote cloud workspace deployment with Docker-backed provisioning and cleanup.
    • Implemented hardened container execution with network isolation, capability restrictions, resource limits, and image allowlist validation.
    • Added CLI commands for remote workspace management (remote add/list/remove, attach, remote repl).

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@delete-cloud has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 58 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4cc5936f-220a-4843-b62c-2a156affaba3

📥 Commits

Reviewing files that changed from the base of the PR and between 28d79cf and 9098b36.

📒 Files selected for processing (1)
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py
📝 Walkthrough

Walkthrough

This PR implements Docker container hardening configuration for the workspace provider, adding image allowlist validation and configurable network/security/resource constraints applied during container startup. The ADR status is updated to reflect completed implementation items.

Changes

Docker Container Hardening Implementation

Layer / File(s) Summary
Config Schema and Constants
src/coding_agent/environment/docker_workspace_provider.py
Default Docker runtime configuration constants introduced (image, CPU quota, memory limit, PID limit, network mode). Config dataclass extended with fields for image_allowlist, network, cpus, memory, pids_limit.
Parsing and Validation
src/coding_agent/environment/docker_workspace_provider.py
Config parsing validates image allowlist, network, CPU/memory/PID limits. Selected Docker image is rejected if not in image_allowlist. Helper functions updated to support optional defaults. New _positive_int validator added.
Docker Execution
src/coding_agent/environment/docker_workspace_provider.py
docker run command construction updated to apply network mode, drop Linux capabilities, set no-new-privileges, apply PID/CPU/memory limits, and conditionally set --user.
Tests and Documentation
tests/coding_agent/environment/test_docker_workspace_provider.py, docs/adr/0019-remote-client-cloud-workspace-deployment.md
Existing test assertions updated for complete hardening flags. New tests verify configured hardening application and image allowlist rejection. ADR status changed to "Accepted / implemented through PR #121"; implementation status section and acceptance criteria checkboxes filled.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • delete-cloud/Coding-Agent-Loop#121: Main PR implements and completes the ADR-0019 proposals adding Docker workspace provider, server wiring, and related tests/features described in the ADR.
  • delete-cloud/Coding-Agent-Loop#113: Introduces the Docker workspace provider implementation and tests that this PR extends by adding configurable container runtime/hardening options and validation.
  • delete-cloud/Coding-Agent-Loop#120: Also modifies DockerWorkspaceProvider in the same file, adding provider readiness/check_readiness behavior alongside this PR's hardening configuration.

Poem

🐰 A hardened bunny workspace appears,
With limits and allowlists to calm our fears!
Docker runs tight with no-new-privileges fair,
Capabilities dropped—security in the air! 🔒

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: harden docker cloud workspaces' accurately and concisely summarizes the main change: hardening Docker containers for cloud workspaces through security constraints.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/adr-0019-docker-hardening

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@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)
coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py (1)

729-729: 💤 Low value

Consider escaping or using raw string for regex pattern.

The static analysis hint is valid: the pattern contains a literal dot that could match any character in regex. While this works in practice, using a raw string or escaping would make the intent clearer and prevent potential false matches.

📝 Suggested fix
     with pytest.raises(
         ValueError,
-        match="cloud_workspace.image is not allowed by image_allowlist",
+        match=r"cloud_workspace\.image is not allowed by image_allowlist",
     ):

As per coding guidelines, run ruff for code formatting with command: uv run ruff format src/.

🤖 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
`@coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py`
at line 729, The regex used in the test assertion (match="cloud_workspace.image
is not allowed by image_allowlist") should use a raw/escaped pattern so the
literal dot isn't treated as "any char": update the match to a raw/escaped
string (e.g., r"cloud_workspace\.image is not allowed by image_allowlist") in
the test in
coding_agent/tests/coding_agent/environment/test_docker_workspace_provider.py
and re-run ruff formatting (uv run ruff format src/) to satisfy style checks.
🤖 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
`@coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py`:
- Line 729: The regex used in the test assertion (match="cloud_workspace.image
is not allowed by image_allowlist") should use a raw/escaped pattern so the
literal dot isn't treated as "any char": update the match to a raw/escaped
string (e.g., r"cloud_workspace\.image is not allowed by image_allowlist") in
the test in
coding_agent/tests/coding_agent/environment/test_docker_workspace_provider.py
and re-run ruff formatting (uv run ruff format src/) to satisfy style checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 62bfa11a-1175-454b-9df5-572ec3fd47d2

📥 Commits

Reviewing files that changed from the base of the PR and between 0253d7d and 28d79cf.

📒 Files selected for processing (3)
  • coding-agent/docs/adr/0019-remote-client-cloud-workspace-deployment.md
  • coding-agent/src/coding_agent/environment/docker_workspace_provider.py
  • coding-agent/tests/coding_agent/environment/test_docker_workspace_provider.py

@delete-cloud
delete-cloud merged commit 7a4e7ed into main May 9, 2026
1 check passed
@delete-cloud
delete-cloud deleted the feat/adr-0019-docker-hardening branch May 9, 2026 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant