Documentation
¶
Overview ¶
Package upgrade downloads a ytrack release, verifies it and replaces the running binary with it.
Trust chain: the release's checksums file must carry a Sigstore keyless signature by this repository's release workflow (ReleaseIdentity); the archive must match its SHA-256 in that file. Only then is the binary extracted and swapped in. Any failed check refuses the upgrade and leaves the installed binary untouched.
Index ¶
- Constants
- Variables
- func ArchiveName(version, goos, goarch string) string
- func BundleName(version string) string
- func CheckSHA256(data []byte, want string) error
- func ChecksumsName(version string) string
- func ExpectedSHA256(checksums []byte, name string) (string, error)
- func ExtractBinary(archive []byte, name string) ([]byte, error)
- func PublicGoodTrustedRoot() (root.TrustedMaterial, error)
- func RemoveOld(exe string)
- func ReplaceExecutable(exe string, data []byte) error
- func VerifyBundle(bundleJSON, artifact []byte, t Trust) error
- type Downloader
- type Identity
- type Trust
Constants ¶
const OldSuffix = ".old"
OldSuffix names the previous binary that a Windows upgrade moves aside.
Variables ¶
var ErrRefused = errors.New("refusing to upgrade")
ErrRefused wraps every verification failure.
var ReleaseIdentity = Identity{
Issuer: "https://token.actions.githubusercontent.com",
SubjectRegexp: `^https://github\.com/BrainerVirus/youtrack-cli/\.github/workflows/release\.yml@refs/` +
`tags/v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$`,
}
ReleaseIdentity is the release workflow of this repository on GitHub Actions, run for a release tag: a tag push signs with refs/tags/vX.Y.Z, and a manual rerun must be dispatched from that tag (never from a branch), so it signs with the same ref.
Functions ¶
func ArchiveName ¶
ArchiveName returns the release archive for version (no "v") on goos/goarch, as .goreleaser.yaml names it.
func BundleName ¶
BundleName returns the Sigstore bundle that signs the checksums file.
func CheckSHA256 ¶
CheckSHA256 reports an error unless data hashes to the hex digest want.
func ChecksumsName ¶
ChecksumsName returns the checksums file of a release.
func ExpectedSHA256 ¶
ExpectedSHA256 returns the hex digest listed for name in a checksums file ("<hex> <name>" lines, as sha256sum writes them).
func ExtractBinary ¶
ExtractBinary returns the ytrack executable from a release archive (tar.gz, or zip for Windows).
func PublicGoodTrustedRoot ¶
func PublicGoodTrustedRoot() (root.TrustedMaterial, error)
PublicGoodTrustedRoot returns Sigstore's public-good trusted root (Fulcio CAs, Rekor v1 and v2 logs, CT logs, timestamp authorities), fetched and verified through Sigstore's TUF repository, starting from the TUF root that sigstore-go embeds. The TUF metadata is cached under ytrack's user cache directory, so key rotations reach ytrack without a new release.
func RemoveOld ¶
func RemoveOld(exe string)
RemoveOld deletes the binary a previous Windows upgrade moved aside.
func ReplaceExecutable ¶
ReplaceExecutable atomically replaces the file at exe with data, keeping its permissions. The new file is written next to exe and renamed over it, so exe is either the old or the new binary, never a partial one. Windows cannot overwrite a running executable but can rename it, so there the old binary is first moved to exe+OldSuffix (removed by the next upgrade).
func VerifyBundle ¶
VerifyBundle checks with sigstore-go that bundleJSON (a Sigstore bundle, as `cosign sign-blob --bundle` writes it) is a keyless signature of artifact by t.Identity: the certificate chains to a trusted Fulcio CA at a time attested by a transparency log entry (Rekor v1 or v2) or a signed timestamp, carries a valid SCT, names the identity, and its key signed the artifact's SHA-256. Any failed check is an error.
Types ¶
type Downloader ¶
Downloader fetches and verifies release binaries.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package upgradetest provides Sigstore bundles signed by sigstore-go's virtual Sigstore and a fake GitHub release server for tests.
|
Package upgradetest provides Sigstore bundles signed by sigstore-go's virtual Sigstore and a fake GitHub release server for tests. |