Repository navigation
fix(hosts): keep a saved secret that can't be decrypted when editing a host - #89
Merged
Merged
Conversation
…a host Reading a host turned a secret that can't be opened into an empty string, so saving the edit form replaced the stored ciphertext with nothing. Editing any field did this, and the host then stopped being reported as unreadable, so backups exported it without its secret. The DAO now keeps the stored value when an empty one is saved over a secret that can't be opened. Erasing it takes an explicit discard, which the form's new Clear button requests. The form reports each unreadable secret whichever auth method is selected, and a copied host says the secret wasn't copied. The generated key cleanup moves to UnsavedGeneratedKey, unchanged, to keep AddServerViewModel under Detekt's function limit. Fixes #88 Co-Authored-By: Claude Opus 5.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.
Summary
Fixes #88. Editing any field of a host, even just its name, erased a saved password or key passphrase that couldn't be decrypted. The host then stopped being reported as unreadable, so backups exported it without its secret.
HostProfileDaokeeps the stored value when an empty one is saved over a secret that can't be opened. A typed value still replaces it, and an empty value still clears a secret that opens normally.replaceDiscarding. Turning the passphrase switch off or picking another key no longer erases one.UnsavedGeneratedKeyis the generated-key cleanup moved out ofAddServerViewModel, with no behaviour change. The new method put the class at Detekt's function limit.Deleting an SSH key still clears the passphrase of hosts that use it through
clearKeyReference, readable or not. I left that as is, since the passphrase has no key left to unlock.Testing
mise run checkpasses.SealedDaoTestcases cover keeping, replacing, discarding, and clearing a readable secret. With the old overwrite temporarily restored, the keeping and replacing tests fail.AddServerFormTestcases cover the notices and the clear state.🤖 Generated with Claude Code