Skip to content
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

signer: _from/_to_dict helpers for Key base fields #558

Merged

Conversation

lukpueh
Copy link
Member

@lukpueh lukpueh commented Mar 31, 2023

Add de/serialization helpers for common fields in the Key base class, which may be used in subclass from/to_dict methods for convenience.

  • _to_dict: This could be Key.to_dict, which subclasses default to, but we prefer that subclasses must implement a to_dict, to avoid unnoticed serialization errors.

  • _from_dict: Other than from_dict, this one does not create a Key instance, but just returns the popped off fields. This makes usage in subclasses more flexible and less mystical (lessons learned from theupdateframework/python-tuf@ace25e4).

Add de/serialization helpers for common fields in the Key base
class, which may be used in subclass from/to_dict methods for
convenience.

* _to_dict: This could be Key.to_dict, which subclasses default to,
but we prefer that subclasses must implement a to_dict, to avoid
unnoticed serialization errors.

* _from_dict: Other than from_dict, this one does not create a Key
instance, but just returns the popped off fields. This makes usage
in subclasses more flexible and less mystical.

Signed-off-by: Lukas Puehringer <[email protected]>
Copy link
Collaborator

@jku jku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method naming is a bit suspicious maybe... but I've tried to come up with better suggestions for a week and came up with nothing so LGTM.

@lukpueh
Copy link
Member Author

lukpueh commented Apr 12, 2023

Method naming is a bit suspicious maybe... but I've tried to come up with better suggestions for a week and came up with nothing so LGTM.

In the TUF metadata API we call these _common_fields_(from,to)_dict. I didn't seem that much better to me.

@lukpueh lukpueh merged commit b1b14eb into secure-systems-lab:main Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants