Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bitwarden extension: fix search when vault contains SSH keys #17492

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jose-elias-alvarez
Copy link
Contributor

@jose-elias-alvarez jose-elias-alvarez commented Mar 2, 2025

Description

Closes #15837 and #16976.

Currently, the Search Vault command, the extension's main entry point, errors out if the vault contains an SSH key, a new item type added in late 2024. (This is why some users may not have any problems and also why downgrading to an earlier version of the CLI "fixes" the issue, since older versions just ignore SSH keys.)

This PR updates the extension's code to correctly handle the new item type. It displays SSH keys in the list of search results and adds an action to copy the public key to the clipboard. (I can also add an action to copy the private key and / or key fingerprint, though I'm not sure how useful these would be.)

I also added a check to ensure that the command won't completely error out if a new item type is added in the future (it'll have placeholder icons and no actions, which seems sensible until proper handling can be added in a PR similar to this one).

Also, while not related, I went ahead and fixed a warning generated by specifying a shortcut for Action.SubmitForm (Raycast is already overriding this to Command + Enter).

Screencast

An SSH key in search results:

CleanShot 2025-03-02 at 12 59 17

Checklist

- docs: update changelog
- chore: unset removed shortcut
- fix: handle ssh keys in search
- Initial commit
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: bitwarden Issues related to the bitwarden extension labels Mar 2, 2025
@raycastbot
Copy link
Collaborator

raycastbot commented Mar 2, 2025

Thank you for your contribution! 🎉

🔔 @jomifepe @daniel-stoneuk @andreaselia @pernielsentikaer @eth-p @YamenSharaf @undefinedzack @anirudhganwal06 @ivaarsson @gasparhabif @marinsokol you might want to have a look.

You can use this guide to learn how to check out the Pull Request locally in order to test it.

Due to our current reduced availability, the initial review may take up to 10-15 business days

@jose-elias-alvarez jose-elias-alvarez changed the title Update bitwarden extension Update bitwarden extension: fix search when vault contains SSH keys Mar 2, 2025
@pernielsentikaer
Copy link
Collaborator

@jomifepe can you check this?

@pernielsentikaer pernielsentikaer self-assigned this Mar 2, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds support for SSH keys in the Bitwarden extension, fixing a critical bug where the Search Vault command would error out when encountering SSH keys in a user's vault.

  • Added proper handling for SSH_KEY item type in src/types/vault.ts with a new interface for SSH key properties
  • Created new CopyPublicKeyAction.tsx component to allow copying public keys to clipboard
  • Updated caching utility in caching.ts to properly handle SSH key items while maintaining security
  • Added icon and label mappings for SSH keys in general.ts and labels.ts for consistent UI representation
  • Implemented defensive error handling in useItemAccessories.ts to prevent crashes from unknown item types in the future

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

13 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +93 to +97
export interface SshKey {
privateKey: string;
publicKey: string;
keyFingerprint: string;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The SshKey interface properties are all defined as required strings without null options, unlike other interfaces like Card and Identity which allow null values. Consider whether these fields should also allow null values for consistency and to handle potential edge cases where some fields might not be present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good bot. This is a fair observation, but at least as of now, SSH keys are not directly editable in the Bitwarden GUI (you have to either import them or generate them in Bitwarden itself), so I don't believe these are truly nullable, but I'm happy to change this for consistency.

Copy link
Contributor

@jomifepe jomifepe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition 💯
Looks clean overall. I've left a few comments.

@@ -17,7 +17,7 @@ const RepromptForm = (props: RepromptFormProps) => {
navigationTitle="Confirmation Required"
actions={
<ActionPanel>
<Action.SubmitForm title="Confirm" onSubmit={onSubmit} shortcut={{ key: "enter", modifiers: [] }} />
<Action.SubmitForm title="Confirm" onSubmit={onSubmit} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the warnings 🙏

"Getting public key..."
);
if (publicKey) {
await Clipboard.copy(publicKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should pass the transient flag depending on the preference here too.

Suggested change
await Clipboard.copy(publicKey);
await Clipboard.copy(publicKey, { transient: getTransientCopyPreference("other") });

{type === ItemType.SSH_KEY && (
<ActionPanel.Section>
<CopyPublicKeyAction />
</ActionPanel.Section>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Might be useful to also have copy actions for the private key and fingerprint. Would you mind creating these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension: bitwarden Issues related to the bitwarden extension extension fix / improvement Label for PRs with extension's fix improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bitwarden Vault] ...
4 participants