-
Notifications
You must be signed in to change notification settings - Fork 278
Add missing method args docs in metadata API #1620
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
Merged
lukpueh
merged 1 commit into
theupdateframework:develop
from
lukpueh:misc-metadata-api-docs
Oct 20, 2021
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I admit that the description I added is not particularly helpful, but I'm unsure what to do. Can we maybe quickly rethink the API design here?
From what I see, the relevant difference between
from_dict
andfrom_securesystemslib_key
is that the former accepts anykeyval
(including private ones ... in the long run we will probably want to choke here, right?), whereas the latter removeskeyval["private"]
, if present.So maybe we can rename
from_securesystemslib_key
tofrom_private_key
?Also, the method becomes a lot easier if we just pop
keyval["private"]
instead of calling the mysticformat_keyval_to_metadata
function, which does other things that we don't really care for (e.g. vet values usingschema
, temporarily assignkeyid_hash_algorithms
, etc.).@avelichka, would you care to weigh in? I'm happy to re-phrase the docs here or with #1600, once I understand the purpose of this method better. :)
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.
Adding the method was my suggestion, and avoiding poking the securesystemslib key_dict internals may have been as well: none of us were probably entirely sure how much of the dict return value is sort of "implicitly API" or if it's a secursystemslib implementation detail -- are we going to be in trouble later if we just start removing things there. I think you've got a much better idea of this so feel free to propose something.
The purpose is that we have needed roughly the following code in multiple places (this is from test RepositorySimulator where we generate new Metadata):
It turned out quite easy to make the mistake of including the private key in the TUF metadata :) and I wanted to make it easier to avoid that...
Other solutions for this are totally fine too.
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.
oh, and if it wasn't clear: some of the places where this is needed are outside of python-tuf: so developers using python-tuf need to be able to do this so it felt like a function in Metadata API was a good idea even if
del sslib_key["private"]
probably would have worked fineThere 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.
Thanks for the context, @jku! I'll try to condense some of this in the docstring with #1600.