fix(sandbox): stop Docker recreating deleted files in the project - #44
Merged
Merged
Conversation
…stent paths and add corresponding tests
…better readability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes deleted files reappearing in the project after starting a new Docker sandbox session.
Problem
append_filesystem_mountsadded a bind mount for every denied-read and denied-write path inside the project, whether or not the path exists on the host. When a mount target is missing inside the bind-mounted project folder, Docker creates a placeholder at that path on the host: an empty file for denied-read file paths, an empty directory for denied-write paths.So when a user deleted one of these files (manually or via git) and started a new sandboxed session, the file came back every time.
Fix
Skip the mount for a denied path that doesn't exist on the host (
src/handlers/run/docker_sandbox.rs). There's nothing to hide or protect, and it's the same kind of check already applied to paths outside the project folder.Trade-offs
Paths that exist when the session starts behave exactly as before. For paths that don't exist at startup:
.env) is visible to the agent. Before, the placeholder mount hid it for the whole session.Possible follow-up: mount missing paths as empty in-memory mounts inside the container and delete any placeholders the sandbox itself created when the session ends. That would keep strict protection without leaving files behind.
Testing
docker_run_command_skips_mounts_for_nonexistent_denied_pathscargo test docker_sandbox)