Repository navigation
Tags
Tags
fix(build): bound outside-context Dockerfiles to the workspace (#157) * fix(build): bound outside-context Dockerfiles to the workspace v0.5.5 (#156) reads a build.dockerfile outside the build context from the host and injects it into the context tar. The path comes from an untrusted devcontainer.json and nothing bounded it, so an absolute path, ../ traversal, ${localEnv:...} or a symlink could name any file the process can read; the daemon's parse error ("unknown instruction: ...") then echoes its first line into the build output. - runtime/docker: locateDockerfile is the only host read of the Dockerfile. It resolves symlinks on both sides and reads a file outside the context only if it is a regular file of at most 1 MiB inside BuildSpec.WorkspaceRoot; an in-context file's host copy must resolve inside the context or the workspace. Otherwise it returns *runtime.DockerfileRefusedError, naming the configured path, before the context is tarred or the daemon is called. prePullBaseImages takes the contents it read instead of reading the path again. - runtime: BuildSpec.WorkspaceRoot; empty allows nothing outside the context. The engine sets it to LocalWorkspaceFolder for the devcontainer build and compose service builds. - config: Resolve rejects, lexically, a build.dockerfile outside both the workspace and the context with *ConfigInvalidError. - In-context Dockerfiles and the #156 layout (.devcontainer/Dockerfile with "context": "..") build as in v0.5.5. - Tests: refusal cases in both packages, a no-daemon BuildImage test, and an integration test with a hostile config that asserts through a recording socket proxy that no build or pull reaches the daemon and that the secret appears in no event or error. Refs #156, crunchloop/dap#8967 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(build): read the bounded Dockerfile through os.Root The bound was checked on a resolved pathname and the file then opened by pathname again, so a directory on the way swapped for a symlink in between could carry the read outside the workspace; SameFile only compared the stat and the open, which both followed the swap. readDockerfile now opens os.Root on the resolved root and stats, opens and reads the file through it, so no symlink or ".." can leave the root whatever the tree does after the check. Any failure to open it there, after the check found it, is a refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(build): confine in-context Dockerfile reads to the workspace root os.OpenRoot opens the root itself by path. For a Dockerfile inside the context, the context was tried first as the root; a context inside the workspace is a folder the repository controls, so it could be swapped for a symlink between the check and the open. Try the workspace root first: its own path lies outside what the repository controls. The context remains the root only for a context outside the workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: bilby91 <2201079+bilby91@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
fix(config): resolve build.dockerfile against devcontainer.json, not … …the context (#156) The spec resolves build.dockerfile relative to the folder holding devcontainer.json, like build.context. We passed it through unchanged and the runtime asked Docker for it inside the context tar, so {"dockerfile": "Dockerfile", "context": ".."} looked for <repo>/Dockerfile and failed with "open Dockerfile: no such file or directory". - config: BuildSource.Dockerfile is now an absolute host path. Both dockerfile and context are resolved after variable substitution, so ${localWorkspaceFolder}/... is no longer joined onto the config folder. - runtime/docker: BuildSpec.Dockerfile may be absolute. Inside the context it becomes the context-relative name; outside it is appended to the context tar as .dockerfile.<content hash>, as `docker build -f` does for the reference CLI. prePullBaseImages reads the host path. - tests: config resolution cases, locateDockerfile / tar injection unit tests, the dcvm layout and an outside-context build end to end. Integration fixtures that relied on the bug now use "../Dockerfile". Co-authored-by: bilby91 <2201079+bilby91@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
fix(features): convert non-string option values like the reference CLI ( #155) * fix(features): convert non-string option values like the reference CLI A string-typed (or untyped) feature option given a non-string JSON value failed with `option "packages" expects string, got []interface {}`. The reference CLI never type-checks option values: it writes each one into devcontainer-features.env through a JavaScript template literal, so ["jq","tree"] installs as jq,tree. MergeOptions now converts such values as JavaScript's String() does: arrays join with "," (null elements empty, nested arrays flattened), numbers use JavaScript's formatting (1e6 -> 1000000, 1e21 -> 1e+21), booleans and null take their literal form. Objects are still rejected and boolean options stay strict. Enums are checked against the converted string, and a WarnFeatureOptionCoerced warning reports each conversion. Non-string defaults and undeclared options are converted too, so feature.env never carries Go formatting such as [jq tree]. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1zV4YDcDbkxa8xkQS5dMA * fix(features): accept "true"/"false" for boolean options, format json.Number like JavaScript The reference CLI never type-checks option values and writes "true" and true identically, so a boolean option given the string "true" or "false" now takes that boolean with a feature_option_coerced warning. Other non-boolean values still error. A json.Number is formatted through its float64 value, as JavaScript parses every JSON number as a double: "1e6" is 1000000, "1.50" is 1.5. Adds edge-case tests checked against node 22's String() (nested empty arrays, null elements, subnormal and max doubles, -0, precision loss) and a test that a second merge of merged options is a no-op, which SameOptions relies on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M1zV4YDcDbkxa8xkQS5dMA --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
fix(compose): hash symlinked local-feature content for reattach (#145) hashDirContent only walked regular files, but GenerateBuildContext copies a symlink in a local feature as the content it names. Editing the target of a symlinked install.sh outside the feature directory left the compose inputs hash unchanged, so Up reattached to the image built from the old content. Hash symlinks as their resolved content, and fail the hash (no label, full path) on a symlink to a directory, which the build context copy cannot handle either. Cut 0.5.3 in the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMTBosSzdEvXqCZ9c7VyLk
fix(compose): reattach existing projects without fetching features (#144 ) Every compose-source Up ran createFreshCompose -> layerFeatures, which fetched each feature from its registry and rebuilt dc-go-final-<id> even when the project's containers already existed. A restart of a compose workspace with features therefore needed registry egress and paid a final-image rebuild; without egress (a docker-in-docker workspace in a guest with no route to ghcr.io) it could not start at all. The image path's attachExisting never had this cost. - Stamp dev.containers.compose-inputs-hash on the primary container: a digest of the container-shaping part of the resolved config (features as requested, with options; local feature content), the loaded compose project, the primary base image ID and the engine options that reshape the project. On a later Up with a matching label and an unmoved image tag, reattachCompose merges the metadata from the existing image's label and brings the project up against the existing images (native under the caller's AdoptExisting with present sidecar images not rebuilt; shell-out with --no-recreate). Any miss takes the full path unchanged. - Escape $ in the devcontainer.metadata LABEL: the Dockerfile parser expanded ${devcontainerId}, so docker-in-docker's volume source was recorded as "dind-var-lib-docker-" and every read of the label lost the per-workspace volume name. - OCI feature cache is local-first for digest refs and exact X.Y.Z tags; floating tags stay online-first and fall back to the recorded resolution only when the registry is unreachable. Extraction is atomic. Adds DiskStoreOptions.OCITransport and ContainerDetails.ImageRef. Cut 0.5.2 in the changelog. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UMTBosSzdEvXqCZ9c7VyLk
fix(compose): carry volume and tmpfs mounts onto the primary service (#… …143) composeBindMounts kept only bind mounts from ResolvedConfig.Mounts, so volume and tmpfs mounts from devcontainer.json and feature/image metadata never reached a compose-source devcontainer. docker-in-docker declares dind-var-lib-docker-${devcontainerId} -> /var/lib/docker as a volume; without it the inner dockerd's data root sits on the container's overlay root and every `docker run` fails with EINVAL (overlay on overlay). The image path already passed every type through. Add compose.Mount and Override.ExtraMounts and apply them on both backends: - native: ApplyRunOverride appends volume/tmpfs service volumes and declares each named volume on project.Volumes so ensureNamedVolumes creates it as <project>_<name> with the project labels; - shell-out: WriteRunOverride emits the same service volumes and a top-level volumes: entry for each named volume. A target the user's compose service already mounts keeps the user's entry; a top-level volume the user already declares is left as is. Binds (ExtraBindMounts) are unchanged. ${devcontainerId} is already substituted by applyMetadataMerge, as on the image path. Cut 0.5.1 in the changelog. Claude-Session: https://claude.ai/code/session_0172W3jer4F1sxWk3US29Muz Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
docs(changelog): cut v0.5.0 (#138) Everything since v0.4.2 becomes 0.5.0: a minor bump, not a patch, because the line carries breaking removals — the Apple Containers backend, checkpoint/restore with the Podman backend, the per-backend capability gating, and the `compose.Plan.Validate` signature. Also backfills the 0.4.3 section. v0.4.3 was tagged at #120 (UpOptions.AdoptExisting) without a changelog cut, so that release shipped with no entry and the compare-link chain skipped it, pointing Unreleased at v0.4.2 while a later tag existed. The entry is written from the shipped behaviour and the chain is repaired. Co-authored-by: bilby91 <2201079+bilby91@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
feat(compose): AdoptExisting option for resume — reattach containers … …unconditionally (#120) On resume, a restored workspace's containers must be reattached exactly as left. The primary service's feature-layered image is rebuilt every boot with a fresh digest, so the config-hash always drifts and ensureService recreates it — abandoning the container's writable upperdir and binding a new empty anonymous volume (the postgres data, the in-container $HOME). New UpOptions.AdoptExisting (threaded to compose.Plan) makes ensureService reuse any existing (project,service) container unconditionally: start if stopped, attach if running, never recreate. Gated to non-recreate Ups. Default path (hash-based reuse/recreate) unchanged. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
PreviousNext