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

[PM-16221] uniffi bindings for ssh agent and keygen #89

Merged
merged 5 commits into from
Jan 10, 2025

Conversation

quexten
Copy link
Contributor

@quexten quexten commented Dec 19, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-16221

📔 Objective

Adds bindings so we can add keygen and import to the mobile clients.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@quexten
Copy link
Contributor Author

quexten commented Dec 19, 2024

Question for whoever reviews: On both the wasm bindings and here, I put the ssh methods on the global "namespace" directly, since things like cryptoclient seemed to be for holding state. They can also act as namespaces though. Should they be moved under something like "sshclient"?

@quexten quexten force-pushed the km/pm_16221/uniffi-ssh-bindings branch from 4a77d22 to 750db94 Compare December 19, 2024 13:20
Copy link
Contributor

github-actions bot commented Dec 19, 2024

Logo
Checkmarx One – Scan Summary & Details7a21e426-10af-43e5-882b-761b5099ef87

No New Or Fixed Issues Found

@quexten quexten force-pushed the km/pm_16221/uniffi-ssh-bindings branch from 51db1f3 to 4d4c67a Compare December 19, 2024 13:22
crates/bitwarden-uniffi/src/error.rs Fixed Show fixed Hide fixed
crates/bitwarden-uniffi/src/error.rs Fixed Show fixed Hide fixed
crates/bitwarden-uniffi/src/error.rs Fixed Show fixed Hide fixed
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 20 lines in your changes missing coverage. Please review.

Project coverage is 65.24%. Comparing base (73747b6) to head (e7384a0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/bitwarden-uniffi/src/tool/ssh.rs 0.00% 16 Missing ⚠️
crates/bitwarden-uniffi/src/lib.rs 0.00% 3 Missing ⚠️
crates/bitwarden-ssh/src/lib.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #89      +/-   ##
==========================================
- Coverage   65.34%   65.24%   -0.10%     
==========================================
  Files         180      181       +1     
  Lines       13801    13821      +20     
==========================================
  Hits         9018     9018              
- Misses       4783     4803      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@quexten quexten marked this pull request as ready for review December 19, 2024 14:09
Comment on lines 92 to 107
pub fn generate_ssh_key(
&self,
key_algorithm: bitwarden_ssh::generator::KeyAlgorithm,
) -> Result<bitwarden_ssh::SshKey> {
bitwarden_ssh::generator::generate_sshkey(key_algorithm)
.map_err(|e| error::BitwardenError::E(error::Error::SshGeneration(e)))
}

pub fn import_ssh_key(
&self,
imported_key: String,
password: Option<String>,
) -> Result<bitwarden_ssh::SshKey> {
bitwarden_ssh::import::import_key(imported_key, password)
.map_err(|e| error::BitwardenError::E(error::Error::SshImport(e)))
}
Copy link
Member

Choose a reason for hiding this comment

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

issue: Please make a client for these, we don't want them in the root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated and moved to a client, should we do the same for wasm in a follow-up pr?

@quexten quexten requested a review from Hinton January 7, 2025 14:10
Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

LGTM. Nit for a potential follow up.

&self,
key_algorithm: bitwarden_ssh::generator::KeyAlgorithm,
) -> Result<bitwarden_ssh::SshKey> {
bitwarden_ssh::generator::generate_sshkey(key_algorithm)
Copy link
Member

Choose a reason for hiding this comment

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

observation: We would probably benefit from taking a look at the public interface of bitwarden_ssh. Exposing modules is a bit clunky and the library is small enough that re-publishing everything in the root would result in a cleaner interface.

@quexten quexten merged commit 203e538 into main Jan 10, 2025
39 checks passed
@quexten quexten deleted the km/pm_16221/uniffi-ssh-bindings branch January 10, 2025 13:08
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.

2 participants