-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SG-10] Refactor Cipher data model #76
base: main
Are you sure you want to change the base?
Changes from all commits
dd25a57
3fcef25
e995e3d
8452d04
cd31c0e
84b4445
b6bfc9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,13 +52,19 @@ public CipherMiniResponseModel(Cipher cipher, IGlobalSettings globalSettings, bo | |
Identity = new CipherIdentityModel(identityData); | ||
break; | ||
default: | ||
throw new ArgumentException("Unsupported " + nameof(Type) + "."); | ||
var customData = JsonSerializer.Deserialize<EncObject>(cipher.Data); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Ensure that JsonSerializer.Deserialize can handle null cipher.Data |
||
Data = customData; | ||
cipherData = null; | ||
break; | ||
} | ||
|
||
Name = cipherData.Name; | ||
Notes = cipherData.Notes; | ||
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f)); | ||
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph)); | ||
if (cipherData != null) | ||
{ | ||
Name = cipherData.Name; | ||
Notes = cipherData.Notes; | ||
Fields = cipherData.Fields?.Select(f => new CipherFieldModel(f)); | ||
PasswordHistory = cipherData.PasswordHistory?.Select(ph => new CipherPasswordHistoryModel(ph)); | ||
} | ||
Comment on lines
+61
to
+67
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: This block may leave Name, Notes, Fields, and PasswordHistory uninitialized for custom types |
||
RevisionDate = cipher.RevisionDate; | ||
OrganizationId = cipher.OrganizationId?.ToString(); | ||
Attachments = AttachmentResponseModel.FromCipher(cipher, globalSettings); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ public enum CipherType : byte | |
Login = 1, | ||
SecureNote = 2, | ||
Card = 3, | ||
Identity = 4 | ||
Identity = 4, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Bit.Core.Enums; | ||
|
||
namespace Bit.Core.Models.Data | ||
{ | ||
public class EncObject | ||
{ | ||
public EncryptionType Type { get; set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: consider adding XML documentation for each property |
||
public string Data { get; set; } | ||
public string Iv { get; set; } | ||
public string Mac { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: This default case allows for custom cipher types, but ensure that proper validation and type checking are implemented to prevent misuse or data corruption.