Repository navigation
Upgrade to Go 1.27.2 and build a static image - #523
Merged
sethterashima merged 2 commits intoOct 20, 2026
Merged
sethterashima merged 2 commits into
sethterashima merged 2 commits into
Conversation
golangci-lint v1 cannot load packages compiled by newer Go releases (with Go 1.27 it fails with "could not load export data ... unsupported version"), so it has to move to v2 before the Go toolchain can be upgraded. Migrate .golangci.yml to the v2 format and keep the same checks: * gosimple is now part of staticcheck, so staticcheck is limited to the S1 and SA checks that ran before. * The ECDH deprecation exclusion is updated for the newer staticcheck message wording. * No exclusion presets are enabled, which matches what --exclude-use-default=false did. That flag no longer exists, so it is dropped from the Makefile. The newer revive also checks if/else chains directly inside switch cases. Drop the else after return in the four places it reports.
The release image is built with Go 1.23.0, which is past end of life and is missing every 1.23.x security fix. govulncheck reports 41 standard library vulnerabilities in tesla-http-proxy built that way, including crypto/tls, crypto/x509 and net/http issues. Build with Go 1.27.2 instead and use the same version in CI. None of the binaries need cgo, so build them with CGO_ENABLED=0 and run them on distroless/static-debian12. This removes glibc and OpenSSL (libssl3) from the image. It also avoids a glibc mismatch: the golang images are now based on Debian 13, while the runtime image is Debian 12. The go directive in go.mod stays at 1.23, so programs that import this module are not forced onto a newer Go. Fixes teslamotors#522
sethterashima
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #522
The release image is built
FROM golang:1.23.0. Go 1.23 is end of life and 1.23.0 has none of the 1.23.x security fixes, and the runtime base (distroless/base-debian12) brings in glibc and libssl3. This PR:golang:1.27.2and uses the same version in CI (setup-go), plus the README "tested with" line, following upgrade to golang v1.23.0 #306;CGO_ENABLED=0and runs them ongcr.io/distroless/static-debian12:nonroot, so the image no longer contains glibc or OpenSSL. The entrypoint, thenonrootuser, the set of binaries in/usr/local/binand the Debian release are unchanged;Why the lint change is needed
With Go 1.27.2 on the PATH, golangci-lint v1.61.0 stops before linting anything:
v1 is no longer maintained (the last release is v1.64.8), so the first commit moves to golangci-lint v2.14.0 (the first release with Go 1.27 support was v2.13.0) and
golangci-lint-action@v9. I kept the same checks as before:.golangci.ymlis converted to the v2 format. gosimple is now part of staticcheck, so staticcheck is limited toS1*andSA*, the checks that ran before (no quickfix or stylecheck).examplesstays excluded, as it was by the v1 default, with the path pattern(^|/)examples/(v2 matches exclusion paths against file paths, so a bareexamples$would not match anything).--exclude-use-default=falsedid. That flag no longer exists, so it is removed from the Makefile.(crypto/elliptic.Curve).ScalarMult has been deprecated since Go 1.21: ...).switchcases, and reports fourindent-error-flowfindings. I fixed them by dropping theelseafterreturninpkg/protocol/key.go(LoadPublicKey) and incharging-schedule-remove/precondition-schedule-removeincmd/tesla-control/commands.go. Behaviour does not change.The first commit also passes lint on its own with Go 1.23.0, so the two commits can be reviewed or reverted separately.
Why CGO_ENABLED=0 is safe here
GOOS=linuxand cgo enabled, the only packages that have cgo files areruntime/cgo,netandos/userfrom the standard library, and they fall back to their pure Go versions. For DNS this is what already happens on Linux with distroless'shosts: files dns.x/sys, and the Linux keyring backends (file, keyctl, secret-service, kwallet, pass) are pure Go.golang:1.27.2is now the Debian 13 (trixie) image, so a cgo build would link against a newer glibc than the Debian 12 runtime provides. Pinninggolang:1.27.2-bookwormwould be the alternative if you want to keep cgo.golang:1.27.2anddistroless/static-debian12:nonrootare both published for linux/amd64, linux/arm64 and linux/arm/v7, the platforms inpublish.yml.What this PR does not change
godirective stays atgo 1.23. Raising it to 1.27, as the issue suggests, would force every program that imports this module onto Go 1.27, and it does not affect the image, because the toolchain there is pinned by the Dockerfile. It would also break golangci-lint builds older than the target Go version. If you would rather raise it, or add atoolchain go1.27.2line so thatgo install .../cmd/...@lateston an older Go picks up a patched toolchain, I can add that.golang.org/x/*modules are not bumped. None of the findings in 0.4.1 image built with EOL Go 1.23.0 and outdated libssl3 (2 CRITICAL incl. CVE-2025-68121, 30+ HIGH) #522 come from them. govulncheck reports one module-level advisory, GO-2026-5024 (CVE-2026-39824, rated low):x/sys/windows.NewNTUnicodeString, Windows only and not called by this code. The fix (x/sys v0.44.0) needsgo 1.25.0in go.mod, so I left it for a separate change.static-debian12) to match the current image.static-debian13also works if you prefer to move now.Type of change
Please select all options that apply to this change:
Checklist:
Confirm you have completed the following steps:
No new tests: nothing about the behaviour changes, and the existing tests are run below on both platforms.
Testing
With Go 1.27.2:
go build ./...,go vet ./...andgo test ./...pass on Windows.go mod tidyleaves go.mod and go.sum unchanged, andgofmt -l .is clean.CGO_ENABLED=0 go build ./...succeeds for linux/amd64, linux/arm64 and linux/arm (GOARM=7).go vetis clean for linux/amd64 and linux/arm.CGO_ENABLED=0, pass on Linux (WSL2, kernel 6.6).GOOS=linuxas well, and with--max-same-issues=0 --max-issues-per-linter=0. golangci-lint v1.61.0 built with Go 1.23 still reports 0 issues on the old config with the code changes.docker-compose.yml.tesla-http-proxystarts, negotiates TLS 1.3 / HTTP/2, and returns the same403 {"error":"client did not provide an OAuth token"}for an unauthenticated command as a Go 1.23.0 build.tesla-keygen -key-file ... createwrites a key, andtesla-control,tesla-jwsandtesla-auth-tokenstart.govulncheck v1.9.0 (DB 2026-10-08), binary mode, linux/amd64:
The 41 include GO-2026-4337 / CVE-2025-68121 (
crypto/tls, the CRITICAL one in the issue) and thecrypto/x509,net/httpandnet/urladvisories. In source mode with Go 1.27.2 the only remaining result is the Windows-only x/sys advisory above, which is not called.Not tested: