mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
A 6to4 address (2002::/16) passed the floor as public even when the IPv4 address in it was private, and Teredo, IPv6's documentation, discard-only, benchmarking, ORCHID, SRv6 and IPv4-translated ranges, and IPv4's documentation ranges and 192.88.99.0/24, counted as the internet. - withIPv4 (was nat64): the IPv6 ranges that carry an IPv4 address, NAT64's and 6to4's, each with its site's prefix length (6to4's /48); embeddedIPv4 (was nat64IPv4) reads either. - hostAddrs.internal: the host's own address first, then the 6to4 site of any of its own addresses (its LAN's), then the embedded IPv4 address; hostAddrs.own, the address map, replaces has. - rule.matchAddr: a 6to4 address matches as its IPv4 address for a deny alone, as 6to4 goes through relays anyone may run; NAT64 still matches for both. - notPublic gains 2001::/32, 2001:db8::/32, 3fff::/20, 100::/64, 2001:2::/48, 2001:10::/28, 2001:20::/28, 5f00::/16, ::ffff:0:0:0/96, 192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24 and 192.88.99.0/24. - Tests: TestInternal's rows, TestInternalOwn6to4, TestSixToFourAllowsNot, TestResolveSixToFourName, a 6to4 deny in TestAddressDenyAppliesToNames; the learning tests' public address is 93.184.215.14 now, as 203.0.113.5 is documentation's. - The structure test's table name, the proxy's README, network.md's range list (with Teredo under a broad IPv6 allow), attack-vectors and safety/network, and a CHANGELOG Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]>
232 lines
8.9 KiB
Plaintext
232 lines
8.9 KiB
Plaintext
# --network learn: a new VM on the internet tier that learns the hosts it
|
|
# reaches, which devvm network lock then adds to its own rules as it goes
|
|
# to the allowlist tier. The events are dated after any test's learning
|
|
# started.
|
|
|
|
# --network takes learn, and nothing that's no choice.
|
|
project learn
|
|
! exec devvm --network learning --no-git-protect
|
|
stderr '^devvm: arg_not_choice choices=open, internet, learn, allowlist, none command=--network given=learning$'
|
|
|
|
# Made learning: the summary says so, its state is internet with when it
|
|
# started, and its start says it learns from now on. (Its hostagent
|
|
# here: the test's runner, so it starts confined and its proxy runs on.)
|
|
exec sh -c 'echo $PPID > "$STUB_DIR/hostagent"'
|
|
exec devvm --network learn --no-git-protect
|
|
rm $STUB_DIR/hostagent
|
|
stdout '^new_vm_network_learn$'
|
|
! stdout new_vm_network\b
|
|
stdout '^==> net_learn_started vm=devvm-learn-[0-9a-f]{14}$'
|
|
! stderr net_learning
|
|
vm_name L learn
|
|
vm_state $L_dir/vm.json
|
|
stdout '^net\.tier=internet$'
|
|
stdout '^net\.learning\.since=\d{4}-'
|
|
# Its log marks when it started learning, which devvm network log doesn't
|
|
# show.
|
|
grep '"event":"learn"' $L_dir/logs/network.jsonl
|
|
exec devvm network log --json
|
|
! stdout '"learn"'
|
|
|
|
# devvm ls shows it after its tier, as devvm network does, and --json adds
|
|
# when it started.
|
|
exec devvm ls
|
|
stdout '^devvm-learn-[0-9a-f]{14} .* internet \(learning\) '
|
|
exec devvm ls --json
|
|
stdout '^ "net": "internet",\n "learning_since": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ",$'
|
|
exec devvm network
|
|
stdout '\Ainternet \(learning\)\n'
|
|
exec devvm network --json
|
|
stdout '^ "policy": "internet",\n "learning_since": "\d{4}-'
|
|
|
|
# What it reached: its launch counts the hosts beyond its allowlist,
|
|
# leaving out github.com, which devvm's rules allow, a host your rules
|
|
# deny, a private address, blocks and what came before it learned.
|
|
cp $WORK/deny.policy $CFG/policy
|
|
exec sh -c 'mkdir -p "$L_dir/logs" && cp "$WORK/events.jsonl" "$L_dir/logs/network.jsonl"'
|
|
exec devvm
|
|
stderr '^net_learning count=6 since=\S+ \S+ vm=devvm-learn-[0-9a-f]{14}$'
|
|
|
|
# --json lists them, each with its exact port, those under a domain the
|
|
# allowlist has first and the risky last, and changes nothing.
|
|
exec devvm network lock --json
|
|
stdout '^ "learning_since": "\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ",$'
|
|
exec sh -c 'devvm network lock --json | grep -v "\"learning_since\""'
|
|
cmp stdout $WORK/learned.json
|
|
vm_state $L_dir/vm.json
|
|
stdout '^net\.tier=internet$'
|
|
! exec devvm network lock --json --all
|
|
stderr '^devvm: flags_exclusive flag=--(json|all) other=--(json|all)$'
|
|
! exec devvm network lock --all --none
|
|
stderr '^devvm: flags_exclusive flag=--(all|none) other=--(all|none)$'
|
|
! exec devvm network lock nope
|
|
stderr '^devvm: args_none command=devvm network lock given=nope$'
|
|
|
|
# Where devvm can't ask, the lock is refused, naming --all and --none, and
|
|
# changes nothing; so is devvm network allowlist while it learns.
|
|
! exec devvm network lock
|
|
stderr 'net_lock_help vm=devvm-learn-[0-9a-f]{14}'
|
|
stderr '^devvm: no_input answer=--all or --none$'
|
|
! exec devvm network allowlist
|
|
stderr '^devvm: net_learning_lock vm=devvm-learn-[0-9a-f]{14}$'
|
|
vm_state $L_dir/vm.json
|
|
stdout '^net\.tier=internet$'
|
|
! exists $L_dir/policy
|
|
|
|
# In a terminal: the context, then the picker, only the reviewed
|
|
# registry's host on 443 ticked, each with its connections and its
|
|
# User-Agent, the risky ones under a heading of their own; j and the
|
|
# space tick example.com too, and what's ticked is added, said once its
|
|
# proxy has it.
|
|
env DEVVM_PICK_ON_PIPE=1
|
|
ttyin -stdin $WORK/pick.txt
|
|
exec devvm network lock
|
|
stdout '^net_lock_context since=\S+ \S+$'
|
|
stdout 'net_lock_help vm=devvm-learn-[0-9a-f]{14}\r$'
|
|
stdout '\[x\] files\.pythonhosted\.org:443 +net_learned_host_anon count=1'
|
|
stdout '\[ \] example\.com:443 +net_learned_host agent=curl/8\.5\.0 count=2'
|
|
stdout '\[ \] new\.test:8080 +net_learned_host_anon count=1'
|
|
stdout '(?s)net_learned_risky_heading\r\n.*\[ \] 93\.184\.215\.14:443 +net_learned_host_anon count=1'
|
|
stdout '\[ \] pastebin\.com:443 +net_learned_host agent=curl/8\.5\.0 count=1'
|
|
stdout '==> net_locked count=2 vm=devvm-learn-[0-9a-f]{14}\n==> setting_applied vm=devvm-learn-[0-9a-f]{14}$'
|
|
cmp $L_dir/policy $WORK/policy
|
|
vm_state $L_dir/vm.json
|
|
stdout '^net\.tier=allowlist$'
|
|
! stdout learning
|
|
env DEVVM_PICK_ON_PIPE=
|
|
|
|
# Locked, it learns no more: lock is refused, ls and network show its
|
|
# tier alone, and its launch says nothing of learning.
|
|
! exec devvm network lock --all
|
|
stderr '^devvm: net_not_learning vm=devvm-learn-[0-9a-f]{14}$'
|
|
exec devvm network
|
|
stdout '\Aallowlist\n'
|
|
exec devvm
|
|
! stderr net_learning
|
|
|
|
# devvm network learn on a VM that exists: from allowlist it widens, at
|
|
# once, and says it learns; again it's that way already. internet stops
|
|
# it, the tier as it was.
|
|
exec devvm network learn
|
|
stdout '^==> net_learn_started vm=devvm-learn-[0-9a-f]{14}$'
|
|
exec devvm network learn
|
|
stdout '^==> setting_already command=devvm network learn vm=devvm-learn-[0-9a-f]{14}$'
|
|
exec devvm network internet
|
|
stdout '^==> net_learn_stopped vm=devvm-learn-[0-9a-f]{14}$'
|
|
vm_state $L_dir/vm.json
|
|
stdout '^net\.tier=internet$'
|
|
! stdout learning
|
|
|
|
# --all adds every host, the risky ones too; --none adds none. Either
|
|
# goes to the allowlist tier at once.
|
|
exec devvm network learn
|
|
exec sh -c 'cp "$WORK/events.jsonl" "$L_dir/logs/network.jsonl" && rm "$L_dir/policy"'
|
|
exec devvm network lock --all
|
|
stdout '^==> net_locked count=6 vm=devvm-learn-[0-9a-f]{14}$'
|
|
cmp $L_dir/policy $WORK/policy-all
|
|
project none
|
|
exec devvm --network learn --no-git-protect
|
|
vm_name N none
|
|
exec devvm network lock --none
|
|
stdout '^==> net_locked count=0 vm=devvm-none-[0-9a-f]{14}$'
|
|
! exists $N_dir/policy
|
|
vm_state $N_dir/vm.json
|
|
stdout '^net\.tier=allowlist$'
|
|
|
|
# Learning is for one VM at a time: no default makes new VMs learn, so
|
|
# devvm network -g learn is refused, naming how to make one learn, and
|
|
# config.toml can't set it.
|
|
! exec devvm network -g learn
|
|
stderr '^devvm: net_learn_not_global$'
|
|
stderr 'usage_help command=devvm network'
|
|
exec devvm network -g
|
|
stdout '^allowlist # '
|
|
cp $WORK/config-learn.toml $CFG/config.toml
|
|
! exec devvm network -g
|
|
stderr '"learn" isn''t one of open, internet, allowlist, none'
|
|
rm $CFG/config.toml
|
|
|
|
-- deny.policy --
|
|
!denied.test
|
|
-- config-learn.toml --
|
|
network = "learn"
|
|
-- events.jsonl --
|
|
{"time":"2001-01-01T00:00:00Z","vm":"x","event":"tunnel","host":"before.test","port":443}
|
|
{"time":"2099-01-01T00:00:00Z","vm":"x","event":"learn","host":"","port":0}
|
|
{"time":"2099-01-01T00:00:01Z","vm":"x","event":"tunnel","host":"example.com","port":443,"method":"CONNECT","agent":"curl/8.5.0"}
|
|
{"time":"2099-01-01T00:00:02Z","vm":"x","event":"intercept","host":"example.com","port":443,"method":"CONNECT","agent":"curl/8.5.0"}
|
|
{"time":"2099-01-01T00:00:03Z","vm":"x","event":"forward","host":"new.test","port":8080,"method":"GET","path":"/"}
|
|
{"time":"2099-01-01T00:00:04Z","vm":"x","event":"tunnel","host":"pastebin.com","port":443,"method":"CONNECT","agent":"curl/8.5.0"}
|
|
{"time":"2099-01-01T00:00:05Z","vm":"x","event":"tunnel","host":"93.184.215.14","port":443,"method":"CONNECT"}
|
|
{"time":"2099-01-01T00:00:06Z","vm":"x","event":"tunnel","host":"10.0.0.5","port":22,"method":"CONNECT"}
|
|
{"time":"2099-01-01T00:00:07Z","vm":"x","event":"tunnel","host":"github.com","port":443,"method":"CONNECT"}
|
|
{"time":"2099-01-01T00:00:08Z","vm":"x","event":"blocked","host":"blocked.test","port":443,"method":"CONNECT","reason":"denied by !blocked.test"}
|
|
{"time":"2099-01-01T00:00:09Z","vm":"x","event":"tunnel","host":"files.pythonhosted.org","port":443,"method":"CONNECT"}
|
|
{"time":"2099-01-01T00:00:09Z","vm":"x","event":"tunnel","host":"objects.github.com","port":443,"method":"CONNECT"}
|
|
{"time":"2099-01-01T00:00:10Z","vm":"x","event":"tunnel","host":"denied.test","port":443,"method":"CONNECT"}
|
|
-- learned.json --
|
|
{
|
|
"version": 1,
|
|
"hosts": [
|
|
{
|
|
"rule": "files.pythonhosted.org:443",
|
|
"host": "files.pythonhosted.org",
|
|
"port": 443,
|
|
"count": 1,
|
|
"last": "2099-01-01T00:00:09Z",
|
|
"tickable": true
|
|
},
|
|
{
|
|
"rule": "example.com:443",
|
|
"host": "example.com",
|
|
"port": 443,
|
|
"count": 2,
|
|
"last": "2099-01-01T00:00:02Z",
|
|
"agent": "curl/8.5.0"
|
|
},
|
|
{
|
|
"rule": "new.test:8080",
|
|
"host": "new.test",
|
|
"port": 8080,
|
|
"count": 1,
|
|
"last": "2099-01-01T00:00:03Z"
|
|
},
|
|
{
|
|
"rule": "objects.github.com:443",
|
|
"host": "objects.github.com",
|
|
"port": 443,
|
|
"count": 1,
|
|
"last": "2099-01-01T00:00:09Z"
|
|
},
|
|
{
|
|
"rule": "93.184.215.14:443",
|
|
"host": "93.184.215.14",
|
|
"port": 443,
|
|
"count": 1,
|
|
"last": "2099-01-01T00:00:05Z",
|
|
"risk": "address"
|
|
},
|
|
{
|
|
"rule": "pastebin.com:443",
|
|
"host": "pastebin.com",
|
|
"port": 443,
|
|
"count": 1,
|
|
"last": "2099-01-01T00:00:04Z",
|
|
"agent": "curl/8.5.0",
|
|
"risk": "paste"
|
|
}
|
|
]
|
|
}
|
|
-- pick.txt --
|
|
j j
|
|
-- policy --
|
|
files.pythonhosted.org:443
|
|
example.com:443
|
|
-- policy-all --
|
|
files.pythonhosted.org:443
|
|
example.com:443
|
|
new.test:8080
|
|
objects.github.com:443
|
|
93.184.215.14:443
|
|
pastebin.com:443
|