Skip to content

Build releases with the newest Go 1.26 patch, and add --readonly - #5

Merged
pierreneter merged 2 commits into
p10node:mainfrom
junior:readonly-and-release-go
Sep 30, 2026
Merged

pierreneter merged 2 commits into
p10node:mainfrom
junior:readonly-and-release-go

Conversation

@junior

@junior junior commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Two changes, one commit each.

1. Release binaries carry an old Go standard library

Every release so far, v0.1.6 included, was built with Go 1.26.0. setup-go reads go-version-file: go.mod, and go.mod's go line is the oldest Go the code builds with, not the toolchain to ship. A trivy scan of the v0.1.6 linux/amd64 binary lists 33 standard library vulnerabilities (22 rated high) that are fixed in 1.26.1 through 1.26.6, among them crypto/x509 certificate validation and crypto/tls issues.

The workflow now asks for 1.26.x with check-latest: true, so every release takes the newest 1.26 patch, and the build step prints go version so the log shows which one it used. go.mod is unchanged; when it moves to 1.27, this line moves with it. A new tag after merging would ship patched binaries.

2. --readonly

k10s --readonly (also --read-only, before or after demo) is for looking at a cluster you must not change, such as production, in the spirit of k9s's --readonly.

  • UI. The Actions pane keeps Describe, YAML, Logs and Top. Edit, Scale, Rollout Restart, Cordon, Drain and Delete are hidden, and so are Shell and Port Forward, which open a session into the cluster. Their keys and :scale show a notice instead of a dialog. Plugins with dangerous: true are hidden, as in k9s. Typed shell commands do not run: they run as the user, outside k10s, so read-only mode cannot vouch for them. The header shows READ-ONLY while the mode is on.
  • On the wire. With the flag set, k8s.New wraps the rest.Config in a transport that refuses, before the request leaves the machine, anything other than GET, HEAD and OPTIONS, plus the GETs that open exec, attach and port-forward streams over WebSockets. Every client is built from that config, the SPDY and WebSocket paths for exec and port-forward included, so a code path the UI misses still cannot write.

The policy is domain.ReadOnlyAllows; the transport is internal/k8s/readonly.go. Docs: the README usage block, a "Read-only mode" section in docs/commands.md, and the dangerous field in docs/plugins.md. I kept this to the flag; a readonly key in config.yaml could follow if you want one.

Testing

  • go vet ./... and go test ./... pass, and the binary builds for every release platform.
  • New tests cover the method and path policy; a clientset, the exec executor and the port-forward dialer run against a recording httptest server, which receives only the GET; the UI hiding and refusing write actions, :scale, typed shell commands and dangerous plugins while still describing; the header tag; and the flag parser.
  • Switching off the transport guard or the UI check makes those tests fail.

Happy to split this into two PRs if you prefer.

Every release so far, v0.1.6 included, was built with Go 1.26.0:
setup-go read the version from go.mod's `go` line, which is the
oldest Go the code builds with rather than the toolchain to ship.
A trivy scan of the v0.1.6 linux/amd64 binary lists 33 standard
library vulnerabilities (22 rated high) that are fixed in 1.26.1
through 1.26.6, among them crypto/x509 certificate validation and
crypto/tls issues.

Build releases with the newest 1.26 patch, and print `go version`
in the build log so every release shows which toolchain made it.
`k10s --readonly` (also `--read-only`, before or after `demo`) opens
the dashboard with nothing that can change the cluster, for looking at
clusters such as production without the risk of a stray key.

The UI hides Edit, Scale, Rollout Restart, Cordon, Drain and Delete,
and Shell and Port Forward, which open a session into the cluster.
Their keys, and `:scale`, answer with a notice instead of a dialog.
Plugins marked dangerous are hidden, as in k9s, and typed shell
commands do not run, since they run as the user, outside k10s. The
header shows READ-ONLY while the mode is on.

The same rule holds on the wire. Every client built from the
kubeconfig gets a transport that refuses, before the request leaves
the machine, anything other than GET, HEAD or OPTIONS, plus the GETs
that open exec, attach and port-forward streams over WebSockets. The
tests drive a clientset, the exec executor and the port-forward dialer
against a recording server and check that only the read reaches it.
@pierreneter
pierreneter self-requested a review September 26, 2026 04:42
@pierreneter

Copy link
Copy Markdown
Member

Reviewed both commits, approving.

Verified locally: go vet, go test ./... and a linux/amd64 build pass. I traced every rest.Config consumer in the repo (clientset, dynamic, discovery, metrics, the apiextensions client in store.go, the SPDY port-forward dialer and the WebSocket exec executor); all of them derive from the wrapped config, so the transport guard really is the backstop the description claims. The recording-server tests are a nice way to prove that. The allowlist shape of ReadOnlyAllows is the right call: a new action is blocked until someone decides otherwise.

The release change is correct as well; go-version-file with go 1.26.0 pins the toolchain to exactly 1.26.0, which is not what we want to ship.

Three optional follow-ups, none blocking:

  1. Plugins without dangerous: true still run in read-only mode. That matches k9s and is documented, but a kubectl delete plugin that forgot the flag bypasses the mode entirely. Worth considering either hiding all plugins in read-only mode or forcing confirm on them.
  2. GET .../pods/<name>/proxy/... (and the service/node proxy subresources) passes the guard. k10s never sends it, but adding proxy to streamSubresource would close that door for future code.
  3. 1.26.x with check-latest: true makes the build non-reproducible: re-tagging later picks a different toolchain. A toolchain go1.26.N line in go.mod would pin local and CI builds alike, and Dependabot can bump it. Trade-off, not a bug.

Happy to merge as is and take these separately.

@pierreneter
pierreneter merged commit a700c20 into p10node:main Sep 30, 2026
pierreneter pushed a commit that referenced this pull request Oct 7, 2026
A GET through .../pods/<name>/proxy/..., .../services/<name>/proxy/...
or .../nodes/<name>/proxy/... is passed on to whatever listens behind
it, and behind a node proxy is the kubelet, whose own API includes
exec. The read-only transport let those through: it only knew the
stream subresources, which always end the path.

proxy is followed by the path it forwards, so the guard now looks for
it anywhere in the path, anchored on "namespaces" for pods and
services and on "v1" for nodes, which keeps objects that are merely
named "proxy" readable. k10s never sends these requests itself.

Suggested in the review of #5.
@junior

junior commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for reviewing and merging all three.

On 1, I would keep k9s's behaviour, which the docs already describe: read-only mode hides the plugins marked dangerous.

On 3, I would keep 1.26.x for now. Dependabot does not bump the toolchain directive (dependabot/dependabot-core#13520 is still an open feature request) and raises no alert for a vulnerable one, so a pinned toolchain would go stale the way go 1.26.0 did, only more quietly. Renovate does propose toolchain bumps by default, and setup-go installs that version directly from v6 on (v5 reads only the go line). Every release now prints go version in its log, and go version -m on a binary shows the toolchain that built it, so a re-tag would at least be visible. If you prefer the pin, I can send it with setup-go v6 or later.

Would you cut a release when you have a moment? The v0.1.6 binaries were built with Go 1.26.0, and trivy lists 33 standard-library vulnerabilities in them (22 high). A build of main with the release flags on Go 1.26.8, the newest 1.26 patch today, scans clean. Anyone on v0.1.6 would see the new version in the status bar within a day.

@junior
junior deleted the readonly-and-release-go branch October 8, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants