refactor(vault): eliminate global mutable state for search identity#361
Merged
Conversation
Move searchIdentity atomic.Pointer from package-level variable to a field on the Vault struct. Remove rememberSearchIdentity, currentSearchIdentity, and the standalone CurrentSearchIdentity function. Replace with a method on Vault that reads from the per-instance cache. Update all callers of List() and FindWithOptions() to pass identity explicitly instead of relying on the global cache. Doctor health checks, audit logger, and UI code now pass nil identity when no vault session is active, handling the missing-identity case gracefully. This eliminates a cross-vault identity leakage risk where opening a second vault would overwrite the first vault's search identity in the global atomic pointer. Closes #334
Update tui_test.go List calls to pass vault.Identity. Update coverage_expansion_test.go to use Vault.CurrentSearchIdentity() method. Refs #334
Update all test callers of List(), FindWithOptions(), and removed rememberSearchIdentity/currentSearchIdentity to match the new function signatures that require an explicit *age.X25519Identity parameter. - Add nil identity to List() calls that don't need decryption - Pass stored identity to FindWithOptions() calls where previously set via rememberSearchIdentity() - Rewrite TestCurrentSearchIdentity tests to use Vault struct field - Remove references to deleted package-level searchIdentity variable Refs PR #361
- TestFindWithNoIdentity and TestFindConcurrentNoIdentity must pass nil identity to verify error when no search identity is available. - TestEncryptedIndexFilterPathsUsingIndexLoadsFromDisk must pass a valid identity (not nil) since filterPathsUsingIndex returns early when identity is nil. - Fix gofmt formatting in affected files. Refs PR #361
golangci-lint flagged nilness: impossible condition nil != nil. The second error check was left from the original code structure where identity was validated before calling VerifyManifestIntegrity. Now nil identity is passed directly and the first error check handles the session-needed case. Refs PR #361
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.
refactor(vault): eliminate global mutable state for search identity
Move searchIdentity atomic.Pointer from package-level variable to a field
on the Vault struct. Remove rememberSearchIdentity, currentSearchIdentity,
and the standalone CurrentSearchIdentity function. Replace with a method
on Vault that reads from the per-instance cache.
Update all callers of List() and FindWithOptions() to pass identity
explicitly instead of relying on the global cache. Doctor health checks,
audit logger, and UI code now pass nil identity when no vault session
is active, handling the missing-identity case gracefully.
This eliminates a cross-vault identity leakage risk where opening a
second vault would overwrite the first vault's search identity in the
global atomic pointer.
Milestone: v0.4.1