feat(auth): surface credential-store failures and add ggshield auth status#1268
Open
AGallouin wants to merge 1 commit into
Open
feat(auth): surface credential-store failures and add ggshield auth status#1268AGallouin wants to merge 1 commit into
ggshield auth status#1268AGallouin wants to merge 1 commit into
Conversation
…tatus When writing a token to the OS credential store failed (e.g. macOS error -25244 after the ggshield binary path changed following a mise/asdf reshim, a pyenv/pipx reinstall or a Homebrew upgrade), the token stayed in cleartext in auth_config.yaml with only a hidden debug-level log. - Saves now print an actionable warning with the humanized error and the commands fixing the stale Keychain entry - Successful cleartext -> credential-store migrations are confirmed with an info message - New `ggshield auth status` command (text and --json) diagnoses the credential-store backend, its reachability and where each instance token actually lives, without ever writing to the store Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Context
When the ggshield binary path changes (mise/asdf reshim, pyenv/pipx reinstall, Homebrew upgrade…), the macOS Keychain entry created by the previous binary can no longer be overwritten: writes fail with
-25244(errSecInvalidOwnerEdit) because the entry's ACL is tied to the old path. ggshield silently fell back to storing the token in cleartext inauth_config.yaml, with only a debug-level log. The availability probe could not catch this, since it writes a fresh key with no ACL conflict.Fixes #1267.
What has been done
AuthConfig.save()prints a warning with a humanized error (the-25244case is translated to plain language), states that the token will stay in cleartext, and gives the copy-pasteable recovery commands (security delete-generic-password …+ggshield auth login). The fix advice is gated on the active keyring backend (not the OS), so a custom backend on macOS doesn't get Keychain-specific commands.ggshield auth statuscommand diagnosing token storage, in text and--json:ok/failed/plaintext/disabled/skipped), with fix commands when actionable;is_reachable()read-only check is used instead ofis_available());GGSHIELD_NO_KEYRINGis set (reachableis reported asnull);okeven if overwriting its entry would fail, because reads are what every command needs at runtime — write failures are surfaced at save time instead.credential_store+ per-instance{instance, status, message, fix}, withnullfor non-applicable fields) intended to be parseable by scripts; tests freeze the contract.Differences from the issue's proposed fixes: instead of making
is_available()probe real instance keys (which would put writes on every command's startup path), the conflict is detected where it matters — the save path warns on the actual failed write, andauth statusverifies each real instance key with reads only. The diagnostic command lives underggshield auth statusrather thanggshield config keyring-status, and its output is ASCII-only for legacy Windows terminals.Validation
Unit tests cover the new behavior (failure warning, migration message, silence on re-saves, read-only guarantee, JSON contract). To validate manually on macOS:
ggshield auth login, then runggshield auth status— the instance should reporttoken_storage: okwith the macOS Keychain location.ggshield auth login) — a warning should explain the failure and print thesecurity delete-generic-passwordfix;auth statusshould reportplaintextwith the same fix.auth statusshould reportokagain, and the save should print the migration confirmation.GGSHIELD_NO_KEYRING=1 ggshield auth status --jsonshould report"reachable": nulland not prompt for Keychain access.PR check list
skip-changeloglabel has been added to the PR.🤖 Generated with Claude Code