From 16a12c03730bba2d2ba0800ae358cc4080908be9 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:04:24 +0100 Subject: [PATCH 01/23] Add initial tracing --- Cargo.lock | 63 +++++++++- Cargo.toml | 1 + crates/bitwarden-core/Cargo.toml | 2 + .../src/client/encryption_settings.rs | 9 +- crates/bitwarden-crypto/Cargo.toml | 2 + .../src/traits/decryptable.rs | 4 + crates/bitwarden-log-error-macro/Cargo.toml | 26 +++++ crates/bitwarden-log-error-macro/src/lib.rs | 108 ++++++++++++++++++ crates/bitwarden-vault/Cargo.toml | 3 + crates/bitwarden-vault/src/cipher/cipher.rs | 4 + crates/bitwarden-wasm-internal/Cargo.toml | 4 + crates/bitwarden-wasm-internal/src/init.rs | 13 ++- 12 files changed, 234 insertions(+), 5 deletions(-) create mode 100644 crates/bitwarden-log-error-macro/Cargo.toml create mode 100644 crates/bitwarden-log-error-macro/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index d36fda4dc..015c7fc63 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -517,6 +517,7 @@ dependencies = [ "bitwarden-crypto", "bitwarden-encoding", "bitwarden-error", + "bitwarden-log-error-macro", "bitwarden-state", "bitwarden-uniffi-error", "bitwarden-uuid", @@ -536,6 +537,7 @@ dependencies = [ "serde_repr", "thiserror 2.0.12", "tokio", + "tracing", "tsify", "uniffi", "uuid", @@ -553,6 +555,7 @@ dependencies = [ "argon2", "bitwarden-encoding", "bitwarden-error", + "bitwarden-log-error-macro", "bitwarden-uniffi-error", "cbc", "chacha20poly1305", @@ -579,6 +582,7 @@ dependencies = [ "sha2", "subtle", "thiserror 2.0.12", + "tracing", "tsify", "typenum", "uniffi", @@ -724,6 +728,15 @@ dependencies = [ "wasm-bindgen-futures", ] +[[package]] +name = "bitwarden-log-error-macro" +version = "1.0.0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "bitwarden-pm" version = "1.0.0" @@ -918,6 +931,7 @@ dependencies = [ "bitwarden-crypto", "bitwarden-encoding", "bitwarden-error", + "bitwarden-log-error-macro", "bitwarden-state", "bitwarden-test", "bitwarden-uuid", @@ -925,6 +939,7 @@ dependencies = [ "data-encoding", "futures", "hmac", + "log", "percent-encoding", "reqwest", "serde", @@ -934,6 +949,7 @@ dependencies = [ "sha2", "thiserror 2.0.12", "tokio", + "tracing", "tsify", "uniffi", "uuid", @@ -953,6 +969,7 @@ dependencies = [ "bitwarden-crypto", "bitwarden-error", "bitwarden-ipc", + "bitwarden-log-error-macro", "bitwarden-pm", "bitwarden-ssh", "bitwarden-state", @@ -962,6 +979,9 @@ dependencies = [ "console_log", "log", "serde", + "tracing", + "tracing-subscriber", + "tracing-web", "tsify", "wasm-bindgen", "wasm-bindgen-futures", @@ -5090,9 +5110,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tracing-core" version = "0.1.34" @@ -5113,15 +5145,42 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + [[package]] name = "tracing-subscriber" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ + "nu-ansi-term", "sharded-slab", + "smallvec", "thread_local", "tracing-core", + "tracing-log", +] + +[[package]] +name = "tracing-web" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e6a141feebd51f8d91ebfd785af50fca223c570b86852166caa3b141defe7c" +dependencies = [ + "js-sys", + "tracing-core", + "tracing-subscriber", + "wasm-bindgen", + "web-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 83a055ea6..af00e2f34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=1.0.0" bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" } bitwarden-ipc = { path = "crates/bitwarden-ipc", version = "=1.0.0" } +bitwarden-log-error-macro = { path = "crates/bitwarden-log-error-macro", version = "=1.0.0" } bitwarden-pm = { path = "crates/bitwarden-pm", version = "=1.0.0" } bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" } bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" } diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 86c184a90..6f999eb03 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -43,6 +43,7 @@ bitwarden-api-identity = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } +bitwarden-log-error-macro = { workspace = true } bitwarden-state = { workspace = true } bitwarden-uniffi-error = { workspace = true, optional = true } bitwarden-uuid = { workspace = true } @@ -59,6 +60,7 @@ serde_json = { workspace = true } serde_qs = { workspace = true } serde_repr = { workspace = true } thiserror = { workspace = true } +tracing = { workspace = true } tsify = { workspace = true, optional = true } uniffi = { workspace = true, optional = true, features = ["tokio"] } uuid = { workspace = true } diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index d7411bc86..06bf2d6ea 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -10,7 +10,9 @@ use bitwarden_crypto::{ use bitwarden_crypto::{KeyStore, SymmetricCryptoKey}; use bitwarden_error::bitwarden_error; #[cfg(feature = "internal")] -use log::warn; +use bitwarden_log_error_macro::log_error; +#[cfg(feature = "internal")] +use log::{info, warn}; use thiserror::Error; #[cfg(any(feature = "secrets", feature = "internal"))] @@ -108,11 +110,13 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] + #[log_error] fn init_v1( user_key: Aes256CbcHmacKey, private_key: EncString, store: &KeyStore, ) -> Result<(), EncryptionSettingsError> { + info!("Account has v1 encryption keys"); let user_key = SymmetricCryptoKey::Aes256CbcHmacKey(user_key); let private_key = { @@ -146,6 +150,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] + #[log_error] fn init_v2( user_key: XChaCha20Poly1305Key, private_key: EncString, @@ -154,6 +159,7 @@ impl EncryptionSettings { store: &KeyStore, sdk_security_state: &RwLock>, ) -> Result<(), EncryptionSettingsError> { + info!("Account has v2 encryption keys"); use crate::key_management::SecurityState; let user_key = SymmetricCryptoKey::XChaCha20Poly1305Key(user_key); @@ -200,6 +206,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] + #[log_error] pub(crate) fn set_org_keys( org_enc_keys: Vec<(OrganizationId, UnsignedSharedKey)>, store: &KeyStore, diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index 05f064588..dd80a7a4c 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -33,6 +33,7 @@ argon2 = { version = "=0.6.0-rc.1", features = [ ], default-features = false } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } +bitwarden-log-error-macro = { workspace = true } bitwarden-uniffi-error = { workspace = true, optional = true } cbc = { version = ">=0.1.2, <0.2", features = ["alloc", "zeroize"] } chacha20poly1305 = { version = "0.10.1" } @@ -59,6 +60,7 @@ subtle = ">=2.5.0, <3.0" thiserror = { workspace = true } tsify = { workspace = true, optional = true } typenum = ">=1.18.0, <1.19.0" +tracing = { workspace = true } uniffi = { workspace = true, optional = true } uuid = { workspace = true } wasm-bindgen = { workspace = true, optional = true } diff --git a/crates/bitwarden-crypto/src/traits/decryptable.rs b/crates/bitwarden-crypto/src/traits/decryptable.rs index e517fdf61..9a8d09002 100644 --- a/crates/bitwarden-crypto/src/traits/decryptable.rs +++ b/crates/bitwarden-crypto/src/traits/decryptable.rs @@ -1,3 +1,5 @@ +use bitwarden_log_error_macro::log_error; + use crate::{CryptoError, EncString, KeyId, KeyIds, store::KeyStoreContext}; /// A decryption operation that takes the input value and decrypts it into the output value. @@ -9,6 +11,7 @@ pub trait Decryptable { } impl Decryptable> for EncString { + #[log_error] fn decrypt( &self, ctx: &mut KeyStoreContext, @@ -19,6 +22,7 @@ impl Decryptable> for EncString { } impl Decryptable for EncString { + #[log_error] fn decrypt( &self, ctx: &mut KeyStoreContext, diff --git a/crates/bitwarden-log-error-macro/Cargo.toml b/crates/bitwarden-log-error-macro/Cargo.toml new file mode 100644 index 000000000..efe05f684 --- /dev/null +++ b/crates/bitwarden-log-error-macro/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "bitwarden-log-error-macro" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +readme.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[lints] +workspace = true + +[lib] +proc-macro = true + +[dependencies] +quote = "1" +syn = { version = "2", features = ["full"] } +proc-macro2 = "1" \ No newline at end of file diff --git a/crates/bitwarden-log-error-macro/src/lib.rs b/crates/bitwarden-log-error-macro/src/lib.rs new file mode 100644 index 000000000..d892926e1 --- /dev/null +++ b/crates/bitwarden-log-error-macro/src/lib.rs @@ -0,0 +1,108 @@ +//! A procedural macro crate that provides the `log_error` attribute macro for logging errors. + +use proc_macro::TokenStream; +use quote::quote; +use syn::{Expr, Ident, ItemFn, Token, parse::Parse, parse::ParseStream, parse_macro_input}; + +/// Attribute parameters for the log_error macro +struct LogErrorArgs { + fields: Vec<(Ident, Expr)>, +} + +impl Parse for LogErrorArgs { + fn parse(input: ParseStream) -> syn::Result { + let mut fields = Vec::new(); + + while !input.is_empty() { + let key: Ident = input.parse()?; + input.parse::()?; + let value: Expr = input.parse()?; + + fields.push((key, value)); + + // Handle trailing comma + if !input.is_empty() { + input.parse::()?; + } + } + + Ok(LogErrorArgs { fields }) + } +} + +/// A procedural macro that logs errors returned by the annotated function. +/// +/// # Parameters +/// +/// Accepts any number of key-value pairs that will be added as fields to the tracing span. +/// +/// # Examples +/// +/// ```rust +/// #[log_error(id = "my_function")] +/// async fn my_function() -> Result<(), MyError> { +/// // function body +/// } +/// +/// #[log_error(user_id = &self.user_id, action = "decrypt")] +/// async fn decrypt(&self) -> Result<(), MyError> { +/// // function body +/// } +/// ``` +#[proc_macro_attribute] +pub fn log_error(attr: TokenStream, item: TokenStream) -> TokenStream { + let args = parse_macro_input!(attr as LogErrorArgs); + let input = parse_macro_input!(item as ItemFn); + let vis = &input.vis; + let sig = &input.sig; + let block = &input.block; + let name = &sig.ident; + + let span_creation = if args.fields.is_empty() { + let name_str = name.to_string(); + quote! { + let __span = tracing::info_span!(#name_str); + } + } else { + // Generate field assignments for the span + let field_assignments = args.fields.iter().map(|(key, value)| { + let var_name = syn::Ident::new(&format!("__span_field_{}", key), key.span()); + quote! { + let #var_name = format!("{:?}", #value); + } + }); + + let field_params = args.fields.iter().map(|(key, _value)| { + let var_name = syn::Ident::new(&format!("__span_field_{}", key), key.span()); + let key_str = key.to_string(); + quote! { + #key_str = %#var_name + } + }); + + quote! { + #(#field_assignments)* + let __span = tracing::span!(tracing::Level::INFO, "log", #(#field_params),*); + } + }; + + let result = quote! { + #vis #sig { + #span_creation + let __guard = __span.enter(); + + let __log_error_result = (|| { + #block + })(); + + if let Err(ref e) = __log_error_result { + tracing::error!(error = %e, "Function returned error"); + } + + drop(__guard); + __log_error_result + } + }; + + result.into() +} diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index e6eb2abda..dd3715643 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -37,12 +37,14 @@ bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } +bitwarden-log-error-macro = { workspace = true } bitwarden-state = { workspace = true } bitwarden-uuid = { workspace = true } chrono = { workspace = true } data-encoding = { workspace = true } futures = { workspace = true } hmac = ">=0.12.1, <0.13" +log = { workspace = true } percent-encoding = ">=2.1, <3.0" reqwest = { workspace = true } serde = { workspace = true } @@ -51,6 +53,7 @@ serde_repr = { workspace = true } sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" thiserror = { workspace = true } +tracing = { workspace = true } tsify = { workspace = true, optional = true } uniffi = { workspace = true, optional = true } uuid = { workspace = true } diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 9b6854f76..0d8c4ef55 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -16,12 +16,14 @@ use bitwarden_crypto::{ PrimitiveEncryptable, }; use bitwarden_error::bitwarden_error; +use bitwarden_log_error_macro::log_error; use bitwarden_state::repository::RepositoryError; use bitwarden_uuid::uuid_newtype; use chrono::{DateTime, SecondsFormat, Utc}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use thiserror::Error; +use tracing::info; #[cfg(feature = "wasm")] use tsify::Tsify; #[cfg(feature = "wasm")] @@ -512,6 +514,7 @@ impl CompositeEncryptable for CipherView { } impl Decryptable for Cipher { + #[log_error(cipher_id = &self.id)] fn decrypt( &self, ctx: &mut KeyStoreContext, @@ -573,6 +576,7 @@ impl Cipher { /// * `key` - The key to use to decrypt the cipher key, this should be the user or organization /// key /// * `ciphers_key` - The encrypted cipher key + #[log_error] pub(super) fn decrypt_cipher_key( ctx: &mut KeyStoreContext, key: SymmetricKeyId, diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index ed5576fe8..052c0efad 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -27,6 +27,7 @@ bitwarden-core = { workspace = true, features = ["wasm", "internal"] } bitwarden-crypto = { workspace = true, features = ["wasm"] } bitwarden-error = { workspace = true } bitwarden-ipc = { workspace = true, features = ["wasm"] } +bitwarden-log-error-macro = { workspace = true } bitwarden-pm = { workspace = true, features = ["wasm"] } bitwarden-ssh = { workspace = true, features = ["wasm"] } bitwarden-state = { workspace = true, features = ["wasm"] } @@ -36,6 +37,9 @@ console_error_panic_hook = "0.1.7" console_log = { version = "1.0.0", features = ["color"] } log = "0.4.20" serde = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = "0.3.20" +tracing-web = "0.1.3" tsify = { workspace = true } # When upgrading wasm-bindgen, make sure to update the version in the workflows! wasm-bindgen = { version = "=0.2.105", features = ["serde-serialize"] } diff --git a/crates/bitwarden-wasm-internal/src/init.rs b/crates/bitwarden-wasm-internal/src/init.rs index 0fd20f069..bcc46b78c 100644 --- a/crates/bitwarden-wasm-internal/src/init.rs +++ b/crates/bitwarden-wasm-internal/src/init.rs @@ -1,4 +1,7 @@ -use log::{Level, set_max_level}; +use log::{Level, info, set_max_level}; +use tracing_subscriber::fmt::format::Pretty; +use tracing_subscriber::prelude::*; +use tracing_web::{MakeWebConsoleWriter, performance_layer}; use wasm_bindgen::prelude::*; #[wasm_bindgen] @@ -9,7 +12,6 @@ pub enum LogLevel { Warn, Error, } - fn convert_level(level: LogLevel) -> Level { match level { LogLevel::Trace => Level::Trace, @@ -30,6 +32,13 @@ pub fn set_log_level(level: LogLevel) { #[wasm_bindgen] pub fn init_sdk(log_level: Option) { console_error_panic_hook::set_once(); + let fmt_layer = tracing_subscriber::fmt::layer() + .with_ansi(false) // Only partially supported across browsers + .without_time() // Time is not supported in wasm + .with_writer(MakeWebConsoleWriter::new()); + tracing_subscriber::registry().with(fmt_layer).init(); + tracing::info!("Initialized tracing"); + let log_level = convert_level(log_level.unwrap_or(LogLevel::Info)); if let Err(_e) = console_log::init_with_level(log_level) { set_max_level(log_level.to_level_filter()) From fd78440fb789568b1492eef41952fae91e0873ba Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:19:43 +0100 Subject: [PATCH 02/23] Add some more logging --- crates/bitwarden-vault/src/cipher/cipher.rs | 2 +- crates/bitwarden-vault/src/folder/folder_client.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 0d8c4ef55..fe964089a 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -514,7 +514,7 @@ impl CompositeEncryptable for CipherView { } impl Decryptable for Cipher { - #[log_error(cipher_id = &self.id)] + #[log_error(cipher_id = &self.id, org_id = &self.organization_id, has_cipher_key = self.key.is_some())] fn decrypt( &self, ctx: &mut KeyStoreContext, diff --git a/crates/bitwarden-vault/src/folder/folder_client.rs b/crates/bitwarden-vault/src/folder/folder_client.rs index 26a202031..9bef3a072 100644 --- a/crates/bitwarden-vault/src/folder/folder_client.rs +++ b/crates/bitwarden-vault/src/folder/folder_client.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use bitwarden_core::Client; +use bitwarden_log_error_macro::log_error; use bitwarden_state::repository::{Repository, RepositoryError}; #[cfg(feature = "wasm")] use wasm_bindgen::prelude::*; @@ -28,6 +29,7 @@ impl FoldersClient { } /// Encrypt a [Folder] to [FolderView]. + #[log_error(folder_id = &folder.id)] pub fn decrypt(&self, folder: Folder) -> Result { let key_store = self.client.internal.get_key_store(); let folder_view = key_store.decrypt(&folder)?; From eb9396cf91fc31575be9d0ba94cfc637b850449d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:28:37 +0100 Subject: [PATCH 03/23] Fix build --- Cargo.toml | 1 + crates/bitwarden-vault/src/folder/folder_client.rs | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index af00e2f34..fd41db299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ serde_repr = ">=0.1.12, <0.2" serde-wasm-bindgen = ">=0.6.0, <0.7" syn = ">=2.0.87, <3" thiserror = ">=1.0.40, <3" +tracing = "= 0.1.41" tokio = { version = "1.36.0", features = ["macros"] } tsify = { version = ">=0.5.5, <0.6", features = [ "js", diff --git a/crates/bitwarden-vault/src/folder/folder_client.rs b/crates/bitwarden-vault/src/folder/folder_client.rs index 9bef3a072..26a202031 100644 --- a/crates/bitwarden-vault/src/folder/folder_client.rs +++ b/crates/bitwarden-vault/src/folder/folder_client.rs @@ -1,7 +1,6 @@ use std::sync::Arc; use bitwarden_core::Client; -use bitwarden_log_error_macro::log_error; use bitwarden_state::repository::{Repository, RepositoryError}; #[cfg(feature = "wasm")] use wasm_bindgen::prelude::*; @@ -29,7 +28,6 @@ impl FoldersClient { } /// Encrypt a [Folder] to [FolderView]. - #[log_error(folder_id = &folder.id)] pub fn decrypt(&self, folder: Folder) -> Result { let key_store = self.client.internal.get_key_store(); let folder_view = key_store.decrypt(&folder)?; From d3a73b706275dfdaac4f7f676596e3d04ffa5f38 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:29:46 +0100 Subject: [PATCH 04/23] Cleanup --- crates/bitwarden-log-error-macro/Cargo.toml | 2 +- crates/bitwarden-vault/src/cipher/cipher.rs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bitwarden-log-error-macro/Cargo.toml b/crates/bitwarden-log-error-macro/Cargo.toml index efe05f684..f0b177a77 100644 --- a/crates/bitwarden-log-error-macro/Cargo.toml +++ b/crates/bitwarden-log-error-macro/Cargo.toml @@ -23,4 +23,4 @@ proc-macro = true [dependencies] quote = "1" syn = { version = "2", features = ["full"] } -proc-macro2 = "1" \ No newline at end of file +proc-macro2 = "1" diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index fe964089a..02fc7b71b 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -23,7 +23,6 @@ use chrono::{DateTime, SecondsFormat, Utc}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use thiserror::Error; -use tracing::info; #[cfg(feature = "wasm")] use tsify::Tsify; #[cfg(feature = "wasm")] From c18ce0cfd8e754787d84e8ba722db899b835b2fe Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:33:35 +0100 Subject: [PATCH 05/23] Cargo fmt --- crates/bitwarden-wasm-internal/src/init.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/bitwarden-wasm-internal/src/init.rs b/crates/bitwarden-wasm-internal/src/init.rs index bcc46b78c..9c5b716e7 100644 --- a/crates/bitwarden-wasm-internal/src/init.rs +++ b/crates/bitwarden-wasm-internal/src/init.rs @@ -1,6 +1,5 @@ use log::{Level, info, set_max_level}; -use tracing_subscriber::fmt::format::Pretty; -use tracing_subscriber::prelude::*; +use tracing_subscriber::{fmt::format::Pretty, prelude::*}; use tracing_web::{MakeWebConsoleWriter, performance_layer}; use wasm_bindgen::prelude::*; From bfbcebbbeb84588cc42597bcfab08545249de137 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 11:37:03 +0100 Subject: [PATCH 06/23] Add span --- crates/bitwarden-core/src/client/internal.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index dbfe7ccb7..e89b52dbe 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -304,6 +304,12 @@ impl InternalClient { user_key: SymmetricCryptoKey, key_state: UserKeyState, ) -> Result<(), EncryptionSettingsError> { + let span = tracing::info_span!( + "User Crypto Initialization", + user_id = ?self.get_user_id(), + ); + let _enter = span.enter(); + match user_key { SymmetricCryptoKey::Aes256CbcHmacKey(ref user_key) => { EncryptionSettings::new_decrypted_key( From 6fa35f5065f25ed1f08fbdfbc51373d00834aca3 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 17:23:22 +0100 Subject: [PATCH 07/23] Cleanup --- Cargo.lock | 13 --- Cargo.toml | 1 - crates/bitwarden-core/Cargo.toml | 1 - .../src/client/encryption_settings.rs | 20 +++- crates/bitwarden-crypto/Cargo.toml | 1 - .../src/traits/decryptable.rs | 6 +- crates/bitwarden-log-error-macro/Cargo.toml | 26 ----- crates/bitwarden-log-error-macro/src/lib.rs | 108 ------------------ crates/bitwarden-vault/Cargo.toml | 1 - crates/bitwarden-vault/src/cipher/cipher.rs | 6 +- crates/bitwarden-wasm-internal/Cargo.toml | 1 - 11 files changed, 21 insertions(+), 163 deletions(-) delete mode 100644 crates/bitwarden-log-error-macro/Cargo.toml delete mode 100644 crates/bitwarden-log-error-macro/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 015c7fc63..cbd1449b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -517,7 +517,6 @@ dependencies = [ "bitwarden-crypto", "bitwarden-encoding", "bitwarden-error", - "bitwarden-log-error-macro", "bitwarden-state", "bitwarden-uniffi-error", "bitwarden-uuid", @@ -555,7 +554,6 @@ dependencies = [ "argon2", "bitwarden-encoding", "bitwarden-error", - "bitwarden-log-error-macro", "bitwarden-uniffi-error", "cbc", "chacha20poly1305", @@ -728,15 +726,6 @@ dependencies = [ "wasm-bindgen-futures", ] -[[package]] -name = "bitwarden-log-error-macro" -version = "1.0.0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "bitwarden-pm" version = "1.0.0" @@ -931,7 +920,6 @@ dependencies = [ "bitwarden-crypto", "bitwarden-encoding", "bitwarden-error", - "bitwarden-log-error-macro", "bitwarden-state", "bitwarden-test", "bitwarden-uuid", @@ -969,7 +957,6 @@ dependencies = [ "bitwarden-crypto", "bitwarden-error", "bitwarden-ipc", - "bitwarden-log-error-macro", "bitwarden-pm", "bitwarden-ssh", "bitwarden-state", diff --git a/Cargo.toml b/Cargo.toml index fd41db299..078cdcd31 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,6 @@ bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=1.0.0" bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" } bitwarden-ipc = { path = "crates/bitwarden-ipc", version = "=1.0.0" } -bitwarden-log-error-macro = { path = "crates/bitwarden-log-error-macro", version = "=1.0.0" } bitwarden-pm = { path = "crates/bitwarden-pm", version = "=1.0.0" } bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" } bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" } diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 6f999eb03..ea091c4bd 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -43,7 +43,6 @@ bitwarden-api-identity = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } -bitwarden-log-error-macro = { workspace = true } bitwarden-state = { workspace = true } bitwarden-uniffi-error = { workspace = true, optional = true } bitwarden-uuid = { workspace = true } diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 06bf2d6ea..a11ecccf0 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -10,10 +10,10 @@ use bitwarden_crypto::{ use bitwarden_crypto::{KeyStore, SymmetricCryptoKey}; use bitwarden_error::bitwarden_error; #[cfg(feature = "internal")] -use bitwarden_log_error_macro::log_error; -#[cfg(feature = "internal")] use log::{info, warn}; use thiserror::Error; +#[cfg(feature = "internal")] +use tracing::instrument; #[cfg(any(feature = "secrets", feature = "internal"))] use crate::OrganizationId; @@ -110,7 +110,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[log_error] + #[instrument(err, skip(user_key, private_key, store))] fn init_v1( user_key: Aes256CbcHmacKey, private_key: EncString, @@ -150,7 +150,17 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[log_error] + #[instrument( + err, + skip( + user_key, + private_key, + signing_key, + security_state, + store, + sdk_security_state + ) + )] fn init_v2( user_key: XChaCha20Poly1305Key, private_key: EncString, @@ -206,7 +216,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[log_error] + #[instrument(err, skip(org_enc_keys, store))] pub(crate) fn set_org_keys( org_enc_keys: Vec<(OrganizationId, UnsignedSharedKey)>, store: &KeyStore, diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index dd80a7a4c..f42966aba 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -33,7 +33,6 @@ argon2 = { version = "=0.6.0-rc.1", features = [ ], default-features = false } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } -bitwarden-log-error-macro = { workspace = true } bitwarden-uniffi-error = { workspace = true, optional = true } cbc = { version = ">=0.1.2, <0.2", features = ["alloc", "zeroize"] } chacha20poly1305 = { version = "0.10.1" } diff --git a/crates/bitwarden-crypto/src/traits/decryptable.rs b/crates/bitwarden-crypto/src/traits/decryptable.rs index 9a8d09002..d018e96f0 100644 --- a/crates/bitwarden-crypto/src/traits/decryptable.rs +++ b/crates/bitwarden-crypto/src/traits/decryptable.rs @@ -1,4 +1,4 @@ -use bitwarden_log_error_macro::log_error; +use tracing::instrument; use crate::{CryptoError, EncString, KeyId, KeyIds, store::KeyStoreContext}; @@ -11,7 +11,7 @@ pub trait Decryptable { } impl Decryptable> for EncString { - #[log_error] + #[instrument(err, skip(self, ctx, key))] fn decrypt( &self, ctx: &mut KeyStoreContext, @@ -22,7 +22,7 @@ impl Decryptable> for EncString { } impl Decryptable for EncString { - #[log_error] + #[instrument(err, skip(self, ctx, key))] fn decrypt( &self, ctx: &mut KeyStoreContext, diff --git a/crates/bitwarden-log-error-macro/Cargo.toml b/crates/bitwarden-log-error-macro/Cargo.toml deleted file mode 100644 index f0b177a77..000000000 --- a/crates/bitwarden-log-error-macro/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "bitwarden-log-error-macro" -description = """ -Internal crate for the bitwarden crate. Do not use. -""" - -version.workspace = true -authors.workspace = true -edition.workspace = true -rust-version.workspace = true -readme.workspace = true -homepage.workspace = true -repository.workspace = true -license-file.workspace = true -keywords.workspace = true - -[lints] -workspace = true - -[lib] -proc-macro = true - -[dependencies] -quote = "1" -syn = { version = "2", features = ["full"] } -proc-macro2 = "1" diff --git a/crates/bitwarden-log-error-macro/src/lib.rs b/crates/bitwarden-log-error-macro/src/lib.rs deleted file mode 100644 index d892926e1..000000000 --- a/crates/bitwarden-log-error-macro/src/lib.rs +++ /dev/null @@ -1,108 +0,0 @@ -//! A procedural macro crate that provides the `log_error` attribute macro for logging errors. - -use proc_macro::TokenStream; -use quote::quote; -use syn::{Expr, Ident, ItemFn, Token, parse::Parse, parse::ParseStream, parse_macro_input}; - -/// Attribute parameters for the log_error macro -struct LogErrorArgs { - fields: Vec<(Ident, Expr)>, -} - -impl Parse for LogErrorArgs { - fn parse(input: ParseStream) -> syn::Result { - let mut fields = Vec::new(); - - while !input.is_empty() { - let key: Ident = input.parse()?; - input.parse::()?; - let value: Expr = input.parse()?; - - fields.push((key, value)); - - // Handle trailing comma - if !input.is_empty() { - input.parse::()?; - } - } - - Ok(LogErrorArgs { fields }) - } -} - -/// A procedural macro that logs errors returned by the annotated function. -/// -/// # Parameters -/// -/// Accepts any number of key-value pairs that will be added as fields to the tracing span. -/// -/// # Examples -/// -/// ```rust -/// #[log_error(id = "my_function")] -/// async fn my_function() -> Result<(), MyError> { -/// // function body -/// } -/// -/// #[log_error(user_id = &self.user_id, action = "decrypt")] -/// async fn decrypt(&self) -> Result<(), MyError> { -/// // function body -/// } -/// ``` -#[proc_macro_attribute] -pub fn log_error(attr: TokenStream, item: TokenStream) -> TokenStream { - let args = parse_macro_input!(attr as LogErrorArgs); - let input = parse_macro_input!(item as ItemFn); - let vis = &input.vis; - let sig = &input.sig; - let block = &input.block; - let name = &sig.ident; - - let span_creation = if args.fields.is_empty() { - let name_str = name.to_string(); - quote! { - let __span = tracing::info_span!(#name_str); - } - } else { - // Generate field assignments for the span - let field_assignments = args.fields.iter().map(|(key, value)| { - let var_name = syn::Ident::new(&format!("__span_field_{}", key), key.span()); - quote! { - let #var_name = format!("{:?}", #value); - } - }); - - let field_params = args.fields.iter().map(|(key, _value)| { - let var_name = syn::Ident::new(&format!("__span_field_{}", key), key.span()); - let key_str = key.to_string(); - quote! { - #key_str = %#var_name - } - }); - - quote! { - #(#field_assignments)* - let __span = tracing::span!(tracing::Level::INFO, "log", #(#field_params),*); - } - }; - - let result = quote! { - #vis #sig { - #span_creation - let __guard = __span.enter(); - - let __log_error_result = (|| { - #block - })(); - - if let Err(ref e) = __log_error_result { - tracing::error!(error = %e, "Function returned error"); - } - - drop(__guard); - __log_error_result - } - }; - - result.into() -} diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index dd3715643..e6177d34c 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -37,7 +37,6 @@ bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } bitwarden-encoding = { workspace = true } bitwarden-error = { workspace = true } -bitwarden-log-error-macro = { workspace = true } bitwarden-state = { workspace = true } bitwarden-uuid = { workspace = true } chrono = { workspace = true } diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 02fc7b71b..ef62f1c5b 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -16,13 +16,13 @@ use bitwarden_crypto::{ PrimitiveEncryptable, }; use bitwarden_error::bitwarden_error; -use bitwarden_log_error_macro::log_error; use bitwarden_state::repository::RepositoryError; use bitwarden_uuid::uuid_newtype; use chrono::{DateTime, SecondsFormat, Utc}; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use thiserror::Error; +use tracing::instrument; #[cfg(feature = "wasm")] use tsify::Tsify; #[cfg(feature = "wasm")] @@ -513,7 +513,7 @@ impl CompositeEncryptable for CipherView { } impl Decryptable for Cipher { - #[log_error(cipher_id = &self.id, org_id = &self.organization_id, has_cipher_key = self.key.is_some())] + #[instrument(err, skip(self, ctx, key), fields(cipher_id = ?self.id, org_id = ?self.organization_id, kind = ?self.r#type))] fn decrypt( &self, ctx: &mut KeyStoreContext, @@ -575,7 +575,7 @@ impl Cipher { /// * `key` - The key to use to decrypt the cipher key, this should be the user or organization /// key /// * `ciphers_key` - The encrypted cipher key - #[log_error] + #[instrument(err, skip(ctx, key, ciphers_key))] pub(super) fn decrypt_cipher_key( ctx: &mut KeyStoreContext, key: SymmetricKeyId, diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index 052c0efad..459a576f3 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -27,7 +27,6 @@ bitwarden-core = { workspace = true, features = ["wasm", "internal"] } bitwarden-crypto = { workspace = true, features = ["wasm"] } bitwarden-error = { workspace = true } bitwarden-ipc = { workspace = true, features = ["wasm"] } -bitwarden-log-error-macro = { workspace = true } bitwarden-pm = { workspace = true, features = ["wasm"] } bitwarden-ssh = { workspace = true, features = ["wasm"] } bitwarden-state = { workspace = true, features = ["wasm"] } From 2384c07cc80ee00812a072a6ce7305b4e8322872 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 19:25:59 +0100 Subject: [PATCH 08/23] Purecrypto tracing --- .../bitwarden-crypto/src/enc_string/symmetric.rs | 2 ++ crates/bitwarden-wasm-internal/src/init.rs | 6 +++--- .../bitwarden-wasm-internal/src/pure_crypto.rs | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 72557bdb0..e9761483a 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -3,6 +3,7 @@ use std::{borrow::Cow, str::FromStr}; use bitwarden_encoding::{B64, FromStrVisitor}; use coset::{CborSerializable, iana::KeyOperation}; use serde::Deserialize; +use tracing::instrument; use super::{check_length, from_b64, from_b64_vec, split_enc_string}; use crate::{ @@ -346,6 +347,7 @@ impl KeyEncryptable for &str { } impl KeyDecryptable for EncString { + #[instrument(err, skip(self, key))] fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result { let dec: Vec = self.decrypt_with_key(key)?; String::from_utf8(dec).map_err(|_| CryptoError::InvalidUtf8String) diff --git a/crates/bitwarden-wasm-internal/src/init.rs b/crates/bitwarden-wasm-internal/src/init.rs index 9c5b716e7..5334ad869 100644 --- a/crates/bitwarden-wasm-internal/src/init.rs +++ b/crates/bitwarden-wasm-internal/src/init.rs @@ -1,6 +1,6 @@ -use log::{Level, info, set_max_level}; -use tracing_subscriber::{fmt::format::Pretty, prelude::*}; -use tracing_web::{MakeWebConsoleWriter, performance_layer}; +use log::{Level, set_max_level}; +use tracing_subscriber::prelude::*; +use tracing_web::MakeWebConsoleWriter; use wasm_bindgen::prelude::*; #[wasm_bindgen] diff --git a/crates/bitwarden-wasm-internal/src/pure_crypto.rs b/crates/bitwarden-wasm-internal/src/pure_crypto.rs index 9bbe13633..e54d3f49e 100644 --- a/crates/bitwarden-wasm-internal/src/pure_crypto.rs +++ b/crates/bitwarden-wasm-internal/src/pure_crypto.rs @@ -10,6 +10,7 @@ use bitwarden_crypto::{ PrimitiveEncryptable, SignatureAlgorithm, SignedPublicKey, SigningKey, SpkiPublicKeyBytes, SymmetricCryptoKey, UnsignedSharedKey, VerifyingKey, }; +use tracing::instrument; use wasm_bindgen::prelude::*; /// This module represents a stopgap solution to provide access to primitive crypto functions for JS @@ -28,6 +29,7 @@ impl PureCrypto { Self::symmetric_decrypt_string(enc_string, key) } + #[instrument(skip_all)] pub fn symmetric_decrypt_string( enc_string: String, key: Vec, @@ -36,6 +38,7 @@ impl PureCrypto { EncString::from_str(&enc_string)?.decrypt_with_key(&SymmetricCryptoKey::try_from(key)?) } + #[instrument(skip_all)] pub fn symmetric_decrypt_bytes( enc_string: String, key: Vec, @@ -46,6 +49,7 @@ impl PureCrypto { /// DEPRECATED: Use `symmetric_decrypt_filedata` instead. /// Cleanup ticket: + #[instrument(skip_all)] pub fn symmetric_decrypt_array_buffer( enc_bytes: Vec, key: Vec, @@ -53,6 +57,7 @@ impl PureCrypto { Self::symmetric_decrypt_filedata(enc_bytes, key) } + #[instrument(skip_all)] pub fn symmetric_decrypt_filedata( enc_bytes: Vec, key: Vec, @@ -76,6 +81,7 @@ impl PureCrypto { .map(|enc| enc.to_string()) } + #[instrument(skip_all)] pub fn symmetric_encrypt_filedata( plain: Vec, key: Vec, @@ -86,6 +92,7 @@ impl PureCrypto { .to_buffer() } + #[instrument(skip_all)] pub fn decrypt_user_key_with_master_password( encrypted_user_key: String, master_password: String, @@ -100,6 +107,7 @@ impl PureCrypto { Ok(result.to_encoded().to_vec()) } + #[instrument(skip_all)] pub fn encrypt_user_key_with_master_password( user_key: Vec, master_password: String, @@ -147,6 +155,7 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the /// unwrapped key as a serialized byte array. + #[instrument(skip_all)] pub fn unwrap_symmetric_key( wrapped_key: String, wrapping_key: Vec, @@ -169,6 +178,7 @@ impl PureCrypto { /// used. The specific use-case for this function is to enable rotateable key sets, where /// the "public key" is not public, with the intent of preventing the server from being able /// to overwrite the user key unlocked by the rotateable keyset. + #[instrument(skip_all)] pub fn wrap_encapsulation_key( encapsulation_key: Vec, wrapping_key: Vec, @@ -185,6 +195,7 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric /// wrapping key. + #[instrument(skip_all)] pub fn unwrap_encapsulation_key( wrapped_key: String, wrapping_key: Vec, @@ -199,6 +210,7 @@ impl PureCrypto { /// Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping /// key, + #[instrument(skip_all)] pub fn wrap_decapsulation_key( decapsulation_key: Vec, wrapping_key: Vec, @@ -215,6 +227,7 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric /// wrapping key. + #[instrument(skip_all)] pub fn unwrap_decapsulation_key( wrapped_key: String, wrapping_key: Vec, @@ -230,6 +243,7 @@ impl PureCrypto { /// Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key) /// in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so /// the sender's authenticity cannot be verified by the recipient. + #[instrument(skip_all)] pub fn encapsulate_key_unsigned( shared_key: Vec, encapsulation_key: Vec, @@ -246,6 +260,7 @@ impl PureCrypto { /// Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8 /// DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the /// recipient. + #[instrument(skip_all)] pub fn decapsulate_key_unsigned( encapsulated_key: String, decapsulation_key: Vec, @@ -283,6 +298,7 @@ impl PureCrypto { /// identity claimed ownership of the public key. This is a one-sided claim and merely shows /// that the signing identity has the intent to receive messages encrypted to the public /// key. + #[instrument(skip_all)] pub fn verify_and_unwrap_signed_public_key( signed_public_key: Vec, verifying_key: Vec, From b26d0550d8f881e646e7afa850ab223ff89a6502 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 12 Nov 2025 19:29:57 +0100 Subject: [PATCH 09/23] Fix --- crates/bitwarden-crypto/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index f42966aba..ce045167b 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -57,9 +57,9 @@ sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" subtle = ">=2.5.0, <3.0" thiserror = { workspace = true } +tracing = { workspace = true } tsify = { workspace = true, optional = true } typenum = ">=1.18.0, <1.19.0" -tracing = { workspace = true } uniffi = { workspace = true, optional = true } uuid = { workspace = true } wasm-bindgen = { workspace = true, optional = true } From 0c2ef20e9968b44409f614b9596aa90c1c18dd49 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:14:41 +0100 Subject: [PATCH 10/23] Cleanup --- .../src/client/encryption_settings.rs | 14 ++------------ .../bitwarden-crypto/src/enc_string/symmetric.rs | 2 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index a11ecccf0..05f20a375 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -110,7 +110,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[instrument(err, skip(user_key, private_key, store))] + #[instrument(err, skip_all)] fn init_v1( user_key: Aes256CbcHmacKey, private_key: EncString, @@ -150,17 +150,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[instrument( - err, - skip( - user_key, - private_key, - signing_key, - security_state, - store, - sdk_security_state - ) - )] + #[instrument(err, skip_all)] fn init_v2( user_key: XChaCha20Poly1305Key, private_key: EncString, diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index e9761483a..65e1cd1ba 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -347,7 +347,7 @@ impl KeyEncryptable for &str { } impl KeyDecryptable for EncString { - #[instrument(err, skip(self, key))] + #[instrument(err, skip_all)] fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result { let dec: Vec = self.decrypt_with_key(key)?; String::from_utf8(dec).map_err(|_| CryptoError::InvalidUtf8String) From 26006580f9eba652e19ebea228da5cc8cd343754 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:20:23 +0100 Subject: [PATCH 11/23] Cleanup --- crates/bitwarden-crypto/src/traits/decryptable.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden-crypto/src/traits/decryptable.rs b/crates/bitwarden-crypto/src/traits/decryptable.rs index d018e96f0..68c051b3b 100644 --- a/crates/bitwarden-crypto/src/traits/decryptable.rs +++ b/crates/bitwarden-crypto/src/traits/decryptable.rs @@ -11,7 +11,7 @@ pub trait Decryptable { } impl Decryptable> for EncString { - #[instrument(err, skip(self, ctx, key))] + #[instrument(err, skip_all)] fn decrypt( &self, ctx: &mut KeyStoreContext, @@ -22,7 +22,7 @@ impl Decryptable> for EncString { } impl Decryptable for EncString { - #[instrument(err, skip(self, ctx, key))] + #[instrument(err, skip_all)] fn decrypt( &self, ctx: &mut KeyStoreContext, From 91f4dc9bcd7b252c32e48749bc197168db542880 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:20:48 +0100 Subject: [PATCH 12/23] Cleanup --- crates/bitwarden-vault/src/cipher/cipher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index ef62f1c5b..cbbdec5ca 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -575,7 +575,7 @@ impl Cipher { /// * `key` - The key to use to decrypt the cipher key, this should be the user or organization /// key /// * `ciphers_key` - The encrypted cipher key - #[instrument(err, skip(ctx, key, ciphers_key))] + #[instrument(err, skip_all)] pub(super) fn decrypt_cipher_key( ctx: &mut KeyStoreContext, key: SymmetricKeyId, From 096615b535c92258af2cf3ee6571201f63a693f2 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:26:37 +0100 Subject: [PATCH 13/23] Cleanup --- Cargo.lock | 1 - crates/bitwarden-core/src/client/encryption_settings.rs | 4 +--- crates/bitwarden-vault/Cargo.toml | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbd1449b5..eddf24977 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -927,7 +927,6 @@ dependencies = [ "data-encoding", "futures", "hmac", - "log", "percent-encoding", "reqwest", "serde", diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 05f20a375..009969154 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -9,11 +9,9 @@ use bitwarden_crypto::{ #[cfg(any(feature = "internal", feature = "secrets"))] use bitwarden_crypto::{KeyStore, SymmetricCryptoKey}; use bitwarden_error::bitwarden_error; -#[cfg(feature = "internal")] -use log::{info, warn}; use thiserror::Error; #[cfg(feature = "internal")] -use tracing::instrument; +use tracing::{info, instrument, warn}; #[cfg(any(feature = "secrets", feature = "internal"))] use crate::OrganizationId; diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index e6177d34c..0cef39b7d 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -43,7 +43,6 @@ chrono = { workspace = true } data-encoding = { workspace = true } futures = { workspace = true } hmac = ">=0.12.1, <0.13" -log = { workspace = true } percent-encoding = ">=2.1, <3.0" reqwest = { workspace = true } serde = { workspace = true } From 3ad907a9db9de41ea6df7adbdea9f21f0753ef2e Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:34:59 +0100 Subject: [PATCH 14/23] Cleanup deps --- crates/bitwarden-wasm-internal/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index 459a576f3..155f2ab86 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -37,8 +37,8 @@ console_log = { version = "1.0.0", features = ["color"] } log = "0.4.20" serde = { workspace = true } tracing = { workspace = true } -tracing-subscriber = "0.3.20" -tracing-web = "0.1.3" +tracing-subscriber = { workspace = true } +tracing-web = { version = "0.1.3" } tsify = { workspace = true } # When upgrading wasm-bindgen, make sure to update the version in the workflows! wasm-bindgen = { version = "=0.2.105", features = ["serde-serialize"] } From 1b840fdc63e0c9943c22f05bdada6f1a21fedcf2 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:36:17 +0100 Subject: [PATCH 15/23] Cleanup deps --- Cargo.lock | 14 ++++++++++++++ Cargo.toml | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index eddf24977..edc8555f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3026,6 +3026,15 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + [[package]] name = "memchr" version = "2.7.5" @@ -5148,10 +5157,15 @@ version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" dependencies = [ + "matchers", "nu-ansi-term", + "once_cell", + "regex-automata", "sharded-slab", "smallvec", "thread_local", + "time", + "tracing", "tracing-core", "tracing-log", ] diff --git a/Cargo.toml b/Cargo.toml index 078cdcd31..85579798f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,7 +75,13 @@ serde_repr = ">=0.1.12, <0.2" serde-wasm-bindgen = ">=0.6.0, <0.7" syn = ">=2.0.87, <3" thiserror = ">=1.0.40, <3" -tracing = "= 0.1.41" +tracing = { version = "0.1.41" } +tracing-subscriber = { version = "0.3.20", features = [ + "fmt", + "env-filter", + "tracing-log", + "time", +] } tokio = { version = "1.36.0", features = ["macros"] } tsify = { version = ">=0.5.5, <0.6", features = [ "js", From 824a1f0400199bb3574492dfd9eb5bcfab24164b Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 14:38:34 +0100 Subject: [PATCH 16/23] Fix wasm bulid --- .../bitwarden-wasm-internal/src/pure_crypto.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/crates/bitwarden-wasm-internal/src/pure_crypto.rs b/crates/bitwarden-wasm-internal/src/pure_crypto.rs index e54d3f49e..9bbe13633 100644 --- a/crates/bitwarden-wasm-internal/src/pure_crypto.rs +++ b/crates/bitwarden-wasm-internal/src/pure_crypto.rs @@ -10,7 +10,6 @@ use bitwarden_crypto::{ PrimitiveEncryptable, SignatureAlgorithm, SignedPublicKey, SigningKey, SpkiPublicKeyBytes, SymmetricCryptoKey, UnsignedSharedKey, VerifyingKey, }; -use tracing::instrument; use wasm_bindgen::prelude::*; /// This module represents a stopgap solution to provide access to primitive crypto functions for JS @@ -29,7 +28,6 @@ impl PureCrypto { Self::symmetric_decrypt_string(enc_string, key) } - #[instrument(skip_all)] pub fn symmetric_decrypt_string( enc_string: String, key: Vec, @@ -38,7 +36,6 @@ impl PureCrypto { EncString::from_str(&enc_string)?.decrypt_with_key(&SymmetricCryptoKey::try_from(key)?) } - #[instrument(skip_all)] pub fn symmetric_decrypt_bytes( enc_string: String, key: Vec, @@ -49,7 +46,6 @@ impl PureCrypto { /// DEPRECATED: Use `symmetric_decrypt_filedata` instead. /// Cleanup ticket: - #[instrument(skip_all)] pub fn symmetric_decrypt_array_buffer( enc_bytes: Vec, key: Vec, @@ -57,7 +53,6 @@ impl PureCrypto { Self::symmetric_decrypt_filedata(enc_bytes, key) } - #[instrument(skip_all)] pub fn symmetric_decrypt_filedata( enc_bytes: Vec, key: Vec, @@ -81,7 +76,6 @@ impl PureCrypto { .map(|enc| enc.to_string()) } - #[instrument(skip_all)] pub fn symmetric_encrypt_filedata( plain: Vec, key: Vec, @@ -92,7 +86,6 @@ impl PureCrypto { .to_buffer() } - #[instrument(skip_all)] pub fn decrypt_user_key_with_master_password( encrypted_user_key: String, master_password: String, @@ -107,7 +100,6 @@ impl PureCrypto { Ok(result.to_encoded().to_vec()) } - #[instrument(skip_all)] pub fn encrypt_user_key_with_master_password( user_key: Vec, master_password: String, @@ -155,7 +147,6 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the /// unwrapped key as a serialized byte array. - #[instrument(skip_all)] pub fn unwrap_symmetric_key( wrapped_key: String, wrapping_key: Vec, @@ -178,7 +169,6 @@ impl PureCrypto { /// used. The specific use-case for this function is to enable rotateable key sets, where /// the "public key" is not public, with the intent of preventing the server from being able /// to overwrite the user key unlocked by the rotateable keyset. - #[instrument(skip_all)] pub fn wrap_encapsulation_key( encapsulation_key: Vec, wrapping_key: Vec, @@ -195,7 +185,6 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric /// wrapping key. - #[instrument(skip_all)] pub fn unwrap_encapsulation_key( wrapped_key: String, wrapping_key: Vec, @@ -210,7 +199,6 @@ impl PureCrypto { /// Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping /// key, - #[instrument(skip_all)] pub fn wrap_decapsulation_key( decapsulation_key: Vec, wrapping_key: Vec, @@ -227,7 +215,6 @@ impl PureCrypto { /// Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric /// wrapping key. - #[instrument(skip_all)] pub fn unwrap_decapsulation_key( wrapped_key: String, wrapping_key: Vec, @@ -243,7 +230,6 @@ impl PureCrypto { /// Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key) /// in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so /// the sender's authenticity cannot be verified by the recipient. - #[instrument(skip_all)] pub fn encapsulate_key_unsigned( shared_key: Vec, encapsulation_key: Vec, @@ -260,7 +246,6 @@ impl PureCrypto { /// Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8 /// DER format. Note: This is unsigned, so the sender's authenticity cannot be verified by the /// recipient. - #[instrument(skip_all)] pub fn decapsulate_key_unsigned( encapsulated_key: String, decapsulation_key: Vec, @@ -298,7 +283,6 @@ impl PureCrypto { /// identity claimed ownership of the public key. This is a one-sided claim and merely shows /// that the signing identity has the intent to receive messages encrypted to the public /// key. - #[instrument(skip_all)] pub fn verify_and_unwrap_signed_public_key( signed_public_key: Vec, verifying_key: Vec, From 6e4588b0c6a9ca43107c472406f74751bb795fd9 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Thu, 13 Nov 2025 21:00:18 +0100 Subject: [PATCH 17/23] Update crates/bitwarden-core/src/client/encryption_settings.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Daniel GarcĂ­a --- crates/bitwarden-core/src/client/encryption_settings.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index e3b12fd76..d79ca9477 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -205,7 +205,7 @@ impl EncryptionSettings { } #[cfg(feature = "internal")] - #[instrument(err, skip(org_enc_keys, store))] + #[instrument(err, skip_all)] pub(crate) fn set_org_keys( org_enc_keys: Vec<(OrganizationId, UnsignedSharedKey)>, store: &KeyStore, From 7ff9302e819345db62c6ee76c8687879ac6c12a5 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 14 Nov 2025 17:23:29 +0100 Subject: [PATCH 18/23] Add more tracing --- crates/bitwarden-core/src/client/internal.rs | 13 +++++++------ crates/bitwarden-core/src/key_management/crypto.rs | 9 +++++++++ crates/bitwarden-crypto/src/cose.rs | 2 ++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index e89b52dbe..f6291d743 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -11,6 +11,8 @@ use bitwarden_crypto::{ #[cfg(feature = "internal")] use bitwarden_state::registry::StateRegistry; use chrono::Utc; +#[cfg(feature = "internal")] +use tracing::instrument; #[cfg(any(feature = "internal", feature = "secrets"))] use crate::client::encryption_settings::EncryptionSettings; @@ -288,6 +290,7 @@ impl InternalClient { } #[cfg(feature = "internal")] + #[instrument(err, skip_all)] pub(crate) fn initialize_user_crypto_master_key( &self, master_key: MasterKey, @@ -299,17 +302,12 @@ impl InternalClient { } #[cfg(feature = "internal")] + #[instrument(err, skip_all, fields(user_id = ?self.get_user_id()))] pub(crate) fn initialize_user_crypto_decrypted_key( &self, user_key: SymmetricCryptoKey, key_state: UserKeyState, ) -> Result<(), EncryptionSettingsError> { - let span = tracing::info_span!( - "User Crypto Initialization", - user_id = ?self.get_user_id(), - ); - let _enter = span.enter(); - match user_key { SymmetricCryptoKey::Aes256CbcHmacKey(ref user_key) => { EncryptionSettings::new_decrypted_key( @@ -346,6 +344,7 @@ impl InternalClient { } #[cfg(feature = "internal")] + #[instrument(err, skip_all)] pub(crate) fn initialize_user_crypto_pin( &self, pin_key: PinKey, @@ -357,6 +356,7 @@ impl InternalClient { } #[cfg(feature = "internal")] + #[instrument(err, skip_all)] pub(crate) fn initialize_user_crypto_pin_envelope( &self, pin: String, @@ -399,6 +399,7 @@ impl InternalClient { } #[cfg(feature = "internal")] + #[instrument(err, skip_all)] pub(crate) fn initialize_user_crypto_master_password_unlock( &self, password: String, diff --git a/crates/bitwarden-core/src/key_management/crypto.rs b/crates/bitwarden-core/src/key_management/crypto.rs index 46f318729..57b5de985 100644 --- a/crates/bitwarden-core/src/key_management/crypto.rs +++ b/crates/bitwarden-core/src/key_management/crypto.rs @@ -17,6 +17,7 @@ use bitwarden_encoding::B64; use bitwarden_error::bitwarden_error; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use tracing::info; #[cfg(feature = "wasm")] use {tsify::Tsify, wasm_bindgen::prelude::*}; @@ -167,6 +168,12 @@ pub(super) async fn initialize_user_crypto( } let key_state = (&req).into(); + let _span_guard = tracing::info_span!( + "User Crypto Initialization", + user_id = ?client.internal.get_user_id(), + method = ?req.method + ) + .entered(); match req.method { InitUserCryptoMethod::Password { password, user_key } => { @@ -261,6 +268,8 @@ pub(super) async fn initialize_user_crypto( } } + info!("User crypto initialized successfully"); + client .internal .set_login_method(LoginMethod::User(UserLoginMethod::Username { diff --git a/crates/bitwarden-crypto/src/cose.rs b/crates/bitwarden-crypto/src/cose.rs index 957c9282c..2fcc408c3 100644 --- a/crates/bitwarden-crypto/src/cose.rs +++ b/crates/bitwarden-crypto/src/cose.rs @@ -9,6 +9,7 @@ use coset::{ }; use generic_array::GenericArray; use thiserror::Error; +use tracing::instrument; use typenum::U32; use crate::{ @@ -135,6 +136,7 @@ const SYMMETRIC_KEY: Label = Label::Int(iana::SymmetricKeyParameter::K as i64); impl TryFrom<&coset::CoseKey> for SymmetricCryptoKey { type Error = CryptoError; + #[instrument(err, skip_all)] fn try_from(cose_key: &coset::CoseKey) -> Result { let key_bytes = cose_key .params From d366d05ab8a517fbe96d5fb156e6e76d40ca005d Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 14 Nov 2025 17:35:28 +0100 Subject: [PATCH 19/23] Skip all --- crates/bitwarden-vault/src/cipher/cipher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index e02609917..fc4bf1355 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -513,7 +513,7 @@ impl CompositeEncryptable for CipherView { } impl Decryptable for Cipher { - #[instrument(err, skip(self, ctx, key), fields(cipher_id = ?self.id, org_id = ?self.organization_id, kind = ?self.r#type))] + #[instrument(err, skip_all, fields(cipher_id = ?self.id, org_id = ?self.organization_id, kind = ?self.r#type))] fn decrypt( &self, ctx: &mut KeyStoreContext, From ce93f3b19ca17818717ffa5e73c3b10d12bbc0ff Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 17 Nov 2025 10:57:49 +0100 Subject: [PATCH 20/23] Set max log level to info --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 69a96aeaf..f10e48ea8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ serde-wasm-bindgen = ">=0.6.0, <0.7" subtle = ">=2.5.0, <3.0" syn = ">=2.0.87, <3" thiserror = ">=1.0.40, <3" -tracing = { version = "0.1.41" } +tracing = { version = "0.1.41", features = "release_max_level_info" } tracing-subscriber = { version = "0.3.20", features = [ "fmt", "env-filter", From ddee1bb2f244aaeea699427c7ae3c87f0a4b7586 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Mon, 17 Nov 2025 10:59:34 +0100 Subject: [PATCH 21/23] Fix build --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index f10e48ea8..2e1d0d304 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,7 +76,7 @@ serde-wasm-bindgen = ">=0.6.0, <0.7" subtle = ">=2.5.0, <3.0" syn = ">=2.0.87, <3" thiserror = ">=1.0.40, <3" -tracing = { version = "0.1.41", features = "release_max_level_info" } +tracing = { version = "0.1.41", features = ["release_max_level_info"] } tracing-subscriber = { version = "0.3.20", features = [ "fmt", "env-filter", From 0f2d0f1782444cd570735e1926486b27f7e198db Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 2 Dec 2025 14:50:11 +0100 Subject: [PATCH 22/23] Fix build --- Cargo.lock | 5 ++--- Cargo.toml | 7 ------- crates/bitwarden-crypto/src/enc_string/symmetric.rs | 1 - 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91524b02e..8d8a676b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -626,7 +626,7 @@ dependencies = [ "rand 0.8.5", "rand_chacha 0.3.1", "rayon", - "rsa 0.9.8", + "rsa 0.9.9", "schemars 1.0.0", "serde", "serde_bytes", @@ -1024,7 +1024,7 @@ dependencies = [ "bitwarden-vault", "console_error_panic_hook", "rand 0.8.5", - "rsa", + "rsa 0.9.9", "serde", "sha1", "tracing", @@ -5693,7 +5693,6 @@ dependencies = [ "sharded-slab", "smallvec", "thread_local", - "time", "tracing", "tracing-core", "tracing-log", diff --git a/Cargo.toml b/Cargo.toml index 382120690..e6bb20308 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -75,13 +75,6 @@ serde-wasm-bindgen = ">=0.6.0, <0.7" subtle = ">=2.5.0, <3.0" syn = ">=2.0.87, <3" thiserror = ">=1.0.40, <3" -tracing = { version = "0.1.41", features = ["release_max_level_info"] } -tracing-subscriber = { version = "0.3.20", features = [ - "fmt", - "env-filter", - "tracing-log", - "time", -] } tokio = { version = "1.36.0", features = ["macros"] } tracing = { version = "0.1.41" } tracing-subscriber = { version = "0.3.20", features = [ diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 3d3136814..d00827187 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -4,7 +4,6 @@ use bitwarden_encoding::{B64, FromStrVisitor}; use coset::{CborSerializable, iana::KeyOperation}; use serde::Deserialize; use tracing::instrument; - #[cfg(feature = "wasm")] use wasm_bindgen::convert::FromWasmAbi; From 8f9b3b4ac78cd667f6c8b3f89588de8345fff55e Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 2 Dec 2025 15:03:35 +0100 Subject: [PATCH 23/23] Undo change --- crates/bitwarden-wasm-internal/src/init.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/bitwarden-wasm-internal/src/init.rs b/crates/bitwarden-wasm-internal/src/init.rs index 75f10359c..283e68856 100644 --- a/crates/bitwarden-wasm-internal/src/init.rs +++ b/crates/bitwarden-wasm-internal/src/init.rs @@ -13,6 +13,7 @@ pub enum LogLevel { Warn, Error, } + fn convert_level(level: LogLevel) -> Level { match level { LogLevel::Trace => Level::TRACE,