cmd: surface home-dir errors and mask config values by allowlist#344
Merged
Conversation
PreRun/Run ignored os.UserHomeDir()'s error (home, _ := ...), so an empty home yielded a bogus relative config path that silently mis-detected config presence. Add resolveConfigFilePath (injectable homeDir) that surfaces the error; both closures log.Fatal on failure. validateConfig masked a value under --debug only when the key name contained "token", leaking any secret-bearing key not literally named that (api_key, secret, password, ...). Replace with maskConfigValue backed by an allowlist of known-safe keys — secret-by-default. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (58.82%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #344 +/- ##
==========================================
+ Coverage 66.42% 66.44% +0.01%
==========================================
Files 51 51
Lines 8170 8177 +7
==========================================
+ Hits 5427 5433 +6
- Misses 2368 2369 +1
Partials 375 375 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
PreRun/Runusedhome, _ := os.UserHomeDir()— an emptyhome yielded a bogus relative config path that silently mis-detected config
presence. Added
resolveConfigFilePath(injectablehomeDir) that surfaces theerror; both closures
log.Fatalon failure.validateConfigmasked a--debug-logged value only when thekey name contained
"token", leaking any other secret-bearing key (api_key,secret,password, future keys). Replaced withmaskConfigValuebacked by anallowlist of known-safe keys — secret-by-default.
Test plan
TestResolveConfigFilePath+TestMaskConfigValuewritten first (red), then greenmake test-allgreen (fmt, vet, lint, test, race, test-fixtures)skip-readme: internal correctness/security, no user-facing config/flag/keybinding changes.🤖 Generated with Claude Code