Skip to content

Make the Devcontainer Snippets' Read-Only Mounts Actually Read-Only - #3868

Merged
ptr727 merged 1 commit into
developfrom
fix/devcontainer-readonly-mounts
Nov 4, 2026
Merged

ptr727 merged 1 commit into
developfrom
fix/devcontainer-readonly-mounts

Conversation

@ptr727

@ptr727 ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Part of #3860.

Why

Each catalog devcontainer snippet declared its public key and allowed_signers mounts in the object form with "readonly": true. The Dev Containers CLI drops that key, so both host files were writable from inside the container. allowed_signers is the file git verify-commit and git log --show-signature trust, so a process in the container could add a signer that outlives the container. docs/devcontainer.md called both mounts read-only.

What Changed

  • Each snippet declares its mounts in the string form, the route the Dev Container metadata reference documents as taking the same values as Docker's --mount flag. The gh config mount moves with them, so the list holds one form, and it stays read-write.
  • docs/devcontainer.md states why the string form is used, so a later tidy does not restore the object form. Its mode table was already what the mounts should do, and now matches what they do.

Verification

Each snippet ran through devcontainer up with post-create, using the Dev Containers extension's bundled CLI (0.469.0) on Docker Desktop's WSL2 backend, from a scratch tree and a synthetic home.

Check Before, on #3866's images After, Python After, .NET
id_ed25519.pub in docker inspect RW=true RW=false RW=false
allowed_signers in docker inspect RW=true RW=false RW=false
.config/gh in docker inspect RW=true RW=true RW=true
Append to each read-only file as vscode not run here, the issue measured it succeeding refused refused
Create and remove a file in .config/gh not run works works
Lines in the host's files afterward not run unchanged unchanged

up exited 0 for each snippet, so the read-only mounts break neither the feature build nor post-create. The full test suite was not run, since no test parses these mounts and the change touches no code.

Not measured: a commit signed and verified in the container with these mounts. The synthetic home holds no real key, so this probe shows the signers file is readable at its path and refuses a write, and stops there.

Not in This Change

🤖 Generated with Claude Code

The Dev Containers CLI drops `readonly` from a mount's object form.
So the host's `allowed_signers`, the file commit verification trusts, was writable from inside the container, while the docs called it read-only.
The string form passes straight to Docker's `--mount` flag and honors it.
Copilot AI lite review requested due to automatic review settings November 4, 2026 17:26
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@ptr727

ptr727 commented Nov 4, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 50bec2e69eb46fb7238e4ea986fbf7071fab4e76, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot AI 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.

🟢 Approval recommended

No active review issues remain, and the changes consistently implement the documented read-only mount behavior while preserving writable GitHub CLI configuration.

No open issues 🎉

What changed in this PR

This pull request updates the catalog Dev Container snippets so SSH public key and Git signer mounts are actually read-only while keeping the GitHub CLI configuration writable. It also documents the required mount syntax.

Changes:

  • Replaces object-form mounts with Docker-compatible string-form mounts.
  • Adds read-only bind mounts for the public key and allowed_signers files.
  • Documents why the string form is required and aligns the documentation with the configuration.
File Description
docs/​devcontainer.md Documents the string-form mount requirement and read-only behavior.
catalog/​snippets/​devcontainer/​python/​devcontainer.json Applies read-only string-form mounts to the Python snippet.
catalog/​snippets/​devcontainer/​dotnet/​devcontainer.json Applies read-only string-form mounts to the .NET snippet.

Review effort: Lite

@codecov

codecov Bot commented Nov 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.31%. Comparing base (b38e084) to head (50bec2e).
⚠️ Report is 96 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3868      +/-   ##
===========================================
+ Coverage    81.60%   83.31%   +1.70%     
===========================================
  Files           26       29       +3     
  Lines         9070     9956     +886     
===========================================
+ Hits          7402     8295     +893     
+ Misses        1668     1661       -7     
Flag Coverage Δ
python-3.13 83.31% <ø> (+1.70%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit fcb0af5 into develop Nov 4, 2026
14 checks passed
@ptr727
ptr727 deleted the fix/devcontainer-readonly-mounts branch November 4, 2026 17:50
ptr727 added a commit that referenced this pull request Nov 4, 2026
#3870)

## Summary

Promotes #3866 and #3868 to `main`.

Closes #3858.
Closes #3860.

- **#3866** repoints the catalog devcontainer snippets at images that
start, `python:3-3.14-bookworm` and `dotnet:2-10.0`. It also documents
why those tags are kept by hand.
- **#3868** moves the snippets' mounts to the string form, so the public
key and `allowed_signers` mounts are read-only rather than writable from
the container.

Each snippet was started with post-create on a Windows host's Docker
Desktop, from a scratch tree and a synthetic home. Each feature pull
request's body holds that measurement.

`ptr727/ESPHome-Config` carries the Python snippet with both defects,
and stays as it is until a resync reaches it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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.

2 participants