Repository navigation
[Storage] Validate account endpoints before attaching SAS credentials - #34230
Open
YangAn-microsoft wants to merge 5 commits into
Open
YangAn-microsoft wants to merge 5 commits into
YangAn-microsoft wants to merge 5 commits into
Conversation
Validate parsed endpoint origins against account and trusted connection-string endpoints before SAS generation or attachment. Preserve external URL passthrough without adding storage credentials and cover copy and filesystem validators. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
microsoft-github-policy-service
Bot
requested a review
from Yong Zhang (yonzhan)
October 16, 2026 00:27
Remove the manual changelog entry; retain the draft PR History Notes for automated release history generation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use the existing get_account_url helper for primary and secondary standard endpoints without changing SAS destination validation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Credential-boundary changes need human review, with an unresolved copy regression and incomplete broader storage validation.
1 open finding
What changed in this PR
Hardens storage copy and filesystem transfers by validating account endpoints before attaching SAS credentials.
Changes:
- Replaces substring matching with parsed-origin validation.
- Preserves credential account selection and supports configured endpoints.
- Adds offline validator and mocked command-level regression tests.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_validators.py | Adds endpoint and credential validation coverage. |
| src/azure-cli/azure/cli/command_modules/storage/tests/latest/test_storage_azcopy_scenarios.py | Adds mocked storage copy regression coverage. |
| src/azure-cli/azure/cli/command_modules/storage/_validators.py | Validates endpoint origins before attaching SAS credentials. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Restrict space rejection to URL authorities and leading whitespace while continuing to reject control characters. Cover Blob and File wildcard paths in both copy directions with generated and supplied SAS credentials. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move existing blob-copy origin normalization and comparison into storage_url_helpers. Reuse normalization in the AzCopy SAS trust gate while preserving credential-boundary validation and existing blob-copy semantics. Cover equivalent DNS, IDNA and IPv6 origins. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
Storage |
YangAn-microsoft
marked this pull request as ready for review
October 16, 2026 05:08
Yu Chen (jsntcy)
approved these changes
Oct 18, 2026
ZelinWang (wangzelin007)
approved these changes
Oct 19, 2026
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.

🤖 PR Validation — ️✔️ All clear
Related command
az storage copyaz storage fs directory uploadaz storage fs directory downloadDescription
Validate the actual destination origin before generating or attaching storage SAS credentials. The previous copy URL recognition used a substring regex, allowing Azure-looking hostnames to be treated as storage endpoints.
This is a draft pending final review and CI. The filesystem callers are hardened at the shared boundary; this does not claim a separately demonstrated exploit through those commands.
Testing Guide
Rerun on the clean branch based on upstream
devat8112200cfa. Set repository source imports in PowerShell:& '.\.tmp_style_env\Scripts\python.exe' -m unittest azure.cli.command_modules.storage.tests.latest.test_storage_validators azure.cli.command_modules.storage.tests.latest.test_storage_url_helpers azure.cli.command_modules.storage.tests.latest.test_storage_azcopy_scenarios.StorageAzcopyEndpointTests azure.cli.command_modules.storage.tests.latest.test_storage_blob_copy_scenarios.StorageBlobCopySecurityTests— Passed: 60 tests. Transfer and SAS generation are mocked in the command-level regression test.& '.\.tmp_style_env\Scripts\python.exe' -m pylint --rcfile .\pylintrc .\src\azure-cli\azure\cli\command_modules\storage\_validators.py .\src\azure-cli\azure\cli\command_modules\storage\storage_url_helpers.py .\src\azure-cli\azure\cli\command_modules\storage\operations\blob.py— Passed: 10.00/10.git diff --check— Passed before committing.& '.\.tmp_style_env\Scripts\python.exe' -m flake8 --append-config .\.flake8 .\src\azure-cli\azure\cli\command_modules\storage\_validators.py .\src\azure-cli\azure\cli\command_modules\storage\tests\latest\test_storage_validators.py .\src\azure-cli\azure\cli\command_modules\storage\tests\latest\test_storage_azcopy_scenarios.py— Failed on pre-existing test-file E302/E122 findings; compared against HEAD before rebasing and confirmed no remaining new findings.& '.\.tmp_style_env\Scripts\python.exe' -m azdev style storage --pylint— Blocked by local azdev repository/extension configuration; direct repository-configured pylint passed as above.History Notes
[Storage]
az storage copy,az storage fs directory upload/download: Validate configured account endpoints before attaching SAS credentialsThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.