-
Notifications
You must be signed in to change notification settings - Fork 275
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
BaseFile._verify_hashes: handle sslib errors #1454
BaseFile._verify_hashes: handle sslib errors #1454
Conversation
Depends on #1451 so opened as a draft. |
This is the core question:
this is the obvious choice... yet I'm left wondering if it's actually useful for the API users.
Follow up in the case that there is a real use case:
|
tuf/api/metadata.py
Outdated
sslib_exceptions.UnsupportedAlgorithmError, | ||
sslib_exceptions.FormatError, | ||
) as e: | ||
raise exceptions.UnsupportedAlgorithmError( |
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.
assuming we go with this, it needs to be documented in at least the public methods
What I think is worth doing is giving the interested users, if any, information about the error. Following this thought maybe your proposal of deriving UnsupportedAlgorithmError from LengthOrHashMismatchError is a good compromise making everyone relatively happy. |
This is absolutely not contested: we should have actionable error messages. But I would like to only add errors if they have a purpose: to understand which component might handle the error (the component may be a hypothetical one: I'd just like to understand the use case). Adding more complex errors in later releases is easy, removing existing ones is really hard. |
Securesystemslib digest() and digest_fileobject() calls raise sslib specific exceptions that need to be handled and re-raised as TUF exceptions. Updated tests in test_api.py accordingly. Signed-off-by: Teodora Sechkova <[email protected]>
c839884
to
752a741
Compare
Kept only |
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, thanks
Fixes #1452
Description of the changes being introduced by the pull request:
BaseFile._verify_hashes handles the following sslib errors raised during hash verification:
and reraises them as tuf.exceptions.UnsupportedAlgorithmError.
securesystemslib.exceptions.FormatError should not be raised if the Target/MetaFile object is
created correctly through its constructor but is possible if Target/MetaFile.hashes is modified
directly so catching it just in case.
Please verify and check that the pull request fulfills the following
requirements: