Files
devvm/testdata/script/host_code.txtar
T
w3cjandClaude Opus 5.5 ceda0bf925 feat(cli): --network TIER, devvm network TIER and the tier question
The command line names the four network tiers. --network TIER (open,
internet, allowlist or none) chooses a new VM's tier, checked before
anything runs (arg_not_choice). devvm network open|internet|allowlist|none
gives the folder's VM a tier through Net.SetTier, and devvm network -g
takes the tiers and ask. config.toml's and settings.json's network is ask
or a tier (settings.NetworkChoices, checked against netpolicy.TierNames
by a test, since settings can't import netpolicy).

The question on creation is Proxy.Choose(vm): net_about says what each
tier reaches, net_ask asks for one (Answer, AnsweredBy("--network")),
Enter or a refusal gives allowlist, and an answer that isn't a tier is
warned of (net_tier_unknown) and asked again. devvm setup's picker
offers ask and the four tiers (network_default_open, _internet,
_allowlist, _none). On an existing VM, --network is ignored with the
devvm network TIER command that changes it.

devvm network --json: policy is the tier or unenforced, and each policy
file whose denies alone apply (internet and none) has denies_only: true,
as the text output's "(denies only)", so a script can tell a file's
denies from all of its rules without knowing the tier rules.

Messages reworded: net_tier_backend (--network open), net_open_policy
(devvm network allowlist), net_about, net_ask, network_default*,
net_default_failed, network_failed, setting_already's and
widen_parent_vm*'s descriptions. safety/network's "Choosing a tier"
replaces its on/off section; docs, the cli skill, testscripts and e2e
use the new forms, and e2e's internet and none checks go through devvm
network.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:54:43 -07:00

99 lines
3.7 KiB
Plaintext

# devvm host and devvm code: the folder's VM launched as devvm does without
# its shell (checked, started, self-checked, set up, in devvm's ssh
# config), then its host name shown, or its folder opened in VS Code (a
# stub code) with the SSH agent devvm started with. The Include line is
# offered for the sandbox's own ~/.ssh/config only.
# No VM.
project web
! exec devvm host
stderr '^devvm: no_vm dir=\S*/web$'
! exec devvm code
stderr '^devvm: no_vm dir=\S*/web$'
# A stopped VM: started and set up, no shell. Without a terminal, the
# Include line is shown, not added.
exec devvm --network open --no-git-protect
vm_name WEB web
exec limactl stop $WEB
stub_reset
exec devvm host
stdout '^==> starting vm=devvm-web-[0-9a-f]{14}$'
stdout '^ssh_include_needed line=Include /\S*/data/devvm/ssh_config$'
stderr '^devvm: ssh_include_yourself$'
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
stub_calls
stdout '^limactl start --tty=false devvm-web-[0-9a-f]{14}$'
stdout 'tar -xf'
! stdout 'limactl shell --workdir /\S*/web devvm-web'
catg $DATA/ssh_config
stdout '^Host devvm-web devvm-web-[0-9a-f]{14}$'
! exists $HOME/.ssh
# With the line there: nothing asked. A size its state asks for waits for
# the running VM's next start, as on a launch.
exec sh -c 'mkdir -p "$HOME/.ssh" && echo "Include $DATA/ssh_config" > "$HOME/.ssh/config"'
# ssh by the folder's name reads devvm's ssh config in its data folder
# through that line: the real ssh resolves the name, connecting to nothing.
[exec:/usr/bin/ssh] exec /usr/bin/ssh -F $HOME/.ssh/config -G devvm-web
[exec:/usr/bin/ssh] stdout '^hostname 127\.0\.0\.1$'
[exec:/usr/bin/ssh] stdout '^userknownhostsfile \S*/data/devvm/vms/[0-9a-f]{14}/run/known_hosts$'
[exec:/usr/bin/ssh] stdout '^hostkeyalias devvm-web-[0-9a-f]{14}$'
json_set $WEB_dir/vm.json size.cpus=6
stub_reset
exec devvm host
! stdout 'starting|ssh_include'
stderr '^devvm: next_start_size vm=devvm-web-[0-9a-f]{14}\ndevvm: next_start count=1 vm=devvm-web-[0-9a-f]{14}$'
stdout '^ssh_host_info dir=/\S*/web host=devvm-web$'
stub_calls
! stdout 'limactl (start|edit)'
# devvm code: the folder in VS Code over Remote-SSH, with the SSH agent
# devvm started with, though this VM's own connections carry none.
env SSH_AUTH_SOCK=$WORK/user-agent.sock
stub_reset
exec devvm code
stub_calls
stdout '^code --remote ssh-remote\+devvm-web /\S*/web$'
exec sh -c 'cat "$STUB_DIR/code-agent"'
stdout '^\S*/user-agent\.sock$'
env SSH_AUTH_SOCK=
# Two folders named web: the VM by its full name.
mkdir $WORK/other/web
cd $WORK/other/web
exec devvm --network open --no-git-protect
stub_reset
exec devvm code
stub_calls
stdout '^code --remote ssh-remote\+devvm-web-[0-9a-f]{14} /\S*/other/web$'
# No code command on PATH: said, with the host to connect to.
exec sh -c 'mkdir "$WORK/nocode" && for f in "$(dirname "$DEVVM_HOST_MISE")"/*; do [ "${f##*/}" = code ] || ln -s "$f" "$WORK/nocode/"; done'
env SAVED_PATH=$PATH
env PATH=$DEVVM_BIN:$WORK/nocode:/usr/bin:/bin:/usr/sbin:/sbin
stub_reset
! exec devvm code
stderr '^devvm: no_code_command host=devvm-web-[0-9a-f]{14}$'
stub_calls
! stdout '^code '
env PATH=$SAVED_PATH
# Network policy: a VM devvm started confined that still reaches the
# internet directly is stopped, as on a launch; no host name. (Its
# hostagent here: the test's runner, which runs on, in place of the
# stub's.)
project leak
exec devvm --network allowlist --no-git-protect
vm_name LEAK leak
exec sh -c 'echo $PPID > "$LIMA_HOME/$LEAK/ha.pid"; echo "$PPID 1" > "$LEAK_dir/run/started"'
stub_reset
exec sh -c ': > "$STUB_DIR/net-direct"'
! exec devvm host
stderr '^devvm: net_direct_route vm=devvm-leak-[0-9a-f]{14}$'
! stdout ssh_host_info
stub_calls
stdout '^limactl stop devvm-leak-[0-9a-f]{14}$'
! stdout 'tar -xf'
rm $STUB_DIR/net-direct