mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
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]>
152 lines
6.0 KiB
Plaintext
152 lines
6.0 KiB
Plaintext
# ls: project VMs, by name, with their status, image, shared tools, .git
|
|
# protection, network policy, links and folder. Images and build VMs
|
|
# aren't listed; a project VM named like an image is.
|
|
|
|
# No VMs: the header alone, and nothing is asked of Lima but its list.
|
|
exec devvm ls
|
|
cmp stdout header.txt
|
|
! stderr .
|
|
stub_calls
|
|
stdout '^limactl list --json\n\z'
|
|
|
|
# A folder named img-foo gives a VM named like an image: listed, while
|
|
# the image it was made from isn't. No network policy: its tier, open.
|
|
project img-foo
|
|
exec devvm --network open --no-git-protect
|
|
exec devvm ls
|
|
stdout '^NAME +STATUS +IMAGE +TOOLS +GIT +NET +LINKS +FOLDER\n'
|
|
stdout '^devvm-img-foo-[0-9a-f]{14} +Running +base +- +off +open +- +/\S*/img-foo\n\z'
|
|
! stdout '^devvm-img-[0-9a-f]{12} '
|
|
|
|
# Network policy: its tier, allowlist, while it runs on the hostagent
|
|
# devvm started (here the test's runner, which runs on); started some
|
|
# other way since, or a failed self-check, unenforced. Stopped, it starts
|
|
# confined next time.
|
|
project net
|
|
exec devvm --network allowlist --no-git-protect
|
|
vm_name NET net
|
|
exec sh -c 'echo $PPID > "$LIMA_HOME/$NET/ha.pid"; echo "$PPID 1" > "$NET_dir/run/started"'
|
|
exec devvm ls
|
|
stdout '^devvm-net-[0-9a-f]{14} +Running +base +- +off +allowlist +- +/'
|
|
json_set $NET_dir/vm.json net.tier=none
|
|
exec devvm ls
|
|
stdout '^devvm-net-[0-9a-f]{14} +Running +base +- +off +none +- +/'
|
|
json_set $NET_dir/vm.json net.tier=allowlist
|
|
# (The exit keeps limactl start sh's child, so its hostagent is sh, soon
|
|
# gone: bash 5.2 and newer as sh, Fedora's, runs a last command in sh's
|
|
# place, which would make the runner, which lasts, its hostagent.)
|
|
exec sh -c 'limactl stop "$NET" && limactl start --tty=false "$NET"; exit $?'
|
|
exec devvm ls
|
|
stdout '^devvm-net-[0-9a-f]{14} +Running +base +- +off +unenforced +- +/'
|
|
exec limactl stop $NET
|
|
exec devvm ls
|
|
stdout '^devvm-net-[0-9a-f]{14} +Stopped +base +- +off +allowlist +- +/'
|
|
json_set $NET_dir/vm.json net.made.check=unenforced
|
|
exec devvm ls
|
|
stdout '^devvm-net-[0-9a-f]{14} +Stopped +base +- +off +unenforced +- +/'
|
|
|
|
# A --clone VM shows clone in GIT, a base from a container image its
|
|
# label, and a VM whose creation didn't finish - for what it lacks. Their
|
|
# folders, /p/..., are gone: (gone) after them, and folder_state gone in --json.
|
|
mkdir $VMS/0123456789ab01 $VMS/0123456789ab02
|
|
cp $WORK/clone.json $VMS/0123456789ab01/vm.json
|
|
cp $WORK/from.json $VMS/0123456789ab02/vm.json
|
|
exec stub vm devvm-cl-0123456789ab01 Stopped
|
|
exec stub vm devvm-from-0123456789ab02 Running
|
|
exec stub vm devvm-half-0123456789ab03 Stopped
|
|
exec stub vm devvm-tools-build Stopped
|
|
exec devvm ls
|
|
stdout '^devvm-cl-0123456789ab01 +Stopped +base +node,claude +clone +allowlist +- +/p/cl \(gone\)\n'
|
|
stdout '^devvm-from-0123456789ab02 +Running +image_from from=node:24 image=base +- +on +open +- +/p/from \(gone\)\n'
|
|
stdout '^devvm-half-0123456789ab03 +Stopped +- +- +- +- +- +-\n'
|
|
! stdout devvm-tools-build
|
|
# Sorted by name.
|
|
stdout '\ndevvm-cl-.*\ndevvm-from-.*\ndevvm-half-.*\ndevvm-img-foo-.*\ndevvm-net-'
|
|
# --json: the same, the image and what its base started from apart, ""
|
|
# for what a VM lacks, and nothing else on stdout.
|
|
exec devvm ls --json
|
|
stdout '^{\n "version": 1,\n "vms": \[\n'
|
|
stdout '^ "name": "devvm-cl-0123456789ab01",\n "status": "Stopped",\n "image": "base",\n "tools": \[\n "node",\n "claude"\n \],\n'
|
|
stdout '^ "name": "devvm-from-0123456789ab02",\n "status": "Running",\n "image": "base",\n "tools": \[\],\n "from": "node:24",\n "git": "on",\n "net": "open",\n "backend": "lima",\n "folder": "/p/from",\n "folder_state": "gone",\n "links": 0\n'
|
|
stdout '^ "name": "devvm-half-0123456789ab03",\n "status": "Stopped",\n "image": "",\n "tools": \[\],\n "git": "",\n'
|
|
! stdout '^NAME'
|
|
|
|
# A VM whose vm.json can't be read is a row of its own, its name and
|
|
# status alone, with a warning naming the file; the rest are listed as
|
|
# before. A folder's control characters never reach the terminal.
|
|
mkdir $VMS/0123456789ab04 $VMS/0123456789ab05
|
|
cp $WORK/broken.json $VMS/0123456789ab04/vm.json
|
|
cp $WORK/esc.json $VMS/0123456789ab05/vm.json
|
|
exec stub vm devvm-bad-0123456789ab04 Running
|
|
exec stub vm devvm-esc-0123456789ab05 Stopped
|
|
exec devvm ls
|
|
stdout '^devvm-bad-0123456789ab04 +Running +- +- +- +- +- +-\n'
|
|
stdout '^devvm-cl-0123456789ab01 +Stopped '
|
|
stdout '^devvm-esc-0123456789ab05 +Stopped +base +- +on +open +- +/p/e\[2Jsc \(gone\)\n'
|
|
! stdout '\x1b'
|
|
stderr '^devvm: vm_state_unreadable path=\S+/0123456789ab04/vm.json$'
|
|
exec devvm ls --json
|
|
stdout '"name": "devvm-bad-0123456789ab04",\n "status": "Running",\n "image": "",'
|
|
rm $VMS/0123456789ab04 $VMS/0123456789ab05
|
|
|
|
# Lima can't list (not installed): fails, as a VM's state names it; with
|
|
# none, the header alone.
|
|
env PATH=$DEVVM_BIN
|
|
! exec devvm ls
|
|
! stdout .
|
|
stderr '^devvm: program_missing name=Lima program=limactl$'
|
|
rm $VMS
|
|
exec devvm ls
|
|
cmp stdout $WORK/header.txt
|
|
exec devvm ls --json
|
|
cmp stdout $WORK/none.json
|
|
|
|
-- none.json --
|
|
{
|
|
"version": 1,
|
|
"vms": []
|
|
}
|
|
-- header.txt --
|
|
NAME STATUS IMAGE TOOLS GIT NET LINKS FOLDER
|
|
-- clone.json --
|
|
{
|
|
"version": 1,
|
|
"id": "0123456789abcdef0123456789abcd01",
|
|
"name": "devvm-cl-0123456789ab01",
|
|
"image": "base",
|
|
"dir": "/p/cl",
|
|
"backend": "lima",
|
|
"created": "2026-01-01T00:00:00Z",
|
|
"clone": {"on": true},
|
|
"git": {"mode": "clone"},
|
|
"net": {"tier": "allowlist"},
|
|
"tools": {"names": ["node", "claude"]}
|
|
}
|
|
-- broken.json --
|
|
{"version": 1, "name": "devvm-bad-0123456789ab04"
|
|
-- esc.json --
|
|
{
|
|
"version": 1,
|
|
"id": "0123456789abcdef0123456789abcd05",
|
|
"name": "devvm-esc-0123456789ab05",
|
|
"image": "base",
|
|
"dir": "/p/e\u001b[2Jsc",
|
|
"backend": "lima",
|
|
"created": "2026-01-01T00:00:00Z",
|
|
"git": {"mode": "on"},
|
|
"net": {"tier": "open"}
|
|
}
|
|
-- from.json --
|
|
{
|
|
"version": 1,
|
|
"id": "0123456789abcdef0123456789abcd02",
|
|
"name": "devvm-from-0123456789ab02",
|
|
"image": "base",
|
|
"from": "node:24",
|
|
"dir": "/p/from",
|
|
"backend": "lima",
|
|
"created": "2026-01-01T00:00:00Z",
|
|
"git": {"mode": "on"},
|
|
"net": {"tier": "open"}
|
|
}
|