mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
With config.toml's proxy naming a user and no proxy secret saved, devvm in a running VM's folder refused (proxy_password_missing) but stopped the VM (net_proxy_down_stopped), and devvm restart stopped it before refusing. Every check that can refuse a proxy start already ran before Prepare stopped the old proxy; runningConfinement stopped the VM on any error. - netpolicy.Proxy.PrepareRunning: Prepare for a running VM. A refusal before its proxy is touched keeps the VM and proxy (net_proxy_kept, a new message) only while that proxy enforces the state's tier now (enforcesNow: built-in, files, denies, open, devvm binary); otherwise, or once its proxy was stopped or started, or with none running, the VM is stopped (unproxied, was Unproxied, which now stops a proxy left running too). - netpolicy.Proxy.Refusal (shared): the user's CAs and the company proxy, checked first in prepare, before a VM is made (up), before a running VM is stopped to start again (target.stopToStart: devvm restart, restartForNextStart), and before a running VM's tier changes between confined tiers (checkTier: devvm network, lock), so its state never names a tier its proxy doesn't enforce. - devvm network's change to a running VM's rules goes through PrepareRunning, so a proxy that can't start again stops the VM rather than leaving it running without one. - Proxy.Upstream removed (no callers); shared, prepare, unproxied and tierNow are functions of the proxy, keeping Proxy within 24 methods. Tests: company_proxy.txtar (launch and restart refused, VM and proxy untouched; devvm network allowlist refused, tier unchanged), TestPrepareRunningRefused (eight rows), e2e corpConfig checks the VM's status after the refused launch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
121 lines
4.1 KiB
Plaintext
121 lines
4.1 KiB
Plaintext
# The company proxy in config.toml: a VM with network policy goes through
|
|
# it when devvm's environment sets none. Its URL names the user alone, and
|
|
# the password is the proxy secret, which the VM's proxy looks up itself,
|
|
# so neither its config nor its arguments hold it. A shell without the
|
|
# settings starts the VM's proxy without them, with a warning. Builds
|
|
# check the password before anything is built, and a VM without network
|
|
# policy, which never gets config.toml's proxy, warns. Every value here is
|
|
# fake, and no password is ever in an argument.
|
|
|
|
# A password in config.toml is refused, never shown.
|
|
project corp
|
|
cp $WORK/password.toml $CFG/config.toml
|
|
! exec devvm --network allowlist --no-git-protect
|
|
stderr 'proxy_password_in_config key=proxy\.https'
|
|
! stderr pa55
|
|
|
|
# The user alone, and no password saved: the VM doesn't start, and
|
|
# builds stop before anything is built.
|
|
cp $WORK/user.toml $CFG/config.toml
|
|
! exec devvm --network allowlist --no-git-protect
|
|
stderr '^devvm: proxy_password_missing$'
|
|
stub_reset
|
|
! exec devvm build base
|
|
stderr '^devvm: proxy_password_missing$'
|
|
! exec devvm rebuild base --force
|
|
stderr '^devvm: proxy_password_missing$'
|
|
stub_calls
|
|
! stdout 'limactl (create|start|clone)'
|
|
|
|
# Saved, the VM's proxy goes through it, the password the secret's.
|
|
stdin $WORK/proxy.password
|
|
exec devvm secret set proxy --stdin
|
|
exec devvm --network allowlist --no-git-protect
|
|
vm_name CORP corp
|
|
exec cat $CORP_dir/run/proxy.json
|
|
stdout '"https": "http://alice@proxy\.corp\.example:3128"'
|
|
stdout '"secret": "proxy"'
|
|
! stdout pa55
|
|
! stderr upstream_proxy_gone
|
|
|
|
# The secret deleted while the VM runs: a launch, and a restart, are
|
|
# refused before they touch the VM or its proxy, which run on as they were.
|
|
exec devvm secret rm --force proxy
|
|
exec sh -c 'cat "$CORP_dir/run/proxy.pid" > "$WORK/corp.pid"'
|
|
stub_reset
|
|
! exec devvm
|
|
stderr '^devvm: proxy_password_missing$'
|
|
stderr '^devvm: net_proxy_kept vm=devvm-corp-[0-9a-f]{14}$'
|
|
! stderr net_proxy_down_stopped
|
|
! exec devvm restart
|
|
stderr '^devvm: proxy_password_missing$'
|
|
stderr '^devvm: net_proxy_kept vm=devvm-corp-[0-9a-f]{14}$'
|
|
! stderr net_proxy_down_stopped
|
|
stub_calls
|
|
! stdout 'limactl (stop|start)'
|
|
exec sh -c 'test "$(cat "$CORP_dir/run/proxy.pid")" = "$(cat "$WORK/corp.pid")" && kill -0 "$(cat "$WORK/corp.pid")"'
|
|
exec devvm ls
|
|
stdout '^devvm-corp-[0-9a-f]{14} +Running '
|
|
stdin $WORK/proxy.password
|
|
exec devvm secret set proxy --stdin
|
|
|
|
# A tier change of the running VM between confined tiers is refused the
|
|
# same way before its state changes, so its state never names a tier its
|
|
# proxy doesn't enforce.
|
|
exec devvm network internet
|
|
exec devvm secret rm --force proxy
|
|
stub_reset
|
|
! exec devvm network allowlist
|
|
stderr '^devvm: proxy_password_missing$'
|
|
! stderr net_proxy_down_stopped
|
|
vm_state $CORP_dir/vm.json
|
|
stdout '^net\.tier=internet$'
|
|
stub_calls
|
|
! stdout 'limactl (stop|start)'
|
|
exec sh -c 'kill -0 "$(cat "$CORP_dir/run/proxy.pid")"'
|
|
stdin $WORK/proxy.password
|
|
exec devvm secret set proxy --stdin
|
|
exec devvm network allowlist
|
|
|
|
# Without config.toml's proxy, and none in the environment, the next start
|
|
# warns, naming config.toml, and the one after doesn't.
|
|
exec devvm stop
|
|
cp $WORK/none.toml $CFG/config.toml
|
|
exec devvm
|
|
stderr '^devvm: upstream_proxy_gone file=\S*/config/devvm/config\.toml vm_name=devvm-corp-[0-9a-f]{14}$'
|
|
exec cat $CORP_dir/run/proxy.json
|
|
! stdout '"upstream"'
|
|
exec devvm stop
|
|
exec devvm
|
|
! stderr upstream_proxy_gone
|
|
exec devvm secret rm --force proxy
|
|
|
|
# An open VM goes through its proxy too, which goes through config.toml's
|
|
# company proxy, so the VM needs none of the shell's settings; Lima
|
|
# passes the shell's on to no VM with devvm's proxy.
|
|
project plain
|
|
cp $WORK/nouser.toml $CFG/config.toml
|
|
exec devvm --network open --no-git-protect
|
|
vm_name PLAIN plain
|
|
exec cat $PLAIN_dir/run/proxy.json
|
|
stdout '"upstream": \{\n "https": "http://proxy\.corp\.example:3128"'
|
|
stdout '"open": true'
|
|
|
|
-- password.toml --
|
|
features = []
|
|
[proxy]
|
|
https = "http://alice:[email protected]:3128"
|
|
-- user.toml --
|
|
features = []
|
|
[proxy]
|
|
https = "http://[email protected]:3128"
|
|
no-proxy = ".corp.example"
|
|
-- nouser.toml --
|
|
features = []
|
|
[proxy]
|
|
https = "http://proxy.corp.example:3128"
|
|
-- none.toml --
|
|
features = []
|
|
-- proxy.password --
|
|
pa55 word
|