Conversation
The upload URL was checked with `"storage.googleapis.com" in upload_url`, so any URL containing that string (e.g. in a query parameter or as a subdomain prefix of another domain) was treated as a GCS bucket and sent without the x-ms-blob-type / x-amz-checksum-sha256 headers. Parse the URL and compare the hostname instead.
Author
|
Following up on #1913: the contributing guide doesn't ask for assignment before a PR, so I went ahead and opened this one. Happy to rework it however you prefer (a helper instead of the inline hostname check, a different test layout, etc.). I also added the exact verification commands to the description. Since this is from a fork, the CI workflows probably need a maintainer to approve the first run. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1913
What
MediaManager._process_upload_media_jobdetected GCS upload targets with"storage.googleapis.com" in upload_url. That matches anywhere in the URL, so a non-GCS URL containing the string (in a query parameter, or as a prefix of another domain) was treated as GCS and sent without thex-ms-blob-type/x-amz-checksum-sha256headers.Change
Parse the URL and treat it as GCS only when the hostname is
storage.googleapis.comor ends with.storage.googleapis.com. Behaviour for real GCS URLs is unchanged.Tests
Added
test_media_upload_gcs_detection_uses_url_host(parametrized) intests/unit/test_media_manager.py: real GCS URLs (path-style and bucket subdomain) and non-GCS URLs with the string in the query or as a domain prefix. The two spoofed cases fail before the change and pass after.pytest tests/unit/test_media_manager.py: 19 passedruff check: cleantests/unitshows 18 errors intest_prompt.py; they are identical onmainwithout this change.The PR appears safe to merge; no actionable regression was established.
Summary
The PR changes GCS upload detection from a substring check to a hostname check.
Reviews (1) · Last reviewed commit: "fix(media): detect GCS upload URLs by ho..."
Verification