diff --git a/Cargo.lock b/Cargo.lock index 346b07a1d2..210886bd0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom 0.2.10", "once_cell", @@ -147,13 +147,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" dependencies = [ "cfg-if 1.0.0", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -589,7 +590,7 @@ checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" dependencies = [ "async-trait", "axum-core", - "base64 0.21.4", + "base64 0.21.5", "bitflags 1.3.2", "bytes", "futures-util", @@ -718,9 +719,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -2315,7 +2316,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -2324,7 +2325,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", "allocator-api2", ] @@ -2334,7 +2335,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "headers-core", "http", @@ -2515,7 +2516,7 @@ dependencies = [ "serde", "serde_derive", "thiserror", - "toml 0.8.2", + "toml 0.8.4", "unic-langid", ] @@ -3050,7 +3051,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f9624e2a843b655f1c1b8262b8d5de6f309413fca4d66f01bb0662429f84dc" dependencies = [ "asynchronous-codec", - "base64 0.21.4", + "base64 0.21.5", "byteorder", "bytes", "either", @@ -3563,9 +3564,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -4148,7 +4149,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "serde", ] @@ -4158,7 +4159,7 @@ version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3163d2912b7c3b52d651a055f2c7eec9ba5cd22d26ef75b8dd3a59980b185923" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "serde", ] @@ -4239,7 +4240,7 @@ version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a4a0cfc5fb21a09dc6af4bf834cf10d4a32fccd9e2ea468c4b1751a097487aa" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "indexmap 1.9.3", "line-wrap", "quick-xml", @@ -4455,7 +4456,7 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1febe054126dd791534c846e295f8b1f9eda1d55e7eaddc91bcbda75343eb3e" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "image", "qrcodegen", ] @@ -4756,7 +4757,7 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", @@ -5002,7 +5003,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] @@ -5284,9 +5285,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -5325,7 +5326,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64cd236ccc1b7a29e7e2739f27c0b2dd199804abc4290e32f59f3b68d6405c23" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "chrono", "hex", "indexmap 1.9.3", @@ -5540,7 +5541,7 @@ dependencies = [ "serde_json", "serial_test", "shell-words", - "sos-net 0.5.19 (registry+https://github.com/rust-lang/crates.io-index)", + "sos-net 0.5.21 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile", "terminal-banner", "thiserror", @@ -5630,7 +5631,7 @@ dependencies = [ [[package]] name = "sos-net" -version = "0.5.19" +version = "0.5.21" dependencies = [ "anyhow", "async-recursion", @@ -5688,9 +5689,9 @@ dependencies = [ [[package]] name = "sos-net" -version = "0.5.19" +version = "0.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4c62ebbb672baa6abddd9e539ce31f4a8581ec749428e3a2374f41240bfdc4" +checksum = "1731aa75fb1e3f7d72e7904cfb152f81075785e767e0c59ceb97bea7257eaa04" dependencies = [ "async-recursion", "async-stream", @@ -6280,21 +6281,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.2" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185d8ab0dfbb35cf1399a6344d8484209c088f75f8f68230da55d48d95d43e3d" +checksum = "2ef75d881185fd2df4a040793927c153d863651108a93c7e17a9e591baa95cc6" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.20.2", + "toml_edit 0.20.4", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -6312,9 +6313,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.20.2" +version = "0.20.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" +checksum = "380f9e8120405471f7c9ad1860a713ef5ece6a670c7eae39225e477340f32fc4" dependencies = [ "indexmap 2.0.2", "serde", @@ -6423,12 +6424,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -6478,9 +6479,9 @@ dependencies = [ [[package]] name = "trust-dns-proto" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "559ac980345f7f5020883dd3bcacf176355225e01916f8c2efecad7534f682c6" +checksum = "3119112651c157f4488931a01e586aa459736e9d6046d3bd9105ffb69352d374" dependencies = [ "async-trait", "cfg-if 1.0.0", @@ -6503,9 +6504,9 @@ dependencies = [ [[package]] name = "trust-dns-resolver" -version = "0.23.1" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c723b0e608b24ad04c73b2607e0241b2c98fd79795a95e98b068b6966138a29d" +checksum = "10a3e6c3aff1718b3c73e395d1f35202ba2ffa847c6a62eea0db8fb4cfe30be6" dependencies = [ "cfg-if 1.0.0", "futures-util", @@ -6519,7 +6520,7 @@ dependencies = [ "thiserror", "tokio", "tracing", - "trust-dns-proto 0.23.1", + "trust-dns-proto 0.23.2", ] [[package]] @@ -6786,7 +6787,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3217210063ba925206fed042d4bff6d4e18c185b7c413e53594c7023deaab49a" dependencies = [ "aho-corasick 0.7.20", - "base64 0.21.4", + "base64 0.21.5", "language-tags", "logos", "serde", @@ -7438,6 +7439,26 @@ dependencies = [ "zvariant", ] +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/workspace/net/Cargo.toml b/workspace/net/Cargo.toml index c67563e9cb..01d6ab57f4 100644 --- a/workspace/net/Cargo.toml +++ b/workspace/net/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sos-net" -version = "0.5.20" +version = "0.5.21" edition = "2021" description = "Networking library for the Save Our Secrets SDK." homepage = "https://saveoursecrets.com" diff --git a/workspace/net/src/client/user/mod.rs b/workspace/net/src/client/user/mod.rs index 65032253e6..0c3aacbb39 100644 --- a/workspace/net/src/client/user/mod.rs +++ b/workspace/net/src/client/user/mod.rs @@ -23,7 +23,7 @@ pub use search_index::{ArchiveFilter, DocumentView, QueryFilter, UserIndex}; #[cfg(feature = "security-report")] pub use security_report::{ - PasswordReport, SecurityReport, SecurityReportOptions, + SecurityReport, SecurityReportOptions, SecurityReportRecord, SecurityReportRow, }; pub use user_storage::{ diff --git a/workspace/net/src/client/user/security_report.rs b/workspace/net/src/client/user/security_report.rs index 768ea446bf..c4715798fe 100644 --- a/workspace/net/src/client/user/security_report.rs +++ b/workspace/net/src/client/user/security_report.rs @@ -36,8 +36,8 @@ pub struct SecurityReportRow { pub folder_id: VaultId, /// Secret identifier. pub secret_id: SecretId, - /// Owner secret identifier (when custom field). - pub owner_id: Option, + /// Custom field identifier. + pub field_id: Option, /// Field index (when custom field). pub field_index: Option, /// The entropy score. @@ -81,8 +81,8 @@ impl From> for Vec> { folder_name: record.folder.name().to_owned(), folder_id: *record.folder.id(), secret_id: record.secret_id, - owner_id: record.owner.map(|(id, _)| id), - field_index: record.owner.map(|(_, index)| index), + field_id: record.field.map(|(id, _)| id), + field_index: record.field.map(|(_, index)| index), score, guesses, guesses_log10, @@ -99,23 +99,15 @@ pub struct SecurityReportRecord { pub folder: Summary, /// Secret identifier. pub secret_id: SecretId, - /// Owner information when the password + /// Field information when the password /// belongs to a parent secret (custom field). - pub owner: Option<(SecretId, usize)>, + pub field: Option<(SecretId, usize)>, /// Report on password entropy. /// /// Will be `None` when the password is empty. pub entropy: Option, } -/// Password report. -pub struct PasswordReport { - /// The entropy score. - pub entropy: Entropy, - /// Determines if the password is empty. - pub is_empty: bool, -} - impl UserStorage { /// Generate a security report. pub async fn generate_security_report( @@ -160,9 +152,9 @@ impl UserStorage { Secret::check_password(field.secret())?; if let Some(check) = check { password_hashes.push(( - *field.id(), + *secret_id, check, - Some((*secret_id, index)), + Some((*field.id(), index)), )); } } @@ -175,13 +167,13 @@ impl UserStorage { } } - for (secret_id, check, owner) in password_hashes { + for (secret_id, check, field) in password_hashes { let (entropy, sha1) = check; let record = SecurityReportRecord { folder: target.clone(), secret_id, - owner, + field, entropy, }; diff --git a/workspace/net/src/client/user/user_storage.rs b/workspace/net/src/client/user/user_storage.rs index 0b718aa9a8..605bc39a68 100644 --- a/workspace/net/src/client/user/user_storage.rs +++ b/workspace/net/src/client/user/user_storage.rs @@ -23,7 +23,7 @@ use sos_sdk::{ storage::{AppPaths, UserPaths}, vault::{ secret::{Secret, SecretData, SecretId, SecretMeta, SecretType}, - Gatekeeper, Summary, Vault, VaultAccess, VaultBuilder, VaultId, + Summary, Vault, VaultAccess, VaultId, VaultWriter, }, vfs::{self, File}, @@ -249,6 +249,7 @@ impl UserStorage { let peer_key = convert_libp2p_identity(user.device().signer())?; let files_dir = storage.paths().files_dir().clone(); + #[cfg(feature = "device")] let devices_dir = storage.paths().devices_dir().clone(); Ok(Self { user, @@ -1178,6 +1179,7 @@ impl UserStorage { ) -> Result<()> { use sos_migrate::export::PublicExport; use std::io::Cursor; + use sos_sdk::vault::Gatekeeper; let mut archive = Vec::new(); let mut migration = PublicExport::new(Cursor::new(&mut archive)); @@ -1304,6 +1306,8 @@ impl UserStorage { folder_name: String, converter: impl Convert, ) -> Result<(Event<'static>, Summary)> { + use sos_sdk::vault::VaultBuilder; + let vaults = LocalAccounts::list_local_vaults(self.address(), false).await?; let existing_name = @@ -1415,6 +1419,8 @@ impl UserStorage { &mut self, path: P, ) -> Result<()> { + use sos_sdk::vault::Gatekeeper; + let contacts = self .contacts_folder() .ok_or_else(|| Error::NoContactsFolder)?;