-
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?
Conversation
…itional-item-types
…itional-item-types
…itional-item-types
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.
14 file(s) reviewed, 15 comment(s)
Edit PR Review Bot Settings | Greptile
default: | ||
throw new ArgumentException("Unsupported type: " + nameof(Type) + "."); | ||
existingCipher.Data = JsonSerializer.Serialize(Data, JsonHelpers.IgnoreWritingNull); | ||
break; |
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Ensure that JsonSerializer.Deserialize can handle null cipher.Data
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)); | ||
} |
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 block may leave Name, Notes, Fields, and PasswordHistory uninitialized for custom types
{ | ||
public class EncObject | ||
{ | ||
public EncryptionType Type { 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.
style: consider adding XML documentation for each property
Type of change
Objective
Draft refactor of the cipher data model. Replaces the
data
with a serialized instance ofEncObject
which is controlled by the clients.Code changes
Before you submit
dotnet tool run dotnet-format --check
) (required)…itional-item-types
Greptile Summary
This pull request introduces significant changes to the cipher data model, focusing on improved flexibility and encryption handling. Here's a concise summary of the major changes:
EncObject
class for enhanced encryption controlCipherRequestModel
andCipherResponseModel
to accommodateEncObject
Cipher
folderCipherType
enum to prepare for potential future additionsCipherAttachment
class with new properties and nestedMetaData
classThese changes aim to provide more flexibility in handling different cipher types and improve the overall structure of the cipher data model. However, careful consideration should be given to data consistency and backward compatibility during implementation.