-
Notifications
You must be signed in to change notification settings - Fork 270
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
Add missing method args docs in metadata API #1620
Add missing method args docs in metadata API #1620
Conversation
Affected methods are: - Root.add_key() - Root.remove_key() - Targets.add_key() - Targets.remove_key() - DelegatedRole.is_delegated_path() - Key.from_securesystemslib_key() Signed-off-by: Lukas Puehringer <lukas.puehringer@nyu.edu>
Pull Request Test Coverage Report for Build 1341144219Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
removing the private key from keyval. | ||
|
||
Args: | ||
key_dict: A key in securesystemlib dict representation. |
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
and from_securesystemslib_key
is that the former accepts any keyval
(including private ones ... in the long run we will probably want to choke here, right?), whereas the latter removes keyval["private"]
, if present.
So maybe we can rename from_securesystemslib_key
to from_private_key
?
Also, the method becomes a lot easier if we just pop keyval["private"]
instead of calling the mystic format_keyval_to_metadata
function, which does other things that we don't really care for (e.g. vet values using schema
, temporarily assign keyid_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):
def create_key(self) -> Tuple[Key, SSlibSigner]:
sslib_key = generate_ed25519_key()
return Key.from_securesystemslib_key(sslib_key), SSlibSigner(sslib_key)
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 fine
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.
While skimming the the API Reference on RTD I noticed more missing args oneliners in:
Our style guide says, that these oneliners may be omitted if obvious, but if we do so, we should probably fix the RTD-rendering, see e.g. incomplete Parameters sections in tuf.api.serialization). Happy to fix here or ticketize and fix in a follow-up. |
On the other missing args, no strong opinions on the documentation but I'll share my thoughts... I've avoided working on the serialization so far: it is sort of part of the same API but still not as critical as the metadata module itself. Looking at serialization is only necessary if
|
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.
LGTM.
If you'd like the sslib-key-to-tuf-public-key transform to be redesigned, maybe a new issue/pr makes sense?
Thanks for the review, @jku! Re serialization API: I'm fine with leaving the docstrings as they are. |
Fixes #1599
Description of the changes being introduced by the pull request:
Affected methods are:
Please verify and check that the pull request fulfills the following
requirements: