Skip to content

fix: address pkce auth review findings#11

Merged
jgowdy-godaddy merged 1 commit into
fix-keyringfrom
fix/pkce-review-findings
Jun 1, 2026
Merged

fix: address pkce auth review findings#11
jgowdy-godaddy merged 1 commit into
fix-keyringfrom
fix/pkce-review-findings

Conversation

@jgowdy-godaddy
Copy link
Copy Markdown
Collaborator

Summary

Addresses all findings and test gaps from the deep review of #10.

  • Finding 1 — Log WARN when the best-effort self-heal delete of a corrupt keychain entry fails, matching the diagnostic pattern in delete_token_from_keychain. Previously the error was silently discarded, causing the corrupt-entry warning to fire on every subsequent load.
  • Finding 2 — Fix SAFETY comment in EnvVarGuard::drop to state the invariant directly (XDG_MUTEX is held) without referencing with_xdg_config_home specifically, since the mutex is also acquired directly in some tests.
  • Finding 4 — Reject leading space and DEL byte (0x7F) in is_safe_path_component, mirroring the existing trailing-space rejection. A leading space produces an invisible path component in directory listings.
  • Finding 5 — Move json into the keychain write closure and return it back, so only one serialized copy of the token material is on the heap at a time in the normal path (eliminates the redundant json.clone()). On task panic/cancel, re-serialize as a fallback.
  • Finding 6 — Update list_environments doc comment to explicitly note that file-fallback tokens from a prior session are not enumerated, not just keychain tokens.
  • Test gap — Add is_safe_path_component_rejects_empty_string, is_safe_path_component_rejects_leading_space_and_del, list_environments_returns_only_cached_keys, and list_environments_returns_empty_without_cache tests.

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets --features pkce-auth -- -D warnings passes
  • cargo test --all-targets --features pkce-auth passes (229 tests)
  • RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --features pkce-auth passes

- Log WARN when best-effort self-heal delete of corrupt keychain entry
  fails, matching the diagnostic pattern in delete_token_from_keychain
- Move json string into keychain write closure and return it back to
  avoid a redundant clone; only one serialized copy on the heap at a
  time in the normal path
- Reject leading space and DEL byte (0x7F) in is_safe_path_component,
  mirroring the existing trailing-space rejection
- Update list_environments doc comment to note file-fallback tokens are
  also not enumerated after a restart
- Fix SAFETY comment in EnvVarGuard::drop to state the invariant
  accurately without referencing a specific helper function
- Add tests: empty-string rejection, leading-space/DEL rejection,
  list_environments cache-only behavior
@jgowdy-godaddy jgowdy-godaddy merged commit f941638 into fix-keyring Jun 1, 2026
2 checks passed
@jgowdy-godaddy jgowdy-godaddy deleted the fix/pkce-review-findings branch June 1, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant