-
Notifications
You must be signed in to change notification settings - Fork 280
ngclient: use MetaFile/TargetFile verification #1467
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
ngclient: use MetaFile/TargetFile verification #1467
Conversation
Use MetaFile.verify_length_and_hashes during snapshot and targets verification in TrustedMetadataSet. Remove pylint: disable=too-many-branches. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
f8ecac8
to
3f18151
Compare
Rebased on |
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.
Looks good I think. Handling the exception just to raise again is a bit annoying but ... also probably correct:
- in these cases we do want to raise a RepositoryError -- client has no way to "handle" this error
- but other cases might be different (like if client itself was testing a cached file)
just on one question: what about the targetfile check in updated_targets()
? it's a bit different case but should be able to use the same methods
tuf/ngclient/updater.py
Outdated
@@ -205,17 +205,21 @@ def download_target( | |||
else: | |||
target_base_url = _ensure_trailing_slash(target_base_url) | |||
|
|||
full_url = parse.urljoin(target_base_url, targetinfo["filepath"]) | |||
target_filepath = targetinfo["filepath"] | |||
target_fileinfo = targetinfo["fileinfo"] |
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.
target_fileinfo = targetinfo["fileinfo"] | |
target_fileinfo:TargetFile = targetinfo["fileinfo"] |
the real fix would be fixing the targetinfo argument type but this helps typing in the mean time
Replace Updater._check_file_lenght and Updater._check_hashes_obj with TargetFile.verify_length_and_hashes. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
Remove the hash check and call TargetFile.verify_length_and_hashes instead. Signed-off-by: Teodora Sechkova <tsechkova@vmware.com>
3f18151
to
1b28604
Compare
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.
👍
Fixes #1410
Description of the changes being introduced by the pull request:
Use the newly added MetaFile/TargetFile.verify_length_and_hashes in the ngclient workflow.
Please verify and check that the pull request fulfills the following
requirements: