Skip to content

Write the guarded runner devrun (copy-in, isolation, network phases, lifecycle) #3

Closed

Description

@flyingrobots
.dag: issue-dag/2
.id: flyingrobots/devcontainers#3
.kind: task
.type: feature
.blocked_by: [flyingrobots/devcontainers#2]
.size_hours: 8
source: Maintainer rule of 2026-11-08 (no host builds; ULTRAMAX PARANOIA hygiene)

Feature

Read docs/hygiene.md sections 1 to 7 and 10.
Write bin/devrun (Python 3.9, standard library only): devrun <project> <repo> (--commit SHA | --history BASE..HEAD | --worktree) [--rust VERSION] [--fetch] [--network] [--export PATH ...] -- COMMAND.
Build the source tarball on the host: git archive, git bundle, or git ls-files. Check and rewrite every member on the host (no .git, no escaping symlink, no setuid or special file, owner 10001) before it reaches Docker.
Run phase 1 (cargo fetch --locked, network) and phase 2 (COMMAND, --network none) in separate containers named <project>-dev-run, with every privilege rule in section 2 and only the named volumes in section 5.
Wrap the run in git-locks (host/heavy-work and host/docker/<project>-dev/) with a timeout below the lease, and remove the container on every exit path.
Export only the declared paths, as regular files, into a fresh host folder outside every repository.
Add tests for the tar sanitizer and the argument handling, and one real-Docker smoke test.
Run every Docker command through the code under test or the workstation git-locks keys host/docker/devcontainers-dev/ and host/heavy-work. Never build or test on the host outside Docker.

1. Background Context

Builds and tests must not run on the host. Containers must not see or change any host repository (maintainer, 2026-11-08). The rules are in docs/hygiene.md.

2. Problem Description

No safe way exists to run a repository's gates in a container.

2b. Proposed Solution

A host-side runner that builds and checks the source tarball itself, then drives two short-lived, locked-down containers and exports only declared outputs.

2c. Alternatives considered and rejected

  • Bind-mount the repository: rejected by the maintainer.
  • Check the tarball inside the container: rejected, because a hostile archive must be refused before it reaches Docker.

2d. Acceptance Criteria

  • The sanitizer refuses .git, absolute or escaping symlinks, setuid and setgid bits, device files, and pipes, and it sets every owner to 10001.
  • --history produces a clone whose HEAD equals the requested SHA and whose origin/main equals the base.
  • Phase 2 runs with --network none, --read-only, --cap-drop ALL, --security-opt no-new-privileges, user 10001, and limits.
  • A timeout or a failing command removes the container.
  • Exports contain only regular files, in a fresh folder.

2e. Test Plan

Golden: devrun devcontainers . --commit HEAD -- true with a small test image.
Edges: an empty repository; a path with spaces; a commit that is not reachable.
Known failure modes: a tarball with a symlink to /etc; a .git file at a nested path.
Fuzz and stress: random tar member lists through the sanitizer.

3. Prerequisites

4. Scope

In:

  • bin/devrun core: copy modes, sanitizer, privileges, network phases, lifecycle, locks, and exports.

Out:

Size: about 8 hours of focused work.

5. Why now

All local validation now goes through containers.

6. Risks

A gap in the sanitizer lets a hostile archive in. Test it with crafted archives.

7. Definition of Done

The runner is merged with tests, and a real run passes.

8. Stakeholders

  • James Ross (maintainer).

9. Related Issues

Activity

  1. changed the title [-]Write the guarded runner devrun with a Docker litter audit[/-] [+]Write the guarded runner devrun (copy-in, isolation, network phases, lifecycle)[/+] on Nov 8, 2026
  2. flyingrobots commented on Nov 8, 2026

    @flyingrobots
    OwnerAuthor

    Runner obligations from the Baker Street review of #6. docs/hygiene.md on that PR specifies them, and nothing enforces them until bin/devrun lands. The current feat/devrun head contradicts the first three.

    1. Work volume at /work. The copy is the root of a <project>-work volume mounted at /work, with working directory /work. Today bin/devrun copies into /scratch/work, under the persistent scratch volume.
    2. Empty the work and scratch volumes completely before each copy-in, hidden entries included. Today the prep step removes only /scratch/work, /scratch/in and /scratch/out, so a planted /scratch/.cargo/config.toml survives. Cargo reads .cargo/config.toml in the working directory and in every parent directory. A hostile run can also remove write permission from its own directories, so prep must restore it first, and it must fail if any entry is left.
    3. No repository-chosen code in the fetch phase (hygiene section 3). The fetch copy must have no .cargo/config* and no rust-toolchain* files. cargo fetch must run with RUSTUP_TOOLCHAIN=<image version>, RUSTC=/usr/local/cargo/bin/rustc, and empty RUSTC_WRAPPER and RUSTC_WORKSPACE_WRAPPER. Evidence: in the image, cargo fetch --offline ran a repository build.rustc-wrapper, build.rustc and path toolchain, and these overrides stopped all four hooks, rustc-workspace-wrapper included.
    4. Check every phase exit code. After the fetch phase, the re-prep and re-copy containers currently ignore their exit status.
    5. Lock key host/docker/<project>-dev-run/, the workstation registry form host/docker/<exact-container-name>/.
    6. CI detection with GITHUB_ACTIONS=true, not CI=true.
    7. Integration tests:
      • A first run plants /work/.cargo/config.toml and /scratch/.cargo/config.toml with an alias, and the next run must not see either.
      • A fetch with each hook (wrapper, build.rustc, path toolchain) must not invoke it.
      • A read-only directory left by a run must not stop the next prep from emptying the volumes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions