mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
nix is a layer devvm ships, as docker is: devvm nix, devvm node+nix, devvm build nix, or added to an existing VM in place. A folder with flake.nix, shell.nix or devenv.nix at its top level, or a default.nix that makes a shell (mkShell), gets it after its toolchains, so package.json and flake.nix give node+nix. - assets/layers/nix.sh: Nix 2.35.4's release tarball (releases.nixos.org), its version and SHA-256 per arch at the top, checked against the tarball's .sha256 files and nixos.org/nix/install, fetched with devvm-fetch; 2.35.3 fixes GHSA-hf6w-2rg9-v84g (store ownership in the scripted installer) and CVE-2026-110450 (store corruption through the daemon's repair flag). The tarball's own install --daemon --yes --no-channel-add, with experimental-features = nix-command flakes, trusted-users = root, sandbox = true and sandbox-fallback = false. The installer runs without proxy variables (it writes any it finds into a systemd override for nix-daemon, which would put a build's proxy into the image) and with NIX_SSL_CERT_FILE at the system's bundle. The layer checks the store is root's, adds Nix's default profile to the end of sudo's secure_path (/etc/sudoers.d/devvm-nix, checked with visudo), and appends Nix's profiles to BASH_ENV's PATH. direnv 2.38.2 (per arch) and nix-direnv 3.2.0's direnvrc, pinned the same way; direnv's hook in ~/.bashrc.d/direnv.sh, which loads before mise.sh so direnv's prompt hook runs after mise's and a dev shell's PATH comes first; a direnv lib file puts each project's layout under ~/.cache/direnv/layouts, so nix-direnv writes no .direnv into the project folder. Without systemd the script refuses in one line. - assets/layers/nix.policy: cache.nixos.org, channels.nixos.org, releases.nixos.org (GitHub is in base.policy). - assets/guest/sync.sh: nix-daemon gets a systemd drop-in with the VM's proxy (http_proxy, https_proxy, no_proxy) under network policy, removed when it's off, the daemon restarted when it changed. - image.NixLayer in Builtins; project.Detect's nix marker (a default.nix is read only as a regular file, at most 64 KiB); backend.FeatureNixLayer (nix-layer), needed by a VM of an image with the layer and by building one: Lima native, smolvm and Docker none, so both refuse in one line (backend_lacks); dockerLayers.choice returns every layer feature of the image, so docker+nix on Docker needs nix-layer too. - scripts/bump.sh: nix (the version nixos.org's installer names, the sums Nix publishes; it fails when the installer names no tarball, as Nix's Rust installer will), direnv, nix-direnv. - Docs: using/images (built-in layers, detection), using/toolchains (Nix projects), safety/network (the layer's hosts; source builds' hosts blocked), internals/images (the nix layer), internals/network (the daemons' drop-ins), internals/backends (nix-layer), internals/design (the nix layer beside Instead of Nix), backends, customizing, coding-agents, contributing (the e2e section); the CLI reference; AGENTS.md's assets/ and e2e lines. - Tests: Detect (markers, default.nix with and without a shell, a linked one), layer and environment lists, layer new nix reserved, nix-layer in ImageSpec and ImageFeatures, caps tests, up_checks.txtar (node+nix detected under an agent), docker.txtar (nix refused for a VM and a build). e2e nix section: the layer built behind a company proxy leaves no proxy settings and no password on its image's disk; a node+nix flake VM with network policy: pins, a root-owned store, sandbox without fallback, trusted-users root and an untrusted substituter ignored, the daemon's drop-in, nix run nixpkgs#hello, sudo nix and nix over ssh, the flake's node ahead of the shared node prompt after prompt through direnv, no .direnv in the folder, a blocked fixed-output fetch named by devvm-why, and the drop-in gone after network off. Review (security-audit skill, guidance mode, against the review task's list): the tarball and direnv's files are pinned in devvm's source and checked before tar or install runs; nothing from the host goes into the image (no proxy override, e2e greps the disk); the drop-in holds only the VM's own proxy URL, devvm's value, and goes when policy is off; trusted-users stays root and an untrusted user's substituters are ignored (the VM's user has sudo, so that guards an honest VM and the allowlist is what holds); secure_path gains only the root-owned default profile, last; /nix is on the VM's own disk and nothing mounts a host's or another VM's store. Found and fixed in review: Nix's default sandbox-fallback would build unsandboxed without a word where the kernel can't sandbox, so it's off. No confirmed findings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
364 lines
19 KiB
Plaintext
364 lines
19 KiB
Plaintext
# The docker backend (experimental), on the docker stub: its checks, base
|
|
# built by committing a container, a project VM made from it with its
|
|
# mounts and its own home volume, made again when its mounts change, and
|
|
# the features it lacks refused in one line naming the VM. The stub is a
|
|
# Linux engine of this machine's (DEVVM_DOCKER_KIND, read by test builds),
|
|
# where builds are confined; on Docker Desktop their confinement is
|
|
# emulated, through a proxy of devvm's. Registries
|
|
# are never reached: the pinned image needs no lookup, and HTTPS_PROXY
|
|
# points at nothing.
|
|
env DEVVM_MESSAGES=names
|
|
env DEVVM_DOCKER_KIND=linux
|
|
env VMS=$XDG_DATA_HOME/devvm/vms
|
|
env HTTPS_PROXY=http://127.0.0.1:9
|
|
env https_proxy=http://127.0.0.1:9
|
|
env PIN=ubuntu:26.04@sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
|
|
# Its checks: an engine it reaches, which doctor names; one the user can't
|
|
# reach, with the fix.
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker_engine_linux version=29\.1\.3$'
|
|
stdout '^doctor_ok backend=docker version=\S+$'
|
|
stdout '^FEATURE +DOCKER +LIMA +SMOLVM$'
|
|
stdout '^build-confinement +native +native +native$'
|
|
stdout '^egress-proxy +emulated +native +emulated$'
|
|
stdout '^ssh +emulated +native +emulated$'
|
|
stdout '^ports-all +emulated +emulated +emulated$'
|
|
stdout '^agent-toggle +emulated +native +emulated$'
|
|
stdout '^docker-layer +none +native +native$'
|
|
! stdout docker_sysbox
|
|
exec sh -c ': > "$STUB_DIR/docker-denied"'
|
|
! exec devvm doctor --backend docker
|
|
stderr '^devvm: docker_access fix=sudo usermod -aG docker \S+$'
|
|
rm $STUB_DIR/docker-denied
|
|
|
|
# Base: the image pulled by its digest, a labelled container from it with
|
|
# base.yaml's size, prepared, its scripts run between the stand-ins, then
|
|
# committed as devvm's image and deleted. Every container devvm makes sets
|
|
# the proxy variables empty, so the Docker client's own proxies stay out.
|
|
# Without a company proxy, the build is on Docker's own network, with no
|
|
# proxy of devvm's (from here on, until the company proxy's own case at the
|
|
# end: its builds need devvm's Linux build).
|
|
env HTTPS_PROXY=
|
|
env https_proxy=
|
|
exec devvm --backend docker --from $PIN build base
|
|
stdout '^==> building_image_from from=ubuntu:26\.04@sha256:a+ image=base key=[0-9a-f]{12}$'
|
|
stub_calls
|
|
stdout '^docker image pull ubuntu:26\.04@sha256:a+$'
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8} --label devvm\.data=\S+/data/devvm --label devvm\.key=[0-9a-f]{12} --label devvm\.kind=build --init --user 0:0 --entrypoint sleep -e HTTP_PROXY= -e http_proxy= -e HTTPS_PROXY= -e https_proxy= -e FTP_PROXY= -e ftp_proxy= -e NO_PROXY= -e no_proxy= -e ALL_PROXY= -e all_proxy= --cpus 4 --memory \d+m --memory-swap \d+m --hostname devvm-build --network bridge ubuntu:26\.04@sha256:a+ infinity$'
|
|
stdout '^docker container start devvm-img-[0-9a-f]{12}-[0-9a-f]{8}$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- \S+ \d+( \d+)?$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- on$'
|
|
stdout '^docker exec -i -u \S+ -w / .* devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -c .* sh bash -s$'
|
|
stdout '^docker exec -i -u 0 devvm-img-[0-9a-f]{12}-[0-9a-f]{8} sh -s -- off$'
|
|
! stdout 'env-file|-proxy '
|
|
stdout '^docker container commit --change LABEL devvm\.kind=image --change LABEL devvm\.key=[0-9a-f]{12} devvm-img-[0-9a-f]{12}-[0-9a-f]{8} devvm-[0-9a-f]{8}:[0-9a-f]{12}$'
|
|
stdout '^docker container rm -f -v devvm-img-[0-9a-f]{12}-[0-9a-f]{8}$'
|
|
! stdout limactl
|
|
exec devvm images
|
|
stdout '^base +ubuntu:26\.04@sha256:a+ +a{12} +[0-9a-f]{12} +current +\S+ +docker$'
|
|
|
|
# What it lacks is refused in one line naming the VM, before anything is
|
|
# made: a disk size; the docker layer without Sysbox, saying to install it
|
|
# on this Linux engine (on Docker Desktop, to use a VM backend).
|
|
mkdir $WORK/web
|
|
cd $WORK/web
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none --disk 200 base
|
|
stderr '^devvm: backend_lacks backend=docker feature=disk vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none docker
|
|
stderr '^devvm: docker_layer_no_sysbox vm=devvm-web-[0-9a-f]{14}$'
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none docker
|
|
stderr '^devvm: docker_layer_needs_vm vm=devvm-web-[0-9a-f]{14}$'
|
|
env DEVVM_DOCKER_KIND=linux
|
|
! exec devvm --backend docker --from $PIN --no-network-policy --ports none nix
|
|
stderr '^devvm: backend_lacks backend=docker feature=nix-layer vm=devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm --backend docker --from $PIN build nix
|
|
stderr '^devvm: backend_lacks backend=docker feature=nix-layer vm=\S+$'
|
|
stub_calls
|
|
! stdout 'container create'
|
|
! exists $VMS
|
|
|
|
# A VM: its home a volume of its own, the project folder bind-mounted,
|
|
# the tools volume read-only, its hostname the folder's; started, its
|
|
# services run without Docker's daemon and with its sshd's config, set
|
|
# up, then the shell, an ssh session forwarding no agent. A default disk
|
|
# size doesn't apply to it, said.
|
|
exec devvm size -g --disk 150
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
stderr '^devvm: size_disk_default_unused backend=docker vm=devvm-web-[0-9a-f]{14}$'
|
|
stdout '^==> creating_from image=base vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-web-[0-9a-f]{14}-home$'
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-tools-[0-9a-f]{8}$'
|
|
stdout '^docker container create --name devvm-web-[0-9a-f]{14} --label devvm\.data=\S+ --label devvm\.config=[0-9a-f]{16} --label devvm\.kind=vm --init --user 0:0 --entrypoint sleep (-e [A-Za-z_]+= ){10}--cpus 4 --memory \d+m --memory-swap \d+m --hostname web --network bridge --mount type=bind,src=\S+/web,dst=\S+/web --mount type=volume,src=devvm-tools-[0-9a-f]{8},dst=/mnt/devvm-tools,readonly --mount type=volume,src=devvm-web-[0-9a-f]{14}-home,dst=/home/\S+\.guest --cap-drop NET_RAW devvm-[0-9a-f]{8}:[0-9a-f]{12} infinity$'
|
|
stdout '^docker container start devvm-web-[0-9a-f]{14}$'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_DOCKERD=off -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-web-[0-9a-f]{14} sh -s -- ssh \S+ ssh-ed25519 \S+ devvm$'
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=none .* -o ForwardAgent=no .* cd -- ''\S+/web'' && exec bash -l$'
|
|
! stdout 'devvm-web-[0-9a-f]{14} sh -c .* sh bash -l$'
|
|
! stderr backend_unreviewed
|
|
exists $STUB_DIR/sync.tar
|
|
exec devvm ls
|
|
stdout '^devvm-web-[0-9a-f]{14} +Running .*image=base +\S+ +off +docker +\S+/web$'
|
|
exec sh -c 'cat "$VMS"/devvm-web-*'
|
|
stdout '^backend=docker$'
|
|
! stdout '^disk='
|
|
|
|
# devvm size: its CPUs and memory, and what its disk holds; changed with
|
|
# docker update on a stopped VM; a disk size refused.
|
|
exec devvm size
|
|
stdout '\Acpus=4 memory=\S+GiB disk_used=\S+GiB\n\z'
|
|
exec devvm stop
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm size --cpus 2
|
|
stdout '^==> vm_size size=cpus=2 memory=\S+ vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker update --cpus 2 devvm-web-[0-9a-f]{14}$'
|
|
! exec devvm size --disk 300
|
|
stderr '^devvm: backend_lacks backend=docker feature=disk vm=devvm-web-[0-9a-f]{14}$'
|
|
|
|
# Started again with the same mounts: the same container.
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
! stdout 'container (commit|create|rm)'
|
|
stdout '^docker container start devvm-web-[0-9a-f]{14}$'
|
|
|
|
# rm deletes its container, its home volume and its record.
|
|
exec devvm rm -f
|
|
stdout '^==> deleted vm=devvm-web-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^docker container rm -f -v devvm-web-[0-9a-f]{14}$'
|
|
stdout '^docker volume rm devvm-web-[0-9a-f]{14}-home$'
|
|
! stdout 'volume rm devvm-tools'
|
|
! exec sh -c 'ls "$XDG_DATA_HOME"/devvm/docker/vms/devvm-web-*'
|
|
exec devvm ls
|
|
! stdout devvm-web
|
|
|
|
# Under Sysbox, where the engine has it, emulated and reviewed, so
|
|
# unwarned: the VM runs under its runtime, said, recorded, on a network of
|
|
# its own, with volumes of its own for Docker's engine, Docker's daemon
|
|
# started after each start; ls shows it; no network policy, at creation or
|
|
# later; rm deletes its network and volumes. Added in place to a VM with
|
|
# network policy, refused before anything changes.
|
|
exec sh -c ': > "$STUB_DIR/docker-sysbox"'
|
|
env DEVVM_DOCKER_PROC_SYS=$WORK/sys
|
|
mkdir $WORK/sys/net/ipv4/conf/br-id-net-devvm
|
|
exec sh -c 'echo 0 > "$DEVVM_DOCKER_PROC_SYS/net/ipv4/conf/br-id-net-devvm/route_localnet"'
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker-layer +emulated +native +native$'
|
|
stdout '^docker_sysbox$'
|
|
mkdir $WORK/sysbox
|
|
cd $WORK/sysbox
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none docker
|
|
stderr '^devvm: net_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --ports none docker
|
|
stdout '^==> docker_layer_runtime backend=docker runtime=sysbox vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
stderr '^devvm: net_off_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
! stderr 'net_about|net_ask'
|
|
! stderr backend_unreviewed
|
|
stub_calls
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-sysbox-[0-9a-f]{14}-docker$'
|
|
stdout '^docker volume create --label devvm\.data=\S+ devvm-sysbox-[0-9a-f]{14}-containerd$'
|
|
stdout '^docker network create --label devvm\.data=\S+ --label devvm\.kind=vm devvm-sysbox-[0-9a-f]{14}-docker-net$'
|
|
stdout '^docker container create --name devvm-sysbox-[0-9a-f]{14} .* --network devvm-sysbox-[0-9a-f]{14}-docker-net .* --mount type=volume,src=devvm-sysbox-[0-9a-f]{14}-containerd,dst=/var/lib/containerd --runtime sysbox-runc devvm-[0-9a-f]{8}:[0-9a-f]{12} infinity$'
|
|
! stdout 'container create --name devvm-sysbox-.* --cap-drop'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-sysbox-[0-9a-f]{14} sh -s -- ssh '
|
|
exec sh -c 'cat "$VMS"/devvm-sysbox-*'
|
|
stdout '^docker_layer=sysbox$'
|
|
stdout '^net=off$'
|
|
exec devvm ls
|
|
[darwin] stdout '^devvm-sysbox-[0-9a-f]{14} +Running +.*image=docker +on +off +docker \(sysbox\) +\S+/sysbox$'
|
|
[linux] stdout '^devvm-sysbox-[0-9a-f]{14} +Running +.*image=docker +off +off +docker \(sysbox\) +\S+/sysbox$'
|
|
! exec devvm network on
|
|
stderr '^devvm: net_docker_layer backend=docker vm=devvm-sysbox-[0-9a-f]{14}$'
|
|
exec devvm rm -f
|
|
stub_calls
|
|
stdout '^docker volume rm devvm-sysbox-[0-9a-f]{14}-docker$'
|
|
stdout '^docker volume rm devvm-sysbox-[0-9a-f]{14}-containerd$'
|
|
stdout '^docker network rm devvm-sysbox-[0-9a-f]{14}-docker-net$'
|
|
mkdir $WORK/inplace
|
|
cd $WORK/inplace
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
exec devvm network on
|
|
! exec devvm docker
|
|
stderr '^devvm: net_docker_layer backend=docker vm=devvm-inplace-[0-9a-f]{14}$'
|
|
exec devvm rm -f
|
|
# A bridge routing to this machine's loopback (Docker's userland proxy
|
|
# off): refused.
|
|
exec sh -c 'echo 1 > "$DEVVM_DOCKER_PROC_SYS/net/ipv4/conf/br-id-net-devvm/route_localnet"'
|
|
mkdir $WORK/localnet
|
|
cd $WORK/localnet
|
|
! exec devvm --backend docker --from $PIN --ports none docker
|
|
stderr '^devvm: docker_route_localnet vm=devvm-localnet-[0-9a-f]{14}$'
|
|
! exec sh -c 'ls -d "$STUB_DIR"/docker/containers/devvm-localnet-*'
|
|
rm $STUB_DIR/docker-sysbox
|
|
|
|
# Its emulations, reviewed, so unwarned: ssh for editors through docker
|
|
# exec, nothing published (devvm's ssh config names devvm _docker-connect
|
|
# as ProxyCommand); every port, through a forwarder of devvm's over that
|
|
# ssh (its host key read through docker exec and pinned); the shell an ssh
|
|
# session forwarding the user's agent.
|
|
mkdir $WORK/emu
|
|
cd $WORK/emu
|
|
exec sh -c 'printf "0100007F:B8E0\n" > "$STUB_DIR/guest-ports"; : > "$STUB_LOG"'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ssh-agent base
|
|
! stderr backend_unreviewed
|
|
! stderr 'ports_(no_ssh|forward_failed)'
|
|
stub_calls
|
|
! stdout 'docker container create .* (-p|--publish) '
|
|
stdout '^docker exec -u 0 devvm-emu-[0-9a-f]{14} sh -c if \[ -x /usr/sbin/sshd \]; then echo sshd; else echo none; fi$'
|
|
stdout '^docker exec -i -u 0 -e DEVVM_DOCKERD=off -e DEVVM_LOOP=off -e DEVVM_SSHD=inetd devvm-emu-[0-9a-f]{14} sh -s -- ssh \S+ ssh-ed25519 \S+ devvm$'
|
|
stdout '^docker exec -u 0 devvm-emu-[0-9a-f]{14} cat /etc/ssh/ssh_host_ed25519_key\.pub$'
|
|
stdout '^ssh -F none -M -S \S+/data/devvm/run/docker-[0-9a-f]{16}\.ctl -T .* -o IdentityAgent=none -o IdentityFile=\S+/docker/vms/devvm-emu-[0-9a-f]{14}\.key .* -o HostKeyAlias=devvm-emu-[0-9a-f]{14} .* -o ForwardAgent=no .* -o ProxyCommand=''\S+'' ''_docker-connect'' ''-docker'' ''\S+/docker'' ''-data'' ''\S+/data/devvm'' ''devvm-emu-[0-9a-f]{14}'' -l \S+ devvm-emu-[0-9a-f]{14} sh -s$'
|
|
stdout '^ssh -F none -T -o ControlMaster=no -o ControlPath=none .* -o IdentityAgent=SSH_AUTH_SOCK .* -o ForwardAgent=yes .* -o ProxyCommand=.* -l \S+ devvm-emu-[0-9a-f]{14} cd -- ''\S+/emu'' && exec bash -l$'
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*.ports.log'
|
|
stdout '^devvm ports: port 47328: forwarded$'
|
|
grep '^Host devvm-emu devvm-emu-[0-9a-f]{14}$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^ ProxyCommand ''\S+'' ''_docker-connect'' ''-docker'' ''\S+/docker'' ''-data'' ''\S+/data/devvm'' ''devvm-emu-[0-9a-f]{14}''$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^ ForwardAgent yes$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
! grep '^ Port ' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
grep '^devvm-emu-[0-9a-f]{14} ssh-ed25519 AAAAstub$' $XDG_CONFIG_HOME/devvm/known_hosts
|
|
exec devvm ssh
|
|
stdout '^ssh_host_info dir=\S+/emu host=devvm-emu$'
|
|
|
|
# The agent turned off while it runs: from its next start, the shell's and
|
|
# the ssh config entry's alike; then none.
|
|
exec devvm ssh-agent off
|
|
stdout '^==> agent_set_running mode=off vm=devvm-emu-[0-9a-f]{14}$'
|
|
! stderr backend_unreviewed
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=SSH_AUTH_SOCK .* -o ForwardAgent=yes .* cd -- ''\S+/emu'' && exec bash -l$'
|
|
grep '^ ForwardAgent yes$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
exec devvm stop
|
|
! exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-"'
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
stdout '^ssh -F none -T .* -o IdentityAgent=none .* -o ForwardAgent=no .* cd -- ''\S+/emu'' && exec bash -l$'
|
|
grep '^ ForwardAgent no$' $XDG_CONFIG_HOME/devvm/ssh_config
|
|
|
|
# Listed ports: through the forwarder too, those alone; one a program on
|
|
# this machine has is left out, warned.
|
|
exec devvm stop
|
|
exec devvm ports 47328,9-10
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm
|
|
stub_calls
|
|
exec sh -c 'cat "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*.ports.log'
|
|
stdout '^devvm ports: forwarding devvm-emu-[0-9a-f]{14}''s ports$'
|
|
exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-"'
|
|
stdout ' -only 47328,9-10$'
|
|
# Running: a change starts its forwarder again at once, for the same
|
|
# start of its container.
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm ports rm 9-10
|
|
stdout '^==> ports_forwarding ports=47328 vm=devvm-emu-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout '^docker (container )?(stop|start|create|commit|rm) '
|
|
exec sh -c 'ps -axww -o command= | grep "[_]docker-ports -vm devvm-emu-"'
|
|
stdout ' -only 47328$'
|
|
! stdout ' -only 47328,9-10$'
|
|
|
|
# rm deletes its forwarder, its keys and its entry.
|
|
exec devvm rm -f
|
|
! exec sh -c 'ls "$XDG_DATA_HOME"/devvm/docker/vms/devvm-emu-*'
|
|
! grep devvm-emu $XDG_CONFIG_HOME/devvm/ssh_config
|
|
rm $STUB_DIR/guest-ports
|
|
|
|
# On Docker Desktop builds' confinement is emulated, and reviewed, as its
|
|
# containers reach the host's loopback (its builds are the unit tests').
|
|
# An image built already is used.
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
mkdir $WORK/desk
|
|
cd $WORK/desk
|
|
exec devvm doctor --backend docker
|
|
stdout '^docker_engine_desktop version=29\.1\.3$'
|
|
stdout '^build-confinement +emulated +native +native$'
|
|
stdout '^egress-proxy +emulated +native +emulated$'
|
|
exec devvm --backend docker --from $PIN --no-network-policy --ports none base
|
|
! stderr backend_unreviewed
|
|
stdout '^==> creating_from image=base vm=devvm-desk-[0-9a-f]{14}$'
|
|
exec devvm rm -f
|
|
|
|
# Another machine's engine can't confine a VM to its proxy: without a
|
|
# flag, the VM is made without network policy, unasked and warned;
|
|
# --network-policy is refused before anything is made.
|
|
env DEVVM_DOCKER_KIND=other
|
|
mkdir $WORK/other
|
|
cd $WORK/other
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stderr '^devvm: backend_lacks backend=docker feature=egress-proxy vm=devvm-other-[0-9a-f]{14}$'
|
|
! exec sh -c 'ls -d "$STUB_DIR"/docker/containers/devvm-other-*'
|
|
exec devvm --backend docker --from $PIN --ports none base
|
|
stderr '^devvm: net_off_backend backend=docker vm=devvm-other-[0-9a-f]{14}$'
|
|
! stderr 'net_about|net_ask'
|
|
exec sh -c 'cat "$VMS"/devvm-other-*'
|
|
stdout '^net=off$'
|
|
exec devvm rm -f
|
|
env DEVVM_DOCKER_KIND=desktop
|
|
|
|
# A release fetches its own version's Linux build, which network policy's
|
|
# relay runs, the first time a Docker VM needs it: from the release's Linux
|
|
# archive (here a loopback server, with a test build of devvm for Linux),
|
|
# checked against the SHA-256 the release has before it's used. One that
|
|
# doesn't match is refused, and nothing kept; doctor never fetches.
|
|
mkdir $WORK/fetch
|
|
cd $WORK/fetch
|
|
linux_release mismatch
|
|
exec devvm doctor --backend docker
|
|
! stdout docker_linux_build
|
|
! exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stdout '^==> docker_linux_build_fetching url=http://127\.0\.0\.1:\d+/devvm-0\.0\.0-linux-\w+\.tar\.gz$'
|
|
stderr '^devvm: docker_linux_build_mismatch url=http://127\.0\.0\.1:\d+/devvm-0\.0\.0-linux-\w+\.tar\.gz$'
|
|
! exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
exec devvm rm -f
|
|
linux_release match
|
|
! exec devvm --backend docker --from $PIN --network-policy --ports none base
|
|
stdout '^==> docker_linux_build_fetching url='
|
|
! stderr docker_linux_build
|
|
# The stub's VM answers the self-check's direct connection, so devvm stops
|
|
# it; the fetch is what's checked here.
|
|
stderr '^devvm: net_direct_route vm=devvm-fetch-[0-9a-f]{14}$'
|
|
exists $XDG_DATA_HOME/devvm/docker/bin/devvm-linux-$LINUX_ARCH
|
|
stub_calls
|
|
stdout '^docker container create --name devvm-fetch-[0-9a-f]{14}-proxy .* --mount type=bind,src=\S+/docker/bin/devvm-linux-\w+,dst=/devvm,readonly '
|
|
# Kept: the next start fetches nothing.
|
|
! exec devvm
|
|
! stdout docker_linux_build_fetching
|
|
stderr '^devvm: net_direct_route vm=devvm-fetch-[0-9a-f]{14}$'
|
|
exec devvm rm -f
|
|
|
|
# Behind a company proxy, a Linux engine's build goes through a proxy of
|
|
# devvm's on its own network, as on Docker Desktop: its commands get that
|
|
# proxy's address and a password made for the build, never the company
|
|
# proxy's, which is in no command and nothing left behind.
|
|
env DEVVM_DOCKER_KIND=linux
|
|
env HTTPS_PROXY=http://corp:[email protected]:9
|
|
env https_proxy=
|
|
exec devvm layer new corp
|
|
exec sh -c ': > "$STUB_LOG"'
|
|
exec devvm --backend docker build corp
|
|
stub_calls
|
|
stdout '^docker network create --internal .* devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-net$'
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-proxy '
|
|
stdout '^docker container create --name devvm-img-[0-9a-f]{12}-[0-9a-f]{8} .* --network devvm-img-[0-9a-f]{12}-[0-9a-f]{8}-net '
|
|
stdout '^docker exec --env-file \S+/builds/devvm-img-[0-9a-f]{12}-[0-9a-f]{8}/env -i -u '
|
|
! stdout c0rp-pa55
|
|
exec sh -c 'grep -rl c0rp-pa55 "$XDG_DATA_HOME" "$STUB_DIR" || true'
|
|
! stdout .
|
|
|
|
# Every container devvm made in this script, VMs, builds and relays, set
|
|
# each proxy variable empty.
|
|
exec sh -c 'grep -c . "$STUB_DIR/containers-made"; grep -vF -- "-e HTTP_PROXY= -e http_proxy= -e HTTPS_PROXY= -e https_proxy= -e FTP_PROXY= -e ftp_proxy= -e NO_PROXY= -e no_proxy= -e ALL_PROXY= -e all_proxy= " "$STUB_DIR/containers-made" || true'
|
|
stdout '^[1-9][0-9]*$'
|
|
! stdout '^docker '
|
|
exec sh -c 'grep -c -- "-proxy " "$STUB_DIR/containers-made"'
|
|
! stdout '^0$'
|