From dc7ff7b38ca7f87a646960de6720e0f37a6fbac3 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Sat, 4 Jan 2025 15:07:05 +0100 Subject: [PATCH] Fix ssh-key sync issues If any of the mandatory ssh-key json data values are not a string or are an empty string, this will break the mobile clients. This commit fixes this by checking if any of the values are missing or invalid and converts the json data to `null`. It will ensure the clients can sync and show the vault. Fixes #5343 Fixes #5322 Signed-off-by: BlackDex --- src/db/models/cipher.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/db/models/cipher.rs b/src/db/models/cipher.rs index 5fa90daf..782ae699 100644 --- a/src/db/models/cipher.rs +++ b/src/db/models/cipher.rs @@ -272,6 +272,19 @@ impl Cipher { } } + // Fix invalid SSH Entries + // This breaks at least the native mobile client if invalid + // The only way to fix this is by setting type_data_json to `null` + // Opening this ssh-key in the mobile client will probably crash the client, but you can edit, save and afterwards delete it + if self.atype == 5 + && (type_data_json["keyFingerprint"].as_str().is_none_or(|v| v.is_empty()) + || type_data_json["privateKey"].as_str().is_none_or(|v| v.is_empty()) + || type_data_json["publicKey"].as_str().is_none_or(|v| v.is_empty())) + { + warn!("Error parsing ssh-key, mandatory fields are invalid for {}", self.uuid); + type_data_json = Value::Null; + } + // Clone the type_data and add some default value. let mut data_json = type_data_json.clone();