blob/azureblob: prevent SAS token endpoint overrides#3737
Conversation
|
Can you explain why you think this change is needed? |
|
Thanks for taking a look. The reason for this change is that the registered Today, if an application accepts or composes an This PR keeps custom endpoints available through trusted I rechecked the patch locally:
If you prefer a narrower compatibility-preserving approach, I can adjust the patch so the restriction only applies when the default registered opener is using environment/default credentials. |
vangent
left a comment
There was a problem hiding this comment.
I'm not sure I'm convinced this belongs here.
If applications are accepting arbitrary config URLs and passing them to this library, they can/should do some verification of them before that. I would expect most applications to have control over both the configuration and the environment.
|
PTAL. I removed the domain allowlist and narrowed the change to SAS tokens in the default opener. URL overrides are rejected only when they change the configured origin; existing custom-domain and Azurite behavior remains unchanged. All repository tests and golangci-lint v2.12 pass. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3737 +/- ##
==========================================
- Coverage 75.28% 75.25% -0.04%
==========================================
Files 104 104
Lines 14176 14199 +23
==========================================
+ Hits 10672 10685 +13
- Misses 2772 2776 +4
- Partials 732 738 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This change prevents the default
azblob://opener from changing the service origin through bucket URL parameters whenAZURE_STORAGE_SAS_TOKENis set.The SAS token is appended to the service URL. The revised check compares the configured and overridden origins instead of maintaining a domain allowlist.
Existing behavior is preserved when no SAS token is configured, when URL parameters leave the origin unchanged, and for endpoints configured through environment variables or a custom
URLOpener.Tests:
go test ./blob/azureblob -count=1go test ./blob/... -count=1go test ./... -count=1go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.0 run