egress allow: private CIDR ranges, not only single addresses (#1357)
carlos apps set --egress-allow now takes private ranges (10.0.64.0/20, fd00:5::/64) alongside single addresses, so a managed store that moves within its subnets on failover stays reachable. - egressaddr: ranges no wider than /16 (IPv4) or /48 (IPv6), wholly inside the instance fence, overlapping no refused class; host bits refused; still at most 8 entries; singles stored byte-identically. - root writes the operator's exact prefix and refuses a range holding one of the box's own addresses; kernel proof on the root runner (20261122T130018-3b700d): inside reachable, outside refused, revoke closes it. - console refuses a range holding a published box address, and refuses any range until every fresh box runs v0.43.0 (an older box reads the whole policy as unverifiable and closes the app's allows and size). - the fleet-box "not checked" warning reworded; docs and CLI help. - census: envelope-only overlays, Astra APPROVE (#280). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from egress-allow-cidr into main.
26 files changed,
+1,618
−146
apps_policy.go+6 −3apps_policy_test.go+6 −5docs/site/cli.md+5 −5docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md+11 −0docs/superpowers/notes/census-proposal-egress-allow-cidr.md+11 −0docs/superpowers/plans/2026-10-21-instance-policy-copy.json+10 −9docs/superpowers/plans/2026-11-22-egress-allow-cidr.md+261 −0internal/apppolicy/apppolicy.go+13 −8internal/apppolicy/apppolicy_test.go+14 −0internal/console/egressfleet.go+170 −42internal/console/egressfleet_test.go+209 −3internal/egressaddr/egressaddr.go+171 −29internal/egressaddr/egressaddr_test.go+184 −1internal/host/egress_fixtures_rootrunner_linux_test.go+48 −16internal/host/egress_prefix_rootrunner_linux_test.go+231 −0internal/host/egress_source_test.go+58 −0internal/instancectl/egress.go+25 −21internal/instancectl/egress_test.go+106 −2internal/instancectl/localaddrs.go+11 −0internal/provision/apppolicy_reconcile_test.go+30 −0internal/provision/testdata/plan14-root-reads-chain.tsv+2 −0internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv+6 −0internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv+5 −0internal/release/layoutintent.go+12 −0internal/release/layoutintent_test.go+11 −0testdata/clireg-golden.jsonl+2 −2
CI cancelled — superseded by a newer push — run details
CI log
=== gate ===
go: downloading go1.26.10 (linux/arm64)
go version go1.26.10 linux/arm64
opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1
tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz
tofu: downloaded, digest verified
aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip
aws: downloaded, digest verified
archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip
archive: downloaded, digest verified
installed in /tmp/carlos-opentofu-RJEiwk
.amadan/test-gate.sh
go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0
go: downloading github.com/aws/smithy-go v1.28.1
go: downloading github.com/benbjohnson/litestream v0.5.14
go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0
go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5
go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0
go: downloading golang.org/x/net v0.62.0
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0
go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2
go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0
go: downloading golang.org/x/sys v0.49.0
go: downloading golang.org/x/crypto v0.58.0
go: downloading github.com/pion/logging v0.2.4
go: downloading github.com/pion/stun/v3 v3.1.5
go: downloading github.com/pion/turn/v4 v4.1.4
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pion/dtls/v3 v3.1.4
go: downloading github.com/pion/randutil v0.1.0
go: downloading github.com/prometheus/client_golang v1.17.0
go: downloading golang.org/x/sync v0.24.0
go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18
go: downloading github.com/lmittmann/tint v1.1.3
go: downloading github.com/pion/transport/v4 v4.0.2
go: downloading golang.org/x/text v0.43.0
go: downloading github.com/wlynxg/anet v0.0.5
go: downloading github.com/prometheus/common v0.45.0
go: downloading github.com/beorn7/perks v1.0.1
go: downloading github.com/cespare/xxhash/v2 v2.3.0
go: downloading github.com/prometheus/client_model v0.5.0
go: downloading google.golang.org/protobuf v1.36.10
go: downloading github.com/prometheus/procfs v0.12.0
go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/memory v1.11.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== launchctx (4 s, from +0 s)
ok amadan.net/carlos/platform.git/launchctx 0.016s
? amadan.net/carlos/platform.git/launchctx/controlname [no test files]
? amadan.net/carlos/platform.git/launchctx/wireid [no test files]
=== vet (174 s, from +0 s)
go: downloading github.com/klauspost/compress v1.20.2
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading modernc.org/sqlite v1.55.0
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading modernc.org/libc v1.74.1
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec
=== vet-tags (180 s, from +0 s)
go: downloading modernc.org/sqlite v1.55.0
go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
go: downloading github.com/klauspost/compress v1.20.2
go: downloading github.com/pierrec/lz4/v4 v4.1.22
go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0
go: downloading modernc.org/libc v1.74.1
go: downloading modernc.org/memory v1.11.0
go: downloading github.com/dustin/go-humanize v1.0.1
go: downloading github.com/google/uuid v1.6.0
go: downloading modernc.org/mathutil v1.7.1
=== gofmt (1 s, from +0 s)
gofmt -l .: clean
=== rest (381 s, from +15 s)
ok github.com/carlosframework/platform/cmd/carlos-media 124.648s
? github.com/carlosframework/platform/cmd/changelog [no test files]
ok github.com/carlosframework/platform/cmd/console 202.102s
ok github.com/carlosframework/platform/cmd/mediaimage 42.977s
ok github.com/carlosframework/platform/cmd/moveprobe 14.970s
ok github.com/carlosframework/platform/cmd/pricebook-export 0.080s
ok github.com/carlosframework/platform/cmd/rootfswitness 0.201s
ok github.com/carlosframework/platform/cmd/runsc-assets 0.252s
ok github.com/carlosframework/platform/cmd/zddprobe 1.063s
ok github.com/carlosframework/platform/internal/agentsock 0.081s
ok github.com/carlosframework/platform/internal/alerting 0.053s
ok github.com/carlosframework/platform/internal/analytics 0.306s
ok github.com/carlosframework/platform/internal/appconfig 45.598s
ok github.com/carlosframework/platform/internal/apperr 0.359s
ok github.com/carlosframework/platform/internal/applog 0.607s
ok github.com/carlosframework/platform/internal/apppolicy 2.994s
ok github.com/carlosframework/platform/internal/assetcache 0.552s
ok github.com/carlosframework/platform/internal/awsinv 0.056s
ok github.com/carlosframework/platform/internal/awsmanaged 0.756s
ok github.com/carlosframework/platform/internal/awsregiongroup 0.084s
ok github.com/carlosframework/platform/internal/awsterminations 0.034s
ok github.com/carlosframework/platform/internal/backupswords 0.018s
ok github.com/carlosframework/platform/internal/billing 0.115s
ok github.com/carlosframework/platform/internal/billing/billingtest 0.058s
ok github.com/carlosframework/platform/internal/billingstripe 2.170s
ok github.com/carlosframework/platform/internal/boxchoice 0.046s
ok github.com/carlosframework/platform/internal/boxid 5.686s
? github.com/carlosframework/platform/internal/boxid/boxidtest [no test files]
? github.com/carlosframework/platform/internal/boxid/internal/signtest [no test files]
ok github.com/carlosframework/platform/internal/boxroles 0.019s
ok github.com/carlosframework/platform/internal/boxself 0.154s
ok github.com/carlosframework/platform/internal/boxvolumes 0.085s
ok github.com/carlosframework/platform/internal/caps 0.153s
ok github.com/carlosframework/platform/internal/certwarm 0.018s
ok github.com/carlosframework/platform/internal/cgroup 1.640s
ok github.com/carlosframework/platform/internal/changelog 4.374s
ok github.com/carlosframework/platform/internal/clamd 0.079s
? github.com/carlosframework/platform/internal/cliflag [no test files]
ok github.com/carlosframework/platform/internal/clireg 0.015s
ok github.com/carlosframework/platform/internal/codehealth 18.093s
ok github.com/carlosframework/platform/internal/compute 0.011s
? github.com/carlosframework/platform/internal/controlname [no test files]
? github.com/carlosframework/platform/internal/controlsock [no test files]
ok github.com/carlosframework/platform/internal/dbdoor 10.660s
ok github.com/carlosframework/platform/internal/dbdoor/dbdoortest 0.066s
ok github.com/carlosframework/platform/internal/dbquery 0.016s
ok github.com/carlosframework/platform/internal/dbreads 3.028s
? github.com/carlosframework/platform/internal/dbreads/dbreadstest [no test files]
ok github.com/carlosframework/platform/internal/dbverify 0.051s
ok github.com/carlosframework/platform/internal/demo 0.010s
ok github.com/carlosframework/platform/internal/demobuild 4.069s
ok github.com/carlosframework/platform/internal/democlaim 0.456s
ok github.com/carlosframework/platform/internal/devbox 18.845s
ok github.com/carlosframework/platform/internal/dnsrec 0.010s
ok github.com/carlosframework/platform/internal/docsite 0.074s
ok github.com/carlosframework/platform/internal/domainreg 0.014s
ok github.com/carlosframework/platform/internal/domains 68.015s
ok github.com/carlosframework/platform/internal/doorkey 0.028s
ok github.com/carlosframework/platform/internal/economics 0.009s
ok github.com/carlosframework/platform/internal/edgefence 0.168s
ok github.com/carlosframework/platform/internal/edgeguard 0.339s
? github.com/carlosframework/platform/internal/edgeproof [no test files]
ok github.com/carlosframework/platform/internal/edgesfile 0.065s
ok github.com/carlosframework/platform/internal/egressaddr 0.007s
ok github.com/carlosframework/platform/internal/execsandbox 102.679s
ok github.com/carlosframework/platform/internal/fileacl 0.005s
ok github.com/carlosframework/platform/internal/fleetapi 2.730s
ok github.com/carlosframework/platform/internal/fleetstore 0.006s
ok github.com/carlosframework/platform/internal/fxrate 0.050s
ok github.com/carlosframework/platform/internal/gate 4.917s
ok github.com/carlosframework/platform/internal/genselect 0.110s
ok github.com/carlosframework/platform/internal/geo 0.102s
ok github.com/carlosframework/platform/internal/geoip 0.170s
ok github.com/carlosframework/platform/internal/groupadmission 0.009s
ok github.com/carlosframework/platform/internal/grouprollaws 18.093s
ok github.com/carlosframework/platform/internal/hadeparture 0.030s
ok github.com/carlosframework/platform/internal/hafresh 0.018s
ok github.com/carlosframework/platform/internal/hairpin 0.222s
ok github.com/carlosframework/platform/internal/historyreadback 1.406s
ok github.com/carlosframework/platform/internal/hostactors 23.981s
ok github.com/carlosframework/platform/internal/hostbox 22.245s
ok github.com/carlosframework/platform/internal/hostclaim 3.664s
ok github.com/carlosframework/platform/internal/hostenv 0.043s
ok github.com/carlosframework/platform/internal/hostevidence 0.023s
ok github.com/carlosframework/platform/internal/hostexec 27.130s
ok github.com/carlosframework/platform/internal/hostfence 0.168s
ok github.com/carlosframework/platform/internal/hostfiles 28.101s
ok github.com/carlosframework/platform/internal/hostfloor 0.077s
ok github.com/carlosframework/platform/internal/hostguard 1.747s
ok github.com/carlosframework/platform/internal/hostops 9.115s
? github.com/carlosframework/platform/internal/hostops/fencerelease [no test files]
ok github.com/carlosframework/platform/internal/hostops/internal/fencerelease 0.007s
ok github.com/carlosframework/platform/internal/hostquarantine 0.018s
ok github.com/carlosframework/platform/internal/hostrelocate 2.817s
ok github.com/carlosframework/platform/internal/hostresolve 0.781s
ok github.com/carlosframework/platform/internal/hostwrite 0.007s
ok github.com/carlosframework/platform/internal/infraview 0.011s
ok github.com/carlosframework/platform/internal/ingresshealth 0.017s
ok github.com/carlosframework/platform/internal/ingresshealth/awstg 0.021s
ok github.com/carlosframework/platform/internal/instancectl 55.217s
ok github.com/carlosframework/platform/internal/instanceexec 9.390s
ok github.com/carlosframework/platform/internal/instancefs 0.027s
ok github.com/carlosframework/platform/internal/instancekey 0.013s
ok github.com/carlosframework/platform/internal/instanceupdates 0.022s
ok github.com/carlosframework/platform/internal/interactive 0.876s
ok github.com/carlosframework/platform/internal/launchd 0.011s
ok github.com/carlosframework/platform/internal/layout 24.221s
ok github.com/carlosframework/platform/internal/layout/pubclass 101.592s
ok github.com/carlosframework/platform/internal/lbhealth 0.022s
ok github.com/carlosframework/platform/internal/lease 143.350s
ok github.com/carlosframework/platform/internal/lease/leasetest 1.648s
ok github.com/carlosframework/platform/internal/lease/locktest 0.024s
ok github.com/carlosframework/platform/internal/ledger 0.032s
ok github.com/carlosframework/platform/internal/mail 1.257s
ok github.com/carlosframework/platform/internal/mailer 0.786s
ok github.com/carlosframework/platform/internal/mailsubmit 1.483s
ok github.com/carlosframework/platform/internal/mailwire 0.021s
ok github.com/carlosframework/platform/internal/maintenance 0.234s
ok github.com/carlosframework/platform/internal/maintenanceexec 8.477s
ok github.com/carlosframework/platform/internal/maintenanceguard 0.228s
ok github.com/carlosframework/platform/internal/media 2.238s
ok github.com/carlosframework/platform/internal/media/mediatest 0.007s
ok github.com/carlosframework/platform/internal/mediaaws 60.432s
ok github.com/carlosframework/platform/internal/mediahandler 43.384s
ok github.com/carlosframework/platform/internal/mediajobs 0.649s
ok github.com/carlosframework/platform/internal/medialocal 10.147s
ok github.com/carlosframework/platform/internal/metrics 0.096s
ok github.com/carlosframework/platform/internal/minorunits 0.007s
ok github.com/carlosframework/platform/internal/moves 54.805s
ok github.com/carlosframework/platform/internal/moves/archive 3.012s
ok github.com/carlosframework/platform/internal/moves/offlinerun 0.127s
ok github.com/carlosframework/platform/internal/namedunits 0.032s
ok github.com/carlosframework/platform/internal/objstore 0.941s
ok github.com/carlosframework/platform/internal/ops 17.581s
ok github.com/carlosframework/platform/internal/pageindex 3.819s
ok github.com/carlosframework/platform/internal/parity 0.086s
? github.com/carlosframework/platform/internal/parity/cmd/parity-doc [no test files]
ok github.com/carlosframework/platform/internal/park 0.592s
ok github.com/carlosframework/platform/internal/perf 0.200s
ok github.com/carlosframework/platform/internal/plans 0.142s
ok github.com/carlosframework/platform/internal/privatefile 0.012s
ok github.com/carlosframework/platform/internal/provision 238.870s
ok github.com/carlosframework/platform/internal/proxyproto 0.941s
ok github.com/carlosframework/platform/internal/publicrelease 0.033s
ok github.com/carlosframework/platform/internal/ratelimit 0.162s
ok github.com/carlosframework/platform/internal/regionlabel 0.044s
ok github.com/carlosframework/platform/internal/regionname 0.028s
ok github.com/carlosframework/platform/internal/registrar 0.009s
ok github.com/carlosframework/platform/internal/registrar/openprovider 0.232s
? github.com/carlosframework/platform/internal/registrar/registrartest [no test files]
ok github.com/carlosframework/platform/internal/registry 86.341s
ok github.com/carlosframework/platform/internal/relay 7.795s
ok github.com/carlosframework/platform/internal/release 78.281s
ok github.com/carlosframework/platform/internal/replicagen 0.047s
ok github.com/carlosframework/platform/internal/replicas 0.093s
ok github.com/carlosframework/platform/internal/reqrec 6.924s
ok github.com/carlosframework/platform/internal/rollout 12.036s
ok github.com/carlosframework/platform/internal/rolloutwords 0.024s
ok github.com/carlosframework/platform/internal/rootaws 99.699s
ok github.com/carlosframework/platform/internal/rootfsimage 0.686s
ok github.com/carlosframework/platform/internal/rootparticipation 0.080s
ok github.com/carlosframework/platform/internal/rootstate 0.037s
ok github.com/carlosframework/platform/internal/runs 0.778s
ok github.com/carlosframework/platform/internal/s3compat 0.037s
ok github.com/carlosframework/platform/internal/s3fake 1.042s
ok github.com/carlosframework/platform/internal/safefile 0.041s
ok github.com/carlosframework/platform/internal/schedule 25.063s
ok github.com/carlosframework/platform/internal/seeds 0.107s
ok github.com/carlosframework/platform/internal/sim/litestreamfacts 5.279s
ok github.com/carlosframework/platform/internal/sim/mediajobs 47.120s
ok github.com/carlosframework/platform/internal/sim/regionha 24.761s
ok github.com/carlosframework/platform/internal/status 0.669s
ok github.com/carlosframework/platform/internal/steering 0.440s
ok github.com/carlosframework/platform/internal/stopevidence 0.607s
ok github.com/carlosframework/platform/internal/storecfg 0.610s
ok github.com/carlosframework/platform/internal/svcrole 0.023s
ok github.com/carlosframework/platform/internal/systemd 5.991s
? github.com/carlosframework/platform/internal/systemdshow [no test files]
ok github.com/carlosframework/platform/internal/team 4.727s
ok github.com/carlosframework/platform/internal/teamcontract 0.240s
ok github.com/carlosframework/platform/internal/telemetry 0.058s
ok github.com/carlosframework/platform/internal/termfence 4.248s
ok github.com/carlosframework/platform/internal/timerspec 0.032s
ok github.com/carlosframework/platform/internal/tsidentity 4.193s
ok github.com/carlosframework/platform/internal/tunnelclient 0.428s
ok github.com/carlosframework/platform/internal/unixdial 0.016s
ok github.com/carlosframework/platform/internal/updatewords 0.026s
ok github.com/carlosframework/platform/internal/upstreamguard 0.022s
? github.com/carlosframework/platform/internal/upstreamguard/guardtest [no test files]
ok github.com/carlosframework/platform/internal/usage 0.072s
ok github.com/carlosframework/platform/internal/version 0.013s
ok github.com/carlosframework/platform/internal/vet 3.121s
ok github.com/carlosframework/platform/internal/zonehost 0.016s
ok github.com/carlosframework/platform/internal/zonehost/route53zones 0.044s
? github.com/carlosframework/platform/internal/zonehost/zonehosttest [no test files]
? github.com/carlosframework/platform/scripts/gitleaks-gate [no test files]
ok github.com/carlosframework/platform/scripts/govulncheck-gate 0.018s
ok github.com/carlosframework/platform/scripts/pathmapcheck 0.075s
ok github.com/carlosframework/platform/scripts/region-ha-g2/fixture 5.200s
ok github.com/carlosframework/platform/scripts/stateless-replicas-drill 1.245s
ok github.com/carlosframework/platform/scripts/witness-pointer 0.021s
=== cutover-witness (159 s, from +15 s)
ok github.com/carlosframework/platform 2.466s
=== internal_grouproll@0 (278 s, from +76 s)
ok github.com/carlosframework/platform/internal/grouproll 276.825s
=== internal_grouproll@1 (282 s, from +76 s)
ok github.com/carlosframework/platform/internal/grouproll 280.057s
=== internal_activator@0 (145 s, from +146 s)
ok github.com/carlosframework/platform/internal/activator 141.550s
=== internal_activator@1 (135 s, from +146 s)
ok github.com/carlosframework/platform/internal/activator 130.995s
=== internal_activator@2 (141 s, from +146 s)
ok github.com/carlosframework/platform/internal/activator 137.265s
=== internal_activator@3 (165 s, from +146 s)
ok github.com/carlosframework/platform/internal/activator 162.013s
=== root@0 (119 s, from +170 s)
ok github.com/carlosframework/platform 111.515s
=== root@1 (111 s, from +170 s)
ok github.com/carlosframework/platform 103.696s
=== root@2 (139 s, from +170 s)
ok github.com/carlosframework/platform 131.034s
=== root@3 (112 s, from +170 s)
ok github.com/carlosframework/platform 104.246s
=== root@4 (99 s, from +170 s)
ok github.com/carlosframework/platform 91.854s
=== internal_edge@0 (194 s, from +176 s)
ok github.com/carlosframework/platform/internal/edge 185.636s
=== internal_edge@1 (189 s, from +176 s)
ok github.com/carlosframework/platform/internal/edge 179.261s
=== internal_edge@2 (158 s, from +176 s)
ok github.com/carlosframework/platform/internal/edge 149.425s
=== internal_edge@3 (158 s, from +176 s)
ok github.com/carlosframework/platform/internal/edge 148.963s
=== internal_host@0 (137 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 132.695s
=== internal_host@1 (178 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 174.674s
=== internal_host@2 (270 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 265.855s
=== internal_host@3 (213 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 209.024s
=== internal_host@4 (196 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 191.547s
=== internal_host@5 (152 s, from +212 s)
ok github.com/carlosframework/platform/internal/host 148.040s
=== internal_console@0 (148 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 140.751s
=== internal_console@1 (162 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 153.760s
=== internal_console@2 (187 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 180.775s
=== internal_console@3 (240 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 233.453s
=== internal_console@4 (214 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 206.894s
=== internal_console@5 (196 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 188.718s
=== internal_console@6 (200 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 191.182s
=== internal_console@7 (202 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 195.150s
=== internal_console@8 (208 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 201.360s
=== internal_console@9 (207 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 201.005s
=== internal_console@10 (210 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 203.041s
=== internal_console@11 (200 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 191.944s
=== internal_console@12 (278 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 269.888s
=== internal_console@13 (201 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 192.760s
=== internal_console@14 (196 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 188.825s
=== internal_console@15 (210 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 201.861s
=== internal_console@16 (203 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 194.515s
=== internal_console@17 (196 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 187.786s
=== internal_console@18 (203 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 195.406s
=== internal_console@19 (200 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 192.041s
=== internal_console@20 (224 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 215.906s
=== internal_console@21 (248 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 240.081s
=== internal_console@22 (238 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 230.330s
=== internal_console@23 (243 s, from +219 s)
ok github.com/carlosframework/platform/internal/console 234.483s
=== lists: internal_console 217 s, internal_edge 174 s, internal_activator 145 s, internal_host 211 s, root 169 s, internal_grouproll 75 s
=== cpu: the gate used 12466 cpu-seconds in 497 s, about 25.1 of 32 cores; the machine as a whole was 84% busy
=== opentofu ===
opentofu: 35 test files in 11 suites, OpenTofu v1.13.9
initialised in 14 s
ok 17 s infra/modules/box-fence-writer/tests/writer.tftest.hcl Success! 1 passed, 0 failed.
ok 32 s infra/modules/deployment-buckets/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 21 s infra/modules/deployment-buckets/tests/db_reads.tftest.hcl Success! 1 passed, 0 failed.
ok 17 s infra/modules/deployment-buckets/tests/evidence.tftest.hcl Success! 1 passed, 0 failed.
ok 29 s infra/modules/deployment-buckets/tests/fence_writers.tftest.hcl Success! 3 passed, 0 failed.
ok 90 s infra/modules/media-engine/tests/media_engine.tftest.hcl Success! 24 passed, 0 failed.
ok 33 s infra/modules/pdf-host/tests/computed.tftest.hcl Success! 2 passed, 0 failed.
ok 72 s infra/modules/pdf-host/tests/pdf_host.tftest.hcl Success! 24 passed, 0 failed.
ok 45 s infra/modules/region-group-operator-document/tests/document.tftest.hcl Success! 12 passed, 0 failed.
ok 21 s infra/modules/region-host/ingress/tests/fixed-targets/tests/targets.tftest.hcl Success! 2 passed, 0 failed.
ok 68 s infra/modules/region-host/ingress/tests/group_ingress.tftest.hcl Success! 30 passed, 0 failed.
ok 47 s infra/modules/region-host/tests/alert_publish.tftest.hcl Success! 18 passed, 0 failed.
ok 43 s infra/modules/region-host/tests/alerts_topic.tftest.hcl Success! 16 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/analytics_prune.tftest.hcl Success! 2 passed, 0 failed.
ok 18 s infra/modules/region-host/tests/console_mail.tftest.hcl Success! 4 passed, 0 failed.
ok 9 s infra/modules/region-host/tests/fixed_state_unchanged.tftest.hcl Success! 1 passed, 0 failed.
ok 71 s infra/modules/region-host/tests/group.tftest.hcl Success! 32 passed, 0 failed.
ok 10 s infra/modules/region-host/tests/group_alarms.tftest.hcl Success! 4 passed, 0 failed.
ok 11 s infra/modules/region-host/tests/group_iam.tftest.hcl Success! 4 passed, 0 failed.
ok 5 s infra/modules/region-host/tests/group_isolation.tftest.hcl Success! 1 passed, 0 failed.
ok 36 s infra/modules/region-host/tests/group_operator.tftest.hcl Success! 13 passed, 0 failed.
ok 9 s infra/modules/region-host/tests/group_user_data.tftest.hcl Success! 3 passed, 0 failed.
ok 29 s infra/modules/region-host/tests/health_alarms.tftest.hcl Success! 10 passed, 0 failed.
ok 10 s infra/modules/region-host/tests/ingress_drain_read.tftest.hcl Success! 4 passed, 0 failed.
ok 5 s infra/modules/region-host/tests/instance_metadata.tftest.hcl Success! 1 passed, 0 failed.
ok 24 s infra/modules/region-host/tests/mailer.tftest.hcl Success! 6 passed, 0 failed.
ok 13 s infra/modules/region-host/tests/mailer_group.tftest.hcl Success! 2 passed, 0 failed.
ok 15 s infra/modules/region-host/tests/managed_fleets/group_refusal.tftest.hcl Success! 2 passed, 0 failed.
ok 104 s infra/modules/region-host/tests/managed_fleets/managed_fleets.tftest.hcl Success! 46 passed, 0 failed.
ok 70 s infra/modules/region-host/tests/store_conversion.tftest.hcl Success! 27 passed, 0 failed.
ok 17 s infra/modules/region-host/tests/store_scanning.tftest.hcl Success! 4 passed, 0 failed.
ok 16 s infra/modules/region-host/tests/user_data_ignored.tftest.hcl Success! 3 passed, 0 failed.
ok 10 s infra/modules/region-remote-host/tests/data_lifecycle.tftest.hcl Success! 3 passed, 0 failed.
ok 14 s infra/modules/region-remote-host/tests/no_deployment_bucket.tftest.hcl Success! 5 passed, 0 failed.
ok 28 s infra/modules/scanner-host/tests/scanner_host.tftest.hcl Success! 14 passed, 0 failed.
opentofu: 35 files in 208 s
opentofu: PASS
=== cross ===
--- shard 0 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling darwin/arm64
--- shard 1 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling darwin/amd64
--- shard 2 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling linux/arm64
linux/arm64 carlos binary: 65667234 bytes (ceiling 70000000)
--- shard 3 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling windows/amd64
--- shard 4 of 5 ---
go version go1.26.10 linux/arm64
cross-compiling windows/arm64
=== minio-contract ===
go version go1.26.10 linux/arm64
minio contract: arm64, minio RELEASE.2025-09-07T16-13-09Z, mc RELEASE.2025-08-13T08-35-41Z
minio: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/minio/minio.linux-arm64.RELEASE.2025-09-07T16-13-09Z
minio: downloaded, digest verified
mc: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/minio/mc.linux-arm64.RELEASE.2025-08-13T08-35-41Z
mc: downloaded, digest verified
minio healthy on 127.0.0.1:35151
Added `local` successfully.
Bucket created successfully `local/contract-bucket`.
Bucket created successfully `local/denied-bucket`.
Created policy `contract-only` successfully.
Added user `scopeduser` successfully.
Attached Policies: [contract-only]
To User: scopeduser
buckets and scoped user ready
=== RUN TestDeliveredContractMinio
=== RUN TestDeliveredContractMinio/put
=== RUN TestDeliveredContractMinio/get_round-trips_the_body
=== RUN TestDeliveredContractMinio/list_shows_the_key
=== RUN TestDeliveredContractMinio/head_and_list_agree_on_the_version
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict
=== RUN TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed
=== RUN TestDeliveredContractMinio/delete_removes_it
=== RUN TestDeliveredContractMinio/cross-bucket_denial
--- PASS: TestDeliveredContractMinio (0.02s)
--- PASS: TestDeliveredContractMinio/put (0.00s)
--- PASS: TestDeliveredContractMinio/get_round-trips_the_body (0.00s)
--- PASS: TestDeliveredContractMinio/list_shows_the_key (0.00s)
--- PASS: TestDeliveredContractMinio/head_and_list_agree_on_the_version (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/not_by_PutObjectTagging (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_its_own_object/and_not_by_x-amz-tagging_on_upload (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route (0.01s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CreateMultipartUpload (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/not_by_CopyObject_with_a_REPLACE_tagging_directive (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/but_multipart_itself_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_copy_itself_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/a_POST-policy_forged_tag_with_a_matching_version_is_still_not_a_verdict (0.00s)
--- PASS: TestDeliveredContractMinio/the_app_cannot_tag_by_any_other_route/and_an_ordinary_tagged-with-something-else_upload_is_allowed (0.00s)
--- PASS: TestDeliveredContractMinio/delete_removes_it (0.00s)
--- PASS: TestDeliveredContractMinio/cross-bucket_denial (0.00s)
PASS
ok github.com/carlosframework/platform/internal/objstore 0.034s
=== RUN TestT4StorageProbeMinio
2026/11/22 15:53:57 moves: T4: STORE: list: operation error S3: ListObjectsV2, https response error StatusCode: 403, RequestID: 18EA68FCFAF61A99, HostID: 8efc634a85729a10b8e1e79bc23548bf16e7202e53f3ed3470e29c44b38789e7, api error SignatureDoesNotMatch: The request signature we calculated does not match the signature you provided. Check your key and signing method.
--- PASS: TestT4StorageProbeMinio (0.01s)
PASS
ok github.com/carlosframework/platform/internal/host 0.042s
=== RUN TestS3StoreMinioContract
=== RUN TestS3StoreMinioContract/conditional_get_and_etag_listing
=== RUN TestS3StoreMinioContract/bump_through_every_mutation_path
--- PASS: TestS3StoreMinioContract (0.03s)
--- PASS: TestS3StoreMinioContract/conditional_get_and_etag_listing (0.01s)
--- PASS: TestS3StoreMinioContract/bump_through_every_mutation_path (0.02s)
PASS
ok github.com/carlosframework/platform/internal/release 0.041s
Bucket created successfully `local/analytics-versions`.
local/analytics-versions versioning is enabled
Created policy `analytics-versions` successfully.
Added user `analyticsversions` successfully.
Attached Policies: [analytics-versions]
To User: analyticsversions
=== RUN TestS3StoreMinioVersions
--- PASS: TestS3StoreMinioVersions (0.03s)
PASS
ok github.com/carlosframework/platform/internal/release 0.041s
=== RUN TestEndToEndMinio
=== RUN TestEndToEndMinio/plan
=== RUN TestEndToEndMinio/roll
=== RUN TestEndToEndMinio/replace
=== RUN TestEndToEndMinio/remove
--- PASS: TestEndToEndMinio (0.48s)
--- PASS: TestEndToEndMinio/plan (0.01s)
--- PASS: TestEndToEndMinio/roll (0.13s)
--- PASS: TestEndToEndMinio/replace (0.16s)
--- PASS: TestEndToEndMinio/remove (0.15s)
PASS
ok github.com/carlosframework/platform/internal/grouproll 0.485s
Bucket created successfully `local/dbf-deploy`.
Bucket created successfully `local/dbf-data-ie`.
Bucket created successfully `local/dbf-data-uk`.
local/dbf-deploy versioning is enabled
Created policy `dbf-console` successfully.
Created policy `dbf-ukbox` successfully.
Added user `dbfconsole` successfully.
Added user `dbfukbox` successfully.
Attached Policies: [dbf-console]
To User: dbfconsole
Attached Policies: [dbf-ukbox]
To User: dbfukbox
=== RUN TestDBForwardMinio
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/22 15:54:03 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000002
2026/11/22 15:54:03 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000002 maxTXID=0000000000000002 size=370
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000002
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000002 txid.db=0000000000000003
2026/11/22 15:54:03 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000003 maxTXID=0000000000000003 size=454
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000003 txid.db=0000000000000003
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000000 txid.db=0000000000000001
2026/11/22 15:54:03 INFO ltx file uploaded system=store db=source.db replica=file level=0 minTXID=0000000000000001 maxTXID=0000000000000001 size=720
2026/11/22 15:54:03 INFO replica sync system=store db=source.db replica=file txid.replica=0000000000000001 txid.db=0000000000000001
2026/11/22 15:54:03 console: CARLOS_SECRETS_PUBKEY is unset, so no region outside the home can be chosen automatically
2026/11/22 15:54:03 console: could not notify member@example.com of a CLI token issue: keymail: lookup member@example.com: keymail: GET /api/federation/lookup?addr=member%40example.com&from=console%40127.0.0.1%3A46627: could not determine target mailbox
agent.go:136: dbreads: dbr_aehpsqx5alolao2giertkussam: planned 3 files (1544 bytes) and restored to 3 in 13ms
agent.go:136: dbreads: dbr_aehpsqx5alolao2giertkussam: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/22 15:54:04 console: db read dbr_aehpsqx5alolao2giertkussam: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_lrph2xc6cjfjjdlblprglr3naq: planned 1 files (720 bytes) and restored to 1 in 12ms
agent.go:136: dbreads: dbr_lrph2xc6cjfjjdlblprglr3naq: output 5 bytes in 1 confirmed chunks in 2ms
2026/11/22 15:54:05 console: db read dbr_lrph2xc6cjfjjdlblprglr3naq: relayed 1 chunks (102 bytes) in 1.005s, ended done
agent.go:136: dbreads: dbr_ytebpfshhwyd37wkjpwpsuaecu: planned 3 files (1544 bytes) and held through 3 in 12ms
agent.go:136: dbreads: dbr_ytebpfshhwyd37wkjpwpsuaecu: output 1544 bytes in 1 confirmed chunks in 1ms
2026/11/22 15:54:06 console: db read dbr_ytebpfshhwyd37wkjpwpsuaecu: relayed 1 chunks (1641 bytes) in 1.005s, ended done
=== RUN TestDBForwardMinio/by_disconnect
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_ifhw2okpriyfxbgtqcvytges2i: planned 3 files (1544 bytes) and restored to 3 in 15ms
2026/11/22 15:54:06 console: db read dbr_ifhw2okpriyfxbgtqcvytges2i: relayed 0 chunks (0 bytes) in 28ms, ended client gone
agent.go:136: dbreads: dbr_ifhw2okpriyfxbgtqcvytges2i: output 5 bytes in 1 confirmed chunks in 104ms
=== RUN TestDBForwardMinio/by_timeout
=== NAME TestDBForwardMinio
agent.go:136: dbreads: dbr_2km3ozsykdpp4wafkpdqdydzhy: planned 3 files (1544 bytes) and restored to 3 in 13ms
2026/11/22 15:54:26 console: db read dbr_2km3ozsykdpp4wafkpdqdydzhy: relayed 0 chunks (0 bytes) in 19.346s, ended no-result
agent.go:136: dbreads: dbr_2km3ozsykdpp4wafkpdqdydzhy: output 5 bytes in 1 confirmed chunks in 19.323s
--- PASS: TestDBForwardMinio (23.01s)
--- PASS: TestDBForwardMinio/by_disconnect (0.24s)
--- PASS: TestDBForwardMinio/by_timeout (19.46s)
PASS
ok github.com/carlosframework/platform/internal/console 23.056s
Bucket created successfully `local/media-transfers`.
Bucket created successfully `local/media-transfer-results`.
Created policy `media-transfers` successfully.
Added user `mediatransfers` successfully.
Attached Policies: [media-transfers]
To User: mediatransfers
=== RUN TestMediaTransfersMinio
upload.go:117: codec: the store already holds video.mp4
upload.go:117: codec: the store already holds video.m3u8
upload.go:117: codec: the store already holds poster.jpg
--- PASS: TestMediaTransfersMinio (0.05s)
PASS
ok github.com/carlosframework/platform/internal/mediaaws 0.060s
Bucket created successfully `local/media-local-store`.
Bucket created successfully `local/media-local-results`.
Created policy `media-local` successfully.
Added user `medialocal` successfully.
Attached Policies: [media-local]
To User: medialocal
=== RUN TestLocalEndToEndMinio
--- PASS: TestLocalEndToEndMinio (0.55s)
PASS
ok github.com/carlosframework/platform/internal/medialocal 0.555s
=== RUN TestHeldHandoverTwoBoxMinio
2026/11/22 15:54:30 edge: mesh key: minted
2026/11/22 15:54:31 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/22 15:54:31 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/22 15:54:31 tenant admission is open. accepting tenant work
2026/11/22 15:54:31 activator: HA placement host=shop-e8e7db10.example.test kind=Place ref=annie reason=roomiest generation=2026-11-22T15:54:31Z lock_generation=0
2026/11/22 15:54:31 lease: t8-e8e7db10/shop-e8e7db10.example.test: HA lease acquired in 4ms (first wake)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: started carlos-instance@shop\x2de8e7db10.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 6ms, control socket 0s, key gate 0s, logs 0s) 7ms, launch file 0s, gate 0s, root start 1ms)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: carlos-instance@shop\x2de8e7db10.example.test.service launched in 8ms, healthy 0s later
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: woke in 20ms: checks 0s, lease 5ms, restore 0s, identity 0s, protect 0s, spawn 8ms, replicate 7ms
2026/11/22 15:54:31 lease: t8-e8e7db10/plain-e8e7db10.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/22 15:54:31 activator: no replica for plain-e8e7db10.example.test in s3://contract-bucket/t8-e8e7db10/plain-e8e7db10.example.test — booting fresh
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: started carlos-instance@plain\x2de8e7db10.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 1ms, instance key 0s, env 4ms, control socket 0s, key gate 0s, logs 0s) 5ms, launch file 0s, gate 0s, root start 1ms)
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: carlos-instance@plain\x2de8e7db10.example.test.service launched in 7ms, healthy 0s later
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: woke in 98ms: checks 0s, lease 1ms, restore 19ms, identity 0s, protect 0s, spawn 7ms, replicate 70ms
2026/11/22 15:54:31 lease: t8-e8e7db10/bot0.shop.bac.sidecar.internal: HA lease acquired in 4ms (first wake)
2026/11/22 15:54:31 activator: bot0.shop.bac.sidecar.internal: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/22 15:54:31 activator: bot0.shop.bac.sidecar.internal: woke in 69ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, settle 0s, replicate 57ms
2026/11/22 15:54:31 activator: next-due probe plain-e8e7db10.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/22 15:54:31 activator: bot0.shop.bac.sidecar.internal: released with a marker (clean true, txid 1, files 3:be8c6e43027b6bc0e8746e0707de8d1a07a5806398a48ae25fdde4818fc11c30) in 7ms: files 1ms, sync 4ms, record 1ms, marker 2ms
2026/11/22 15:54:31 activator: bot0.shop.bac.sidecar.internal hibernated
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test hibernated
2026/11/22 15:54:31 activator: next-due probe shop-e8e7db10.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: released with a marker (clean true, txid 1, files 3:f36972f0f5e1b9f82d1ec29c9dc8a48cb0291254635f2e17c65b9a7a0f1e021f) in 6ms: files 1ms, sync 2ms, record 1ms, marker 2ms
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test hibernated
2026/11/22 15:54:31 lease: t8-e8e7db10/shop-e8e7db10.example.test: HA lease acquired in 3ms (clean marker)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: restored (other-box)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: started carlos-instance@shop\x2de8e7db10.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 1ms, control socket 0s, key gate 0s, logs 0s) 1ms, launch file 0s, gate 0s, root start 1ms)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: carlos-instance@shop\x2de8e7db10.example.test.service launched in 2ms, healthy 0s later
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: woke in 86ms: checks 0s, lease 4ms, restore 23ms, identity 0s, protect 0s, spawn 2ms, replicate 57ms
2026/11/22 15:54:31 edge: ha-take shop-e8e7db10.example.test from annie (txn t8-witness, marker generation 1): holder betty, generation 2
2026/11/22 15:54:31 edge: forward shop-e8e7db10.example.test: annie handed the request over to betty; sending it there (occurrence #1)
hadrain_twobox_minio_linux_test.go:1238: drain report: {V:1 Transaction:t8-witness Incarnation:c896d1ce9c16f64186c6e8bc6fe23308 Step:move Result:ok Reasons:[] Fence:t8-witness StartedAt:2026-11-22 15:54:31.381796127 +0000 UTC FinishedAt:2026-11-22 15:54:31.529235581 +0000 UTC Acked:[betty carol] Departed:[] Moved:[{Host:shop-e8e7db10.example.test Holder:betty Gen:2 Confirmed:take}] Released:[{Host:bot0.shop.bac.sidecar.internal Kind:worker Marker:true Clean:true Reason:} {Host:plain-e8e7db10.example.test Kind:other Marker:true Clean:true Reason:}] Unclean:[] Left:[] Holds:{LongestMS:128 Todays:0 RefusedAtOnce:1} Closed:0 Quiet:{DrainQuiet:{Waking:0 Stopping:0 Recovering:0 Owed:0} Held:[]}}
hadrain_twobox_minio_linux_test.go:1239: driver calls: [begin shop-e8e7db10.example.test <nil> stop bot0.shop.bac.sidecar.internal marker=true clean=true <nil> stop plain-e8e7db10.example.test marker=true clean=true <nil> releasing shop-e8e7db10.example.test <nil> stop shop-e8e7db10.example.test marker=true clean=true <nil> taken shop-e8e7db10.example.test betty <nil> end-moves]
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/bot0.shop.bac.sidecar.internal/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/bot0.shop.bac.sidecar.internal/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: DELETE /contract-bucket/t8-e8e7db10/plain-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/head.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/generations/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0008/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0007/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0006/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0005/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0004/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/0009/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/files/0/manifest.json
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/files/0/objects/0000000000000001-de355fbda61fde902ec425e3f22bbb90b320bc13dc971f0269172028195bdad7
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/files/0/objects/0000000000000003-459f31c7cac9466a3c80c0424ea12106910af6a5078aeb427d33dafdbdf51557
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/0000/0000000000000001-0000000000000001.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0000/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0009/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: PUT /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/0000/0000000000000002-0000000000000002.ltx
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0001/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0002/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: LIST /contract-bucket?t8-e8e7db10/shop-e8e7db10.example.test/0003/
hadrain_twobox_minio_linux_test.go:1241: S3 during the drain: GET /contract-bucket/t8-e8e7db10/shop-e8e7db10.example.test/lock.json
hadrain_twobox_minio_linux_test.go:1243: drain took 191ms; S3 calls 45 (DELETE lock=1 GET files=3 GET head=1 GET lock=3 GET replica=2 LIST replica=29 PUT lock=3 PUT replica=3); deployment store calls 20 (GET edges=14 LIST edges=4 PUT edges=2)
hadrain_twobox_minio_linux_test.go:1367: the fenced A's start gate answers 503 "This service is unavailable. Try again later.\n" (Retry-After "10")
2026/11/22 15:54:31 lease: t8-e8e7db10/plain-e8e7db10.example.test: acquired in 1ms (client 0s, lock read and write 1ms)
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: started carlos-instance@plain\x2de8e7db10.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 0s, control socket 0s, key gate 0s, logs 0s) 0s, launch file 0s, gate 0s, root start 1ms)
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: carlos-instance@plain\x2de8e7db10.example.test.service launched in 1ms, healthy 0s later
2026/11/22 15:54:31 lease: /tmp/carlos-minio-contract-4nWEiZ/g/dw229794236/data/instances/plain-e8e7db10.example.test/plain-e8e7db10.example.test.db: continuity with the last clean close not proven; snapshot 1-0000000000000001 written before serving
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test: woke in 8ms: checks 0s, lease 2ms, restore 0s, identity 0s, protect 1ms, spawn 1ms, replicate 4ms
2026/11/22 15:54:31 activator: next-due probe shop-e8e7db10.example.test: decode /api/next-due: invalid character 'b' looking for beginning of value — recording none (it sleeps until a request)
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test: released with a marker (clean true, txid 2, files 3:f36972f0f5e1b9f82d1ec29c9dc8a48cb0291254635f2e17c65b9a7a0f1e021f) in 4ms: files 1ms, sync 0s, record 1ms, marker 2ms
2026/11/22 15:54:31 activator: shop-e8e7db10.example.test hibernated
2026/11/22 15:54:31 tenant admission is closed for shutdown
2026/11/22 15:54:31 activator: next-due probe plain-e8e7db10.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/22 15:54:31 activator: plain-e8e7db10.example.test hibernated
--- PASS: TestHeldHandoverTwoBoxMinio (0.64s)
=== RUN TestHeldHandoverLostLeaseMinio
2026/11/22 15:54:31 edge: mesh key: minted
2026/11/22 15:54:31 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/22 15:54:31 provision: minted sidecar route bot0.shop.bac.sidecar.internal (app "shop" acct "bac" args ["work"])
2026/11/22 15:54:31 tenant admission is open. accepting tenant work
2026/11/22 15:54:31 activator: HA placement host=shop-d74c54b2.example.test kind=Place ref=annie reason=roomiest generation=2026-11-22T15:54:31Z lock_generation=0
2026/11/22 15:54:31 lease: t8-d74c54b2/shop-d74c54b2.example.test: HA lease acquired in 3ms (first wake)
2026/11/22 15:54:31 activator: shop-d74c54b2.example.test: restored (no-marker): first wake, the prefix proven empty, booting fresh
2026/11/22 15:54:31 activator: shop-d74c54b2.example.test: started carlos-instance@shop\x2dd74c54b2.example.test.service memory.max=536870912 (build 0s, prepare (dirs 0s, admin token 0s, instance key 0s, env 5ms, control socket 0s, key gate 0s, logs 0s) 6ms, launch file 0s, gate 0s, root start 1ms)
2026/11/22 15:54:31 activator: shop-d74c54b2.example.test: carlos-instance@shop\x2dd74c54b2.example.test.service launched in 7ms, healthy 0s later
2026/11/22 15:54:31 activator: shop-d74c54b2.example.test: woke in 66ms: checks 0s, lease 4ms, restore 0s, identity 0s, protect 0s, spawn 7ms, replicate 54ms
2026/11/22 15:54:31 activator: next-due probe shop-d74c54b2.example.test: decode /api/next-due: invalid character 'a' looking for beginning of value — recording none (it sleeps until a request)
2026/11/22 15:54:31 activator: final checkpoint shop-d74c54b2.example.test: lease: release marker owed for s3://contract-bucket/t8-d74c54b2/shop-d74c54b2.example.test/lock.json (If-Match "20bc1045f8339169347f8ec97d765176"): lease: write release marker: operation error S3: PutObject, https response error StatusCode: 503, RequestID: , HostID: , api error ServiceUnavailable: witness: refused
2026/11/22 15:54:31 activator: shop-d74c54b2.example.test hibernated
2026/11/22 15:54:31 activator: handover of shop-d74c54b2.example.test left: released without a marker; its held requests get today's answer
hadrain_twobox_minio_linux_test.go:1469: the held request's hold ended "shop-d74c54b2.example.test client 4 "
hadrain_twobox_minio_linux_test.go:1486: driver calls: [begin shop-d74c54b2.example.test <nil> releasing shop-d74c54b2.example.test <nil> stop shop-d74c54b2.example.test marker=false clean=false <nil> left shop-d74c54b2.example.test released without a marker]
hadrain_twobox_minio_linux_test.go:1487: a request after the loss: 503 "This instance cannot wake right now. Please try again shortly.\n" (Retry-After "10", holder "none", 0s, err <nil>)
2026/11/22 15:54:31 tenant admission is closed for shutdown
2026/11/22 15:54:31 http: proxy error: context canceled
--- PASS: TestHeldHandoverLostLeaseMinio (0.32s)
PASS
ok github.com/carlosframework/platform/internal/host 1.005s
Bucket created successfully `local/gen-take`.
local/gen-take versioning is enabled
Created policy `gen-take` successfully.
Added user `gentake` successfully.
Attached Policies: [gen-take]
To User: gentake
=== RUN TestGenerationTakeMinio
=== RUN TestGenerationTakeMinio/take
2026/11/22 15:54:33 lease: instances/gen-1795362873132669915.shop.example.com: HA lease acquired in 5ms (first wake)
2026/11/22 15:54:33 lease: instances/gen-1795362873132669915.shop.example.com: HA lease acquired in 4ms (holder terminated)
gentake_minio_test.go:308: a second create-only copy onto instances/gen-1795362873132669915.shop.example.com/g-00000000000000000002/0000/0000000000000001-0000000000000001.ltx: <nil> (destination condition honoured: false)
2026/11/22 15:54:33 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: remove ltx files: lease: invalid or changed generation binding"
2026/11/22 15:54:33 http: proxy error: context canceled
2026/11/22 15:54:33 ERROR retention enforcement failed system=store db=w.example.com.db error="enforce snapshot retention: remove ltx files: lease: a write has waited too long to reach storage (write fence)"
=== RUN TestGenerationTakeMinio/switch-412
2026/11/22 15:54:33 lease: instances/gen-1795362873259425469.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/22 15:54:33 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: fetch ltx files: lease: a write has waited too long to reach storage (write fence)"
2026/11/22 15:54:33 http: proxy error: context canceled
2026/11/22 15:54:33 lease: instances/gen-1795362873259425469.shop.example.com: HA lease acquired in 2ms (clean marker)
=== RUN TestGenerationTakeMinio/copy-version
=== RUN TestGenerationTakeMinio/store-time
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 3ms (first wake)
2026/11/22 15:54:33 ERROR retention enforcement failed system=store db=seed.db error="enforce snapshot retention: fetch ltx files: lease: a write has waited too long to reach storage (write fence)"
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 2ms (clean marker)
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 2ms (unclean marker)
2026/11/22 15:54:33 lease: instances/gen-1795362873308919509.shop.example.com: HA lease acquired in 3ms (unclean marker)
=== RUN TestGenerationTakeMinio/skew
--- PASS: TestGenerationTakeMinio (0.28s)
--- PASS: TestGenerationTakeMinio/take (0.13s)
--- PASS: TestGenerationTakeMinio/switch-412 (0.04s)
--- PASS: TestGenerationTakeMinio/copy-version (0.01s)
--- PASS: TestGenerationTakeMinio/store-time (0.10s)
--- PASS: TestGenerationTakeMinio/skew (0.01s)
PASS
ok github.com/carlosframework/platform/internal/lease 0.296s
minio contract: PASS
=== staticcheck ===
go version go1.26.10 linux/arm64
go: downloading honnef.co/go/tools v0.8.2
go: downloading github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
go: downloading golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
go: downloading golang.org/x/sync v0.23.0
go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
amadan: job cancelled — a newer push superseded it
diff --git a/apps_policy.go b/apps_policy.go| index b39815bd9..c9515ace8 100644 |
| --- a/apps_policy.go |
| +++ b/apps_policy.go |
| @@ -33,11 +33,14 @@ import ( |
| // Copy (approved by delegation, Luna pass 2026-10-26; deck copy-instance-policy-plan1.md). |
| const ( |
| - appsSetFlagEgress = `private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; "" clears it. system operators only` |
| + appsSetFlagEgress = `private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; "" clears it. system operators only` |
| appsSetFlagSize = "the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only" |
| instancesSetFlagSize = "this instance's size: small, standard, large or xlarge. default follows the app's size. system operators only" |
| appsSetPolicyUsage = `Only system operators may pass --egress-allow or --size. A change reaches |
| -the app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.` |
| +the app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box. |
| +--egress-allow takes at most 8 entries. A range must start at its first address, so |
| +10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on |
| +every box, and a box refuses a range that holds one of its own addresses.` |
| appsSetBadEgress = "apps set: --egress-allow: %v" |
| appsSetBadSize = "apps set: --size is small, standard, large, xlarge or default, not %q" |
| instancesSetBadSize = "instances set: --size is small, standard, large, xlarge or default, not %q" |
| @@ -45,7 +48,7 @@ the app's boxes within seconds on a box following the deployment's change index, |
| appsPolicyChanged = "the policy changed while this ran. run it again" |
| appsSetEgressDone = "egress allow for %s set to %s" |
| appsSetEgressCleared = "egress allow for %s cleared" |
| - appsSetEgressNotChecked = "not checked against these boxes, which publish no address list: %s" |
| + appsSetEgressNotChecked = "not checked against these boxes, which publish no address list (fleet boxes never do): %s. each one still refuses an entry that covers its own address" |
| appsSetSizeDone = "default size for %s set to %s. instances with their own size are unchanged" |
| appsSetSizeCleared = "default size for %s set to the build's size. instances with their own size are unchanged" |
| instancesSetSizeDone = "%s size set to %s" |
diff --git a/apps_policy_test.go b/apps_policy_test.go| index 190a68d16..2d81f82f0 100644 |
| --- a/apps_policy_test.go |
| +++ b/apps_policy_test.go |
| @@ -99,7 +99,8 @@ func TestAppsSetPolicyRefusesClientSide(t *testing.T) { |
| want string |
| }{ |
| {[]string{"--egress-allow", "10.0.5.20:5432"}, "has a port"}, |
| - {[]string{"--egress-allow", "10.0.5.0/24"}, "is a range"}, |
| + {[]string{"--egress-allow", "10.0.64.5/20"}, "has host bits set. write it as 10.0.64.0/20"}, |
| + {[]string{"--egress-allow", "10.0.0.0/8"}, "is wider than /16"}, |
| {[]string{"--egress-allow", "8.8.8.8"}, "already reachable"}, |
| {[]string{"--egress-allow", "10.0.5.20,8.8.8.8"}, "already reachable"}, |
| } |
| @@ -287,12 +288,12 @@ func TestAppsShowPrintsThePolicy(t *testing.T) { |
| // egress_conflicts, marks nothing. |
| func TestAppsShowMarksConflicts(t *testing.T) { |
| out := captureStdout(t) |
| - c := &policyConsole{getBody: `{"policy":{"v":1,"egress_allow":["10.0.5.20","fd00:5::20"]},` + |
| - `"etag":"e1","not_checked":[],"egress_conflicts":["fd00:5::20","10.0.5.30"]}`} |
| + c := &policyConsole{getBody: `{"policy":{"v":1,"egress_allow":["10.0.5.20","10.0.64.0/20","fd00:5::20"]},` + |
| + `"etag":"e1","not_checked":[],"egress_conflicts":["fd00:5::20","10.0.5.30","10.0.64.0/20"]}`} |
| if err := appsShowRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop"); err != nil { |
| t.Fatal(err) |
| } |
| - if want := "egress allow 10.0.5.20, !fd00:5::20\ndefault size the build's size\n"; out.String() != want { |
| + if want := "egress allow 10.0.5.20, !10.0.64.0/20, !fd00:5::20\ndefault size the build's size\n"; out.String() != want { |
| t.Fatalf("stdout = %q, want %q", out.String(), want) |
| } |
| @@ -323,7 +324,7 @@ func TestAppsSetPrintsNotChecked(t *testing.T) { |
| if out.String() != want { |
| t.Fatalf("stdout = %q, want %q", out.String(), want) |
| } |
| - if want := "not checked against these boxes, which publish no address list: box-c\n"; !strings.HasSuffix(out.String(), want) { |
| + if want := "not checked against these boxes, which publish no address list (fleet boxes never do): box-c. each one still refuses an entry that covers its own address\n"; !strings.HasSuffix(out.String(), want) { |
| t.Fatalf("stdout = %q, want it to end %q", out.String(), want) |
| } |
diff --git a/docs/site/cli.md b/docs/site/cli.md| index 3923a88ca..1b5121cdf 100644 |
| --- a/docs/site/cli.md |
| +++ b/docs/site/cli.md |
| @@ -253,21 +253,21 @@ If a box is lost or detached, the requested count stays the same. The platform u |
| System operators can also set an app's instance policy: which private addresses its instances may reach and the size each instance runs at. `carlos apps show` reads it back. |
| ```sh |
| -carlos apps set shop --egress-allow 10.0.5.20,fd00:5::20 |
| +carlos apps set shop --egress-allow 10.0.5.20,10.0.64.0/20 |
| carlos apps set shop --size large |
| carlos instances set shop-a.example.com --app shop --size xlarge |
| carlos apps show shop |
| ``` |
| -An instance cannot reach a private address unless its app allows it. `--egress-allow` takes the app's whole list, comma-separated, and replaces the list before it. To drop one address, pass the list without it; `--egress-allow ""` removes them all. Each entry is a single IP address, with no range, port or zone. Public addresses are refused because instances can reach them already, and so are loopback, link-local, multicast and reserved addresses, the cloud metadata service and the NAT64 prefix. An app may allow at most 8. |
| +An instance cannot reach a private address unless its app allows it. `--egress-allow` takes the app's whole list, comma-separated, and replaces the list before it. To drop one entry, pass the list without it; `--egress-allow ""` removes them all. Each entry is a single IP address or a private range such as `10.0.64.0/20` or `fd00:5::/64`, with no port or zone. The widest range is /16 for IPv4 or /48 for IPv6. Every range must start at its first address, so `10.0.64.5/20` is refused. Public addresses are refused because instances can reach them already, and so are loopback, link-local, multicast and reserved addresses, the cloud metadata service and the NAT64 prefix, and any range that contains one of them. An app may allow at most 8 entries, and a range counts as one. |
| -A change that adds an address is checked against the deployment's boxes. An address that belongs to one of them is refused, and so is any new address while a box does not publish its address list yet. Boxes that publish none at all are named after the change. An allow takes effect only on a box where every instance runs nested (see `carlos status --layout`). It does not take effect while host claims are on. If a box later takes an allowed address, the console sends an alert. |
| +A change that adds an entry is checked against the deployment's boxes. An entry that covers an address of one of them is refused, and so is any new entry while a box does not publish its address list yet. Boxes that publish no address list are named after the change (fleet boxes never publish one), and each of them still refuses an entry that covers its own address. A range can be added only while every box runs v0.43.0 or later. Single addresses are not affected by the v0.43.0 floor; they keep working on the releases that already support egress allows. Once an app has a range, do not roll a console back below v0.43.0, because an older console cannot read that app's policy, and a later change from it would clear the app's allows and sizes. An allow takes effect only on a box where every instance runs nested (see `carlos status --layout`). It does not take effect while host claims are on. If a box later takes an allowed address, or an address in an allowed range, the console sends an alert. |
| The sizes are `small` (256 MiB of memory), `standard` (512 MiB), `large` (1 GiB) and `xlarge` (2 GiB), with CPU and IO to match. `carlos apps set --size` sets the app's size, and `--size default` goes back to the build's size. `carlos instances set --size` gives one instance a size of its own, and `--size default` makes it follow the app's size again. A size above `standard` is refused when it is more than a quarter of the memory on the smallest box the app can run on, or when one of those boxes reports no memory total. |
| After a size change, the command prints each box's memory committed to awake instances, out of its total. CPU and IO change at once. A larger size's memory applies when an instance next starts or is deployed. A smaller size applies only when the instance starts cold. Restart it to apply the new memory now. `carlos status --layout` shows the size each instance runs at. |
| -The console records a change, and the app's boxes apply it. A box that follows the deployment's change index does so within seconds; any other box within about 33 minutes. `carlos apps show` prints the egress allow, the app's size, and every instance with a size of its own. A `!` before an address means one of the deployment's boxes now holds it. |
| +The console records a change, and the app's boxes apply it. A box that follows the deployment's change index does so within seconds; any other box within about 33 minutes. `carlos apps show` prints the egress allow, the app's size, and every instance with a size of its own. A `!` before an entry means one of the deployment's boxes now holds that address, or an address in that range. |
| ### carlos ship |
| @@ -3310,7 +3310,7 @@ socket does not exist. Requests to that address then fail. Like |
| The REGION column names where each route or box runs, such as London (UK). |
| -The `SIZE` column is the size an awake nested instance runs at: `swap` while a deploy is swapping it, `?` when its box could not read it, and `-` for anything else. `standard>large` means it runs at standard and its policy asks for large; a note under the table says when that takes effect. The `EGRESS` column is the instance's egress allow as its box applies it. A `!` before an address means one of the deployment's boxes now holds it. A word after `!` means the allow is not in force: `failing`, `policy unreadable`, `policy unverifiable`, `policy expired`, `box not wholly nested`, `not yet supported under claims`, or `refused` when the box dropped an entry. `REASON` gives the detail after `egress:`. |
| +The `SIZE` column is the size an awake nested instance runs at: `swap` while a deploy is swapping it, `?` when its box could not read it, and `-` for anything else. `standard>large` means it runs at standard and its policy asks for large; a note under the table says when that takes effect. The `EGRESS` column is the instance's egress allow as its box applies it. A `!` before an entry means one of the deployment's boxes now holds that address, or an address in that range. A word after `!` means the allow is not in force: `failing`, `policy unreadable`, `policy unverifiable`, `policy expired`, `box not wholly nested`, `not yet supported under claims`, or `refused` when the box dropped an entry. `REASON` gives the detail after `egress:`. |
| A box that runs `nested` instances beside `flat`, `foreign` or `external` |
| ones gets a warning after the table. Each of those still shares the agent's |
diff --git a/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md b/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md| new file mode 100644 |
| index 000000000..179eb2171 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md |
| @@ -0,0 +1,11 @@ |
| +# Census approval: egress-allow-cidr-console |
| + |
| +Ruling `census-ruling-egress-allow-cidr-console`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +Envelopes re-pinned: `.`, `internal/egressaddr`, `internal/instancectl`, `internal/release`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-egress-allow-cidr.md b/docs/superpowers/notes/census-proposal-egress-allow-cidr.md| new file mode 100644 |
| index 000000000..1d886cb02 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-egress-allow-cidr.md |
| @@ -0,0 +1,11 @@ |
| +# Census approval: egress-allow-cidr |
| + |
| +Ruling `census-ruling-egress-allow-cidr`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +Envelopes re-pinned: `internal/apppolicy`, `internal/egressaddr`, `internal/instancectl`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-10-21-instance-policy-copy.json b/docs/superpowers/plans/2026-10-21-instance-policy-copy.json| index e07e57792..9fb984da4 100644 |
| --- a/docs/superpowers/plans/2026-10-21-instance-policy-copy.json |
| +++ b/docs/superpowers/plans/2026-10-21-instance-policy-copy.json |
| @@ -1,6 +1,7 @@ |
| { |
| "approved_by": "delegation (Luna pass, gpt-5.6-luna; Paul's standing rule for platform copy decks)", |
| "approved_on": "2026-10-26", |
| + "amended_by": "approved by delegation (Luna pass 2026-11-22): IP1-06, IP1-08, IP1-10, IP1-11, IP1-14, IP1-50, IP1-53, IP2-30, IP2-60", |
| "source": "docs/superpowers/specs/LUNA-COPY-RESULT-INSTANCE-POLICY.md", |
| "entries": [ |
| {"id": "IP1-01", "file": "internal/egressaddr/egressaddr.go", "text": "an address is empty"}, |
| @@ -8,15 +9,15 @@ |
| {"id": "IP1-03", "file": "internal/egressaddr/egressaddr.go", "text": "%q has a port. an allow opens an address, never a port"}, |
| {"id": "IP1-04", "file": "internal/egressaddr/egressaddr.go", "text": "%q has a zone. name the address without it"}, |
| {"id": "IP1-05", "file": "internal/egressaddr/egressaddr.go", "text": "%q is not an IP address"}, |
| - {"id": "IP1-06", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a loopback address"}, |
| + {"id": "IP1-06", "file": "internal/egressaddr/egressaddr.go", "text": "%s is loopback"}, |
| {"id": "IP1-07", "file": "internal/egressaddr/egressaddr.go", "text": "%s is the unspecified address"}, |
| - {"id": "IP1-08", "file": "internal/egressaddr/egressaddr.go", "text": "%s is the cloud metadata service"}, |
| + {"id": "IP1-08", "file": "internal/egressaddr/egressaddr.go", "text": "%s would reach the cloud metadata service"}, |
| {"id": "IP1-09", "file": "internal/egressaddr/egressaddr.go", "text": "%s is link-local"}, |
| - {"id": "IP1-10", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a multicast address"}, |
| - {"id": "IP1-11", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in %s, a reserved range"}, |
| + {"id": "IP1-10", "file": "internal/egressaddr/egressaddr.go", "text": "%s is multicast"}, |
| + {"id": "IP1-11", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in or overlaps %s, a reserved range"}, |
| {"id": "IP1-12", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address"}, |
| {"id": "IP1-13", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a public address and is already reachable. no allow is needed"}, |
| - {"id": "IP1-14", "file": "internal/egressaddr/egressaddr.go", "text": "at most %d addresses per app (%d given)"}, |
| + {"id": "IP1-14", "file": "internal/egressaddr/egressaddr.go", "text": "at most %d entries per app (%d given)"}, |
| {"id": "IP1-15", "file": "internal/console/policylease.go", "text": "another console (%s) is the policy writer for this deployment until %s. use that console, or try again after that"}, |
| {"id": "IP1-16", "file": "internal/console/policylease.go", "text": "another console is the policy writer for this deployment until %s. use the console that holds the lease, or try again after that"}, |
| {"id": "IP1-17", "file": "internal/console/policylease.go", "text": "could not take the policy writer lease. try again"}, |
| @@ -57,7 +58,7 @@ |
| {"id": "IP1-35", "file": "apps_policy.go", "text": "the policy changed while this ran. run it again"}, |
| {"id": "IP1-36", "file": "apps_policy.go", "text": "egress allow for %s set to %s"}, |
| {"id": "IP1-37", "file": "apps_policy.go", "text": "egress allow for %s cleared"}, |
| - {"id": "IP2-30", "file": "apps_policy.go", "text": "not checked against these boxes, which publish no address list: %s"}, |
| + {"id": "IP2-30", "file": "apps_policy.go", "text": "not checked against these boxes, which publish no address list (fleet boxes never do): %s. each one still refuses an entry that covers its own address"}, |
| {"id": "IP1-38", "file": "apps_policy.go", "text": "default size for %s set to %s. instances with their own size are unchanged"}, |
| {"id": "IP1-39", "file": "apps_policy.go", "text": "default size for %s set to the build's size. instances with their own size are unchanged"}, |
| {"id": "IP1-42", "file": "apps_policy.go", "text": "%s size set to %s"}, |
| @@ -65,10 +66,10 @@ |
| {"id": "IP3-10", "file": "apps_policy.go", "text": "%s: %d MiB committed to awake instances, of %d MiB. %d MiB free"}, |
| {"id": "IP3-11", "file": "apps_policy.go", "text": "the new memory size applies at the next start. a larger size also applies at the next deploy; a smaller size waits for a cold start. CPU and IO apply now"}, |
| {"id": "IP1-44", "file": "apps_policy.go", "text": "apps show works through a console, and this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set). log in instead: carlos auth login --console <url>"}, |
| - {"id": "IP1-50", "file": "apps_policy.go", "text": "private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only"}, |
| + {"id": "IP1-50", "file": "apps_policy.go", "text": "private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only"}, |
| {"id": "IP1-51", "file": "apps_policy.go", "text": "the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only"}, |
| {"id": "IP1-52", "file": "apps_policy.go", "text": "this instance's size: small, standard, large or xlarge. default follows the app's size. system operators only"}, |
| - {"id": "IP1-53", "file": "apps_policy.go", "text": "Only system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box."}, |
| + {"id": "IP1-53", "file": "apps_policy.go", "text": "Only system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses."}, |
| {"id": "IP1-54", "file": "apps_policy.go", "text": "usage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]"}, |
| {"id": "IP1-60", "file": "apps_policy.go", "text": "egress allow %s"}, |
| {"id": "IP1-61", "file": "apps_policy.go", "text": "default size %s"}, |
| @@ -107,7 +108,7 @@ |
| {"id": "IP2-20", "file": "internal/console/apiinstances.go", "text": "the allow takes effect when the instance next starts"}, |
| {"id": "IP2-21", "file": "internal/console/apiinstances.go", "text": "the box could not apply the allow, and tries again"}, |
| {"id": "IP2-22", "file": "internal/console/apiinstances.go", "text": "the allow is not in force on this box"}, |
| - {"id": "IP2-60", "file": "internal/instancectl/egress.go", "text": "%s: an address of this box (%s)"}, |
| + {"id": "IP2-60", "file": "internal/instancectl/egress.go", "text": "%s: this box has an address in %s"}, |
| {"id": "IP2-61", "file": "internal/instancectl/egress.go", "text": ": this box's addresses could not be read"}, |
| {"id": "IP2-45", "file": "internal/instancectl/egress.go", "text": "the policy has more than %d addresses (%d); every one is closed"}, |
| {"id": "IP2-49", "file": "internal/instancectl/egress.go", "text": "revoked (restarted)"}, |
diff --git a/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md b/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md| new file mode 100644 |
| index 000000000..46dac014b |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md |
| @@ -0,0 +1,261 @@ |
| +# Egress allow by private CIDR (#1357) |
| + |
| +Spec: docs/superpowers/specs/2026-10-21-instance-sizes-and-egress-design.md §4 |
| +(the single-address egress allow, #328). This plan widens §4.1 from "a single |
| +address" to "a single address or a private prefix". All of the spec's other |
| +rules and rulings still apply. Issue: #1357 (amadan discuss carlos/platform). |
| + |
| +## Findings (what is there today) |
| + |
| +- One rule set, `internal/egressaddr`, is applied at the console door |
| + (`Normalize`, apipolicy.go ~1047), in `apppolicy.Policy.Validate` (signing |
| + and every open on a box), and by root (`instancectl.EgressAsserter.desired`, |
| + egress.go ~638). Root writes `IPAddressAllow=` as full-length prefixes, |
| + and `readBack`/`parseHeld` already parse prefixes (masked). |
| +- **Old box given a CIDR entry:** `egressaddr.Parse` refuses any `/`, so |
| + `Validate` fails and the policy is `ErrUnverifiable`. `policyColsFor` then |
| + fails closed with `Known: true` (apppolicy_reconcile.go ~113-140): the |
| + app's whole allow list AND its size override are cleared on that box. It |
| + never fails open, but it does regress the app's other entries. So CIDR |
| + entries are gated behind a box version floor (Task 3). |
| +- **~33 minutes:** fleet boxes have no change index |
| + (changeindex.go:59-61), so `PolicyCache` re-reads only on the 30-minute |
| + backstop (`release.ChangeIndexBackstop`) plus up to 3 minutes of jitter |
| + (apppolicy_cache.go:128). Shared boxes follow the change index and apply |
| + a change within seconds. A serial-triggered fleet full pass does not |
| + re-read an already cached policy (`backstopDue` waits for `c.next`). |
| +- **"publish no address list":** `apps_policy.go:48`. Grant-time |
| + checking reads box addresses from edges files |
| + (`control/edges/<box>.json`, `addrs`), and only platform boxes write edges |
| + files (edgesfile.go:1267). So for bucketless fleet boxes the warning is |
| + accurate and by design (spec §4.2), but its wording reads like a fault. |
| + Root on every box, fleet boxes included, still refuses an entry that is |
| + one of its own addresses. |
| + |
| +## Decisions |
| + |
| +1. **Entry forms.** A single address (as today) or a prefix `a.b.c.d/n` / |
| + `x::/n`. IPv6 prefixes are accepted, because IPv6 singles are accepted. |
| +2. **Stored form.** A full-length prefix (`/32`, `/128`) is stored as the |
| + bare address, so a policy with singles only is byte-identical to today |
| + and old boxes keep reading it. Other prefixes are stored as |
| + `netip.Prefix.String()`. |
| +3. **Host bits set is refused, not normalized** (`10.0.64.5/20`): the |
| + operator may have meant the single address. The refusal names the |
| + canonical prefix (`10.0.64.0/20`). |
| +4. **Minimum prefix length:** /16 for IPv4 and /48 for IPv6. /16 is the |
| + largest CIDR block an AWS VPC can have, and a common VPC size elsewhere, |
| + so one entry covers at most one whole VPC and never spans `10.0.0.0/8` |
| + or `172.16.0.0/12`. /48 is a ULA site prefix (RFC 4193), so one entry |
| + never spans sites. A wider prefix is refused and names the limit. |
| +5. **Private ranges only, exactly as today.** A prefix is allowed when its |
| + whole range lies inside one `FenceDeny` range and it overlaps none of |
| + the refused classes: loopback, unspecified, link-local, both metadata |
| + addresses, multicast, the reserved ranges and NAT64. Equivalently, |
| + every address in it would pass `Allowed`, and the check is done on |
| + prefixes, not by enumeration. Example: `fd00:ec2::/48` is refused |
| + because it holds the v6 metadata address. |
| +6. **Count limit unchanged:** at most `MaxAllow` (8) entries. Each |
| + prefix counts as one entry. Exact duplicates collapse, and an entry |
| + inside another entry is kept as written (no subsumption). The sort |
| + order is address, then prefix length, so `10.0.64.0/20` comes before |
| + `10.0.64.0`. |
| +7. **Root accepts the prefix exactly.** Root writes `IPAddressAllow=` with |
| + the entry's own prefix: no widening, and no masking of a stored |
| + host-bits entry (`Validate` already refused those). An entry |
| + **overlapping** any of the box's own addresses is refused on that box |
| + with a reason. `IPAddressAllow` beats `IPAddressDeny` in systemd, so |
| + the box's address cannot be carved out of the prefix. The equality rule |
| + for singles becomes an overlap rule. |
| +8. **Console grant check and live report:** an added prefix is refused if |
| + any published box address lies inside it, naming the box. This is the |
| + §4.2 rule with "equals" widened to "contains". The live report and |
| + `apps show`'s `!` work the same way. |
| +9. **Version floor.** `release.EgressPrefixFloor = v0.43.0` (the next |
| + minor; v0.42.1 is the latest tag). A grant that adds a non-full-length |
| + prefix is refused with a 409 while any fresh heartbeat box of the |
| + deployment reports a release below the floor or no release. This |
| + follows the `teamFloorRefusal` pattern in internal/console/teamfloor.go |
| + and is not scoped to the app's placement, because an app can move to |
| + any box. If the release ships under another number, the floor constant |
| + moves with it. A floor set too high only refuses prefixes for longer |
| + (fail safe). |
| +10. **Propagation is documented, not shortened, in this slice.** |
| + Shortening it means a fleet full pass that re-lists |
| + `control/app-policy/` whenever the serial moves. Serial bumps follow |
| + any console activity, so that adds S3 requests on every fleet box, which |
| + ruling 11 forbids without a budget. The bound (about 33 minutes on |
| + fleet boxes, seconds on shared boxes) is already in docs/site/cli.md. |
| + The proposal goes on #1357. |
| +11. **Fleet-box warning reworded**, not removed. It names the boxes as |
| + fleet boxes that do not publish their addresses, and says that root |
| + on each of those boxes still refuses an entry holding the box's own |
| + address. |
| +12. **Hostname entries:** not built here. A proposal goes on #1357. |
| + |
| +## Global constraints |
| + |
| +- `internal/egressaddr` stays a pure leaf package (no platform imports). |
| +- No new per-box polling, no new S3 reads on a timer. |
| +- Policies with singles only stay byte-identical (stored form, signed wire, |
| + registry column, the `IPAddressAllow=` line root writes). |
| +- User-facing text: no em dashes, curly quotes in docs prose, plain and |
| + short. Refusals are lower-case fragments in the existing `egressaddr` |
| + style (`"%q is ..."`). Copy gets a Luna pass after Task 3. |
| +- No tenant names; examples use `shop`, `10.0.64.0/20`, `fd00:5::/64`. |
| +- Root-read code changes (instancectl) need a census card |
| + (`make census-card` / `census-propose`) if `TestPlan14RootReadCensus` |
| + moves. |
| +- Local tests: targeted `-run` on changed packages only. Also cross-build |
| + `GOOS=darwin` and `GOOS=windows` for `./...`-touched packages. |
| + |
| +## Task 1: egressaddr prefixes |
| + |
| +Files: internal/egressaddr/egressaddr.go, egressaddr_test.go. |
| + |
| +- Add `ParseEntry(s string) (netip.Prefix, error)`. A bare address becomes |
| + its full-length prefix, with an IPv4-mapped address unmapped. `a/n` is |
| + parsed with `netip.ParsePrefix`. A mapped-v4 prefix is refused as |
| + not-an-address, to keep it simple. Ports, zones and empty input are |
| + refused as today. Host bits set gives `"%q has host bits set. write it |
| + as %s"`. Keep `Parse` (single addresses) for existing callers that still |
| + need an address. |
| +- Add `AllowedPrefix(p netip.Prefix) error`: |
| + - Full-length → `Allowed(p.Addr())` (same messages as today). |
| + - Otherwise: |
| + - min length (decision 4): `"%s is wider than /%d. allow at most a /%d"`; |
| + - containment in a `FenceDeny` range, else public or partly public: |
| + `"%s is not wholly inside a private range"`; |
| + - no overlap with loopback, multicast, link-local |
| + (`169.254.0.0/16`, `fe80::/10`), the metadata addresses, reserved |
| + or NAT64: reuse the existing messages with the prefix in place of |
| + the address. Loopback and multicast are already caught by the |
| + length plus containment rules, but test them anyway. |
| +- `Normalize` works on entries (decisions 2, 3 and 6), and stays the one |
| + door function. |
| +- Constants: `MinPrefixV4 = 16`, `MinPrefixV6 = 48`. |
| +- `Parse` stays the single-address reader and keeps refusing a `/` |
| + (Task 2's old-box witness pins that). Update the package doc for |
| + ranges. |
| +- **Witness: table tests.** |
| + - Accepted: `10.0.64.0/20`, `10.0.0.0/16`, `172.16.0.0/16`, |
| + `192.168.0.0/16`, `100.64.0.0/16`, `fd00:5::/64`, `fd00:5::/48`, |
| + `10.0.5.20/32` → stored `10.0.5.20`, `fd00:5::20/128` → |
| + `fd00:5::20`. |
| + - Refused, each with its message: `10.0.0.0/8`, `10.0.0.0/15`, |
| + `fd00::/47`, `10.0.64.5/20`, `169.254.0.0/16`, |
| + `169.254.169.0/24`, `fd00:ec2::/48`, `64:ff9b::/96`, |
| + `198.18.0.0/16`, `8.8.8.0/24`, `0.0.0.0/16`, `224.0.0.0/16`, |
| + `fe80::/64`, `10.0.64.0/20:5432`, `::ffff:10.0.0.0/112`. |
| + - Sort and dedup: `10.0.64.0`, `10.0.64.0/20`, `10.0.64.0/20` → |
| + `[10.0.64.0/20 10.0.64.0]`. |
| + - The count limit holds with prefixes. |
| + - A fuzz-free property test: for each accepted prefix, its first and last |
| + addresses pass `Allowed`. |
| + |
| +## Task 2: the box accepts prefixes exactly |
| + |
| +Files: |
| +- internal/apppolicy/apppolicy.go (Validate uses `ParseEntry`, |
| + `AllowedPrefix` and the decision-6 order); |
| +- internal/instancectl/egress.go (`desired`); |
| +- internal/instancectl/localaddrs.go (an overlap helper); |
| +- callers of `egressaddr.Parse` in internal/console/egressfleet.go only as |
| + far as compiling needs (the logic is Task 3). |
| + |
| +- `desired`: |
| + - parse with `ParseEntry`, check with `AllowedPrefix`, and dedup by |
| + prefix; |
| + - refuse an entry overlapping any local prefix |
| + (`"%s: holds an address of this box (%s)"`, with the existing |
| + single-address text unchanged for full-length entries); |
| + - write the prefix as is. |
| +- The `want`/read-back comparison already uses masked prefixes. Confirm |
| + that systemd's read-back of `10.0.64.0/20` parses equal (a unit test |
| + with the fake systemctl). |
| +- **Witnesses:** |
| + - (a) `desired` table: a prefix is written verbatim, a prefix |
| + overlapping a local /32 is refused, singles are unchanged, and the |
| + count limit applies. |
| + - (b) Assert writes `IPAddressAllow=10.0.64.0/20` through the fake |
| + systemctl. A read-back of `10.0.64.0/20` counts as in force, not |
| + failing. |
| + - (c) **old-box safety:** a test in internal/provision that pins the |
| + old-box path. A policy whose `Validate` fails (a bad entry) gives |
| + fail-closed columns, with an empty allow, never a wider one. Also |
| + assert in egressaddr's tests that `Parse` (the old single-address |
| + reader, still used by old boxes' code shape) refuses every prefix |
| + form. The floor in Task 3 is the guard that stops it happening. |
| + - (d) **production-wired:** a registry egress column `10.0.64.0/20 |
| + 10.0.5.20` goes through the real egress source (internal/host |
| + egress_source.go) into the asserter, which writes exactly those two |
| + prefixes. Use the existing wiring test's harness |
| + (egress_claim_wiring_test.go or egress_source_test.go). |
| +- Run the census test (`go test ./internal/provision -run |
| + TestPlan14RootReadCensus`). If it moves, produce the card per AGENTS.md |
| + ("The census: an approval, not a decision"). |
| + |
| +## Task 3: console door, fleet check, floor, copy |
| + |
| +Files: |
| +- internal/console/egressfleet.go; |
| +- internal/console/apipolicy.go; |
| +- internal/console/teamfloor.go (or a new egressfloor.go); |
| +- internal/release/layoutintent.go (the floor); |
| +- apps_policy.go, plus the CLI help for `--egress-allow`; |
| +- docs/site/cli.md (~262). |
| + |
| +- `grantAdded` returns added prefixes. The check refuses a prefix that |
| + contains any published box address, naming the box and the address. |
| + `egressFleetHeldMsg` gets the prefix wording when the entry is a |
| + prefix. |
| +- The live report and `apps show` `!` work on prefix containment. |
| +- Floor (decision 9): refuse with 409 using the teamfloor phrasing |
| + pattern: |
| + - `"box %s runs %s. allowing a range needs v%s or later on every box. single addresses are unaffected"`; |
| + - a heartbeat read failure → 503, as in teamfloor. |
| + - Only grants that add a non-full-length entry are gated. Revokes and |
| + singles never are. |
| +- Fleet warning reworded (decision 11). |
| +- CLI help and the docs paragraph: entries may be a private range with at |
| + least /16 (IPv4) or /48 (IPv6). Host bits refused. Count 8. The floor. |
| + The box refuses a range that holds one of its own addresses. The |
| + propagation bound stays. |
| +- **Witnesses:** console tests. |
| + - A grant of a prefix holding an edges-file address → 409 naming the |
| + box. |
| + - A prefix with no conflicts → 200. |
| + - Floor: one fresh box at v0.42.1 → 409. All at v0.43.0 → 200. A |
| + single address with an old box → 200. |
| + - The report flags a prefix that later contains a box address. |
| + |
| +## Task 4: kernel witness (root runner) |
| + |
| +File: internal/host/egress_kernel_rootrunner_linux_test.go (or a sibling |
| +`egress_prefix_rootrunner_linux_test.go`), `//go:build linux && |
| +rootrunner`. |
| + |
| +- Use the kernel proof's dummy-link harness: |
| + - put two listeners on a dummy link, one inside `10.250.64.0/20` |
| + (`10.250.64.10`) and one outside it but in the same /16 |
| + (`10.250.80.10`); |
| + - give a tenant in a child unit with the template's `IPAddressDeny=` |
| + a slice allow of `10.250.64.0/20`, written by the real asserter; |
| + - the tenant reaches the inside listener and is refused at the outside |
| + one; |
| + - revoke, and the inside listener is refused as well. |
| +- Log one `verdict:` line per question. |
| +- The controller runs it on the root runner (memory root-runner) and |
| + records the run id in the ledger. |
| + |
| +## After the tasks (controller) |
| + |
| +- Luna copy pass over the new strings and the docs paragraph, then apply it. |
| +- Post on #1357: |
| + - progress; |
| + - the propagation finding and proposal (decision 10); |
| + - the warning explanation; |
| + - the hostname proposal. |
| +- Final whole-branch review by Astra (max three rounds), CI, squash-merge |
| + with amadan. |
| +- Tell paseo 09cca118 and 8a3d302 the SHA. The release waits for Paul's GO. |
diff --git a/internal/apppolicy/apppolicy.go b/internal/apppolicy/apppolicy.go| index 97df1976a..2984b1f0d 100644 |
| --- a/internal/apppolicy/apppolicy.go |
| +++ b/internal/apppolicy/apppolicy.go |
| @@ -73,10 +73,12 @@ type SizeOverride struct { |
| } |
| // Validate checks the policy's shape: the version, known size names, host |
| -// keys, and an egress allow already in its stored form (canonical text, |
| -// strictly ascending, at most egressaddr.MaxAllow). It does not decide |
| -// whether an address may be granted (the door does, with |
| -// egressaddr.Normalize) and does not look at the signing fields. |
| +// keys, and an egress allow already in its stored form (each entry a single |
| +// address or a prefix in egressaddr.EntryString's text, one |
| +// egressaddr.AllowedPrefix accepts, strictly ascending in |
| +// egressaddr.ComparePrefix's order, at most egressaddr.MaxAllow). It does |
| +// not look at the signing fields. A box whose Validate predates prefixes |
| +// refuses a policy holding one (#1357), and its reader then fails closed. |
| func (p Policy) Validate() error { |
| if p.Demo != nil || p.EgressMode != "" { |
| if p.Demo == nil || p.EgressMode != "deny-all" || p.DefaultSize != "small" || len(p.EgressAllow) != 0 || len(p.Sizes) != 0 { |
| @@ -109,13 +111,16 @@ func (p Policy) Validate() error { |
| if len(p.EgressAllow) > egressaddr.MaxAllow { |
| return fmt.Errorf("%w: %d egress allows, at most %d", ErrInvalid, len(p.EgressAllow), egressaddr.MaxAllow) |
| } |
| - var prev netip.Addr |
| + var prev netip.Prefix |
| for i, e := range p.EgressAllow { |
| - a, err := egressaddr.Parse(e) |
| - if err != nil || a.String() != e { |
| + a, err := egressaddr.ParseEntry(e) |
| + if err != nil || egressaddr.EntryString(a) != e { |
| return fmt.Errorf("%w: egress allow %q", ErrInvalid, e) |
| } |
| - if i > 0 && prev.Compare(a) >= 0 { |
| + if err := egressaddr.AllowedPrefix(a); err != nil { |
| + return fmt.Errorf("%w: egress allow %v", ErrInvalid, err) |
| + } |
| + if i > 0 && egressaddr.ComparePrefix(prev, a) >= 0 { |
| return fmt.Errorf("%w: egress allow %q out of order", ErrInvalid, e) |
| } |
| prev = a |
diff --git a/internal/apppolicy/apppolicy_test.go b/internal/apppolicy/apppolicy_test.go| index eb4e734ad..1a2ce8b9d 100644 |
| --- a/internal/apppolicy/apppolicy_test.go |
| +++ b/internal/apppolicy/apppolicy_test.go |
| @@ -76,6 +76,9 @@ func TestValidate(t *testing.T) { |
| {V: 1}, |
| {V: 1, AppID: "x", EgressAllow: []string{"10.0.5.20", "fd00:5::20"}, DefaultSize: "small", |
| Sizes: map[string]SizeOverride{"shop-a.example.com": {"xlarge", t0}}}, |
| + // Prefixes in their stored form and decision 6's order: address, |
| + // then prefix length, so a prefix sorts before its own first address. |
| + {V: 1, EgressAllow: []string{"10.0.5.20", "10.0.64.0/20", "10.0.64.0", "fd00:5::/64", "fd00:5::20"}}, |
| } { |
| if err := p.Validate(); err != nil { |
| t.Errorf("Validate(%+v) = %v", p, err) |
| @@ -99,6 +102,17 @@ func TestValidate(t *testing.T) { |
| "duplicate allows": {V: 1, EgressAllow: []string{"10.0.5.20", "10.0.5.20"}}, |
| "allow with a port": {V: 1, EgressAllow: []string{"10.0.5.20:80"}}, |
| "allow not in canon form": {V: 1, EgressAllow: []string{"::ffff:10.0.5.20"}}, |
| + "single stored as /32": {V: 1, EgressAllow: []string{"10.0.5.20/32"}}, |
| + "single stored as /128": {V: 1, EgressAllow: []string{"fd00:5::20/128"}}, |
| + "prefix with host bits": {V: 1, EgressAllow: []string{"10.0.64.5/20"}}, |
| + "prefix not canonical": {V: 1, EgressAllow: []string{"fd00:5:0::/64"}}, |
| + "prefix with space": {V: 1, EgressAllow: []string{" 10.0.64.0/20"}}, |
| + "prefix after its first": {V: 1, EgressAllow: []string{"10.0.64.0", "10.0.64.0/20"}}, |
| + "duplicate prefixes": {V: 1, EgressAllow: []string{"10.0.64.0/20", "10.0.64.0/20"}}, |
| + "prefix too wide": {V: 1, EgressAllow: []string{"10.0.0.0/8"}}, |
| + "prefix public": {V: 1, EgressAllow: []string{"8.8.8.0/24"}}, |
| + "prefix holds metadata": {V: 1, EgressAllow: []string{"fd00:ec2::/48"}}, |
| + "single public": {V: 1, EgressAllow: []string{"8.8.8.8"}}, |
| } { |
| if err := p.Validate(); !errors.Is(err, ErrInvalid) { |
| t.Errorf("%s: Validate = %v, want ErrInvalid", name, err) |
diff --git a/internal/console/egressfleet.go b/internal/console/egressfleet.go| index abfe747bb..cc4b6c79f 100644 |
| --- a/internal/console/egressfleet.go |
| +++ b/internal/console/egressfleet.go |
| @@ -12,6 +12,11 @@ |
| // fleet boxes) cannot be checked; the grant goes through and the door's |
| // reply names them as not_checked. |
| // |
| +// An added entry may be a prefix (#1357): it is refused when any published |
| +// box address lies in it (decision 8), and it is added only while every |
| +// fresh box of the deployment runs release.EgressPrefixFloor or later |
| +// (decision 9). Single addresses are never held by the floor. |
| +// |
| // Only additions are checked (ruling C5): a revoke, a re-send of the same |
| // list or a size-only change reads nothing, so a store outage never holds |
| // one up. A grant reads the edges files through the console's AddrCache, |
| @@ -40,37 +45,57 @@ import ( |
| // Door copy (approved by delegation, Luna pass 2026-10-26; deck copy-instance-policy-plan2.md). |
| const ( |
| - egressFleetHeldMsg = "%s is an address of box %s. an egress allow cannot open a box of this fleet" |
| + egressFleetHeldMsg = "%s is an address of box %s. an egress allow cannot open a box of this fleet" |
| + // egressFleetRangeHeldMsg and egressRangeBelowFloorMsg are #1357's, |
| + // awaiting their copy pass. |
| + egressFleetRangeHeldMsg = "%s overlaps %s, an address or range held by box %s. an egress allow cannot open a box of this fleet" |
| + // egressRangeBelowFloorMsg is filled with the first fresh box below |
| + // release.EgressPrefixFloor (by label), the release it runs |
| + // (boxReleaseWord) and the floor. |
| + egressRangeBelowFloorMsg = "box %s reports %s. allowing a range needs v%s or later on every box. single addresses are unaffected" |
| egressFleetUnreadableMsg = "box %s's address list could not be read. try again in a minute" |
| egressFleetOlderBoxMsg = "box %s does not publish its addresses yet. upgrade it before granting an egress allow" |
| egressFleetListMsg = "the fleet's address lists could not be read. try again in a minute" |
| egressFleetBoxesMsg = "the fleet's list of boxes could not be read. try again in a minute" |
| ) |
| -// egressGrantCheck checks the addresses a grant adds (new minus old) against |
| +// egressGrantCheck checks the entries a grant adds (new minus old) against |
| // every readable edges file, whatever its age. notChecked: labels of |
| // non-stale boxes in systemBoxes that publish no edges file. |
| // |
| -// The refusals, in order: an added address a file lists (409, naming the |
| -// box); a listed file that could not be read (503, naming it); a file with |
| -// no addrs (409, naming its box); a failed listing of control/edges/ or of |
| -// the boxes (503). With nothing added it reads nothing. |
| -func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notChecked []string, ref *doorRefusal) { |
| +// The refusals, in order: an added range while a fresh box runs below |
| +// release.EgressPrefixFloor (409, naming the box) or the heartbeats could |
| +// not be read whole (503); an added entry holding an address a file lists |
| +// (409, naming the box); a listed file that could not be read (503, naming |
| +// it); a file with no addrs (409, naming its box); a failed listing of |
| +// control/edges/ or of the boxes (503). With nothing added it reads |
| +// nothing. |
| +func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Prefix) (notChecked []string, ref *doorRefusal) { |
| if len(added) == 0 { |
| return []string{}, nil |
| } |
| if s.cfg.Releases == nil { |
| return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg} |
| } |
| + if slices.ContainsFunc(added, func(p netip.Prefix) bool { return !p.IsSingleIP() }) { |
| + if ref := s.egressPrefixFloorRefusal(ctx); ref != nil { |
| + return nil, ref |
| + } |
| + } |
| inv, err := edgesfile.ReadAddrsCached(ctx, s.cfg.Releases, &s.egressAddrs) |
| if err != nil { |
| s.policyLogf("console: egress grant check: list %s: %v", edgesfile.Prefix, err) |
| return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg} |
| } |
| - for _, a := range added { |
| - if box, ok := inv.Holder(a); ok { |
| - return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetHeldMsg, a, box)} |
| + for _, p := range added { |
| + box, held, ok := egressHolder(inv, p) |
| + if !ok { |
| + continue |
| + } |
| + if p.IsSingleIP() { |
| + return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetHeldMsg, p.Addr(), box)} |
| } |
| + return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetRangeHeldMsg, p, held, box)} |
| } |
| if len(inv.Unreadable) > 0 { |
| s.policyLogf("console: egress grant check: unreadable edges files: %s", strings.Join(inv.Unreadable, ", ")) |
| @@ -103,31 +128,123 @@ func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notC |
| return slices.Compact(notChecked), nil |
| } |
| +// egressHolder names the first box (by label) with a published address that |
| +// overlaps entry, and that address as the box published it (a bare address, |
| +// or a prefix). For a single address this is edgesfile's Holder; for a |
| +// prefix it is containment, the box's address inside the range (decision |
| +// 8). An IPv4-mapped entry is matched as IPv4. |
| +func egressHolder(inv edgesfile.AddrInventory, entry netip.Prefix) (box, held string, ok bool) { |
| + if a := entry.Addr(); a.Is4In6() && entry.Bits() >= 96 { |
| + entry = netip.PrefixFrom(a.Unmap(), entry.Bits()-96) |
| + } |
| + entry = netip.PrefixFrom(entry.Addr().WithZone(""), entry.Bits()) |
| + boxes := slices.Sorted(maps.Keys(inv.Boxes)) |
| + for _, b := range boxes { |
| + for _, q := range inv.Boxes[b] { |
| + if entry.Overlaps(q) { |
| + return b, egressaddr.EntryString(q), true |
| + } |
| + } |
| + } |
| + return "", "", false |
| +} |
| + |
| +// egressPrefixFloorRefusal is the version floor on adding a range (decision |
| +// 9): nil when every fresh heartbeat box of the deployment (the platform's |
| +// and every fleet's, as an app can move to any box) runs |
| +// release.EgressPrefixFloor or later. A box below it would read the policy |
| +// as unverifiable and clear the app's whole allow. A deployment with no |
| +// fresh box admits, as teamFloorRefusal does. A release that is missing or |
| +// does not parse counts as below; heartbeats that cannot be read whole are |
| +// 503. |
| +func (s *Server) egressPrefixFloorRefusal(ctx context.Context) *doorRefusal { |
| + boxes, ok := s.egressFloorBoxes(ctx) |
| + if !ok { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetBoxesMsg} |
| + } |
| + now := time.Now() |
| + var old *status.Box |
| + for i, b := range boxes { |
| + if status.BoxStale(b, now, status.SnapshotPeriod) || boxAtEgressPrefixFloor(b) { |
| + continue |
| + } |
| + if old == nil || b.Label < old.Label { |
| + old = &boxes[i] |
| + } |
| + } |
| + if old == nil { |
| + return nil |
| + } |
| + return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressRangeBelowFloorMsg, |
| + old.Label, boxReleaseWord(*old), release.EgressPrefixFloor.String())} |
| +} |
| + |
| +// boxAtEgressPrefixFloor is boxAtTeamFloor against release.EgressPrefixFloor. |
| +func boxAtEgressPrefixFloor(b status.Box) bool { |
| + if b.Metrics == nil { |
| + return false |
| + } |
| + v, ok := release.ParseReleaseVersion(b.Metrics.Release) |
| + return ok && v.Compare(release.EgressPrefixFloor) >= 0 |
| +} |
| + |
| +// egressFloorBoxes is every heartbeat of the deployment: the platform's and |
| +// each fleet's, less a fleet's detached boxes. ok is false when the fleets |
| +// or any heartbeat could not be read (systemBoxes, by contrast, reads past |
| +// an incomplete listing). |
| +func (s *Server) egressFloorBoxes(ctx context.Context) ([]status.Box, bool) { |
| + reg, fleets, err := s.systemFleets() |
| + if err != nil { |
| + s.policyLogf("console: egress prefix floor: fleets: %v", err) |
| + return nil, false |
| + } |
| + boxes, complete, err := s.loadBoxes(ctx, s.cfg.Releases, "") |
| + if err != nil || !complete { |
| + s.policyLogf("console: egress prefix floor: heartbeats: complete %t, %v", complete, err) |
| + return nil, false |
| + } |
| + boxes = slices.Clone(boxes) |
| + for _, f := range fleets { |
| + fb, complete, err := s.loadBoxes(ctx, s.cfg.Releases, "fleets/"+f.Name+"/") |
| + if err != nil || !complete { |
| + s.policyLogf("console: egress prefix floor: fleet %s heartbeats: complete %t, %v", f.Name, complete, err) |
| + return nil, false |
| + } |
| + detached, err := detachedFleetBoxes(ctx, reg, f.Name) |
| + if err != nil { |
| + s.policyLogf("console: egress prefix floor: fleet %s registry boxes: %v; counting every report", f.Name, err) |
| + } |
| + boxes = append(boxes, withoutDetached(fb, detached)...) |
| + } |
| + return boxes, true |
| +} |
| + |
| // edgesKeyBox is the box an edges file's key names: control/edges/<box>.json. |
| func edgesKeyBox(key string) string { |
| return strings.TrimSuffix(strings.TrimPrefix(key, edgesfile.Prefix), ".json") |
| } |
| -// grantAdded is next minus old, as addresses: what a grant opens that the |
| -// stored allow did not. next is the normalized list, so an entry that does |
| -// not parse is refused with egressaddr's reason; an old entry that does not |
| -// parse matches nothing. |
| -func grantAdded(old, next []string) ([]netip.Addr, error) { |
| - had := make(map[netip.Addr]bool, len(old)) |
| +// grantAdded is next minus old, as entries (a single address is its |
| +// full-length prefix): what a grant opens that the stored allow did not. A |
| +// range and an address inside it are separate entries. next is the |
| +// normalized list, so an entry that does not parse is refused with |
| +// egressaddr's reason; an old entry that does not parse matches nothing. |
| +func grantAdded(old, next []string) ([]netip.Prefix, error) { |
| + had := make(map[netip.Prefix]bool, len(old)) |
| for _, o := range old { |
| - if a, err := egressaddr.Parse(o); err == nil { |
| - had[a] = true |
| + if p, err := egressaddr.ParseEntry(o); err == nil { |
| + had[p] = true |
| } |
| } |
| - var added []netip.Addr |
| + var added []netip.Prefix |
| for _, n := range next { |
| - a, err := egressaddr.Parse(n) |
| + p, err := egressaddr.ParseEntry(n) |
| if err != nil { |
| return nil, err |
| } |
| - if !had[a] { |
| - had[a] = true |
| - added = append(added, a) |
| + if !had[p] { |
| + had[p] = true |
| + added = append(added, p) |
| } |
| } |
| return added, nil |
| @@ -166,12 +283,19 @@ var pageEgressConflict = alerting.Page |
| const ( |
| egressConflictSubject = "Egress allow %s is now a fleet box's address." |
| egressConflictBody = "App %s in account id %s may reach %s, and box %s now holds that address. The allow is still in force. Set the whole list again without that address by running carlos apps set %s --egress-allow, or move the address off the box." |
| + // The same alert for an allowed range (#1357, awaiting its copy pass). |
| + egressRangeConflictSubject = "Egress allow %s now holds a fleet box's address." |
| + egressRangeConflictBody = "App %s in account id %s may reach %s, and box %s now holds an address in that range. The allow is still in force. Set the whole list again without that range by running carlos apps set %s --egress-allow, or move the address off the box." |
| ) |
| -// egressConflictAlert is the report's alert. |
| -func egressConflictAlert(sqid, app string, addr netip.Addr, box string) (subject, body string) { |
| - return fmt.Sprintf(egressConflictSubject, addr), |
| - fmt.Sprintf(egressConflictBody, app, sqid, addr, box, app) |
| +// egressConflictAlert is the report's alert for an allowed entry. |
| +func egressConflictAlert(sqid, app string, entry netip.Prefix, box string) (subject, body string) { |
| + if !entry.IsSingleIP() { |
| + return fmt.Sprintf(egressRangeConflictSubject, entry), |
| + fmt.Sprintf(egressRangeConflictBody, app, sqid, entry, box, app) |
| + } |
| + return fmt.Sprintf(egressConflictSubject, entry.Addr()), |
| + fmt.Sprintf(egressConflictBody, app, sqid, entry.Addr(), box, app) |
| } |
| // egressReportState is the report's memory. Every field after mu is guarded |
| @@ -186,10 +310,10 @@ type egressReportState struct { |
| // genOK (the watch could vouch for it then). |
| gen uint64 |
| genOK bool |
| - // conflicts is the last pass's findings, address -> box; nil before |
| - // the first pass. |
| + // conflicts is the last pass's findings, allowed entry (its stored |
| + // form) -> box; nil before the first pass. |
| conflicts map[string]string |
| - // alerted is when each "<sqid>/<app> <addr>" alert was last sent. |
| + // alerted is when each "<sqid>/<app> <entry>" alert was last sent. |
| alerted map[string]time.Time |
| now func() time.Time // nil: time.Now |
| @@ -213,13 +337,17 @@ func (s *Server) egressEdgesGen() (uint64, bool) { |
| return w.Gen(egressEdgesScope) |
| } |
| -// egressAllowed is one address of one app's allow. |
| +// egressAllowed is one entry of one app's allow: a single address as its |
| +// full-length prefix, or a range. |
| type egressAllowed struct { |
| sqid, app string |
| - addr netip.Addr |
| + entry netip.Prefix |
| } |
| -// egressLiveAllows is every address of every live allow, read from the |
| +// key is the entry's stored form, the report's and the alert's key. |
| +func (a egressAllowed) key() string { return egressaddr.EntryString(a.entry) } |
| + |
| +// egressLiveAllows is every entry of every live allow, read from the |
| // console's own policy rows (AppPolicyRowsContext) and opened with the key |
| // they were signed with. unopened names the rows that do not open (or hold |
| // an entry that does not parse): their allows are not checked. |
| @@ -236,12 +364,12 @@ func (s *Server) egressLiveAllows(ctx context.Context) (allows []egressAllowed, |
| continue |
| } |
| for _, e := range p.EgressAllow { |
| - a, err := egressaddr.Parse(e) |
| + p, err := egressaddr.ParseEntry(e) |
| if err != nil { |
| unopened = append(unopened, r.Sqid+"/"+r.App) |
| continue |
| } |
| - allows = append(allows, egressAllowed{sqid: r.Sqid, app: r.App, addr: a}) |
| + allows = append(allows, egressAllowed{sqid: r.Sqid, app: r.App, entry: p}) |
| } |
| } |
| return allows, unopened, nil |
| @@ -375,12 +503,12 @@ func (s *Server) egressReportPass(ctx context.Context) error { |
| } |
| allowed := map[string]bool{} |
| for _, a := range allows { |
| - allowed[a.addr.String()] = true |
| - box, ok := inv.Holder(a.addr) |
| + allowed[a.key()] = true |
| + box, _, ok := egressHolder(inv, a.entry) |
| if !ok { |
| continue |
| } |
| - conflicts[a.addr.String()] = box |
| + conflicts[a.key()] = box |
| s.egressAlert(ctx, a, box, now) |
| } |
| st.mu.Lock() |
| @@ -429,7 +557,7 @@ func egressBoxReadInFull(inv edgesfile.AddrInventory, box string) bool { |
| // address within egressAlertEvery. The slot is taken before the send and |
| // given back if it fails, so the next pass tries again. |
| func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, now time.Time) { |
| - key := a.sqid + "/" + a.app + " " + a.addr.String() |
| + key := a.sqid + "/" + a.app + " " + a.key() |
| st := &s.egressReport |
| st.mu.Lock() |
| if at, ok := st.alerted[key]; ok && now.Sub(at) < egressAlertEvery { |
| @@ -445,7 +573,7 @@ func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, n |
| if page == nil { |
| page = pageEgressConflict |
| } |
| - subject, body := egressConflictAlert(a.sqid, a.app, a.addr, box) |
| + subject, body := egressConflictAlert(a.sqid, a.app, a.entry, box) |
| sctx, cancel := context.WithTimeout(ctx, egressAlertTimeout) |
| defer cancel() |
| if err := page(sctx, alerting.LevelWarning, subject, body); err != nil { |
| @@ -458,8 +586,8 @@ func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, n |
| } |
| } |
| -// egressConflicts is the last pass's findings, allowed address -> the box |
| -// that holds it, or nil before the first pass. The map is a copy. |
| +// egressConflicts is the last pass's findings, allowed entry -> the box |
| +// that holds it (or, for a range, an address in it), or nil before the first pass. The map is a copy. |
| func (s *Server) egressConflicts() map[string]string { |
| st := &s.egressReport |
| st.mu.Lock() |
diff --git a/internal/console/egressfleet_test.go b/internal/console/egressfleet_test.go| index 8ada88f18..f90544759 100644 |
| --- a/internal/console/egressfleet_test.go |
| +++ b/internal/console/egressfleet_test.go |
| @@ -136,11 +136,13 @@ func grantServer(t *testing.T) (*Server, *edgesCountingStore) { |
| return &Server{cfg: Config{Releases: cs}, policyLog: func(string, ...any) {}}, cs |
| } |
| -func addrs(t *testing.T, ss ...string) []netip.Addr { |
| +// addrs is single addresses as the full-length prefixes grantAdded gives. |
| +func addrs(t *testing.T, ss ...string) []netip.Prefix { |
| t.Helper() |
| - out := make([]netip.Addr, 0, len(ss)) |
| + out := make([]netip.Prefix, 0, len(ss)) |
| for _, s := range ss { |
| - out = append(out, netip.MustParseAddr(s)) |
| + a := netip.MustParseAddr(s) |
| + out = append(out, netip.PrefixFrom(a, a.BitLen())) |
| } |
| return out |
| } |
| @@ -975,3 +977,207 @@ func TestEgressReportKeepsAConflictItCannotRead(t *testing.T) { |
| fx.mustPut(t, "shop", `{"egress_allow":["10.0.5.21"]}`, policyIfMatch(first.ETag)) |
| pass("the allow narrowed while betty is unreadable", map[string]string{}) |
| } |
| + |
| +func prefixes(t *testing.T, ss ...string) []netip.Prefix { |
| + t.Helper() |
| + out := make([]netip.Prefix, 0, len(ss)) |
| + for _, s := range ss { |
| + if !strings.Contains(s, "/") { |
| + a := netip.MustParseAddr(s) |
| + out = append(out, netip.PrefixFrom(a, a.BitLen())) |
| + continue |
| + } |
| + out = append(out, netip.MustParsePrefix(s)) |
| + } |
| + return out |
| +} |
| + |
| +// setBoxRelease writes a fresh heartbeat for label naming release rel ("" for |
| +// a heartbeat that names none). |
| +func setBoxRelease(t *testing.T, s release.Store, label, rel string, at time.Time) { |
| + t.Helper() |
| + if err := status.WriteBox(context.Background(), s, status.Box{Label: label, GeneratedAt: at, Metrics: &status.BoxMetrics{Release: rel}}); err != nil { |
| + t.Fatalf("snapshot %s: %v", label, err) |
| + } |
| +} |
| + |
| +// A range that holds a published box address is refused (409), naming the |
| +// box and the address; a range that holds none goes through. Decision 8. |
| +func TestEgressGrantRefusesARangeHoldingAFleetAddress(t *testing.T) { |
| + t.Parallel() |
| + s, cs := grantServer(t) |
| + now := time.Now() |
| + putEdgesAddrs(t, cs, "annie", []string{"10.0.64.7", "fd00:5::/64"}) |
| + setBoxRelease(t, cs, "annie", "v0.43.0", now) |
| + for _, c := range []struct { |
| + add string |
| + want string |
| + }{ |
| + {"10.0.64.0/20", "10.0.64.0/20 overlaps 10.0.64.7, an address or range held by box annie. an egress allow cannot open a box of this fleet"}, |
| + {"fd00:5::/48", "fd00:5::/48 overlaps fd00:5::/64, an address or range held by box annie. an egress allow cannot open a box of this fleet"}, |
| + } { |
| + nc, ref := s.egressGrantCheck(context.Background(), prefixes(t, c.add)) |
| + if ref == nil || ref.Status != http.StatusConflict || ref.Msg != c.want { |
| + t.Errorf("grant %s = %v %+v, want 409 %q", c.add, nc, ref, c.want) |
| + } |
| + } |
| + nc, ref := s.egressGrantCheck(context.Background(), prefixes(t, "10.0.80.0/20", "fd00:6::/48")) |
| + if ref != nil || nc == nil || len(nc) != 0 { |
| + t.Fatalf("ranges no box address is in = %#v %+v, want [] and no refusal", nc, ref) |
| + } |
| +} |
| + |
| +// Through the door: a range is added only while every fresh box runs |
| +// EgressPrefixFloor or later (decision 9). A single address is never held |
| +// up by the floor, nor is a revoke of a range. |
| +func TestPolicyDoorRangeNeedsTheFloorOnEveryBox(t *testing.T) { |
| + t.Parallel() |
| + fx := newPolicyFx(t, "code-policy-range-floor") |
| + now := time.Now() |
| + putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"}) |
| + setBoxRelease(t, fx.rel, "annie", "v0.43.0", now) |
| + putEdgesAddrs(t, fx.rel, "betty", []string{"10.0.1.6"}) |
| + setBoxRelease(t, fx.rel, "betty", "v0.42.1", now) |
| + putEdgesAddrs(t, fx.rel, "olive", []string{"10.0.1.7"}) |
| + setBoxRelease(t, fx.rel, "olive", "v0.30.0", now.Add(-24*time.Hour)) // stale: not counted |
| + |
| + st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.64.0/20"]}`, policyCreate) |
| + if want := "box betty reports v0.42.1. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected"; st != http.StatusConflict || errorOf(t, out) != want { |
| + t.Fatalf("a range with betty on v0.42.1 = %d %s, want 409 %q", st, out, want) |
| + } |
| + fx.noObject(t, "shop") |
| + |
| + single := fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.5"]}`, policyCreate) |
| + |
| + setBoxRelease(t, fx.rel, "betty", "v0.43.0", now) |
| + ranged := fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20","10.0.64.5"]}`, policyIfMatch(single.ETag)) |
| + if want := []string{"10.0.64.0/20", "10.0.64.5"}; !slices.Equal(ranged.Policy.EgressAllow, want) { |
| + t.Fatalf("allow = %v, want %v", ranged.Policy.EgressAllow, want) |
| + } |
| + |
| + setBoxRelease(t, fx.rel, "betty", "", now) // names no release: below |
| + if st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.64.0/20","fd00:5::/64"]}`, policyIfMatch(ranged.ETag)); st != http.StatusConflict || |
| + errorOf(t, out) != "box betty reports no release. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected" { |
| + t.Fatalf("a second range with betty naming no release = %d %s, want 409", st, out) |
| + } |
| + fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20"]}`, policyIfMatch(ranged.ETag)) |
| +} |
| + |
| +// A heartbeat read that fails refuses a range with 503: the floor is not |
| +// passed on what the console could not see. |
| +func TestEgressGrantRangeFloorUnreadable(t *testing.T) { |
| + t.Parallel() |
| + s, cs := grantServer(t) |
| + putEdgesAddrs(t, cs, "annie", []string{"10.0.1.5"}) |
| + setBoxRelease(t, cs, "annie", "v0.43.0", time.Now()) |
| + cs.fail(true) |
| + _, ref := s.egressGrantCheck(context.Background(), prefixes(t, "10.0.64.0/20")) |
| + if want := "the fleet's list of boxes could not be read. try again in a minute"; ref == nil || |
| + ref.Status != http.StatusServiceUnavailable || ref.Msg != want { |
| + t.Fatalf("a range with heartbeats unreadable = %+v, want 503 %q", ref, want) |
| + } |
| +} |
| + |
| +// grantAdded works on prefixes: an entry already allowed is not added, and |
| +// a range and an address inside it are separate entries. |
| +func TestGrantAddedPrefixes(t *testing.T) { |
| + t.Parallel() |
| + got, err := grantAdded([]string{"10.0.64.0/20", "10.0.5.20"}, []string{"10.0.64.0/20", "10.0.64.5", "fd00:5::/64"}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if want := prefixes(t, "10.0.64.5", "fd00:5::/64"); !slices.Equal(got, want) { |
| + t.Fatalf("added = %v, want %v", got, want) |
| + } |
| +} |
| + |
| +// The report checks a range by containment: a box that later takes an |
| +// address inside an allowed range is found, alerted on, and named by GET |
| +// (which `apps show` marks with "!"). |
| +func TestEgressReportFlagsARangeHoldingABoxAddress(t *testing.T) { |
| + t.Parallel() |
| + fx := newReportFx(t, "code-egress-report-range") |
| + setBoxRelease(t, fx.cs, "annie", "v0.43.0", time.Now()) |
| + putEdgesAddrs(t, fx.cs, "annie", []string{"10.0.1.5"}) |
| + fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20","10.0.5.21"]}`, policyCreate) |
| + if !fx.tick(t) { |
| + t.Fatal("the first tick with a live allow ran no pass") |
| + } |
| + if got := fx.srv.egressConflicts(); len(got) != 0 { |
| + t.Fatalf("conflicts before a box takes an address = %v", got) |
| + } |
| + putEdgesAddrs(t, fx.cs, "betty", []string{"10.0.64.9"}) |
| + if n := fx.ticks(t, reportBackstopTo); n != 1 { |
| + t.Fatalf("the backstop ran %d passes, want 1", n) |
| + } |
| + if got := fx.srv.egressConflicts(); !maps.Equal(got, map[string]string{"10.0.64.0/20": "betty"}) { |
| + t.Fatalf("conflicts = %v, want 10.0.64.0/20 on betty", got) |
| + } |
| + want := "Egress allow 10.0.64.0/20 now holds a fleet box's address.\n" + |
| + "App shop in account id " + fx.sqid + " may reach 10.0.64.0/20, and box betty now holds an address in that range. " + |
| + "The allow is still in force. Set the whole list again without that range by running carlos apps set shop --egress-allow, or move the address off the box." |
| + if got := fx.sent(); len(got) != 1 || got[0] != want { |
| + t.Fatalf("pages = %q, want one: %q", got, want) |
| + } |
| + if g := fx.get(t, "shop"); !slices.Equal(g.EgressConflicts, []string{"10.0.64.0/20"}) { |
| + t.Fatalf("GET egress_conflicts = %v, want [10.0.64.0/20]", g.EgressConflicts) |
| + } |
| +} |
| + |
| +// carlos status --layout marks a range the report found, in the form the box |
| +// reports it (the entry's stored form). |
| +func TestEgressViewMarksARange(t *testing.T) { |
| + t.Parallel() |
| + e := egressView(status.HostEgress{Allowed: []string{"10.0.5.20", "10.0.64.0/20"}}, true, map[string]string{"10.0.64.0/20": "betty"}) |
| + if !slices.Equal(e.Conflicts, []string{"10.0.64.0/20"}) { |
| + t.Fatalf("conflicts = %v, want [10.0.64.0/20]", e.Conflicts) |
| + } |
| +} |
| + |
| +// The floor reads every fleet's heartbeats as well as the platform's: an |
| +// old box under fleets/<name>/ refuses a range, a detached one does not |
| +// count, and a fleet heartbeat that cannot be read refuses with 503. |
| +func TestEgressGrantRangeFloorCountsFleetBoxes(t *testing.T) { |
| + t.Parallel() |
| + fx := newConsoleFixture(t) |
| + now := time.Now() |
| + putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"}) |
| + setBoxRelease(t, fx.rel, "annie", "v0.43.0", now) |
| + reg := openTestReg(t, fx) |
| + t.Cleanup(func() { reg.Close() }) |
| + if _, err := reg.CreateFleet(registry.Fleet{Name: "fx", Account: fx.sqid, Bucket: "fx-data"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, label := range []string{"bx-1", "bx-2"} { |
| + if err := reg.AddFleetBox(registry.FleetBox{Fleet: "fx", Label: label, TokenHash: strings.Repeat("a", 64)}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + fleet := release.NewPrefixStore(fx.rel, "fleets/fx/") |
| + setBoxRelease(t, fleet, "bx-1", "v0.43.0", now) |
| + setBoxRelease(t, fleet, "bx-2", "v0.42.1", now) |
| + ctx := context.Background() |
| + |
| + _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20")) |
| + if want := "box bx-2 reports v0.42.1. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected"; ref == nil || |
| + ref.Status != http.StatusConflict || ref.Msg != want { |
| + t.Fatalf("a range with fleet box bx-2 on v0.42.1 = %+v, want 409 %q", ref, want) |
| + } |
| + |
| + if err := reg.SetFleetBoxStatus("fx", "bx-2", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20")); ref != nil { |
| + t.Fatalf("a range with old bx-2 detached = %+v, want no refusal", ref) |
| + } |
| + |
| + putFixtureObject(t, fleet, "status/boxes/bx-3.json", []byte(`{"label":"bx-3",`)) |
| + _, ref = fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20")) |
| + if want := "the fleet's list of boxes could not be read. try again in a minute"; ref == nil || |
| + ref.Status != http.StatusServiceUnavailable || ref.Msg != want { |
| + t.Fatalf("a range with a fleet heartbeat unreadable = %+v, want 503 %q", ref, want) |
| + } |
| + if _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.5")); ref != nil { |
| + t.Fatalf("a single address with a fleet heartbeat unreadable = %+v, want no refusal", ref) |
| + } |
| +} |
diff --git a/internal/egressaddr/egressaddr.go b/internal/egressaddr/egressaddr.go| index bc938751c..384c6cf5c 100644 |
| --- a/internal/egressaddr/egressaddr.go |
| +++ b/internal/egressaddr/egressaddr.go |
| @@ -3,11 +3,18 @@ |
| // rule set the console door applies when an operator grants an address and |
| // root applies again on the box before it writes the allow. |
| // |
| -// An allow re-opens one address the instance fence closes. So an allow must |
| -// be a single address, inside the fence (a public address is already |
| -// reachable), and never one of the classes no tenant may reach from any |
| -// box: loopback, unspecified, link-local, the metadata service, multicast, |
| -// the reserved ranges and the NAT64 prefix. |
| +// An allow re-opens an address, or a range of addresses, the instance fence |
| +// closes. An entry is a single address or a prefix (#1357). It must lie |
| +// wholly inside the fence (a public address is already reachable) and hold |
| +// none of the classes no tenant may reach from any box: loopback, |
| +// unspecified, link-local, the metadata service, multicast, the reserved |
| +// ranges and the NAT64 prefix. A prefix is allowed exactly when every |
| +// address in it would be allowed alone, checked on the prefix, not by |
| +// enumeration, and it is no wider than MinPrefixV4 or MinPrefixV6. |
| +// |
| +// A single address is stored as the bare address, so a list of singles |
| +// reads the same as before prefixes. Parse stays the single-address |
| +// reader for callers that need one address and refuses a prefix. |
| // |
| // FenceDeny is the fence itself, the IPAddressDeny= line the instance unit |
| // templates write. internal/host's TestInstanceFenceIsEgressaddrFenceDeny |
| @@ -28,9 +35,17 @@ import ( |
| "strings" |
| ) |
| -// MaxAllow is the most addresses one app may be granted. |
| +// MaxAllow is the most entries one app may be granted. A prefix counts as |
| +// one entry. |
| const MaxAllow = 8 |
| +// The widest prefix an entry may be: /16 is the largest AWS VPC, /48 a ULA |
| +// site prefix (RFC 4193). |
| +const ( |
| + MinPrefixV4 = 16 |
| + MinPrefixV6 = 48 |
| +) |
| + |
| // Refusal text. A person reads these at the door and in root's report. |
| const ( |
| msgEmpty = "an address is empty" |
| @@ -38,15 +53,18 @@ const ( |
| msgPort = "%q has a port. an allow opens an address, never a port" |
| msgZone = "%q has a zone. name the address without it" |
| msgNotAddr = "%q is not an IP address" |
| - msgLoopback = "%s is a loopback address" |
| + msgLoopback = "%s is loopback" |
| msgUnspecified = "%s is the unspecified address" |
| - msgMetadata = "%s is the cloud metadata service" |
| + msgMetadata = "%s would reach the cloud metadata service" |
| msgLinkLocal = "%s is link-local" |
| - msgMulticast = "%s is a multicast address" |
| - msgReserved = "%s is in %s, a reserved range" |
| + msgMulticast = "%s is multicast" |
| + msgReserved = "%s is in or overlaps %s, a reserved range" |
| msgNAT64 = "%s is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address" |
| msgPublic = "%s is a public address and is already reachable. no allow is needed" |
| - msgTooMany = "at most %d addresses per app (%d given)" |
| + msgTooMany = "at most %d entries per app (%d given)" |
| + msgHostBits = "%q has host bits set. write it as %s" |
| + msgWide = "%s is wider than /%d. allow at most a /%d" |
| + msgNotPrivate = "%s is not wholly inside a private range" |
| ) |
| // FenceDeny is the instance fence: the IPAddressDeny= line of the instance |
| @@ -61,6 +79,12 @@ var FenceDeny = mustPrefixes( |
| ) |
| var ( |
| + // The classes a prefix may not overlap, as Allowed's net/netip tests |
| + // read them. |
| + loopback = mustPrefixes("127.0.0.0/8", "::1/128") |
| + linkLocal = mustPrefixes("169.254.0.0/16", "fe80::/10") |
| + multicast = mustPrefixes("224.0.0.0/4", "ff00::/8") |
| + |
| // The cloud metadata service's two addresses (as ResolverAllowed). |
| metadataV4 = netip.MustParseAddr("169.254.169.254") |
| metadataV6 = netip.MustParseAddr("fd00:ec2::254") |
| @@ -139,40 +163,158 @@ func Allowed(a netip.Addr) error { |
| return fmt.Errorf(msgPublic, a) |
| } |
| +// ParseEntry reads one entry as an operator writes it: surrounding space |
| +// trimmed, a single address (as Parse reads it) or a prefix a/n with no |
| +// host bits set, port or zone. A single address becomes its full-length |
| +// prefix. An IPv4-mapped IPv6 prefix is refused. |
| +func ParseEntry(s string) (netip.Prefix, error) { |
| + s = strings.TrimSpace(s) |
| + slash := strings.LastIndex(s, "/") |
| + if slash < 0 { |
| + a, err := Parse(s) |
| + if err != nil { |
| + return netip.Prefix{}, err |
| + } |
| + return netip.PrefixFrom(a, a.BitLen()), nil |
| + } |
| + if strings.Contains(s[slash:], ":") { |
| + return netip.Prefix{}, fmt.Errorf(msgPort, s) |
| + } |
| + if strings.Contains(s, "%") { |
| + return netip.Prefix{}, fmt.Errorf(msgZone, s) |
| + } |
| + p, err := netip.ParsePrefix(s) |
| + if err != nil || p.Addr().Is4In6() { |
| + return netip.Prefix{}, fmt.Errorf(msgNotAddr, s) |
| + } |
| + if m := p.Masked(); m != p { |
| + return netip.Prefix{}, fmt.Errorf(msgHostBits, s, m) |
| + } |
| + return p, nil |
| +} |
| + |
| +// AllowedPrefix reports why p may not be granted, or nil if it may. A |
| +// full-length prefix is the single address and gets Allowed's answer. A |
| +// wider one must be no wider than the minimum length, lie wholly inside |
| +// one FenceDeny range, and overlap none of the refused classes, so every |
| +// address in it would pass Allowed. |
| +func AllowedPrefix(p netip.Prefix) error { |
| + if !p.IsValid() || (p.Addr().Is4In6() && !p.IsSingleIP()) { |
| + return fmt.Errorf(msgNotAddr, p.String()) |
| + } |
| + if p.IsSingleIP() { |
| + return Allowed(p.Addr()) |
| + } |
| + if m := p.Masked(); m != p { |
| + return fmt.Errorf(msgHostBits, p.String(), m) |
| + } |
| + minBits := MinPrefixV6 |
| + if p.Addr().Is4() { |
| + minBits = MinPrefixV4 |
| + } |
| + if p.Bits() < minBits { |
| + return fmt.Errorf(msgWide, p, minBits, minBits) |
| + } |
| + inside := false |
| + for _, f := range FenceDeny { |
| + if f.Bits() <= p.Bits() && f.Contains(p.Addr()) { |
| + inside = true |
| + break |
| + } |
| + } |
| + if !inside { |
| + return fmt.Errorf(msgNotPrivate, p) |
| + } |
| + // Link-local before metadata: a link-local prefix holding the |
| + // metadata address reads better as link-local. |
| + switch { |
| + case overlapsAny(p, loopback): |
| + return fmt.Errorf(msgLoopback, p) |
| + case overlapsAny(p, linkLocal): |
| + return fmt.Errorf(msgLinkLocal, p) |
| + case p.Contains(metadataV4), p.Contains(metadataV6): |
| + return fmt.Errorf(msgMetadata, p) |
| + case overlapsAny(p, multicast): |
| + return fmt.Errorf(msgMulticast, p) |
| + } |
| + for _, r := range reserved { |
| + if r.Overlaps(p) { |
| + return fmt.Errorf(msgReserved, p, r) |
| + } |
| + } |
| + if nat64.Overlaps(p) { |
| + return fmt.Errorf(msgNAT64, p) |
| + } |
| + // Unspecified is inside 0.0.0.0/8 (reserved) for IPv4 and outside |
| + // the fence for IPv6, so it is refused above; kept for the rule set. |
| + if p.Contains(netip.IPv4Unspecified()) || p.Contains(netip.IPv6Unspecified()) { |
| + return fmt.Errorf(msgUnspecified, p) |
| + } |
| + return nil |
| +} |
| + |
| +func overlapsAny(p netip.Prefix, ps []netip.Prefix) bool { |
| + for _, q := range ps { |
| + if q.Overlaps(p) { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| // Normalize turns an operator's list into the stored form: every |
| -// non-empty entry parsed and allowed, duplicates collapsed, sorted (IPv4 |
| -// before IPv6), at most MaxAllow after the collapse, each in its |
| -// canonical text. An empty result is nil. The first refused entry is the |
| -// error. |
| +// non-empty entry parsed and allowed, exact duplicates collapsed (an entry |
| +// inside another is kept), sorted by address then prefix length (IPv4 |
| +// before IPv6), at most MaxAllow after the collapse. A full-length prefix |
| +// is stored as the bare address, any other as its canonical prefix text. |
| +// An empty result is nil. The first refused entry is the error. |
| func Normalize(in []string) ([]string, error) { |
| - seen := map[netip.Addr]bool{} |
| - var addrs []netip.Addr |
| + seen := map[netip.Prefix]bool{} |
| + var entries []netip.Prefix |
| for _, s := range in { |
| if strings.TrimSpace(s) == "" { |
| continue |
| } |
| - a, err := Parse(s) |
| + p, err := ParseEntry(s) |
| if err != nil { |
| return nil, err |
| } |
| - if err := Allowed(a); err != nil { |
| + if err := AllowedPrefix(p); err != nil { |
| return nil, err |
| } |
| - if !seen[a] { |
| - seen[a] = true |
| - addrs = append(addrs, a) |
| + if !seen[p] { |
| + seen[p] = true |
| + entries = append(entries, p) |
| } |
| } |
| - if len(addrs) > MaxAllow { |
| - return nil, fmt.Errorf(msgTooMany, MaxAllow, len(addrs)) |
| + if len(entries) > MaxAllow { |
| + return nil, fmt.Errorf(msgTooMany, MaxAllow, len(entries)) |
| } |
| - if len(addrs) == 0 { |
| + if len(entries) == 0 { |
| return nil, nil |
| } |
| - slices.SortFunc(addrs, netip.Addr.Compare) |
| - out := make([]string, len(addrs)) |
| - for i, a := range addrs { |
| - out[i] = a.String() |
| + slices.SortFunc(entries, ComparePrefix) |
| + out := make([]string, len(entries)) |
| + for i, p := range entries { |
| + out[i] = EntryString(p) |
| } |
| return out, nil |
| } |
| + |
| +// ComparePrefix is the stored order: by address (IPv4 before IPv6), then |
| +// by prefix length, so 10.0.64.0/20 comes before 10.0.64.0. |
| +func ComparePrefix(a, b netip.Prefix) int { |
| + if c := a.Addr().Compare(b.Addr()); c != 0 { |
| + return c |
| + } |
| + return a.Bits() - b.Bits() |
| +} |
| + |
| +// EntryString is p's stored form: a full-length prefix as the bare |
| +// address, any other as its canonical prefix text. |
| +func EntryString(p netip.Prefix) string { |
| + if p.IsSingleIP() { |
| + return p.Addr().String() |
| + } |
| + return p.String() |
| +} |
diff --git a/internal/egressaddr/egressaddr_test.go b/internal/egressaddr/egressaddr_test.go| index b3ec2f03e..d2d07c133 100644 |
| --- a/internal/egressaddr/egressaddr_test.go |
| +++ b/internal/egressaddr/egressaddr_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "fmt" |
| "net/netip" |
| "reflect" |
| + "slices" |
| "strings" |
| "testing" |
| ) |
| @@ -116,7 +117,7 @@ func TestNormalize(t *testing.T) { |
| for i := 1; i <= 9; i++ { |
| nine = append(nine, fmt.Sprintf("10.0.5.%d", i)) |
| } |
| - if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 addresses per app (9 given)") { |
| + if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 entries per app (9 given)") { |
| t.Errorf("Normalize(nine) error %v, want the cap", err) |
| } |
| // The cap counts after the dedupe: eight addresses given twice each fit. |
| @@ -127,3 +128,185 @@ func TestNormalize(t *testing.T) { |
| t.Errorf("Normalize with a public address error %v, want it refused", err) |
| } |
| } |
| + |
| +// acceptedEntries are entries an operator may grant, each with its |
| +// stored form. |
| +var acceptedEntries = map[string]string{ |
| + "10.0.64.0/20": "10.0.64.0/20", |
| + "10.0.0.0/16": "10.0.0.0/16", |
| + "172.16.0.0/16": "172.16.0.0/16", |
| + "192.168.0.0/16": "192.168.0.0/16", |
| + "100.64.0.0/16": "100.64.0.0/16", |
| + "fd00:5::/64": "fd00:5::/64", |
| + "fd00:5::/48": "fd00:5::/48", |
| + "10.0.5.20/32": "10.0.5.20", |
| + "fd00:5::20/128": "fd00:5::20", |
| + "10.0.5.20": "10.0.5.20", |
| + " fd00:5::20 ": "fd00:5::20", |
| +} |
| + |
| +func TestEntriesAccepted(t *testing.T) { |
| + for in, want := range acceptedEntries { |
| + got, err := Normalize([]string{in}) |
| + if err != nil { |
| + t.Errorf("Normalize(%q): %v", in, err) |
| + continue |
| + } |
| + if len(got) != 1 || got[0] != want { |
| + t.Errorf("Normalize(%q) = %q, want [%s]", in, got, want) |
| + } |
| + } |
| +} |
| + |
| +func TestEntriesRefused(t *testing.T) { |
| + for in, want := range map[string]string{ |
| + "10.0.0.0/8": "10.0.0.0/8 is wider than /16. allow at most a /16", |
| + "10.0.0.0/15": "10.0.0.0/15 is wider than /16. allow at most a /16", |
| + "fd00::/47": "fd00::/47 is wider than /48. allow at most a /48", |
| + "10.0.64.5/20": `"10.0.64.5/20" has host bits set. write it as 10.0.64.0/20`, |
| + "169.254.0.0/16": "169.254.0.0/16 is link-local", |
| + "169.254.169.0/24": "169.254.169.0/24 is link-local", |
| + "fd00:ec2::/48": "fd00:ec2::/48 would reach the cloud metadata service", |
| + "64:ff9b::/96": "64:ff9b::/96 is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address", |
| + "198.18.0.0/16": "198.18.0.0/16 is in or overlaps 198.18.0.0/15, a reserved range", |
| + "8.8.8.0/24": "8.8.8.0/24 is not wholly inside a private range", |
| + "0.0.0.0/16": "0.0.0.0/16 is in or overlaps 0.0.0.0/8, a reserved range", |
| + "224.0.0.0/16": "224.0.0.0/16 is multicast", |
| + "127.0.0.0/16": "127.0.0.0/16 is loopback", |
| + "fe80::/64": "fe80::/64 is link-local", |
| + "10.0.64.0/20:5432": `"10.0.64.0/20:5432" has a port. an allow opens an address, never a port`, |
| + "::ffff:10.0.0.0/112": `"::ffff:10.0.0.0/112" is not an IP address`, |
| + "10.0.0.0/16%eth0": "has a zone", |
| + "10.0.0.0/33": "is not an IP address", |
| + "10.0.0.0/": "is not an IP address", |
| + "fd00:5::/129": "is not an IP address", |
| + "172.16.0.0/12": "172.16.0.0/12 is wider than /16", |
| + "fec0::/48": "fec0::/48 is in or overlaps fec0::/10, a reserved range", |
| + "2001:db8::/48": "2001:db8::/48 is not wholly inside a private range", |
| + "8.8.8.8/32": "8.8.8.8 is a public address", |
| + "169.254.169.254/32": "169.254.169.254 would reach the cloud metadata service", |
| + } { |
| + got, err := Normalize([]string{in}) |
| + if err == nil { |
| + t.Errorf("Normalize(%q) = %q, want an error containing %q", in, got, want) |
| + continue |
| + } |
| + if !strings.Contains(err.Error(), want) { |
| + t.Errorf("Normalize(%q) error %q, want it to contain %q", in, err, want) |
| + } |
| + } |
| +} |
| + |
| +func TestParseEntryUnmapsAndKeepsParseStrict(t *testing.T) { |
| + p, err := ParseEntry("::ffff:10.0.5.20") |
| + if err != nil || p != netip.MustParsePrefix("10.0.5.20/32") { |
| + t.Errorf("ParseEntry(::ffff:10.0.5.20) = %s, %v; want 10.0.5.20/32", p, err) |
| + } |
| + if _, err := ParseEntry(""); err == nil || err.Error() != "an address is empty" { |
| + t.Errorf("ParseEntry(\"\") error %v, want empty", err) |
| + } |
| + // Parse stays the single-address reader: an old box refuses a range. |
| + if _, err := Parse("10.0.64.0/20"); err == nil || !strings.Contains(err.Error(), "is a range") { |
| + t.Errorf("Parse(10.0.64.0/20) error %v, want the range refusal", err) |
| + } |
| +} |
| + |
| +func TestNormalizeSortsAndDedupsEntries(t *testing.T) { |
| + got, err := Normalize([]string{"fd00:5::/64", "10.0.64.0", "10.0.64.0/20", "10.0.64.0/20", "10.0.64.0/32"}) |
| + if err != nil { |
| + t.Fatalf("Normalize: %v", err) |
| + } |
| + if want := []string{"10.0.64.0/20", "10.0.64.0", "fd00:5::/64"}; !reflect.DeepEqual(got, want) { |
| + t.Errorf("Normalize = %q, want %q", got, want) |
| + } |
| + got, err = Normalize([]string{"10.0.64.0", "10.0.64.0/20", "10.0.64.0/20"}) |
| + if err != nil { |
| + t.Fatalf("Normalize: %v", err) |
| + } |
| + if want := []string{"10.0.64.0/20", "10.0.64.0"}; !reflect.DeepEqual(got, want) { |
| + t.Errorf("Normalize = %q, want %q", got, want) |
| + } |
| +} |
| + |
| +func TestNormalizeCountsPrefixesAsEntries(t *testing.T) { |
| + var nine []string |
| + for i := 1; i <= 9; i++ { |
| + nine = append(nine, fmt.Sprintf("10.%d.0.0/16", i)) |
| + } |
| + if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 entries per app (9 given)") { |
| + t.Errorf("Normalize(nine prefixes) error %v, want the cap", err) |
| + } |
| + if got, err := Normalize(nine[:8]); err != nil || len(got) != MaxAllow { |
| + t.Errorf("Normalize(eight prefixes) = %q, %v; want eight and no error", got, err) |
| + } |
| +} |
| + |
| +// lastAddr is the highest address in p. |
| +func lastAddr(p netip.Prefix) netip.Addr { |
| + b := p.Masked().Addr().AsSlice() |
| + for i := p.Bits(); i < len(b)*8; i++ { |
| + b[i/8] |= 0x80 >> (i % 8) |
| + } |
| + a, _ := netip.AddrFromSlice(b) |
| + return a |
| +} |
| + |
| +// AllowedPrefix agrees with Allowed at the edges: an accepted prefix's |
| +// first and last addresses would each be accepted alone. |
| +func TestAcceptedPrefixEdgesPassAllowed(t *testing.T) { |
| + for in := range acceptedEntries { |
| + p, err := ParseEntry(in) |
| + if err != nil { |
| + t.Fatalf("ParseEntry(%q): %v", in, err) |
| + } |
| + if err := AllowedPrefix(p); err != nil { |
| + t.Fatalf("AllowedPrefix(%s): %v", p, err) |
| + } |
| + for _, a := range []netip.Addr{p.Addr(), lastAddr(p)} { |
| + if err := Allowed(a); err != nil { |
| + t.Errorf("%s is accepted but its edge %s is not: %v", p, a, err) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// Parse is the single-address reader an old box's code shape still uses: |
| +// it refuses every prefix form, a full-length one included, so an old |
| +// box's Validate fails on a prefix and never reads it as an address. |
| +func TestParseRefusesEveryPrefixForm(t *testing.T) { |
| + for _, in := range []string{ |
| + "10.0.64.0/20", "10.0.5.20/32", "10.0.64.5/20", " 10.0.64.0/20 ", "10.0.0.0/8", |
| + "fd00:5::/64", "fd00:5::20/128", "::ffff:10.0.5.20/128", "10.0.64.0/", "/20", |
| + } { |
| + if a, err := Parse(in); err == nil { |
| + t.Errorf("Parse(%q) = %s, want a refusal", in, a) |
| + } |
| + } |
| +} |
| + |
| +// ComparePrefix is decision 6's order, and EntryString the stored form: |
| +// the one definition Normalize, apppolicy.Validate and root share. |
| +func TestComparePrefixAndEntryString(t *testing.T) { |
| + in := []string{"fd00:5::/64", "10.0.64.0", "fd00:5::", "10.0.64.0/20", "10.0.5.20", "10.0.64.0/24"} |
| + var ps []netip.Prefix |
| + for _, s := range in { |
| + p, err := ParseEntry(s) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + ps = append(ps, p) |
| + } |
| + slices.SortFunc(ps, ComparePrefix) |
| + var got []string |
| + for _, p := range ps { |
| + got = append(got, EntryString(p)) |
| + } |
| + want := []string{"10.0.5.20", "10.0.64.0/20", "10.0.64.0/24", "10.0.64.0", "fd00:5::/64", "fd00:5::"} |
| + if !reflect.DeepEqual(got, want) { |
| + t.Errorf("sorted = %q, want %q", got, want) |
| + } |
| + norm, err := Normalize(in) |
| + if err != nil || !reflect.DeepEqual(norm, want) { |
| + t.Errorf("Normalize = %q, %v; want %q", norm, err, want) |
| + } |
| +} |
diff --git a/internal/host/egress_fixtures_rootrunner_linux_test.go b/internal/host/egress_fixtures_rootrunner_linux_test.go| index 6cfa25609..cd85608d2 100644 |
| --- a/internal/host/egress_fixtures_rootrunner_linux_test.go |
| +++ b/internal/host/egress_fixtures_rootrunner_linux_test.go |
| @@ -197,7 +197,7 @@ func egressTargetNetns(t *testing.T) map[string]string { |
| // the test's end, tears it down once, last-made first. |
| func egressTargetNetnsClosable(t *testing.T) (map[string]string, func()) { |
| t.Helper() |
| - return egressTargetNetnsAt(t, egressNetnsTask13) |
| + return egressTargetNetnsAt(t, egressNetnsTask13, egressNetnsTask13Addrs) |
| } |
| // egressNetnsNames names a target fixture's namespace and veth pair, so |
| @@ -210,9 +210,24 @@ type egressNetnsNames struct { |
| // egressNetnsTask13 is Task 13's fixture (carlos-egr, carlos-egr1/1n). |
| var egressNetnsTask13 = egressNetnsNames{ns: egressNetns, hostLink: egressHostLink, nsLink: egressNsLink} |
| +// egressNetnsAddrs lays out a target fixture's addresses: the box end's |
| +// IPv4 and IPv6 address (each a host address; box6 "" for none) and the |
| +// targets inside the namespace, each IPv4 or IPv6. |
| +type egressNetnsAddrs struct { |
| + box4, box6 string |
| + targets []string |
| +} |
| + |
| +// egressNetnsTask13Addrs is the layout Task 13's and Task 14's witnesses |
| +// use: 10.0.5.1 and fd00:5::1 on the box end, egressTargets inside. |
| +var egressNetnsTask13Addrs = egressNetnsAddrs{box4: "10.0.5.1", box6: "fd00:5::1", targets: egressTargets} |
| + |
| // egressTargetNetnsAt is egressTargetNetnsClosable with the fixture's |
| -// names given. |
| -func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, func()) { |
| +// names and addresses given: the box end holds lay.box4 (and lay.box6), with a |
| +// host route to each target through the veth from the box address of its |
| +// family; the namespace end holds the targets, with host routes back to |
| +// the box addresses. |
| +func egressTargetNetnsAt(t *testing.T, n egressNetnsNames, lay egressNetnsAddrs) (map[string]string, func()) { |
| t.Helper() |
| var steps []func() |
| var once sync.Once |
| @@ -268,24 +283,41 @@ func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, f |
| } |
| } |
| }) |
| - egressIP(t, "addr", "add", "10.0.5.1/32", "dev", n.hostLink) |
| - egressIP(t, "-6", "addr", "add", "fd00:5::1/128", "dev", n.hostLink, "nodad") |
| + for _, target := range lay.targets { |
| + if netip.MustParseAddr(target).Is6() && lay.box6 == "" { |
| + t.Fatalf("target %s is IPv6, but the fixture's box end has no IPv6 address", target) |
| + } |
| + } |
| + egressIP(t, "addr", "add", lay.box4+"/32", "dev", n.hostLink) |
| + if lay.box6 != "" { |
| + egressIP(t, "-6", "addr", "add", lay.box6+"/128", "dev", n.hostLink, "nodad") |
| + } |
| egressIP(t, "link", "set", n.hostLink, "up") |
| - egressIP(t, "route", "add", "10.0.5.20/32", "dev", n.hostLink, "src", "10.0.5.1") |
| - egressIP(t, "route", "add", "10.0.5.21/32", "dev", n.hostLink, "src", "10.0.5.1") |
| - egressIP(t, "-6", "route", "add", "fd00:5::20/128", "dev", n.hostLink, "src", "fd00:5::1") |
| + for _, target := range lay.targets { |
| + if netip.MustParseAddr(target).Is6() { |
| + egressIP(t, "-6", "route", "add", target+"/128", "dev", n.hostLink, "src", lay.box6) |
| + } else { |
| + egressIP(t, "route", "add", target+"/32", "dev", n.hostLink, "src", lay.box4) |
| + } |
| + } |
| in := func(args ...string) { t.Helper(); egressIP(t, append([]string{"-n", n.ns}, args...)...) } |
| in("link", "set", "lo", "up") |
| - in("addr", "add", "10.0.5.20/32", "dev", n.nsLink) |
| - in("addr", "add", "10.0.5.21/32", "dev", n.nsLink) |
| - in("-6", "addr", "add", "fd00:5::20/128", "dev", n.nsLink, "nodad") |
| + for _, target := range lay.targets { |
| + if netip.MustParseAddr(target).Is6() { |
| + in("-6", "addr", "add", target+"/128", "dev", n.nsLink, "nodad") |
| + } else { |
| + in("addr", "add", target+"/32", "dev", n.nsLink) |
| + } |
| + } |
| in("link", "set", n.nsLink, "up") |
| - in("route", "add", "10.0.5.1/32", "dev", n.nsLink) |
| - in("-6", "route", "add", "fd00:5::1/128", "dev", n.nsLink) |
| + in("route", "add", lay.box4+"/32", "dev", n.nsLink) |
| + if lay.box6 != "" { |
| + in("-6", "route", "add", lay.box6+"/128", "dev", n.nsLink) |
| + } |
| addrs := map[string]string{} |
| - for _, a := range egressTargets { |
| + for _, a := range lay.targets { |
| ln, err := egressListenIn(nsPath, net.JoinHostPort(a, "0")) |
| if err != nil { |
| t.Fatalf("listen on %s in %s: %v", a, n.ns, err) |
| @@ -321,7 +353,7 @@ func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, f |
| if err != nil { |
| t.Fatal("LocalAddresses:", err) |
| } |
| - for _, a := range egressTargets { |
| + for _, a := range lay.targets { |
| addr := netip.MustParseAddr(a) |
| for _, p := range local { |
| if p.Contains(addr) { |
| @@ -807,7 +839,7 @@ func newEgressPreClaimBoxWith(t *testing.T, o egressBoxOptions) *egressBox { |
| if o.netns == (egressNetnsNames{}) { |
| b.targets = egressTargetNetns(t) |
| } else { |
| - b.targets, _ = egressTargetNetnsAt(t, o.netns) |
| + b.targets, _ = egressTargetNetnsAt(t, o.netns, egressNetnsTask13Addrs) |
| } |
| // The build: the test binary, as the platform binary the templates |
diff --git a/internal/host/egress_prefix_rootrunner_linux_test.go b/internal/host/egress_prefix_rootrunner_linux_test.go| new file mode 100644 |
| index 000000000..9d7aad764 |
| --- /dev/null |
| +++ b/internal/host/egress_prefix_rootrunner_linux_test.go |
| @@ -0,0 +1,231 @@ |
| +//go:build linux && rootrunner |
| + |
| +package host |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "io/fs" |
| + "net/netip" |
| + "os" |
| + "path/filepath" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/instancectl" |
| +) |
| + |
| +// The prefix witness's names and addresses (#1357 Task 4). The namespace |
| +// and veth pair are its own: carlos-egr0 (kernel proof), carlos-egr1/1n |
| +// (Task 13) and carlos-egr2/2n (Task 14) belong to other witnesses. |
| +const ( |
| + egressPrefixNetns = "carlos-egr3" |
| + egressPrefixHostEnd = "carlos-egr3" |
| + egressPrefixNsEnd = "carlos-egr3n" |
| + |
| + egressPrefixAllow = "10.250.64.0/20" |
| + egressPrefixInside = "10.250.64.10" // inside the allow |
| + egressPrefixOutside = "10.250.80.10" // outside it, in the same /16 |
| + // egressPrefixBoxAddr is the box's end of the veth pair: outside the |
| + // allow, so the asserter's own-address check passes the prefix. |
| + egressPrefixBoxAddr = "10.250.96.1" |
| + |
| + egressPrefixHost = "egress-prefix.example.com" |
| + egressPrefixUnit = "carlos-egress-prefix-a" |
| +) |
| + |
| +// TestRootEgressPrefixKernelProof is the kernel witness for egress allow |
| +// prefixes (#1357): a host slice's IPAddressAllow=10.250.64.0/20, written |
| +// by the production asserter (newEgressAsserter: the real systemctl, the |
| +// box's own addresses from procfs, cgroupfs for the slice's running |
| +// units), lets a tenant in a child unit carrying the template's |
| +// IPAddressDeny= reach an address inside the prefix, refuses it one |
| +// outside the prefix in the same /16, and once the policy is revoked and |
| +// the asserter runs again, refuses the inside address too. |
| +// |
| +// The asserter's source is an in-memory policy for one host, so no |
| +// registry or control service is involved; everything from the source on |
| +// is production code. Its DueDir is in the test's scratch directory, not |
| +// the box's control directory. |
| +// |
| +// Network: the test reaches nothing beyond its own target fixture, a |
| +// network namespace carlos-egr3 behind a veth pair (carlos-egr3 on the |
| +// box with 10.250.96.1, carlos-egr3n inside with the two targets). The |
| +// targets are not addresses of the box, so the asserter's check against |
| +// LocalAddresses stays on. The tenant is this binary (plan14-tenant) |
| +// behind a Unix socket in a scratch directory. |
| +// |
| +// It logs one "verdict:" line per question (inside reachable, outside |
| +// refused, revoke closes inside), fails on any wrong answer, fails, never |
| +// skips, without root, systemd as PID 1 or cgroup v2, and removes every |
| +// unit, drop-in, slice state, link, namespace, listener and file it made. |
| +func TestRootEgressPrefixKernelProof(t *testing.T) { |
| + verdicts := map[string]string{} |
| + order := []string{"inside reachable", "outside refused", "revoke closes inside"} |
| + t.Cleanup(func() { |
| + for _, k := range order { |
| + v := verdicts[k] |
| + if v == "" { |
| + v = "not reached" |
| + } |
| + t.Logf("verdict: %s: %s", k, v) |
| + } |
| + }) |
| + verdict := func(k string, ok bool) { |
| + if ok { |
| + verdicts[k] = "yes" |
| + } else { |
| + verdicts[k] = "no" |
| + } |
| + } |
| + |
| + egressRootPrereqs(t) |
| + ctx := context.Background() |
| + host := egressPrefixHost |
| + slice := instancectl.SliceName(host) |
| + unitName := egressPrefixUnit + ".service" |
| + |
| + // Refuse anything this test would otherwise overwrite or remove. The |
| + // nudge leaves a runtime drop-in for the unit, removed on cleanup. |
| + unitControl := filepath.Join("/run/systemd/system.control", unitName+".d") |
| + if _, err := os.Lstat(unitControl); !errors.Is(err, fs.ErrNotExist) { |
| + t.Fatal("unit already has set-property drop-ins", unitControl, err) |
| + } |
| + |
| + scratch, err := os.MkdirTemp("", "egrp") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { |
| + if err := os.RemoveAll(scratch); err != nil { |
| + t.Error(err) |
| + } |
| + }) |
| + |
| + targets := egressPrefixTargets(t) |
| + inside, outside := targets[egressPrefixInside], targets[egressPrefixOutside] |
| + |
| + egressSliceProperties(t, slice) |
| + |
| + // The production asserter over an in-memory policy for the host. |
| + var mu sync.Mutex |
| + allow := []string{egressPrefixAllow} |
| + src := func(_ context.Context, h string) (instancectl.EgressPolicy, error) { |
| + mu.Lock() |
| + defer mu.Unlock() |
| + if h != host { |
| + return instancectl.EgressPolicy{}, nil |
| + } |
| + return instancectl.EgressPolicy{Allow: append([]string(nil), allow...), Account: "abc", App: "shop"}, nil |
| + } |
| + e := newEgressAsserter(src, func() ([]string, error) { return []string{host}, nil }) |
| + e.Logf = t.Logf |
| + e.DueDir = filepath.Join(scratch, "egress-due") |
| + |
| + // Grant before the child starts (the start-path order). |
| + if err := e.Assert(ctx, host); err != nil { |
| + t.Fatal("grant: Assert:", err) |
| + } |
| + raw := egressShow(t, slice, "IPAddressAllow") |
| + t.Logf("slice IPAddressAllow after the grant: %q", raw) |
| + held, err := egressProofPrefixes(raw) |
| + if err != nil { |
| + t.Fatal("grant:", err) |
| + } |
| + if len(held) != 1 || held[0] != netip.MustParsePrefix(egressPrefixAllow) { |
| + t.Fatalf("grant: slice IPAddressAllow is %v, want exactly [%s]", held, egressPrefixAllow) |
| + } |
| + rep := e.Reports()[host] |
| + t.Logf("report after the grant: %+v", rep) |
| + if rep.State != "" || len(rep.Refused) != 0 { |
| + t.Fatalf("grant: report %+v, want no state and nothing refused", rep) |
| + } |
| + |
| + // The tenant. The cleanup of the nudge's drop-in is registered first, |
| + // so it runs after the unit's own cleanup has stopped and removed it. |
| + t.Cleanup(func() { |
| + if err := os.RemoveAll(unitControl); err != nil { |
| + t.Error(err) |
| + } |
| + if out, err := egressCtl("daemon-reload"); err != nil { |
| + t.Errorf("daemon-reload: %v: %s", err, out) |
| + } |
| + }) |
| + deny := egressTemplateDeny(t) |
| + socket := filepath.Join(scratch, "a.sock") |
| + c := egressUnitTenant(t, egressPrefixUnit, slice, deny, socket) |
| + t.Logf("unit's IPAddressAllow: %q, IPAddressDeny: %q", egressShow(t, unitName, "IPAddressAllow"), egressShow(t, unitName, "IPAddressDeny")) |
| + |
| + // Question 1: an address inside the prefix is reachable. |
| + in := egressWithin(t, time.Now().Add(egressLiveBound), c, true, inside) |
| + verdict("inside reachable", in) |
| + if !in { |
| + egressFirewallDiag(t, unitName, slice, c, inside) |
| + t.Errorf("inside: %s (in %s) not reachable under the slice's allow", egressPrefixInside, egressPrefixAllow) |
| + } |
| + |
| + // Question 2: an address outside it, in the same /16, is refused. |
| + out := !egressReach(t, c, outside) |
| + verdict("outside refused", out) |
| + if !out { |
| + egressFirewallDiag(t, unitName, slice, c, outside) |
| + t.Errorf("outside: %s (outside %s) reachable", egressPrefixOutside, egressPrefixAllow) |
| + } |
| + |
| + // Question 3: revoke the policy; the asserter's next run closes the |
| + // inside address for the running tenant (live, or by restarting it). |
| + mu.Lock() |
| + allow = nil |
| + mu.Unlock() |
| + if err := e.Assert(ctx, host); err != nil { |
| + t.Fatal("revoke: Assert:", err) |
| + } |
| + if got := egressShow(t, slice, "IPAddressAllow"); got != "" { |
| + t.Fatalf("revoke: slice IPAddressAllow is %q, want empty", got) |
| + } |
| + rep = e.Reports()[host] |
| + t.Logf("report after the revoke: %+v", rep) |
| + restarted := rep.Detail == "revoked (restarted)" |
| + deadline := time.Now().Add(egressLiveBound) |
| + if restarted { |
| + deadline = time.Now().Add(egressRestartBound) |
| + egressServingBy(t, unitName, c, deadline) |
| + } |
| + closed := egressWithin(t, deadline, c, false, inside) |
| + verdict("revoke closes inside", closed) |
| + t.Logf("revoke closed by restart: %v", restarted) |
| + if !closed { |
| + egressFirewallDiag(t, unitName, slice, c, inside) |
| + t.Errorf("revoke: %s still reachable after the policy was revoked (restarted %v)", egressPrefixInside, restarted) |
| + } |
| +} |
| + |
| +// egressPrefixTargets is the prefix witness's target fixture: the shared |
| +// egressTargetNetnsAt with its own names (carlos-egr3, carlos-egr3/3n) |
| +// and addresses (10.250.96.1 on the box end; 10.250.64.10 and |
| +// 10.250.80.10 inside). Before and after it, no address of the box may lie |
| +// in 10.250.64.0/20: the asserter would refuse a prefix holding one, and |
| +// the witness must not lean on one. |
| +func egressPrefixTargets(t *testing.T) map[string]string { |
| + t.Helper() |
| + prefix := netip.MustParsePrefix(egressPrefixAllow) |
| + noLocalInPrefix := func(when string) { |
| + t.Helper() |
| + local, err := instancectl.LocalAddresses() |
| + if err != nil { |
| + t.Fatal("LocalAddresses:", err) |
| + } |
| + for _, p := range local { |
| + if p.Overlaps(prefix) { |
| + t.Fatalf("%s: this box holds %s, inside %s", when, p, prefix) |
| + } |
| + } |
| + } |
| + noLocalInPrefix("before the fixture") |
| + addrs, _ := egressTargetNetnsAt(t, |
| + egressNetnsNames{ns: egressPrefixNetns, hostLink: egressPrefixHostEnd, nsLink: egressPrefixNsEnd}, |
| + egressNetnsAddrs{box4: egressPrefixBoxAddr, targets: []string{egressPrefixInside, egressPrefixOutside}}) |
| + noLocalInPrefix("with the fixture up") |
| + return addrs |
| +} |
diff --git a/internal/host/egress_source_test.go b/internal/host/egress_source_test.go| index 905bb1a93..fbe033924 100644 |
| --- a/internal/host/egress_source_test.go |
| +++ b/internal/host/egress_source_test.go |
| @@ -7,6 +7,7 @@ import ( |
| "encoding/json" |
| "errors" |
| "io/fs" |
| + "net/netip" |
| "os" |
| "path/filepath" |
| "reflect" |
| @@ -939,3 +940,60 @@ func TestRegistryEgressSourceRefusesFormerDemo(t *testing.T) { |
| } |
| } |
| } |
| + |
| +// TestRegistryPrefixColumnReachesTheSliceExactly is #1357's production |
| +// wiring: a registry egress column holding a prefix and a single goes |
| +// through root's real source (registryEgressSource) into root's asserter |
| +// (newEgressAsserter), which writes exactly those two prefixes, with only |
| +// systemctl, the box's addresses and the cgroup tree faked. |
| +func TestRegistryPrefixColumnReachesTheSliceExactly(t *testing.T) { |
| + t.Parallel() |
| + const host = "shop-a.example.com" |
| + reg, dd := egressRegistry(t) |
| + clock := &testClock{now: time.Date(2026, 11, 22, 9, 0, 0, 0, time.UTC)} |
| + upsertRows(t, reg, nestedRow(dd, host)) |
| + setAllow(t, reg, host, "10.0.64.0/20 10.0.5.20", unixText(clock.Now().Add(time.Hour))) |
| + |
| + var mu sync.Mutex |
| + var sets []string |
| + held := "" |
| + slice := instancectl.SliceName(host) |
| + e := newEgressAsserter(testEgressSource(t, dd, clock.Now), nil) |
| + e.Systemctl = func(_ context.Context, args ...string) (string, error) { |
| + mu.Lock() |
| + defer mu.Unlock() |
| + switch { |
| + case len(args) == 5 && args[0] == "show" && args[4] == slice: |
| + return held + "\n", nil |
| + case len(args) == 5 && args[0] == "show": |
| + return "\n", nil // the parent holds nothing |
| + case len(args) >= 4 && args[0] == "set-property" && args[2] == slice: |
| + sets = append(sets, strings.Join(args, " ")) |
| + held = strings.TrimPrefix(args[len(args)-1], "IPAddressAllow=") |
| + return "", nil |
| + } |
| + return "", errors.New("unexpected call: " + strings.Join(args, " ")) |
| + } |
| + e.LocalAddrs = func() ([]netip.Prefix, error) { return []netip.Prefix{netip.MustParsePrefix("127.0.0.0/8")}, nil } |
| + e.CgroupRoot = t.TempDir() |
| + e.Logf = func(string, ...any) {} |
| + e.DueDir = "" |
| + |
| + if err := e.Assert(context.Background(), host); err != nil { |
| + t.Fatal(err) |
| + } |
| + want := []string{"set-property --runtime " + slice + " IPAddressAllow= IPAddressAllow=10.0.5.20/32 10.0.64.0/20"} |
| + if !slices.Equal(sets, want) { |
| + t.Fatalf("writes = %q, want %q", sets, want) |
| + } |
| + if rep := e.Reports()[host]; rep.State != "" || !slices.Equal(rep.Allowed, []string{"10.0.5.20", "10.0.64.0/20"}) { |
| + t.Fatalf("report = %+v, want both in force", rep) |
| + } |
| + // Asserted again: in force as read back, nothing written. |
| + if err := e.Assert(context.Background(), host); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(sets) != 1 { |
| + t.Fatalf("writes = %q, want the one write", sets) |
| + } |
| +} |
diff --git a/internal/instancectl/egress.go b/internal/instancectl/egress.go| index a8f15b2d9..f4d2365de 100644 |
| --- a/internal/instancectl/egress.go |
| +++ b/internal/instancectl/egress.go |
| @@ -630,33 +630,36 @@ func (e *EgressAsserter) Reports() map[string]EgressReport { |
| return out |
| } |
| -// desired validates a policy's entries in order: egressaddr.Parse, then |
| -// egressaddr.Allowed, then not one of the box's own addresses. It returns |
| -// the full-length prefixes to write, sorted, and a refusal per entry |
| -// refused. More than egressaddr.MaxAllow accepted closes them all, and |
| -// tooMany says so. When the box's addresses cannot be read, no entry is |
| -// accepted: an allow that might name the box itself is never written. |
| +// desired validates a policy's entries in order: egressaddr.ParseEntry, |
| +// then egressaddr.AllowedPrefix, then overlapping none of the box's own |
| +// addresses (#1357: an entry may be a prefix, and IPAddressAllow beats |
| +// IPAddressDeny, so a prefix holding one cannot be carved out). It returns |
| +// each entry's own prefix to write, never widened or masked, sorted, and a |
| +// refusal per entry refused. More than egressaddr.MaxAllow accepted closes |
| +// them all, and tooMany says so. When the box's addresses cannot be read, |
| +// no entry is accepted: an allow that might name the box itself is never |
| +// written. |
| func (e *EgressAsserter) desired(host string, allow []string) (want []netip.Prefix, refused []string, tooMany string) { |
| local, lerr := e.localAddrs() |
| if lerr != nil { |
| e.logf("egress: %s: this box's addresses: %v; every entry is closed", host, lerr) |
| } |
| - seen := map[netip.Addr]bool{} |
| + seen := map[netip.Prefix]bool{} |
| for _, s := range allow { |
| s = strings.TrimSpace(s) |
| if s == "" { |
| continue |
| } |
| - a, err := egressaddr.Parse(s) |
| - if err == nil && seen[a] { |
| + p, err := egressaddr.ParseEntry(s) |
| + if err == nil && seen[p] { |
| continue |
| } |
| if err == nil { |
| - seen[a] = true |
| - err = egressaddr.Allowed(a) |
| + seen[p] = true |
| + err = egressaddr.AllowedPrefix(p) |
| } |
| if err != nil { |
| - // egressaddr's errors already name the address. |
| + // egressaddr's errors already name the entry. |
| refused = append(refused, err.Error()) |
| continue |
| } |
| @@ -664,11 +667,15 @@ func (e *EgressAsserter) desired(host string, allow []string) (want []netip.Pref |
| refused = append(refused, s+": this box's addresses could not be read") |
| continue |
| } |
| - if lp, ok := isLocal(a, local); ok { |
| - refused = append(refused, fmt.Sprintf("%s: an address of this box (%s)", s, lp)) |
| + if lp, ok := overlapsLocal(p, local); ok { |
| + if p.IsSingleIP() { |
| + refused = append(refused, fmt.Sprintf("%s: this box has an address in %s", s, lp)) |
| + } else { |
| + refused = append(refused, fmt.Sprintf("%s: overlaps an address or range of this box (%s)", s, lp)) |
| + } |
| continue |
| } |
| - want = append(want, netip.PrefixFrom(a, a.BitLen())) |
| + want = append(want, p) |
| } |
| if len(want) > egressaddr.MaxAllow { |
| return nil, refused, fmt.Sprintf("the policy has more than %d addresses (%d); every one is closed", egressaddr.MaxAllow, len(want)) |
| @@ -784,12 +791,9 @@ func prefixesText(ps []netip.Prefix) string { |
| return strings.Join(s, " ") |
| } |
| -func comparePrefix(a, b netip.Prefix) int { |
| - if c := a.Addr().Compare(b.Addr()); c != 0 { |
| - return c |
| - } |
| - return a.Bits() - b.Bits() |
| -} |
| +// comparePrefix is the stored order (egressaddr.ComparePrefix), so root |
| +// writes and reports an allow in the order the policy holds it. |
| +func comparePrefix(a, b netip.Prefix) int { return egressaddr.ComparePrefix(a, b) } |
| func (e *EgressAsserter) readSource(ctx context.Context, host string) (EgressPolicy, error) { |
| if e.Source == nil { |
diff --git a/internal/instancectl/egress_test.go b/internal/instancectl/egress_test.go| index 78d666162..dc82183f5 100644 |
| --- a/internal/instancectl/egress_test.go |
| +++ b/internal/instancectl/egress_test.go |
| @@ -200,7 +200,7 @@ func TestEgressRefusesEachBadEntryWithItsReason(t *testing.T) { |
| wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.5.20/32", "10.0.5.21/32")) |
| // egressaddr's errors already name the address (C4): carried as-is. |
| want := []string{ |
| - "127.0.0.1 is a loopback address", |
| + "127.0.0.1 is loopback", |
| "8.8.8.8 is a public address and is already reachable. no allow is needed", |
| `"10.0.5.20:5432" has a port. an allow opens an address, never a port`, |
| } |
| @@ -220,7 +220,7 @@ func TestEgressDropsTheBoxsOwnAddress(t *testing.T) { |
| } |
| rep := mustAssert(t, e, egressHost) |
| wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.5.21/32")) |
| - if want := []string{"10.0.5.20: an address of this box (10.0.5.20/32)"}; !reflect.DeepEqual(rep.Refused, want) { |
| + if want := []string{"10.0.5.20: this box has an address in 10.0.5.20/32"}; !reflect.DeepEqual(rep.Refused, want) { |
| t.Fatalf("Refused = %q, want %q", rep.Refused, want) |
| } |
| if want := []string{"10.0.5.21"}; !reflect.DeepEqual(rep.Allowed, want) { |
| @@ -228,6 +228,110 @@ func TestEgressDropsTheBoxsOwnAddress(t *testing.T) { |
| } |
| } |
| +// desired takes a prefix exactly (#1357 decision 7): written as its own |
| +// prefix, never widened and never masked, refused when it overlaps any of |
| +// the box's own addresses, a single address as before. |
| +func TestEgressDesiredTakesPrefixesExactly(t *testing.T) { |
| + local := []netip.Prefix{ |
| + netip.MustParsePrefix("127.0.0.0/8"), |
| + netip.MustParsePrefix("10.0.5.20/32"), |
| + netip.MustParsePrefix("10.0.80.7/32"), |
| + netip.MustParsePrefix("10.1.0.0/24"), |
| + netip.MustParsePrefix("fd00:6::9/128"), |
| + } |
| + pfx := func(ss ...string) []netip.Prefix { |
| + var out []netip.Prefix |
| + for _, s := range ss { |
| + out = append(out, netip.MustParsePrefix(s)) |
| + } |
| + return out |
| + } |
| + var nine []string |
| + for i := 1; i <= 9; i++ { |
| + nine = append(nine, fmt.Sprintf("10.%d.0.0/16", 100+i)) |
| + } |
| + for _, c := range []struct { |
| + name string |
| + allow []string |
| + want []netip.Prefix |
| + refused []string |
| + tooMany bool |
| + }{ |
| + {name: "a prefix is written as is", allow: []string{"10.0.64.0/20", "10.0.5.21"}, |
| + want: pfx("10.0.5.21/32", "10.0.64.0/20")}, |
| + {name: "a prefix and its own first address are two entries", allow: []string{"10.0.64.0", "10.0.64.0/20", "fd00:5::/64"}, |
| + want: pfx("10.0.64.0/20", "10.0.64.0/32", "fd00:5::/64")}, |
| + {name: "duplicates collapse by prefix", allow: []string{"10.0.64.0/20", " 10.0.64.0/20", "10.0.5.21", "10.0.5.21/32"}, |
| + want: pfx("10.0.5.21/32", "10.0.64.0/20")}, |
| + {name: "a prefix holding a local /32 is refused", allow: []string{"10.0.80.0/20", "10.0.64.0/20"}, |
| + want: pfx("10.0.64.0/20"), |
| + refused: []string{"10.0.80.0/20: overlaps an address or range of this box (10.0.80.7/32)"}}, |
| + {name: "a prefix overlapping a local range is refused", allow: []string{"10.1.0.0/16", "fd00:6::/64"}, |
| + refused: []string{ |
| + "10.1.0.0/16: overlaps an address or range of this box (10.1.0.0/24)", |
| + "fd00:6::/64: overlaps an address or range of this box (fd00:6::9/128)", |
| + }}, |
| + {name: "a single local address keeps its text", allow: []string{"10.0.5.20", "10.1.0.9"}, |
| + refused: []string{ |
| + "10.0.5.20: this box has an address in 10.0.5.20/32", |
| + "10.1.0.9: this box has an address in 10.1.0.0/24", |
| + }}, |
| + {name: "a host-bits entry is refused, never masked", allow: []string{"10.0.64.5/20"}, |
| + refused: []string{`"10.0.64.5/20" has host bits set. write it as 10.0.64.0/20`}}, |
| + {name: "a wide prefix is refused", allow: []string{"10.0.0.0/8"}, |
| + refused: []string{"10.0.0.0/8 is wider than /16. allow at most a /16"}}, |
| + {name: "nine prefixes close every one", allow: nine, tooMany: true}, |
| + {name: "eight prefixes are written", allow: nine[:8], |
| + want: pfx("10.101.0.0/16", "10.102.0.0/16", "10.103.0.0/16", "10.104.0.0/16", |
| + "10.105.0.0/16", "10.106.0.0/16", "10.107.0.0/16", "10.108.0.0/16")}, |
| + } { |
| + e := newEgressAsserter(newEgressCtl(), nil) |
| + e.LocalAddrs = func() ([]netip.Prefix, error) { return local, nil } |
| + want, refused, tooMany := e.desired(egressHost, c.allow) |
| + if !slices.Equal(want, c.want) { |
| + t.Errorf("%s: want = %v, want %v", c.name, want, c.want) |
| + } |
| + if !slices.Equal(refused, c.refused) { |
| + t.Errorf("%s: refused = %q, want %q", c.name, refused, c.refused) |
| + } |
| + if (tooMany != "") != c.tooMany { |
| + t.Errorf("%s: tooMany = %q, want set %v", c.name, tooMany, c.tooMany) |
| + } |
| + } |
| +} |
| + |
| +// Assert writes a prefix through systemctl as is, and systemd's read-back |
| +// of it counts as in force: nothing is written again and nothing fails. |
| +func TestEgressWritesAPrefixAndReadsItBack(t *testing.T) { |
| + ctl := newEgressCtl() |
| + e := newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.64.0/20", "10.0.5.20", "fd00:5::/64"}}, nil)) |
| + rep := mustAssert(t, e, egressHost) |
| + wantCalls(t, ctl.takeCalls(), |
| + showCall(egressHost), |
| + setCall(egressHost, "10.0.5.20/32", "10.0.64.0/20", "fd00:5::/64"), |
| + showCall(egressHost)) |
| + if want := (EgressReport{Allowed: []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}}); !reflect.DeepEqual(rep, want) { |
| + t.Fatalf("report = %+v, want %+v", rep, want) |
| + } |
| + |
| + // systemd's own form of the same allow, in its order: in force. |
| + ctl = newEgressCtl() |
| + ctl.setHeld(SliceName(egressHost), "10.0.64.0/20 fd00:5::/64 10.0.5.20/32") |
| + e = newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}}, nil)) |
| + rep = mustAssert(t, e, egressHost) |
| + wantCalls(t, ctl.takeCalls(), showCall(egressHost)) |
| + if rep.State != "" || !reflect.DeepEqual(rep.Allowed, []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}) { |
| + t.Fatalf("report = %+v, want in force with nothing written", rep) |
| + } |
| + |
| + // A held prefix that differs from the wanted one is not in force. |
| + ctl = newEgressCtl() |
| + ctl.setHeld(SliceName(egressHost), "10.0.0.0/16") |
| + e = newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.64.0/20"}}, nil)) |
| + mustAssert(t, e, egressHost) |
| + wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.64.0/20")) |
| +} |
| + |
| func TestEgressClosesWhenTheBoxsAddressesCannotBeRead(t *testing.T) { |
| ctl := newEgressCtl() |
| ctl.setHeld(SliceName(egressHost), "10.0.5.20/32") |
diff --git a/internal/instancectl/localaddrs.go b/internal/instancectl/localaddrs.go| index 4be41e2ec..f0d0ba517 100644 |
| --- a/internal/instancectl/localaddrs.go |
| +++ b/internal/instancectl/localaddrs.go |
| @@ -126,6 +126,17 @@ func isLocal(a netip.Addr, local []netip.Prefix) (netip.Prefix, bool) { |
| return netip.Prefix{}, false |
| } |
| +// overlapsLocal names the local prefix p overlaps, if any: for a |
| +// full-length p, the one holding its address, as isLocal. |
| +func overlapsLocal(p netip.Prefix, local []netip.Prefix) (netip.Prefix, bool) { |
| + for _, l := range local { |
| + if l.Overlaps(p) { |
| + return l, true |
| + } |
| + } |
| + return netip.Prefix{}, false |
| +} |
| + |
| // LocalAddresses is everything that routes to this box, read from |
| // procfs as the resolver allow reads it: the egress asserter's |
| // LocalAddrs, and the agent's list of the box's addresses. |
diff --git a/internal/provision/apppolicy_reconcile_test.go b/internal/provision/apppolicy_reconcile_test.go| index a43c3c75a..7e49be561 100644 |
| --- a/internal/provision/apppolicy_reconcile_test.go |
| +++ b/internal/provision/apppolicy_reconcile_test.go |
| @@ -4,6 +4,7 @@ import ( |
| "context" |
| "crypto/ed25519" |
| "database/sql" |
| + "encoding/base64" |
| "errors" |
| "fmt" |
| "os" |
| @@ -215,6 +216,16 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) { |
| other.App = "other" |
| stale := good() |
| stale.SignedAt = fx.now.Add(-apppolicy.Lifetime - time.Minute) |
| + // A record the release key did sign, holding an entry this box's |
| + // Validate refuses: the old-box path (#1357), where a box whose |
| + // Validate predates prefixes reads "10.0.64.0/20" the way this one |
| + // reads a host-bits or too-wide prefix. The whole allow closes, the |
| + // good single beside it included, and nothing wider is ever written. |
| + badEntry := func(entry string) []byte { |
| + p := good() |
| + p.EgressAllow = []string{"10.0.5.20", entry} |
| + return signUnchecked(t, fx.priv, p) |
| + } |
| for _, c := range []struct { |
| name string |
| @@ -225,6 +236,9 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) { |
| {"another key", sign(otherPriv, grant), "policy unverifiable"}, |
| {"another app's record", sign(fx.priv, other), "policy unverifiable"}, |
| {"expired", sign(fx.priv, stale), "policy expired"}, |
| + {"a host-bits prefix", badEntry("10.0.64.5/20"), "policy unverifiable"}, |
| + {"a too-wide prefix", badEntry("10.0.0.0/8"), "policy unverifiable"}, |
| + {"a single stored as /32", badEntry("10.0.5.21/32"), "policy unverifiable"}, |
| } { |
| converge() |
| fx.putRaw(c.body) |
| @@ -236,6 +250,13 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) { |
| fx.wantState(c.state) |
| } |
| + // signUnchecked's control: the same signing over a policy this box |
| + // accepts converges, so the refusals above are the entry's. |
| + fx.putRaw(badEntry("10.0.64.0/20")) |
| + fx.run() |
| + wantCols(t, fx.row(policyHost), "10.0.5.20 10.0.64.0/20", "large", fx.now.Add(apppolicy.Lifetime).Unix()) |
| + fx.wantState("") |
| + |
| // No release key on the box: a valid record cannot be verified. |
| converge() |
| fx.cfg.ReleasePub = nil |
| @@ -610,3 +631,12 @@ func mintOrder(t *testing.T, reg *registry.Registry) []string { |
| } |
| return hosts |
| } |
| + |
| +// signUnchecked signs p the way apppolicy.Sign does, without Sign's |
| +// Validate: a record the release key signed whose shape a box refuses. |
| +func signUnchecked(t *testing.T, priv ed25519.PrivateKey, p apppolicy.Policy) []byte { |
| + t.Helper() |
| + payload := base64.StdEncoding.EncodeToString(mustJSON(t, p)) |
| + return mustJSON(t, map[string]string{"payload": payload, |
| + "sig": base64.StdEncoding.EncodeToString(ed25519.Sign(priv, []byte("carlos app-policy v1\n"+payload)))}) |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 609b7dd6a..67247eea6 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -279,3 +279,5 @@ plan14-root-reads-group-revoke-readback-1255.tsv 47ebd73418bcbe1bdf9cf34a2b94e33 |
| plan14-root-reads-precert-dns01-1293.tsv b2f039a12bb284c9a36b391339e25e3f77ec94a3d4e38389ec9ef75261d7873f |
| plan14-root-reads-fleet-client-address-1348.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0 |
| plan14-root-reads-flake-hostexec-renewal.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0 |
| +plan14-root-reads-egress-allow-cidr.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0 |
| +plan14-root-reads-egress-allow-cidr-console.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0 |
diff --git a/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv| new file mode 100644 |
| index 000000000..2292b17bd |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay egress-allow-cidr-console, written by census-propose (#369). census-ruling-egress-allow-cidr-console, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md. |
| +# 0 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@coverage . 678ff93df9d4bba86e5fb3174b6e521c50a4a2b8e8da278eb7345f1dcc6b28ba |
| +@coverage internal/egressaddr f23f1c889694411f185a4e46acf541fd5e37320693c3cc5ce8d5f68fba1561ed |
| +@coverage internal/instancectl 4d36599760134ea7456756dba3fa02a90c7194454d355e8b1fab8f0bcc2a4bea |
| +@coverage internal/release d5ad27f00e653c322b60826f5174354b6f2deae4f27f41bdd148aad959a35fd1 |
diff --git a/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv| new file mode 100644 |
| index 000000000..5d8aad2ca |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv |
| @@ -0,0 +1,5 @@ |
| +# Census overlay egress-allow-cidr, written by census-propose (#369). census-ruling-egress-allow-cidr, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-egress-allow-cidr.md. |
| +# 0 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@coverage internal/apppolicy 3162130ffcbc2153e5c075bb08f7c29384b4bd365569aa1cab69014d9eb4747a |
| +@coverage internal/egressaddr 489cfb43f5fc489a0e824081ad5f34cffc2d46b69c76ef7ce85f393541d6d209 |
| +@coverage internal/instancectl 14cc1cfb38c3e337cc44691bbe2484d137abade42cff654166f5f4d655a5f092 |
diff --git a/internal/release/layoutintent.go b/internal/release/layoutintent.go| index baa1d3f71..a358e3e4c 100644 |
| --- a/internal/release/layoutintent.go |
| +++ b/internal/release/layoutintent.go |
| @@ -246,6 +246,18 @@ var RootfsLifecycleFloor = SemVer{Major: 0, Minor: 29, Patch: 0} |
| // TestTeamEnvironmentFloorIsPinned pins it. |
| var TeamEnvironmentFloor = SemVer{Major: 0, Minor: 30, Patch: 0} |
| +// EgressPrefixFloor is the first platform release whose boxes accept an |
| +// egress allow entry that is a prefix (#1357). An older box reads such a |
| +// policy as unverifiable and clears the app's whole allow and size override |
| +// on that box (fail closed, but a regression of the app's other entries). |
| +// So the console adds a prefix entry only while every fresh box of the |
| +// deployment runs at or above it (console/egressfleet.go); single |
| +// addresses, and revokes, are never gated. The latest tag at the time of |
| +// writing is v0.42.1, so this names the next minor: if the release ships |
| +// under another number, this moves with it (a floor set too high only |
| +// refuses prefixes for longer). TestEgressPrefixFloorIsPinned pins it. |
| +var EgressPrefixFloor = SemVer{Major: 0, Minor: 43, Patch: 0} |
| + |
| // RegionalDomainsFloor is the first platform release that reads a regional |
| // custom-domain claim (#447). A box below it skips the claim entirely: a |
| // regional claim is stamped schema 2, and every older reader refuses a |
diff --git a/internal/release/layoutintent_test.go b/internal/release/layoutintent_test.go| index dd43e2df2..888e0dcb7 100644 |
| --- a/internal/release/layoutintent_test.go |
| +++ b/internal/release/layoutintent_test.go |
| @@ -322,3 +322,14 @@ func TestFleetForwardFloorAllows(t *testing.T) { |
| } |
| } |
| } |
| + |
| +func TestEgressPrefixFloorIsPinned(t *testing.T) { |
| + if EgressPrefixFloor != (SemVer{Major: 0, Minor: 43, Patch: 0}) { |
| + t.Fatalf("EgressPrefixFloor = %+v, want v0.43.0 (the first release whose boxes accept egress prefixes)", EgressPrefixFloor) |
| + } |
| + for v, below := range map[string]bool{"v0.42.1": true, "v0.43.0": false, "v0.43.2": false} { |
| + if got := BelowFloor(v, EgressPrefixFloor); got != below { |
| + t.Errorf("BelowFloor(%q, EgressPrefixFloor) = %v, want %v", v, got, below) |
| + } |
| + } |
| +} |
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl| index 1cc1f793f..effa3f070 100644 |
| --- a/testdata/clireg-golden.jsonl |
| +++ b/testdata/clireg-golden.jsonl |
| @@ -68,8 +68,8 @@ |
| {"case":"apps region | -h","argv":["apps","region","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps region --app <name> [--set <region>] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --app, -a <string> app whose region to show or change\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --set <string> the region where this app's new instances start. existing instances stay where they are. only account owners and deployment operators can change it\n"} |
| {"case":"apps restore | --zz-unknown-flag","argv":["apps","restore","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps restore [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --console <string> console origin to restore through (signed-in mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"} |
| {"case":"apps restore | -h","argv":["apps","restore","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps restore [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --console <string> console origin to restore through (signed-in mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"} |
| -{"case":"apps set | --zz-unknown-flag","argv":["apps","set","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"} |
| -{"case":"apps set | -h","argv":["apps","set","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"} |
| +{"case":"apps set | --zz-unknown-flag","argv":["apps","set","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"} |
| +{"case":"apps set | -h","argv":["apps","set","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"} |
| {"case":"apps show | --zz-unknown-flag","argv":["apps","show","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"} |
| {"case":"apps show | -h","argv":["apps","show","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"} |
| {"case":"apps source delete | extra","argv":["apps","source","delete"],"exit":1,"stdout":"","stderr":"carlos apps source pull --app <app> [--account <name-or-sqid> | --account-id <sqid>] --console <origin> [--output <path>]\n"} |