Repository navigation
Commit ba74344
committed
fix(site-router)!: put the guest console switch out of tenant reach
The console carries whatever the guest prints, and giving tenants logs
safely is separate work that does not exist yet, so a tenant must not be
able to turn a serial console on for their own site-router. Round 1 made
this a tenant-facing chart value, copying the convention
packages/apps/kubernetes already uses. That was the wrong call.
The switch is now `_logSerialConsole`, and the underscore is the access
control rather than a naming style. The aggregated apps.cozystack.io API
reserves every top-level values key beginning with `_`:
validateNoInternalKeys rejects one with a 400 on both Create (rest.go
~200) and Update (rest.go ~546), and filterInternalKeys strips them from
what a tenant reads back. Templates read only the reserved form, so the
un-prefixed name a tenant can actually submit is read by nothing. That
pairing is the whole boundary: the key that works cannot be submitted, and
the key that can be submitted does not work.
Dropping the field from the generated schema is NOT what protects it, and
it is worth being precise because the opposite is easy to assume.
Application.Spec is a raw apiextensionsv1.JSON so no Go struct prunes an
undeclared field; the generated values.schema.json carries no
additionalProperties so Helm accepts extras; and pkg/cmd/server/openapi.go
deliberately re-opens the published spec so undocumented Helm values are
accepted rather than rejected. Removing it from the schema hides it from
the dashboard and the published OpenAPI. validateNoInternalKeys is the
part with teeth.
This follows the existing platform-injected-value convention rather than
inventing one. `_cluster` and `_namespace` are written into app
HelmReleases by the tenant chart and the platform, consumed as
`.Values._cluster` / `.Values._namespace`, and declared in no values.yaml
anywhere in the tree. The key is likewise absent from values.yaml, not
merely un-annotated: cozyvalues-gen errors on an annotation-less key, and
hack/update-crd.sh builds the dashboard's keysOrder from values.yaml
content rather than from annotations, so a present-but-unannotated key
would leave a dangling dashboard hint pointing at a field the schema does
not describe.
The e2e suite is unaffected in capability. It sets `_logSerialConsole` on
the HelmRelease directly, which is an admin write to a resource the tenant
ClusterRoles grant no access to at all: cozy:tenant* grant `siterouters`
on the aggregated API and nothing on helm.toolkit.fluxcd.io. B's raw
KubeVirt VM keeps the un-prefixed spec.template.spec.domain.devices
.logSerialConsole, which is KubeVirt's own device field and not a chart
value. Round 2's collection is untouched. The flag is still opt-in and
still rendered only when true, so the kubevirt/kubevirt#15989 exposure
stays behind an explicit choice.
Tests prove the boundary rather than asserting it. The chart-side pair
supplies the un-prefixed key exactly as a tenant would and observes that
the rendered VM has no console and the cloud-init installs no emitter; the
API-side trio drives Create and Update and pins that the reserved key is
refused while the un-prefixed one is accepted-but-inert. Red phases: point
the templates back at the un-prefixed key and the tenant-supplied
assertions fail; remove the API guard and the Create assertion fails.
BREAKING CHANGE: the site-router `logSerialConsole` chart value is removed
from the tenant-facing API, schema and ApplicationDefinition. It was never
released, so no tenant can be relying on it; anything setting it must move
to `_logSerialConsole` on the HelmRelease, which requires platform
privileges by design.
Assisted-By: LLM
Signed-off-by: Myasnikov Daniil <[email protected]>1 parent f7d0c6b commit ba74344
12 files changed
Lines changed: 363 additions & 42 deletions
File tree
- api/apps/v1alpha1/siterouter
- hack
- e2e-chainsaw/site-router
- packages
- apps/site-router
- templates
- tests
- system/site-router-rd/cozyrds
- pkg/registry/apps/application
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | | - | |
| 106 | + | |
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
77 | 79 | | |
78 | 80 | | |
79 | 81 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
183 | | - | |
| 185 | + | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
245 | 247 | | |
246 | 248 | | |
247 | 249 | | |
248 | | - | |
| 250 | + | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| |||
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
263 | | - | |
| 265 | + | |
264 | 266 | | |
265 | | - | |
| 267 | + | |
266 | 268 | | |
267 | 269 | | |
268 | 270 | | |
| |||
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
281 | 307 | | |
282 | 308 | | |
283 | 309 | | |
| |||
0 commit comments