Skip to content

cmd: surface home-dir errors and mask config values by allowlist#344

Merged
clcollins merged 2 commits into
mainfrom
srepd/cmd-correctness
Jul 9, 2026
Merged

cmd: surface home-dir errors and mask config values by allowlist#344
clcollins merged 2 commits into
mainfrom
srepd/cmd-correctness

Conversation

@clcollins

Copy link
Copy Markdown
Owner

Summary

  1. Home-dir errors: PreRun/Run used home, _ := os.UserHomeDir() — an empty
    home yielded a bogus relative config path that silently mis-detected config
    presence. Added resolveConfigFilePath (injectable homeDir) that surfaces the
    error; both closures log.Fatal on failure.
  2. Token masking: validateConfig masked a --debug-logged value only when the
    key name contained "token", leaking any other secret-bearing key (api_key,
    secret, password, future keys). Replaced with maskConfigValue backed by an
    allowlist of known-safe keys — secret-by-default.

Test plan

  • TDD: TestResolveConfigFilePath + TestMaskConfigValue written first (red), then green
  • make test-all green (fmt, vet, lint, test, race, test-fixtures)

skip-readme: internal correctness/security, no user-facing config/flag/keybinding changes.

🤖 Generated with Claude Code

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>
@clcollins clcollins added the skip-readme Skip README update CI check label Jul 8, 2026
@codecov-commenter

codecov-commenter commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.82353% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.44%. Comparing base (e85194b) to head (844eb89).

Files with missing lines Patch % Lines
cmd/root.go 41.66% 7 Missing ⚠️

❌ 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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clcollins clcollins merged commit 792c98a into main Jul 9, 2026
11 checks passed
@clcollins clcollins deleted the srepd/cmd-correctness branch July 9, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-readme Skip README update CI check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants