Documentation
¶
Index ¶
- Variables
- func AutoUpdate(currentVersion string) error
- func CleanupOldBinary()
- func GetPluginVersion(target, plugin string, cfg http.Config) string
- func GetPluginVersionWithClient(ctx context.Context, client *http.HTTPClientManager, target, plugin string) string
- func GetPluginVersionWithContext(ctx context.Context, target, plugin string, cfg http.Config) string
- func GetThemeVersionWithClient(ctx context.Context, httpClient *http.HTTPClientManager, target, theme string) string
- func GetThemeVersionWithContext(ctx context.Context, target, theme string, cfg http.Config) string
- func IsVersionVulnerable(version, fromVersion, toVersion string) bool
- func RememberLatestRelease(tag string)
- type Info
- type Latest
Constants ¶
This section is empty.
Variables ¶
var GitHubDownloadURL = func(version, osName, arch string) string { var ext string if osName == "windows" { ext = ".exe" } return fmt.Sprintf( "https://github.com/%s/releases/download/%s/wpprobe_%s_%s_%s%s", githubRepo, version, version, osName, arch, ext, ) }
var GitHubLatestReleaseURL = func() string { return fmt.Sprintf("https://api.github.com/repos/%s/releases/latest", githubRepo) }
var Version = "dev"
Functions ¶
func AutoUpdate ¶
func CleanupOldBinary ¶ added in v0.11.4
func CleanupOldBinary()
func GetPluginVersionWithClient ¶ added in v0.10.13
func GetPluginVersionWithClient(ctx context.Context, client *http.HTTPClientManager, target, plugin string) string
GetPluginVersionWithClient uses an existing HTTP client instead of creating a new one.
func GetPluginVersionWithContext ¶ added in v0.10.0
func GetThemeVersionWithClient ¶ added in v0.12.7
func GetThemeVersionWithClient( ctx context.Context, httpClient *http.HTTPClientManager, target, theme string, ) string
GetThemeVersionWithClient uses an existing HTTP client instead of creating a new one, so a scan reuses connections across every theme it looks up.
func GetThemeVersionWithContext ¶ added in v0.11.0
GetThemeVersionWithContext fetches the theme version from style.css. Only reads the first 8KB since the Version header is at the top of the file.
func IsVersionVulnerable ¶
func RememberLatestRelease ¶ added in v0.12.8
func RememberLatestRelease(tag string)
RememberLatestRelease records a release tag learned elsewhere, so a lookup the update command already paid for corrects the banner instead of leaving it to contradict what the user was just told. The tag is normalized to match what fetchLatestTag stores.
Types ¶
type Info ¶ added in v0.12.6
type Info struct {
// Display is the short form shown in the banner.
Display string
// Comparable is the form checked against the published releases. It is
// empty when the build carries no version the toolchain could derive, in
// which case no comparison should be attempted at all.
Comparable string
// Release reports whether the version was linked in at build time, which
// only the release pipeline does. A build from source is not a release even
// when its derived version is perfectly comparable.
Release bool
}
Info describes the running build.
func Current ¶ added in v0.12.6
func Current() Info
Current describes the running binary.
A release binary carries its version through -ldflags and needs nothing else. A build from source does not, and used to report itself as "dev", which the semver comparison could not parse, so every such build was labelled outdated and pointed at `wpprobe update` - which would have replaced it with an older release binary. The Go toolchain already embeds a usable version in both source install paths, so that is what fills the gap.
type Latest ¶ added in v0.12.6
type Latest struct {
// Version is the newest published release. Empty when Known is false.
Version string
// Known reports whether the lookup produced an answer at all. A failed
// lookup used to be indistinguishable from "you are behind", so running
// offline reported the build as outdated and advised an update.
Known bool
// Current reports whether the running build is at or ahead of Version. It
// carries no meaning when Known is false.
Current bool
}
Latest is what the release check could establish.
func CheckLatestVersion ¶
CheckLatestVersion compares currentVersion with the newest published tag, reusing a cached answer for releaseCheckTTL so the lookup does not run on every invocation.
func RefreshLatestVersion ¶ added in v0.12.8
RefreshLatestVersion is CheckLatestVersion without the cached shortcut, for the moments where the answer has to be current rather than recent: `wpprobe update` is about to act on it, and a banner contradicting the command running underneath it is worse than a request.