Skip to content

cmd: install stable updates from the CDN (PRINFRA-6718) - #583

Merged
somanshreddy merged 1 commit into
mainfrom
11-16-update_from_cdn
Nov 16, 2026
Merged

somanshreddy merged 1 commit into
mainfrom
11-16-update_from_cdn

Conversation

@somanshreddy

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CLI | Module: Self-update

Summary

heygen update now installs stable releases from the same CDN the install script uses, and checks each archive against that release's checksums before it replaces the binary. heygen update --check and the "update available" notice read the same source, so they always agree. Dev builds still update from GitHub prereleases.

How it works

  • The latest version comes from the CDN's stable pointer. It must be a plain vX.Y.Z tag, or the update stops.
  • --version vX.Y.Z looks in that version's CDN folder. A missing folder reports "version not found".
  • The archive for this platform is downloaded, and its sha256 must match the entry for that exact file in the release's checksums.txt. Then only the heygen (or heygen.exe) file at the archive root is installed.
  • A missing entry, a mismatch, or any network or HTTP error stops the update, and the installed binary stays as it was. Downloads are size-bounded, time-limited, and not redirected.
  • Output, exit codes, install-method checks and downgrades with --version are unchanged. A stable build's --version now accepts stable versions only.

Testing

  • New tests use a local fake CDN. They cover reading the stable pointer and refusing a malformed one, --version folders (including 403 and 404 as not found), refusing a checksum mismatch, a missing entry or a misplaced binary without touching the installed file, a successful install, the dev channel staying on GitHub, and --check agreeing with the notice.
  • Each check was broken on purpose to confirm its test fails.
  • Manually updated a v0.10.0 build to v0.11.0 and back against the real CDN.

🤖 Generated with Claude Code

Stable-channel updates now come from the same CDN the installer uses,
and are verified against that release's checksums before they replace
the binary. The dev channel still reads GitHub prereleases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Reviewed at 1c02a76; range-diff against 4c947f4 shows the single commit unchanged after the rebase.

update_cdn.go, everything that runs before the binary is replaced

  • URLs: every one is built only from a tag that matches stableReleaseTag (anchored vX.Y.Z, no leading zeros), for the stable pointer, --version and UpdateTo alike. Nothing caller-supplied reaches a path otherwise.
  • Checksum entry: the platform asset's line must have exactly two fields, with the name matching assetName exactly. A duplicate entry is refused, the hex must decode to 32 bytes, and the comparison is against the lower-cased value. A missing entry maps to "not found"; a malformed one is an error.
  • Order: the archive is hashed whole, before extraction. Extraction takes only a regular file named exactly heygen/heygen.exe at the root: tar.TypeReg, zip Mode().IsRegular(). Nothing is written from an entry's own name, and update.Apply gets only bytes.
  • Caps: the pointer is capped at its existing limit, checksums.txt at 16 KiB, the archive at 64 MiB and the decompressed binary at 256 MiB, each read through LimitReader(max+1) with an explicit overflow error. So a decompression bomb stops at the cap.
  • Redirects: CheckRedirect returns ErrUseLastResponse, so a 3xx surfaces as a non-200 error rather than being followed. Any error leaves the installed binary untouched.
  • Notice: it now reads the pointer through the same client, so --check and the notice can't disagree.

Verified (Go 1.26.11):

  • go test -count=1 ./cmd/heygen/ passes and go vet is clean.
  • I removed checks one at a time and the tests failed for each: skipping the sha256 comparison, matching any tar entry ending in heygen, and following redirects.

Non-blocking:

  • Test gap: loosening the entry match to strings.Contains(fields[1], asset) still passes the suite. The code's exact match is right, but no test pins it. A fixture with a lookalike line (e.g. heygen_v0.11.0_linux_amd64.tar.gz.sbom.json) listed before the real one would.
  • Trust model: checksums.txt comes from the same CDN prefix as the archive, so it guards against corruption and partial uploads, not against someone who can write to that prefix. That's the same level as install.sh, and the old GitHub path also read checksums.txt from the same release. GitHub releases are now immutable with protected tags, though, while the CDN prefix is writable by whatever holds the publish role. Taking checksums.txt from the GitHub release while downloading the archive from the CDN would need two separate stores to be tampered with. Worth considering as a follow-up.

— Rames

@somanshreddy
somanshreddy merged commit 76a6a4f into main Nov 16, 2026
12 checks passed
@somanshreddy
somanshreddy deleted the 11-16-update_from_cdn branch November 16, 2026 03:25
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