Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
414ae4d
{Doc} Update track2 migration roadmap (#16871)
jsntcy Feb 10, 2021
68d30cc
hotfix: pin version for azure-keyvault-administration (#16887)
houk-ms Feb 10, 2021
8aedd2d
added start/end time in show-log-chain table output (#16753)
akshayneema Feb 10, 2021
f86f327
Merge branch 'release' of github.com:Azure/azure-cli into dev
fengzhou-msft Feb 10, 2021
39fe66a
[SQL] Update az sql mi examples (#16852)
kukislav Feb 18, 2021
c803a54
Use MSIFASTINSTALL (#16903)
Petermarcu Feb 18, 2021
45c185b
{ServiceFabric} Refine code to unblock CI Lint (#16970)
evelyn-ys Feb 19, 2021
f742dbf
[SQL] az sql db/elastic-pool create/update: Added maint-config-id arg…
Feb 19, 2021
bc4d70c
[AppService]: fix ##8743- az webapp deploy (#16715)
Kotasudhakarreddy Feb 19, 2021
58a2ba2
[AKS] Add support for SGX addon 'confcom' (#16869)
Pengpeng-Microsoft Feb 19, 2021
4b6a6c8
{ARM} ts: show command bug fixed, improved error handling for export …
detienne20 Feb 19, 2021
a896091
[Storage] Fix #16872: az storage blob now (2.19) requires login even …
Juliehzl Feb 19, 2021
3739c5e
[Storage] Fix #16959: az storage copy crashes: ValidationError: local…
Juliehzl Feb 19, 2021
1f87589
{Packaging} Bump cryptography from 2.8 to 3.2 (#15687)
dependabot[bot] Feb 19, 2021
61fcd29
[Compute] az vm (extension) image list: Make it more robust (#16992)
qwordy Feb 20, 2021
da146f2
{Packaging} Bump ADAL to 1.2.6 (#16671)
jiasli Feb 20, 2021
69c0684
roleDefinitionName should be roleName (#16781)
houk-ms Feb 20, 2021
0f56b1b
Update _help.py (#17015)
Feb 22, 2021
109f495
expose real exception while getting sdk (#16993)
evelyn-ys Feb 22, 2021
247a1ad
[Compute] vmss create: Fix a license type issue (#17007)
qwordy Feb 22, 2021
ada4878
{Network} Revert deprecation for network route table (#17004)
yonzhan Feb 22, 2021
3221fe2
[Storage] Fix #16679: `az storage blob download` fails with "Permissi…
evelyn-ys Feb 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Storage] Fix Azure#16679: az storage blob download fails with "Per…
…mission denied" if the destination file is a directory (Azure#17008)

* file path validator

* add tests
  • Loading branch information
evelyn-ys authored Feb 22, 2021
commit 3221fe285d375017d143aa8005b6b30a9e0f2773
5 changes: 3 additions & 2 deletions src/azure-cli/azure/cli/command_modules/storage/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
validate_delete_retention_days, validate_container_delete_retention_days,
validate_file_delete_retention_days,
validate_fs_public_access, validate_logging_version, validate_or_policy, validate_policy,
get_api_version_type)
get_api_version_type, blob_download_file_path_validator)


def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statements, too-many-lines
Expand Down Expand Up @@ -709,7 +709,8 @@ def load_arguments(self, _): # pylint: disable=too-many-locals, too-many-statem
c.extra('socket_timeout', socket_timeout_type)

with self.argument_context('storage blob download') as c:
c.argument('file_path', options_list=('--file', '-f'), type=file_type, completer=FilesCompleter())
c.argument('file_path', options_list=('--file', '-f'), type=file_type,
completer=FilesCompleter(), validator=blob_download_file_path_validator)
c.argument('max_connections', type=int)
c.argument('start_range', type=int)
c.argument('end_range', type=int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1142,6 +1142,12 @@ def blob_tier_validator(cmd, namespace):
raise ValueError('Blob tier is only applicable to block or page blob.')


def blob_download_file_path_validator(namespace):
if os.path.isdir(namespace.file_path):
from azure.cli.core.azclierror import FileOperationError
raise FileOperationError('File is expected, not a directory: {}'.format(namespace.file_path))


def blob_rehydrate_priority_validator(namespace):
if namespace.blob_type == 'page' and namespace.rehydrate_priority:
raise ValueError('--rehydrate-priority is only applicable to block blob.')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
CommandName:
- storage account keys list
Connection:
- keep-alive
Content-Length:
- '0'
ParameterSetName:
- -n -g --query -o
User-Agent:
- AZURECLI/2.19.1 azsdk-python-azure-mgmt-storage/16.0.0 Python/3.7.9 (Windows-10-10.0.19041-SP0)
method: POST
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/clitest.rg000001/providers/Microsoft.Storage/storageAccounts/clitest000002/listKeys?api-version=2019-06-01&$expand=kerb
response:
body:
string: '{"keys":[{"keyName":"key1","value":"veryFakedStorageAccountKey==","permissions":"FULL"},{"keyName":"key2","value":"veryFakedStorageAccountKey==","permissions":"FULL"}]}'
headers:
cache-control:
- no-cache
content-length:
- '288'
content-type:
- application/json
date:
- Mon, 22 Feb 2021 02:29:22 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- Microsoft-Azure-Storage-Resource-Provider/1.0,Microsoft-HTTPAPI/2.0 Microsoft-HTTPAPI/2.0
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
x-ms-ratelimit-remaining-subscription-resource-requests:
- '11999'
status:
code: 200
message: OK
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ def is_block_put_req(request):
'The expected number of block put requests is {} but the actual '
'number is {}.'.format(block_count, len(put_blocks)))

@ResourceGroupPreparer()
@StorageAccountPreparer()
def test_storage_blob_download_directory(self, resource_group, storage_account):
local_dir = self.create_temp_dir()
account_info = self.get_account_info(resource_group, storage_account)
from azure.cli.core.azclierror import FileOperationError
with self.assertRaisesRegexp(FileOperationError, 'File is expected, not a directory'):
self.storage_cmd('storage blob download -c mycontainer -n myblob -f "{}"', account_info, local_dir)

@ResourceGroupPreparer()
@StorageAccountPreparer()
def test_storage_blob_socket_timeout(self, resource_group, storage_account):
Expand Down