fix: resolve security, reliability, and code quality issues across the codebase - #6
Merged
Conversation
added 12 commits
June 15, 2026 21:45
Using cobra.CheckErr instead of panic provides a cleaner user experience with a proper error message and os.Exit(1) instead of an abrupt stack trace.
… listRemote Move includeDevel, limit, and forceRefresh from package-level variables to local variables read directly from cobra command flags. This is concurrency-safe and eliminates confusing viper.Get* mid-execution overrides of bound flag values.
After the install subcommand succeeds, re-stat the version file to ensure it was actually created before creating the symlink. This prevents broken symlinks when install exits successfully but the expected file is missing.
Add a guard in ExtractSpecificFile that skips archive entries containing '..' or absolute paths, printing a warning when such entries are encountered. This prevents malicious tarballs from writing outside the intended destination directory.
Add best-effort checksum verification for both download paths: - GitHub releases: search release assets for checksum files (.sha256, .sha256sum, SHA256SUMS, etc.), download and parse, verify binary - Direct URL downloads (kubectl/helm): fetch <url>.sha256 and verify On verification failure the binary is deleted and installation aborted. If no checksum file is found, a warning is printed but installation proceeds (best-effort). Also fixes: - Temp file cleanup in DownloadBinary now only runs on error - Deferred Close error variable no longer shadows the function error
Using strings.Split(fileName, '-') with len==2 check breaks when tool names or versions contain hyphens. Using strings.TrimPrefix with the known tool prefix is robust against such inputs.
Cache operations are internal bookkeeping and their error messages should not mix with CLI output on stdout.
Both getLatestVersion (for 'latest' resolution) and DownloadRelease created a new GitHub client. Hoist it to the top of the install function so a single instance is shared.
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.
This PR addresses findings from a code audit, focusing on supply-chain security (checksum verification, path traversal protection), correctness (symlink race, error shadowing, concurrency-safe flag reads), and housekeeping (stderr routing, restrictive permissions, deduplication).
usecommandpanicwithcobra.CheckErron Viper binding failureslistRemoteTrimPrefixinstead ofSplit("-")for version extraction0755install