From 70d0d7fc425949d3e4f7375df1af81e628044cd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 16 Dec 2024 13:39:09 +0100 Subject: [PATCH 1/5] Fix clippy CI --- .github/workflows/lint.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e68b83ce..6680e582 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,12 +38,20 @@ jobs: - name: Install clippy-sarif and sarif-fmt run: cargo install clippy-sarif sarif-fmt --locked --git https://github.com/psastras/sarif-rs.git --rev 11c33a53f6ffeaed736856b86fb6b7b09fabdfd8 - - name: Cargo clippy + - name: Cargo clippy-sarif run: cargo clippy --all-features --tests --message-format=json | clippy-sarif | tee clippy_result.sarif | sarif-fmt env: RUSTFLAGS: "-D warnings" + # Run it again but this time with the sarif output so that the + # status code of the command is caught and reported as failed in GitHub. + # This should be cached from the previous step and should be fast. + - name: Cargo clippy + run: cargo clippy --all-features --tests + env: + RUSTFLAGS: "-D warnings" + - name: Upload Clippy results to GitHub uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 with: From fbec65752cf85961306db58fe833474248ba87bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 16 Dec 2024 13:43:12 +0100 Subject: [PATCH 2/5] Fix lints --- crates/bitwarden-error-macro/src/lib.rs | 2 +- crates/bitwarden-fido/src/types.rs | 4 ++-- crates/bitwarden-vault/src/cipher/attachment.rs | 2 +- crates/bitwarden-vault/src/mobile/client_attachments.rs | 2 +- crates/bitwarden-vault/src/mobile/client_ciphers.rs | 2 +- crates/bitwarden-vault/src/mobile/client_collection.rs | 2 +- crates/bitwarden-vault/src/mobile/client_folders.rs | 2 +- crates/bitwarden-vault/src/mobile/client_password_history.rs | 2 +- crates/bitwarden-wasm-internal/src/client.rs | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/bitwarden-error-macro/src/lib.rs b/crates/bitwarden-error-macro/src/lib.rs index 01f8b887..0a98a492 100644 --- a/crates/bitwarden-error-macro/src/lib.rs +++ b/crates/bitwarden-error-macro/src/lib.rs @@ -9,7 +9,7 @@ mod full; /// # Attributes /// /// ## Error type - +/// /// - `basic`: The error is converted into a string using the `ToString` trait. /// - `flat`: The error is converted into a flat structure using the `FlatError` trait. /// - `full`: The entire error stack is made available using `serde`. diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index 409db7a9..e985e928 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -390,7 +390,7 @@ pub enum Origin { Android(UnverifiedAssetLink), } -impl<'a> TryFrom for passkey::client::Origin<'a> { +impl TryFrom for passkey::client::Origin<'_> { type Error = InvalidOriginError; fn try_from(value: Origin) -> Result { @@ -404,7 +404,7 @@ impl<'a> TryFrom for passkey::client::Origin<'a> { } } -impl<'a> TryFrom for passkey::client::UnverifiedAssetLink<'a> { +impl TryFrom for passkey::client::UnverifiedAssetLink<'_> { type Error = InvalidOriginError; fn try_from(value: UnverifiedAssetLink) -> Result { diff --git a/crates/bitwarden-vault/src/cipher/attachment.rs b/crates/bitwarden-vault/src/cipher/attachment.rs index bf589879..dd939b8a 100644 --- a/crates/bitwarden-vault/src/cipher/attachment.rs +++ b/crates/bitwarden-vault/src/cipher/attachment.rs @@ -57,7 +57,7 @@ pub struct AttachmentFileView<'a> { pub contents: &'a [u8], } -impl<'a> KeyEncryptable for AttachmentFileView<'a> { +impl KeyEncryptable for AttachmentFileView<'_> { fn encrypt_with_key( self, key: &SymmetricCryptoKey, diff --git a/crates/bitwarden-vault/src/mobile/client_attachments.rs b/crates/bitwarden-vault/src/mobile/client_attachments.rs index a98a7d1e..ee37b383 100644 --- a/crates/bitwarden-vault/src/mobile/client_attachments.rs +++ b/crates/bitwarden-vault/src/mobile/client_attachments.rs @@ -12,7 +12,7 @@ pub struct ClientAttachments<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientAttachments<'a> { +impl ClientAttachments<'_> { pub fn encrypt_buffer( &self, cipher: Cipher, diff --git a/crates/bitwarden-vault/src/mobile/client_ciphers.rs b/crates/bitwarden-vault/src/mobile/client_ciphers.rs index 063fb4bc..ad973df8 100644 --- a/crates/bitwarden-vault/src/mobile/client_ciphers.rs +++ b/crates/bitwarden-vault/src/mobile/client_ciphers.rs @@ -8,7 +8,7 @@ pub struct ClientCiphers<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientCiphers<'a> { +impl ClientCiphers<'_> { pub fn encrypt(&self, mut cipher_view: CipherView) -> Result { let enc = self.client.internal.get_encryption_settings()?; diff --git a/crates/bitwarden-vault/src/mobile/client_collection.rs b/crates/bitwarden-vault/src/mobile/client_collection.rs index 0c007f9e..77b2cbc1 100644 --- a/crates/bitwarden-vault/src/mobile/client_collection.rs +++ b/crates/bitwarden-vault/src/mobile/client_collection.rs @@ -7,7 +7,7 @@ pub struct ClientCollections<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientCollections<'a> { +impl ClientCollections<'_> { pub fn decrypt(&self, collection: Collection) -> Result { let enc = self.client.internal.get_encryption_settings()?; let key = collection.locate_key(&enc, &None)?; diff --git a/crates/bitwarden-vault/src/mobile/client_folders.rs b/crates/bitwarden-vault/src/mobile/client_folders.rs index d8ebb76e..5730cf90 100644 --- a/crates/bitwarden-vault/src/mobile/client_folders.rs +++ b/crates/bitwarden-vault/src/mobile/client_folders.rs @@ -7,7 +7,7 @@ pub struct ClientFolders<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientFolders<'a> { +impl ClientFolders<'_> { pub fn encrypt(&self, folder_view: FolderView) -> Result { let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None)?; diff --git a/crates/bitwarden-vault/src/mobile/client_password_history.rs b/crates/bitwarden-vault/src/mobile/client_password_history.rs index 98d989db..7900b208 100644 --- a/crates/bitwarden-vault/src/mobile/client_password_history.rs +++ b/crates/bitwarden-vault/src/mobile/client_password_history.rs @@ -7,7 +7,7 @@ pub struct ClientPasswordHistory<'a> { pub(crate) client: &'a Client, } -impl<'a> ClientPasswordHistory<'a> { +impl ClientPasswordHistory<'_> { pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None)?; diff --git a/crates/bitwarden-wasm-internal/src/client.rs b/crates/bitwarden-wasm-internal/src/client.rs index c42534df..4049be56 100644 --- a/crates/bitwarden-wasm-internal/src/client.rs +++ b/crates/bitwarden-wasm-internal/src/client.rs @@ -54,7 +54,7 @@ impl BitwardenClient { env!("SDK_VERSION").to_owned() } - pub async fn throw(&self, msg: String) -> Result<(), TestError> { + pub fn throw(&self, msg: String) -> Result<(), TestError> { Err(TestError(msg)) } From b088304dc1b5e40f2e8079ea874da6de1c980dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 16 Dec 2024 13:47:55 +0100 Subject: [PATCH 3/5] Typo --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6680e582..3a2891c4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -44,7 +44,7 @@ jobs: env: RUSTFLAGS: "-D warnings" - # Run it again but this time with the sarif output so that the + # Run it again but this time without the sarif output so that the # status code of the command is caught and reported as failed in GitHub. # This should be cached from the previous step and should be fast. - name: Cargo clippy From 545f90403beb716e6099dcd15617e8ab9b515bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 16 Dec 2024 14:28:11 +0100 Subject: [PATCH 4/5] Fix last set of lints --- crates/bitwarden-core/src/util.rs | 1 + crates/bitwarden-uniffi/src/error.rs | 14 ++++++-------- crates/bitwarden-uniffi/src/platform/fido2.rs | 4 ++-- crates/bitwarden-uniffi/src/tool/mod.rs | 14 +++++++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/crates/bitwarden-core/src/util.rs b/crates/bitwarden-core/src/util.rs index 59ef930d..a8641399 100644 --- a/crates/bitwarden-core/src/util.rs +++ b/crates/bitwarden-core/src/util.rs @@ -9,6 +9,7 @@ const INDIFFERENT: GeneralPurposeConfig = pub const STANDARD_INDIFFERENT: GeneralPurpose = GeneralPurpose::new(&alphabet::STANDARD, INDIFFERENT); +#[allow(dead_code)] #[cfg(test)] pub async fn start_mock(mocks: Vec) -> (wiremock::MockServer, crate::Client) { let server = wiremock::MockServer::start().await; diff --git a/crates/bitwarden-uniffi/src/error.rs b/crates/bitwarden-uniffi/src/error.rs index 889e3c7f..89096e8b 100644 --- a/crates/bitwarden-uniffi/src/error.rs +++ b/crates/bitwarden-uniffi/src/error.rs @@ -48,11 +48,11 @@ pub enum Error { // Generators #[error(transparent)] - UsernameError(#[from] UsernameError), + Username(#[from] UsernameError), #[error(transparent)] - PassphraseError(#[from] PassphraseError), + Passphrase(#[from] PassphraseError), #[error(transparent)] - PasswordError(#[from] PasswordError), + Password(#[from] PasswordError), // Vault #[error(transparent)] @@ -61,7 +61,7 @@ pub enum Error { Totp(#[from] bitwarden_vault::TotpError), #[error(transparent)] - ExportError(#[from] ExportError), + Export(#[from] ExportError), // Fido #[error(transparent)] @@ -71,11 +71,9 @@ pub enum Error { #[error(transparent)] SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError), #[error(transparent)] - CredentialsForAutofillError(#[from] bitwarden_fido::CredentialsForAutofillError), + CredentialsForAutofill(#[from] bitwarden_fido::CredentialsForAutofillError), #[error(transparent)] - DecryptFido2AutofillCredentialsError( - #[from] bitwarden_fido::DecryptFido2AutofillCredentialsError, - ), + DecryptFido2AutofillCredentials(#[from] bitwarden_fido::DecryptFido2AutofillCredentialsError), #[error(transparent)] Fido2Client(#[from] bitwarden_fido::Fido2ClientError), } diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 99c99864..db42ae0c 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -52,7 +52,7 @@ impl ClientFido2 { .0 .fido2() .decrypt_fido2_autofill_credentials(cipher_view) - .map_err(Error::DecryptFido2AutofillCredentialsError)?; + .map_err(Error::DecryptFido2AutofillCredentials)?; Ok(result) } @@ -122,7 +122,7 @@ impl ClientFido2Authenticator { let result = auth .credentials_for_autofill() .await - .map_err(Error::CredentialsForAutofillError)?; + .map_err(Error::CredentialsForAutofill)?; Ok(result) } } diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index d816e0f8..04476006 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -27,7 +27,7 @@ impl ClientGenerators { .0 .generator() .password(settings) - .map_err(Error::PasswordError)?) + .map_err(Error::Password)?) } /// Generate Passphrase @@ -37,7 +37,7 @@ impl ClientGenerators { .0 .generator() .passphrase(settings) - .map_err(Error::PassphraseError)?) + .map_err(Error::Passphrase)?) } /// Generate Username @@ -48,7 +48,7 @@ impl ClientGenerators { .generator() .username(settings) .await - .map_err(Error::UsernameError)?) + .map_err(Error::Username)?) } } @@ -69,7 +69,7 @@ impl ClientExporters { .0 .exporters() .export_vault(folders, ciphers, format) - .map_err(Error::ExportError)?) + .map_err(Error::Export)?) } /// Export organization vault @@ -84,7 +84,7 @@ impl ClientExporters { .0 .exporters() .export_organization_vault(collections, ciphers, format) - .map_err(Error::ExportError)?) + .map_err(Error::Export)?) } /// Credential Exchange Format (CXF) @@ -99,7 +99,7 @@ impl ClientExporters { .0 .exporters() .export_cxf(account, ciphers) - .map_err(Error::ExportError)?) + .map_err(Error::Export)?) } /// Credential Exchange Format (CXF) @@ -114,6 +114,6 @@ impl ClientExporters { .0 .exporters() .import_cxf(payload) - .map_err(Error::ExportError)?) + .map_err(Error::Export)?) } } From ef9c08423d5af296256b2301d05aa7431c4adee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garci=CC=81a?= Date: Mon, 16 Dec 2024 14:48:52 +0100 Subject: [PATCH 5/5] Move lint after upload --- .github/workflows/lint.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3a2891c4..b49db795 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -44,6 +44,11 @@ jobs: env: RUSTFLAGS: "-D warnings" + - name: Upload Clippy results to GitHub + uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 + with: + sarif_file: clippy_result.sarif + # Run it again but this time without the sarif output so that the # status code of the command is caught and reported as failed in GitHub. # This should be cached from the previous step and should be fast. @@ -52,11 +57,6 @@ jobs: env: RUSTFLAGS: "-D warnings" - - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 - with: - sarif_file: clippy_result.sarif - - name: Install cargo-sort run: cargo install cargo-sort --locked --git https://github.com/DevinR528/cargo-sort.git --rev f5047967021cbb1f822faddc355b3b07674305a1