update

package
v0.9.6-dev.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: GPL-3.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package update downloads and replaces the Mihari binary (self-update).

Index

Constants

View Source
const (
	// ChannelMain tracks official GitHub latest releases.
	ChannelMain = "main"
	// ChannelDev tracks canonical prerelease tags vX.Y.Z-dev.N.
	ChannelDev = "dev"
)

Variables

This section is empty.

Functions

func LoadChannel added in v0.9.0

func LoadChannel(path string) (string, error)

LoadChannel reads the Mihari release channel from path. A missing file defaults to ChannelMain. An invalid first line is an error.

func RecheckReplacement added in v0.9.3

RecheckReplacement rejects a changed candidate or installation.

func ReplacementConfirmationError added in v0.9.3

func ReplacementConfirmationError(p ReplacementPreview) error

ReplacementConfirmationError returns the existing usage error with safe risk details.

func ReplacementWarning added in v0.9.3

func ReplacementWarning(p ReplacementPreview) string

ReplacementWarning renders safe compatibility information, without file paths.

func SaveChannel added in v0.9.0

func SaveChannel(path, channel string) error

SaveChannel atomically writes channel to path. Only main and dev are accepted.

func ValidateReplacementConsent added in v0.9.3

func ValidateReplacementConsent(p ReplacementPreview, c ReplacementConsent) error

ValidateReplacementConsent enforces the public confirmation contract.

Types

type Asset

type Asset struct {
	Name string `json:"name"`
	URL  string `json:"browser_download_url"`
	Size int64  `json:"size"`
}

Asset is a GitHub release asset.

func SelectSelfAsset

func SelectSelfAsset(release Release, goos, goarch string) (Asset, error)

SelectSelfAsset picks the unique mihari binary asset for goos/goarch. Expected names are mihari-windows-<arch>.exe or mihari-<goos>-<arch>.

type CheckResult added in v0.4.0

type CheckResult struct {
	Current   string
	Latest    string
	Available bool
	Ahead     bool
	Channel   string
}

CheckResult describes the latest Mihari release relative to the running version.

type ExecVersionRunner added in v0.9.3

type ExecVersionRunner struct{}

ExecVersionRunner queries an already trusted executable without a shell.

func (ExecVersionRunner) RunVersion added in v0.9.3

func (ExecVersionRunner) RunVersion(ctx context.Context, executable, dir string) ([]byte, error)

RunVersion runs self version in an isolated temporary environment.

type OfficialReleaseSource added in v0.9.3

type OfficialReleaseSource struct {
	Client *http.Client
	// Reporter borrows an existing diagnostic outlet; nil skips close warnings.
	Reporter diagnostics.Reporter
}

OfficialReleaseSource obtains independent fixed-tag evidence from the project release origin. Client permits an injected transport; URLs are never inputs.

func (OfficialReleaseSource) Checksum added in v0.9.3

func (s OfficialReleaseSource) Checksum(ctx context.Context, tag, asset string) (string, error)

Checksum returns the unique digest in the official fixed-tag manifest.

func (OfficialReleaseSource) Download added in v0.9.3

func (s OfficialReleaseSource) Download(ctx context.Context, tag, asset string, limit int64) (result []byte, resultErr error)

Download retrieves a bounded asset from the immutable release URL. Callers must verify its independent checksum before trusting executable/resource bytes.

type PreparedUpdate added in v0.9.3

type PreparedUpdate struct {
	Version, CandidatePath, SHA256, Channel string
	Available, Ahead                        bool
	TargetPath                              string
	Preview                                 ReplacementPreview
	Consent                                 ReplacementConsent
	// contains filtered or unexported fields
}

PreparedUpdate owns a verified download until Apply or Close consumes it. Fields describe a candidate, not authority for privileged installation.

func (*PreparedUpdate) Close added in v0.9.3

func (p *PreparedUpdate) Close() error

Close releases the prepared candidate. It is safe to call repeatedly.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Draft   bool    `json:"draft"`
	Assets  []Asset `json:"assets"`
}

Release is a GitHub release document.

type ReplacementCandidate added in v0.9.3

type ReplacementCandidate struct{ Version, SHA256, Channel string }

ReplacementCandidate identifies verified candidate bytes independently of staging paths.

type ReplacementConsent added in v0.9.3

type ReplacementConsent struct {
	Yes             bool
	ExpectedPreview string
	// Warn reports safe compatibility text for this call; it is never fingerprinted.
	Warn func(string) error `json:"-"`
}

ReplacementConsent is scoped to one replacement attempt.

type ReplacementObserver added in v0.9.3

type ReplacementObserver func(context.Context, string) (ReplacementSnapshot, error)

ReplacementObserver discovers only files the current operation will replace.

type ReplacementPreview added in v0.9.3

type ReplacementPreview struct {
	Candidate ReplacementCandidate
	Snapshot  ReplacementSnapshot
	Risk      ReplacementRisk
	ID        string
}

ReplacementPreview owns a normalized snapshot and its opaque confirmation identifier.

func NewReplacementPreview added in v0.9.3

NewReplacementPreview copies and normalizes observations before hashing them.

type ReplacementRisk added in v0.9.3

type ReplacementRisk string

ReplacementRisk describes compatibility risk when replacing installed bytes.

const (
	// ReplacementNone means no known compatibility risk.
	ReplacementNone ReplacementRisk = "none"
	// ReplacementDowngrade means at least one installed version is newer.
	ReplacementDowngrade ReplacementRisk = "downgrade"
	// ReplacementUnknown means compatibility cannot be determined.
	ReplacementUnknown ReplacementRisk = "unknown"
)

func ClassifyReplacementVersion added in v0.9.3

func ClassifyReplacementVersion(current, target string) ReplacementRisk

ClassifyReplacementVersion compares installed and candidate versions.

type ReplacementSnapshot added in v0.9.3

type ReplacementSnapshot struct {
	Targets                 []ReplacementTarget
	ServiceDefinitionSHA256 string
}

ReplacementSnapshot binds actual targets and the persistent service definition.

type ReplacementTarget added in v0.9.3

type ReplacementTarget struct {
	Roles                []string
	Path, FileID, SHA256 string
	Exists               bool
	Version              string
	// UnrecognizedVersion is bounded display evidence for the TUI only.
	// It never participates in version comparison, JSON or the preview ID.
	UnrecognizedVersion string `json:"-"`
	// contains filtered or unexported fields
}

ReplacementTarget describes one actual file to be overwritten. Never render it directly.

func ObserveReplacementTarget added in v0.9.3

func ObserveReplacementTarget(ctx context.Context, role, path string, runner VersionRunner) (ReplacementTarget, error)

ObserveReplacementTarget binds a trusted version query to file observations.

type Result

type Result struct {
	Version string
	Updated bool
	Ahead   bool
	Channel string
}

Result describes a self-update attempt.

type SelfUpdater

type SelfUpdater struct {
	// Reporter borrows the current execution owner's diagnostic outlet.
	Reporter   diagnostics.Reporter
	HTTPClient *http.Client
	APIBase    string
	Repository string
	GOOS       string
	GOARCH     string
	// AfterReplace is optional; used to restart the OS service after a successful replace.
	AfterReplace func(ctx context.Context, version string) error
	// ObserveTargets discovers every installation copy replaced by this operation.
	ObserveTargets ReplacementObserver
	// AfterReplacePrepared takes precedence over AfterReplace when configured.
	AfterReplacePrepared func(context.Context, PreparedUpdate) error
	// contains filtered or unexported fields
}

SelfUpdater installs a newer Mihari binary from GitHub Releases.

func (SelfUpdater) ApplyPrepared added in v0.9.3

func (u SelfUpdater) ApplyPrepared(ctx context.Context, p PreparedUpdate) (result Result, err error)

ApplyPrepared validates and installs the fixed candidate without querying releases.

func (SelfUpdater) Check added in v0.4.0

func (u SelfUpdater) Check(ctx context.Context, currentVersion, channel string) (CheckResult, error)

Check reports whether GitHub Releases contains a newer Mihari version for channel.

func (SelfUpdater) Prepare added in v0.9.3

func (u SelfUpdater) Prepare(ctx context.Context, binaryPath, currentVersion, channel string) (PreparedUpdate, error)

Prepare downloads and verifies a fixed release without replacing binaryPath.

func (SelfUpdater) Update

func (u SelfUpdater) Update(ctx context.Context, binaryPath, currentVersion, channel string) (result Result, err error)

Update downloads the latest release when newer than currentVersion and replaces binaryPath.

type VersionRunner added in v0.9.3

type VersionRunner interface {
	RunVersion(context.Context, string, string) ([]byte, error)
}

VersionRunner owns the bounded version child process and its cancellation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL