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]>
146 lines
5.1 KiB
Plaintext
146 lines
5.1 KiB
Plaintext
# devvm in a subfolder of a folder with a VM: it opens that VM in the
|
|
# subfolder, saying so; --here and --clone make the subfolder its own;
|
|
# stop acts on the parent's VM, naming it first; rm refuses it without a
|
|
# terminal. adopt doesn't look upward, and nothing does from a repo of
|
|
# its own below the parent's folder unless --parent. Commands that give
|
|
# the parent's VM more access are refused without a terminal.
|
|
mkdir $WORK/app/src/lib
|
|
cd $WORK/app
|
|
exec git init -q
|
|
exec devvm --network open
|
|
|
|
# The parent's VM, its shell in the subfolder.
|
|
cd $WORK/app/src/lib
|
|
stub_reset
|
|
exec devvm
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! stdout creating
|
|
stub_calls
|
|
! stdout 'limactl (clone|create)'
|
|
stdout '^limactl shell --workdir /\S*/app/src/lib devvm-app-[0-9a-f]{14}\n\z'
|
|
exec sh -c 'ls "$VMS" | wc -l'
|
|
stdout '^ *1$'
|
|
|
|
# adopt is for this path's VM only.
|
|
! exec devvm adopt
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|
|
|
|
# stop: the parent's, named first.
|
|
stub_reset
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl stop devvm-app-[0-9a-f]{14}$'
|
|
|
|
# --here: a new VM for the subfolder, nothing asked; then it's the
|
|
# subfolder's own.
|
|
cd $WORK/app/src
|
|
exec devvm --here --network open
|
|
stdout '^==> creating_from image=base vm=devvm-src-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm
|
|
! stdout using_parent_vm
|
|
stub_calls
|
|
stdout '^limactl shell --workdir /\S*/app/src devvm-src-[0-9a-f]{14}\n\z'
|
|
|
|
# The nearest folder with a VM wins.
|
|
cd $WORK/app/src/lib
|
|
exec devvm stop
|
|
stdout '^==> using_parent_vm dir=/\S*/app/src vm=devvm-src-[0-9a-f]{14}$'
|
|
|
|
# A repo of its own below the parent's folder: other commands find no VM,
|
|
# and devvm makes the subfolder's own. --parent takes the parent's
|
|
# across the repo.
|
|
mkdir $WORK/app/tool/bin
|
|
cd $WORK/app/tool
|
|
exec git init -q
|
|
cd $WORK/app/tool/bin
|
|
! exec devvm stop
|
|
stderr '^devvm: no_vm dir=/\S*/app/tool/bin$'
|
|
! stdout using_parent_vm
|
|
stub_reset
|
|
exec devvm --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
stdout '^limactl shell --workdir /\S*/app/tool/bin devvm-app-[0-9a-f]{14}\n\z'
|
|
exec devvm stop --parent
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}\n==> stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm --network open
|
|
stdout '^==> creating_from image=base vm=devvm-bin-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
|
|
# Once it has its own: --parent passes over it, --here keeps to it, and
|
|
# the two don't go together.
|
|
exec devvm stop --parent
|
|
stdout '^==> already_stopped vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm stop --here
|
|
! stdout using_parent_vm
|
|
stdout '^==> stopped vm=devvm-bin-[0-9a-f]{14}$'
|
|
! exec devvm stop --here --parent
|
|
stderr '^devvm: flags_exclusive flag=--here other=--parent$'
|
|
! exec devvm --clone --parent
|
|
stderr '^devvm: flags_exclusive flag=--clone other=--parent$'
|
|
! exec devvm rm devvm-bin-0123456789abcd --here
|
|
stderr '^devvm: rm_vm_folder_flag flag=--here$'
|
|
exec devvm rm --force --no-export
|
|
|
|
# --parent where no folder above has a VM.
|
|
cd $WORK/app
|
|
! exec devvm stop --parent
|
|
stderr '^devvm: no_parent_vm dir=/\S*/app$'
|
|
|
|
# --clone: a new VM for the subfolder's own repo, as --here, nothing
|
|
# asked.
|
|
mkdir $WORK/app/repo
|
|
cd $WORK/app/repo
|
|
env GIT_AUTHOR_NAME=t GIT_AUTHOR_EMAIL=t@t GIT_COMMITTER_NAME=t GIT_COMMITTER_EMAIL=t@t
|
|
exec git init -q -b main
|
|
exec git commit -q --allow-empty -m one
|
|
exec devvm --clone --network open
|
|
stdout '^==> creating_from image=base vm=devvm-repo-[0-9a-f]{14}$'
|
|
! stdout using_parent_vm
|
|
exec devvm rm --force --no-export
|
|
|
|
# rm: never a parent's without asking. Without a terminal it's refused,
|
|
# --force or not, and nothing is deleted; in the parent's folder it goes.
|
|
cd $WORK/app/src
|
|
exec devvm rm --force
|
|
cd $WORK/app/src/lib
|
|
|
|
# Commands that give a parent's VM more access are refused without a
|
|
# terminal, naming the VM and its folder, and change nothing.
|
|
! exec devvm secret use github
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm secret use dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
! exec devvm ssh-agent on
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm ssh-agent on dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm ssh-agent
|
|
stdout '^off$'
|
|
! exec devvm network allow example.com
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network allow dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
exec devvm network deny bad.example.com
|
|
stdout 'rule_added'
|
|
! exec devvm network rm '!bad.example.com'
|
|
stderr '^devvm: widen_parent_vm_refused cmd=devvm network rm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
vm_name APP app
|
|
exec cat $APP_dir/policy
|
|
stdout '!bad.example.com'
|
|
! stdout '^example.com'
|
|
|
|
stub_reset
|
|
! exec devvm rm --force --no-export
|
|
stdout '^==> using_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stderr '^devvm: rm_parent_vm dir=/\S*/app vm=devvm-app-[0-9a-f]{14}$'
|
|
stub_calls
|
|
! stdout 'limactl delete'
|
|
exec sh -c 'ls "$VMS" | grep -v "\.policy$" | wc -l'
|
|
stdout '^ *1$'
|
|
cd $WORK/app
|
|
exec devvm rm --force
|
|
stdout '^==> deleted vm=devvm-app-[0-9a-f]{14}$'
|
|
exec ls $VMS
|
|
! stdout .
|
|
cd $WORK/app/src/lib
|
|
! exec devvm rm --force
|
|
stderr '^devvm: no_vm dir=/\S*/app/src/lib$'
|