Skip to content

Commit

Permalink
Fix linting and clean up deps
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten committed Dec 16, 2024
1 parent 8488c40 commit b2b9740
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
13 changes: 6 additions & 7 deletions crates/bitwarden-ssh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,20 @@ keywords.workspace = true
wasm = [
"bitwarden-error/wasm",
"dep:tsify-next",
"dep:wasm-bindgen"
"dep:wasm-bindgen",
] # WASM support

[dependencies]
bitwarden-error = { workspace = true }
ed25519 = { version = "2.2.3", features = ["pkcs8"] }
pkcs8 = { version = "0.10.2", features = ["encryption"] }
rand = "0.8.5"
rsa = "0.9.7"
ed25519 = { version = ">=2.2.3, <3.0", features = ["pkcs8"] }
pkcs8 = { version = ">=0.10.2, <0.11", features = ["encryption"] }
rand = ">=0.8.5, <0.9"
rsa = ">=0.9.2, <0.10"
serde.workspace = true
ssh-key = { version = "0.6.7", features = [
ssh-key = { version = ">=0.6.7, <0.7", features = [
"ed25519",
"encryption",
"rsa",
"getrandom",
], default-features = false }
thiserror = { workspace = true }
tsify-next = { workspace = true, optional = true }
Expand Down
15 changes: 9 additions & 6 deletions crates/bitwarden-ssh/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ fn import_pkcs8_key(
let private_key = ssh_key::private::PrivateKey::from(Ed25519Keypair::from(
&private_key.secret_key.into(),
));
return Ok(SshKey {
Ok(SshKey {
private_key: private_key.to_openssh(LineEnding::LF).unwrap().to_string(),

Check failure

Code scanning / clippy

used unwrap() on a Result value Error

used unwrap() on a Result value
public_key: private_key.public_key().to_string(),
key_fingerprint: private_key.fingerprint(HashAlg::Sha256).to_string(),
});
})
}
KeyType::Rsa => {
let private_key: rsa::RsaPrivateKey = match password {
Expand All @@ -112,13 +112,16 @@ fn import_pkcs8_key(
let private_key = ssh_key::private::PrivateKey::from(
RsaKeypair::try_from(private_key).map_err(|_| SshKeyImportError::ParsingError)?,
);
return Ok(SshKey {
private_key: private_key.to_openssh(LineEnding::LF).unwrap().to_string(),
let private_key_openssh = private_key
.to_openssh(LineEnding::LF)
.map_err(|_| SshKeyImportError::ParsingError)?;
Ok(SshKey {
private_key: private_key_openssh.to_string(),
public_key: private_key.public_key().to_string(),
key_fingerprint: private_key.fingerprint(HashAlg::Sha256).to_string(),
});
})
}
_ => return Err(SshKeyImportError::UnsupportedKeyType),
_ => Err(SshKeyImportError::UnsupportedKeyType),
}
}

Expand Down

0 comments on commit b2b9740

Please sign in to comment.