Files
w3cjandClaude Opus 5.5 b2b12ee55d feat(gitprotect): protect every repo nested in a VM's folder
A VM over a folder of repos now protects each nested git repo, not only
the folder's own: one walk (hostsafety.Walk, at most 4 folders down and
100 repos, no symlinks, one device) finds them, and each is locked on
macOS, pinned on Linux or watched where Linux can't pin, scanned within
its own top folder and the mount. A repo counts as covered only when a
scan locks its git dir; git dirs follow git's own rule, .git is matched
without case on macOS, and a recorded repo stays protected while
anything is at its .git. Repos the walk can't protect, that appear,
that leave or that look like bare repos are named, with the config keys
and hooks a VM-made repo would run. Existing VMs get a one-time notice
and opt in with devvm git-protect on. Ownership fails closed under one
host lock, so a VM never unlocks what another protects; one scan budget
covers every repo, and launches into a running VM check only the top
repo. devvm doctor gives a tip to set safe.bareRepository=explicit,
reading the user's GIT_CONFIG_GLOBAL when set.

Refs #3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-08 16:34:40 -07:00

78 lines
2.6 KiB
Plaintext

# devvm _qemu exec: the QEMU wrapper runs the real QEMU (here one that prints
# its arguments, one per line) with Lima's network restricted. The wrapper's
# own folder is first on PATH, so it must skip itself; a relative entry names
# the folder Lima runs in, which holds a planted QEMU.
# Messages' text, not their names.
env DEVVM_MESSAGES=
chmod 0755 wrap/qemu-system-aarch64
chmod 0755 real/qemu-system-aarch64
chmod 0755 qemu-system-aarch64
env PATH=$WORK/wrap${:}.${:}${:}$WORK/real${:}$PATH
env DEVVM_GUESTFWD='/x/devvm _qemu connect 127.0.0.1:5'
exec wrap/qemu-system-aarch64 -m 4G -netdev user,id=net0,net=192.168.5.0/24,hostfwd=tcp:127.0.0.1:41083-:22 -device virtio-net-pci,netdev=net0
cmp stdout restricted
! stdout planted
# Lima's probes pass through as they are.
exec wrap/qemu-system-aarch64 -M none -netdev help
cmp stdout probe
# Never unrestricted: a second network is refused, and QEMU doesn't run.
! exec wrap/qemu-system-aarch64 -netdev user,id=net0,x=1 -netdev socket,id=net1,listen=:1234
stderr '^devvm: The arguments for QEMU don''t have exactly one -netdev user'
! stdout .
# Lima's own network (an open VM's, a build's with the internet): QEMU
# gets Lima's arguments as they are.
env DEVVM_QEMU_NET=open
exec wrap/qemu-system-aarch64 -m 4G -netdev user,id=net0,net=192.168.5.0/24
stdout '^user,id=net0,net=192.168.5.0/24\n'
! stdout restrict
env DEVVM_QEMU_NET=
# Pins that aren't what devvm writes, in their file or as the variable:
# QEMU doesn't run.
env DEVVM_QEMU_PINS=$WORK/bad-pins.json
! exec wrap/qemu-system-aarch64 -m 4G -netdev user,id=net0,net=192.168.5.0/24
! stdout .
env DEVVM_QEMU_PINS='{"root":"/p","pins":[{"path":".git"}]}'
! exec wrap/qemu-system-aarch64 -m 4G -netdev user,id=net0,net=192.168.5.0/24
! stdout .
env DEVVM_QEMU_PINS=
# No real QEMU on PATH (only the wrapper's and devvm's folders, as a host
# with QEMU installed has it in /usr/bin): the planted one isn't used either.
env PATH=$WORK/wrap${:}.${:}$DEVVM_BIN
env DEVVM_MESSAGES=names
! exec $WORK/wrap/qemu-system-aarch64 -accel help
stderr '^devvm: program_missing name=QEMU program=qemu-system-aarch64$'
# Its usage.
! exec devvm _qemu nope
stderr 'usage: devvm _qemu'
-- wrap/qemu-system-aarch64 --
#!/bin/sh
exec devvm _qemu exec "$0" "$@"
-- real/qemu-system-aarch64 --
#!/bin/sh
printf '%s\n' "$@"
-- qemu-system-aarch64 --
#!/bin/sh
echo planted
-- restricted --
-m
4G
-netdev
user,id=net0,net=192.168.5.0/24,hostfwd=tcp:127.0.0.1:41083-:22,restrict=on,guestfwd=tcp:192.168.5.4:3128-cmd:/x/devvm _qemu connect 127.0.0.1:5
-device
virtio-net-pci,netdev=net0
-- probe --
-M
none
-netdev
help
-- bad-pins.json --
{"root":"/p","pins":[{"path":"../x"}]}