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

ngclient: review download code #1399

Closed
jku opened this issue May 19, 2021 · 3 comments · Fixed by #1448
Closed

ngclient: review download code #1399

jku opened this issue May 19, 2021 · 3 comments · Fixed by #1448
Assignees
Labels
Milestone

Comments

@jku
Copy link
Member

jku commented May 19, 2021

(this is about code currently in experimental-client branch, hopefully soon in develop)

After we removed mirrors support, we should look through the download code

  • Add type annotations
  • replace old style docstrings
  • see if code can be simplified
  • consider removing average download speed check (it is useless in practice, will trigger false positives if the limit was usefully low and makes the code complex). It also prevents setting chunk size to a reasonable value (it's currently way too large but I'm afraid to lower it because the average speed check then becomes even more volatile for the first chunks -- if the limit is even close to reasonable, it could trigger for the first chunk much easier than later chunks just because that's how statistics works)
  • consider getting rid of strict_required_length: I do not see the value, and it makes the code more complex (if on the other hand there is actual value in length checks, we should implement them in MetadataBundle: the spec does not require them but they would be easy to add)
@jku
Copy link
Member Author

jku commented May 20, 2021

Additional reasoning for length check opinion:

if on the other hand there is actual value in length checks, we should implement them in MetadataBundle

  • MetadataBundle ensures new metadata is correct: it checks hashes, signatures and data validity. checking that length is correct fits right in there (even though spec does not require it)
  • the download code on the other hand should worry about A) getting the requested bytes B) not downloading more than is needed

@jku jku changed the title experimental client: review download code ngclient: review download code May 25, 2021
@jku jku added the backlog Issues to address with priority for current development goals label May 26, 2021
@sechkova sechkova added this to the weeks22-23 milestone May 26, 2021
@sechkova sechkova self-assigned this May 26, 2021
@sechkova sechkova modified the milestones: weeks22-23, weeks24-25 Jun 9, 2021
@sechkova
Copy link
Contributor

  • consider removing average download speed check (it is useless in practice, will trigger false positives if the limit was usefully low and makes the code complex). It also prevents setting chunk size to a reasonable value (it's currently way too large but I'm afraid to lower it because the average speed check then becomes even more volatile for the first chunks -- if the limit is even close to reasonable, it could trigger for the first chunk much easier than later chunks just because that's how statistics works)

Given that defense against slow retrieval attack is considered optional and hard to specify (theupdateframework/specification#124), this sounds like a fair decision.

  • consider getting rid of strict_required_length: I do not see the value, and it makes the code more complex (if on the other hand there is actual value in length checks, we should implement them in MetadataBundle: the spec does not require them but they would be easy to add)

I agree about strict length check. I think we can still keep an upper boundary length check without much cost.

@sechkova
Copy link
Contributor

In addition we can consider creating a Download class with a Download object owned by Updater and instantiated with a Fetcher (default or user-provided).
We can probably keep Fetcher as it is now (the plug-in networking) and Download will add the file object handling.

@sechkova sechkova mentioned this issue Jun 15, 2021
3 tasks
@sechkova sechkova modified the milestones: weeks24-25, weeks26-27 Jun 23, 2021
@joshuagl joshuagl modified the milestones: weeks26-27, Sprint 4 Jul 7, 2021
@joshuagl joshuagl removed the backlog Issues to address with priority for current development goals label Jul 7, 2021
@jku jku closed this as completed in #1448 Jul 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants