-
Notifications
You must be signed in to change notification settings - Fork 653
controllers/krate/publish: Validate JSON metadata before reading tarball #10069
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10069 +/- ##
==========================================
- Coverage 89.50% 89.49% -0.01%
==========================================
Files 295 295
Lines 31257 31309 +52
==========================================
+ Hits 27976 28021 +45
- Misses 3281 3288 +7 ☔ View full report in Codecov by Sentry. |
222d6ae
to
d22b113
Compare
nice, I'll have a look tomorrow :D |
Previously, the `BytesRequest` allocated memory for the full tarball (and the JSON metadata blob) before even validating that the `name` and `vers` fields of the JSON metadata correspond to a crate and version that the user has publish access too. This commit changes the code to first read the JSON metadata from the request body stream, validate it, and then read the tarball bytes afterwards.
d22b113
to
1fb5bed
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.
LGTM 👍
Yeah, it would be great if we could stream uploads to S3 and abort them if they're invalid. But this might incur additional costs(?). |
1fb5bed
to
cf2a4fe
Compare
yeah, that's the part that I'm slightly worried about. not sure if we can protect against that in a reasonable way. |
…am" (rust-lang#10102) This reverts commit 4f55cbe.
…am" (rust-lang#10102) This reverts commit 4f55cbe.
…am" (rust-lang#10102) This reverts commit 4f55cbe.
This reverts commit 4f55cbe.
Previously, the
BytesRequest
allocated memory for the full tarball (and the JSON metadata blob) before even validating that thename
andvers
fields of the JSON metadata correspond to a crate and version that the user has publish access too. This commit changes the code to first read the JSON metadata from the request body stream, validate it, and then read the tarball bytes afterwards.Unfortunately, this means that we still buffer the full tarball in memory, but since we only want to upload the tarball to S3 once we validated the content of the tarball, this is somewhat hard to fix. Ideas are welcome! 😉