fix: address pkce auth review findings#11
Merged
Conversation
- 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
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
Addresses all findings and test gaps from the deep review of #10.
delete_token_from_keychain. Previously the error was silently discarded, causing the corrupt-entry warning to fire on every subsequent load.SAFETYcomment inEnvVarGuard::dropto state the invariant directly (XDG_MUTEX is held) without referencingwith_xdg_config_homespecifically, since the mutex is also acquired directly in some tests.DELbyte (0x7F) inis_safe_path_component, mirroring the existing trailing-space rejection. A leading space produces an invisible path component in directory listings.jsoninto 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 redundantjson.clone()). On task panic/cancel, re-serialize as a fallback.list_environmentsdoc comment to explicitly note that file-fallback tokens from a prior session are not enumerated, not just keychain tokens.is_safe_path_component_rejects_empty_string,is_safe_path_component_rejects_leading_space_and_del,list_environments_returns_only_cached_keys, andlist_environments_returns_empty_without_cachetests.Test plan
cargo fmt --all --checkpassescargo clippy --all-targets --features pkce-auth -- -D warningspassescargo test --all-targets --features pkce-authpasses (229 tests)RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --features pkce-authpasses