azure-cli-core 2.89.1__tar.gz → 2.91.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/HISTORY.rst +9 -0
  2. {azure_cli_core-2.89.1/azure_cli_core.egg-info → azure_cli_core-2.91.0}/PKG-INFO +3 -3
  3. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/__init__.py +1 -1
  4. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_profile.py +4 -1
  5. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_arg_fmt.py +3 -4
  6. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/identity.py +4 -2
  7. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/cloud.py +1 -1
  8. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commandIndex.latest.json +1 -1
  9. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/dynamic_install.py +10 -6
  10. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/operations.py +36 -4
  11. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/helpIndex.latest.json +3 -3
  12. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/telemetry.py +5 -2
  13. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/util.py +113 -3
  14. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0/azure_cli_core.egg-info}/PKG-INFO +3 -3
  15. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure_cli_core.egg-info/requires.txt +4 -4
  16. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/setup.py +3 -3
  17. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/LICENSE.txt +0 -0
  18. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/MANIFEST.in +0 -0
  19. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/README.rst +0 -0
  20. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/__init__.py +0 -0
  21. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/__init__.py +0 -0
  22. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_breaking_change.py +0 -0
  23. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_completers.py +0 -0
  24. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_config.py +0 -0
  25. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_debug.py +0 -0
  26. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_environment.py +0 -0
  27. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_help.py +0 -0
  28. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_help_loaders.py +0 -0
  29. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_output.py +0 -0
  30. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/_session.py +0 -0
  31. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/__init__.py +0 -0
  32. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_arg.py +0 -0
  33. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_arg_action.py +0 -0
  34. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_arg_browser.py +0 -0
  35. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_base.py +0 -0
  36. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_client.py +0 -0
  37. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_command.py +0 -0
  38. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_command_ctx.py +0 -0
  39. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_content_builder.py +0 -0
  40. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_error_format.py +0 -0
  41. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_field_type.py +0 -0
  42. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_field_value.py +0 -0
  43. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_help.py +0 -0
  44. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_http_policy.py +0 -0
  45. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_operation.py +0 -0
  46. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_paging.py +0 -0
  47. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_poller.py +0 -0
  48. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_prompt.py +0 -0
  49. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_selector.py +0 -0
  50. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/_utils.py +0 -0
  51. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/exceptions.py +0 -0
  52. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/aaz/utils.py +0 -0
  53. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/api.py +0 -0
  54. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/__init__.py +0 -0
  55. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/agentic_session.py +0 -0
  56. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/binary_cache.py +0 -0
  57. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/constants.py +0 -0
  58. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/credential_adaptor.py +0 -0
  59. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/landing_pages/error.html +0 -0
  60. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/landing_pages/success.html +0 -0
  61. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/msal_credentials.py +0 -0
  62. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/persistence.py +0 -0
  63. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/auth/util.py +0 -0
  64. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/azclierror.py +0 -0
  65. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/azlogging.py +0 -0
  66. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/breaking_change.py +0 -0
  67. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/command_recommender.py +0 -0
  68. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/__init__.py +0 -0
  69. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/arm.py +0 -0
  70. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/client_factory.py +0 -0
  71. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/command_operation.py +0 -0
  72. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/constants.py +0 -0
  73. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/events.py +0 -0
  74. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/parameters.py +0 -0
  75. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/progress.py +0 -0
  76. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/sensitive.py +0 -0
  77. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/template_create.py +0 -0
  78. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/transform.py +0 -0
  79. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/commands/validators.py +0 -0
  80. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/credential_helper.py +0 -0
  81. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/decorators.py +0 -0
  82. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/__init__.py +0 -0
  83. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/_homebrew_patch.py +0 -0
  84. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/_index.py +0 -0
  85. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/extension/_resolve.py +0 -0
  86. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/file_util.py +0 -0
  87. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/intercept_survey.py +0 -0
  88. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/keys.py +0 -0
  89. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/local_context.py +0 -0
  90. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/mock.py +0 -0
  91. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/parser.py +0 -0
  92. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/profiles/__init__.py +0 -0
  93. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/profiles/_shared.py +0 -0
  94. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/sdk/__init__.py +0 -0
  95. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/sdk/policies.py +0 -0
  96. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure/cli/core/style.py +0 -0
  97. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure_cli_core.egg-info/SOURCES.txt +0 -0
  98. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure_cli_core.egg-info/dependency_links.txt +0 -0
  99. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure_cli_core.egg-info/not-zip-safe +0 -0
  100. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/azure_cli_core.egg-info/top_level.txt +0 -0
  101. {azure_cli_core-2.89.1 → azure_cli_core-2.91.0}/setup.cfg +0 -0
@@ -3,6 +3,15 @@
3
3
  Release History
4
4
  ===============
5
5
 
6
+ 2.91.0
7
+ ++++++
8
+ * Remove AzureGermanCloud from hard-coded cloud list (#34042)
9
+ * PREVIEW: Enable broker-based authentication on macOS (opt-in via `az config set core.enable_broker_on_mac=true`) (#33376)
10
+
11
+ 2.90.0
12
+ ++++++
13
+ * Minor fixes
14
+
6
15
  2.89.1
7
16
  ++++++
8
17
  * Allow SSH certificate flow in Cloud Shell (#33860)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azure-cli-core
3
- Version: 2.89.1
3
+ Version: 2.91.0
4
4
  Summary: Microsoft Azure Command-Line Tools Core Module
5
5
  Home-page: https://github.com/Azure/azure-cli
6
6
  Author: Microsoft Corporation
@@ -30,8 +30,8 @@ Requires-Dist: jmespath
30
30
  Requires-Dist: knack~=0.14.0
31
31
  Requires-Dist: microsoft-security-utilities-secret-masker~=1.0.0b4
32
32
  Requires-Dist: msal-extensions==1.3.1
33
- Requires-Dist: msal[broker]==1.36.0; sys_platform == "win32"
34
- Requires-Dist: msal==1.36.0; sys_platform != "win32"
33
+ Requires-Dist: msal[broker]==1.39.0; sys_platform == "win32" or sys_platform == "darwin"
34
+ Requires-Dist: msal==1.39.0; sys_platform != "win32" and sys_platform != "darwin"
35
35
  Requires-Dist: packaging>=20.9
36
36
  Requires-Dist: pkginfo>=1.12.0
37
37
  Requires-Dist: psutil>=5.9; sys_platform != "cygwin"
@@ -4,7 +4,7 @@
4
4
  # --------------------------------------------------------------------------------------------
5
5
  # pylint: disable=line-too-long
6
6
 
7
- __version__ = "2.89.1"
7
+ __version__ = "2.91.0"
8
8
 
9
9
  import os
10
10
  import sys
@@ -975,8 +975,10 @@ def _create_identity_instance(cli_ctx, authority, tenant_id=None, client_id=None
975
975
 
976
976
  # On Windows, use core.enable_broker_on_windows=false to disable broker (WAM) for authentication.
977
977
  enable_broker_on_windows = cli_ctx.config.getboolean('core', 'enable_broker_on_windows', fallback=True)
978
+ # On macOS, broker authentication is opt-in. Use core.enable_broker_on_mac=true to enable it.
979
+ enable_broker_on_mac = cli_ctx.config.getboolean('core', 'enable_broker_on_mac', fallback=False)
978
980
  from .telemetry import set_broker_info
979
- set_broker_info(enable_broker_on_windows)
981
+ set_broker_info(enable_broker_on_windows, enable_broker_on_mac)
980
982
 
981
983
  # PREVIEW: In Azure Stack environment, use core.instance_discovery=false to disable MSAL's instance discovery.
982
984
  instance_discovery = cli_ctx.config.getboolean('core', 'instance_discovery', True)
@@ -985,4 +987,5 @@ def _create_identity_instance(cli_ctx, authority, tenant_id=None, client_id=None
985
987
  encrypt=encrypt,
986
988
  use_msal_http_cache=use_msal_http_cache,
987
989
  enable_broker_on_windows=enable_broker_on_windows,
990
+ enable_broker_on_mac=enable_broker_on_mac,
988
991
  instance_discovery=instance_discovery)
@@ -52,9 +52,6 @@ class AAZStrArgFormat(AAZBaseArgFormat):
52
52
  if self._max_length is not None and len(data) > self._max_length:
53
53
  raise AAZInvalidArgValueError(
54
54
  f"Invalid format: '{data}' length is greater than {self._max_length}")
55
- if self._pattern is not None and not self._compiled_pattern.fullmatch(data):
56
- raise AAZInvalidArgValueError(
57
- f"Invalid format: '{data}' does not fully match regular expression pattern '{self._pattern}'")
58
55
 
59
56
  return value
60
57
 
@@ -767,7 +764,9 @@ class AAZPaginationTokenArgFormat(AAZBaseArgFormat):
767
764
  # `next_link` is a URL that the next page request is sent to with an Azure access token.
768
765
  # Validate it shares the same origin as a trusted endpoint of the active cloud to prevent
769
766
  # the token from being sent to an attacker-controlled host such as
770
- # `https://management.azure.com.attacker`.
767
+ # `https://management.azure.com.attacker`. URLs that are not normalized, such as
768
+ # `https://management.azure.com//attacker.example/leak`, are rejected as well, since they
769
+ # may be resolved to a different host by a downstream parser, proxy or server.
771
770
  if next_link is not None:
772
771
  from azure.cli.core.util import is_trusted_cloud_endpoint
773
772
  if not is_trusted_cloud_endpoint(next_link, ctx.cli_ctx):
@@ -58,7 +58,7 @@ class Identity: # pylint: disable=too-many-instance-attributes
58
58
  _service_principal_store_instance = None
59
59
 
60
60
  def __init__(self, authority, tenant_id=None, client_id=None, encrypt=False, use_msal_http_cache=True,
61
- enable_broker_on_windows=None, instance_discovery=None):
61
+ enable_broker_on_windows=None, enable_broker_on_mac=None, instance_discovery=None):
62
62
  """
63
63
  :param authority: Authentication authority endpoint. For example,
64
64
  - AAD: https://login.microsoftonline.com
@@ -74,6 +74,7 @@ class Identity: # pylint: disable=too-many-instance-attributes
74
74
  self._encrypt = encrypt
75
75
  self._use_msal_http_cache = use_msal_http_cache
76
76
  self._enable_broker_on_windows = enable_broker_on_windows
77
+ self._enable_broker_on_mac = enable_broker_on_mac
77
78
  self._instance_discovery = instance_discovery
78
79
 
79
80
  # Build the authority in MSAL style
@@ -111,9 +112,10 @@ class Identity: # pylint: disable=too-many-instance-attributes
111
112
  @property
112
113
  def _msal_public_app_kwargs(self):
113
114
  """kwargs for creating PublicClientApplication."""
114
- # enable_broker_on_windows can only be used on PublicClientApplication.
115
+ # enable_broker_on_windows and enable_broker_on_mac can only be used on PublicClientApplication.
115
116
  return {**self._msal_app_kwargs,
116
117
  "enable_broker_on_windows": self._enable_broker_on_windows,
118
+ "enable_broker_on_mac": self._enable_broker_on_mac,
117
119
  "enable_pii_log": True}
118
120
 
119
121
  @property
@@ -519,7 +519,7 @@ AZURE_BLEU_CLOUD = Cloud(
519
519
  mariadb_server_endpoint='.mariadb.database.sovcloud-api.fr',
520
520
  synapse_analytics_endpoint='.dev.azuresynapse.sovcloud-api.fr'))
521
521
 
522
- HARD_CODED_CLOUD_LIST = [AZURE_PUBLIC_CLOUD, AZURE_CHINA_CLOUD, AZURE_US_GOV_CLOUD, AZURE_GERMAN_CLOUD, AZURE_BLEU_CLOUD]
522
+ HARD_CODED_CLOUD_LIST = [AZURE_PUBLIC_CLOUD, AZURE_CHINA_CLOUD, AZURE_US_GOV_CLOUD, AZURE_BLEU_CLOUD]
523
523
 
524
524
 
525
525
  def retrieve_arm_cloud_metadata():
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.89.1",
2
+ "version": "2.91.0",
3
3
  "cloudProfile": "latest",
4
4
  "commandIndex": {
5
5
  "account": [
@@ -241,13 +241,17 @@ def _check_value_in_extensions(cli_ctx, parser, args, no_prompt): # pylint: dis
241
241
  from azure.cli.core.extension.operations import add_extension
242
242
  add_extension(cli_ctx=cli_ctx, extension_name=ext_name, upgrade=True, allow_preview=extension_allow_preview)
243
243
  if run_after_extension_installed:
244
- import subprocess
245
- import platform
246
- exit_code = subprocess.call(args, shell=platform.system() == 'Windows')
244
+ # Rerun the command with the CLI's own entry point instead of handing the raw argv back to a
245
+ # shell. The previous implementation used `subprocess.call(args, shell=True)` on Windows, which
246
+ # let cmd.exe reinterpret user-controlled arguments (e.g. `&`, `|`, `^`) and allowed command
247
+ # injection. `run_az_cmd` executes the command in-process with the args kept as a list, so no
248
+ # shell is involved.
249
+ from azure.cli.core.util import run_az_cmd
250
+ result = run_az_cmd(args[1:])
251
+ exit_code = getattr(result, 'exit_code', 0)
247
252
  # In this case, error msg is for telemetry recording purpose only.
248
- # From UX perspective, the command will rerun in subprocess. Whether it succeeds or fails,
249
- # mesages will be shown from the subprocess and this process should not print more message to
250
- # interrupt that.
253
+ # From UX perspective, the command is rerun and its messages are already shown,
254
+ # so this process should not print more message to interrupt that.
251
255
  print_error = False
252
256
  error_msg = ("Extension {} dynamically installed{} and commands will be "
253
257
  "rerun automatically.").format(ext_name, prompt_info)
@@ -180,7 +180,7 @@ def _add_whl_ext(cli_ctx, source, ext_sha256=None, pip_extra_index_urls=None, pi
180
180
  return extension_name
181
181
 
182
182
 
183
- def _install_deps_for_psycopg2(): # pylint: disable=too-many-statements
183
+ def _install_deps_for_psycopg2(): # pylint: disable=too-many-statements, too-many-branches
184
184
  # If we are in Cloud Shell, dependencies should have already been installed.
185
185
  from azure.cli.core.util import in_cloud_console
186
186
  if in_cloud_console():
@@ -215,8 +215,17 @@ def _install_deps_for_psycopg2(): # pylint: disable=too-many-statements
215
215
  '/usr/local/opt/openssl/lib/'
216
216
  ])
217
217
  elif system == 'Linux':
218
- distname, _ = get_linux_distro()
219
- distname = distname.lower().strip()
218
+ distname, distversion = get_linux_distro()
219
+ distname = (distname or '').lower().strip()
220
+ distversion = (distversion or '').strip()
221
+ # Extract major version from VERSION_ID (e.g., "4", "4.0", "4.0.1" all map to major=4)
222
+ azl_major_version = None
223
+ if 'azure linux' in distname and distversion:
224
+ try:
225
+ azl_major_version = int(distversion.partition('.')[0])
226
+ except ValueError:
227
+ pass
228
+ is_azure_linux_4 = azl_major_version == 4
220
229
  if installer == 'DEB' or any(x in distname for x in ['ubuntu', 'debian']):
221
230
  exit_code = subprocess.call(['dpkg', '-s', 'gcc', 'libpq-dev', 'python3-dev'], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
222
231
  if exit_code != 0:
@@ -230,7 +239,7 @@ def _install_deps_for_psycopg2(): # pylint: disable=too-many-statements
230
239
  if exit_code == 0:
231
240
  logger.debug("Install dependencies with '%s'", " ".join(apt_install_cmd))
232
241
  subprocess.call(apt_install_cmd, True)
233
- elif installer == 'RPM' or any(x in distname for x in ['centos', 'rhel', 'red hat', 'fedora', 'opensuse', 'suse', 'sles']):
242
+ elif installer == 'RPM' or any(x in distname for x in ['centos', 'rhel', 'red hat', 'fedora', 'opensuse', 'suse', 'sles']) or is_azure_linux_4:
234
243
  if any(x in distname for x in ['centos', 'rhel', 'red hat', 'fedora']):
235
244
  yum_install_cmd = 'yum install -y gcc postgresql-devel python3-devel'.split()
236
245
  if os.geteuid() != 0: # pylint: disable=no-member
@@ -249,6 +258,29 @@ def _install_deps_for_psycopg2(): # pylint: disable=too-many-statements
249
258
  if exit_code == 0:
250
259
  logger.debug("Install dependencies with '%s'", " ".join(zypper_install_cmd))
251
260
  subprocess.call(zypper_install_cmd)
261
+ elif is_azure_linux_4:
262
+ from shutil import which
263
+ if which('tdnf') is None:
264
+ raise CLIError(
265
+ 'tdnf package manager not found. This extension requires Azure Linux 4 with tdnf '
266
+ 'to install required system dependencies: gcc, libpq-devel, python3-devel, binutils, '
267
+ 'glibc-devel, kernel-headers.'
268
+ )
269
+ rpm_packages = ['gcc', 'libpq-devel', 'python3-devel', 'binutils', 'glibc-devel', 'kernel-headers']
270
+ rpm_install_cmd = ['tdnf', 'install', '-y'] + rpm_packages
271
+ if os.geteuid() != 0: # pylint: disable=no-member
272
+ rpm_install_cmd.insert(0, 'sudo')
273
+ logger.debug("Install dependencies with '%s'", " ".join(rpm_install_cmd))
274
+ logger.warning(
275
+ 'This extension depends on %s and will now be installed.',
276
+ ' '.join(rpm_packages)
277
+ )
278
+ exit_code = subprocess.call(rpm_install_cmd)
279
+ if exit_code != 0:
280
+ raise CLIError(
281
+ 'Failed to install required system dependencies for psycopg2: {}.'
282
+ .format(' '.join(rpm_packages))
283
+ )
252
284
  elif installer == 'DOCKER' or any(x in distname for x in ['alpine linux']):
253
285
  apk_install_cmd = 'apk add --no-cache libpq-dev'.split()
254
286
  logger.debug("Install dependencies with '%s'", " ".join(apk_install_cmd))
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.89.1",
2
+ "version": "2.91.0",
3
3
  "cloudProfile": "latest",
4
4
  "helpIndex": {
5
5
  "groups": {
@@ -152,7 +152,7 @@
152
152
  "tags": ""
153
153
  },
154
154
  "eventhubs": {
155
- "summary": "Eventhubs.",
155
+ "summary": "Manage Event Hub.",
156
156
  "tags": ""
157
157
  },
158
158
  "extension": {
@@ -292,7 +292,7 @@
292
292
  "tags": ""
293
293
  },
294
294
  "servicebus": {
295
- "summary": "Servicebus.",
295
+ "summary": "Manage Service Bus.",
296
296
  "tags": ""
297
297
  },
298
298
  "sf": {
@@ -77,6 +77,7 @@ class TelemetrySession: # pylint: disable=too-many-instance-attributes
77
77
  self.user_agent = None
78
78
  # authentication-related
79
79
  self.enable_broker_on_windows = None
80
+ self.enable_broker_on_mac = None
80
81
  self.msal_telemetry = None
81
82
  self.login_experience_v2 = None
82
83
  self.agentic_session = False
@@ -238,6 +239,7 @@ class TelemetrySession: # pylint: disable=too-many-instance-attributes
238
239
  set_custom_properties(result, 'SecretNames', ','.join(self.secret_names or []))
239
240
  # authentication-related
240
241
  set_custom_properties(result, 'EnableBrokerOnWindows', str(self.enable_broker_on_windows))
242
+ set_custom_properties(result, 'EnableBrokerOnMac', str(self.enable_broker_on_mac))
241
243
  set_custom_properties(result, 'MsalTelemetry', self.msal_telemetry)
242
244
  set_custom_properties(result, 'LoginExperienceV2', str(self.login_experience_v2))
243
245
  set_custom_properties(result, 'AgenticSession', str(self.agentic_session))
@@ -485,9 +487,10 @@ def set_region_identified(region_input, region_identified):
485
487
 
486
488
  # region authentication-related
487
489
  @decorators.suppress_all_exceptions()
488
- def set_broker_info(enable_broker_on_windows):
489
- # Log the value of `enable_broker_on_windows`
490
+ def set_broker_info(enable_broker_on_windows, enable_broker_on_mac=None):
491
+ # Log the value of `enable_broker_on_windows` and `enable_broker_on_mac`
490
492
  _session.enable_broker_on_windows = enable_broker_on_windows
493
+ _session.enable_broker_on_mac = enable_broker_on_mac
491
494
 
492
495
 
493
496
  @decorators.suppress_all_exceptions()
@@ -1028,7 +1028,13 @@ def send_raw_request(cli_ctx, method, url, headers=None, uri_parameters=None, #
1028
1028
  # default to Azure Resource Manager.
1029
1029
  # https://management.azure.com + /subscriptions/xxx/resourcegroups/xxx?api-version=2019-07-01
1030
1030
  if '://' not in url:
1031
- url = endpoints.resource_manager.rstrip('/') + url
1031
+ # lstrip('/') prevents a protocol-relative path like '//attacker.example/leak' from
1032
+ # producing 'https://management.azure.com//attacker.example/leak'.
1033
+ url = endpoints.resource_manager.rstrip('/') + '/' + url.lstrip('/')
1034
+
1035
+ # Normalize before validating and before sending, so that the URL whose origin is validated is
1036
+ # exactly the URL the request is sent to.
1037
+ url = normalize_url(url)
1032
1038
 
1033
1039
  # Replace common tokens with real values. It is for smooth experience if users copy and paste the url from
1034
1040
  # Azure Rest API doc
@@ -1075,6 +1081,13 @@ def send_raw_request(cli_ctx, method, url, headers=None, uri_parameters=None, #
1075
1081
  req = Request(method=method, url=url, headers=headers, params=uri_parameters, data=body)
1076
1082
  prepped = s.prepare_request(req)
1077
1083
 
1084
+ # Final defense: make sure requests didn't resolve the URL to a different origin than the one
1085
+ # whose origin was validated above before an access token was attached.
1086
+ if 'Authorization' in prepped.headers and not is_same_origin(prepped.url, url):
1087
+ from .azclierror import InvalidArgumentValueError
1088
+ raise InvalidArgumentValueError(
1089
+ "The request URL '{}' doesn't match the validated URL '{}'.".format(prepped.url, url))
1090
+
1078
1091
  # Merge environment settings into session
1079
1092
  settings = s.merge_environment_settings(prepped.url, {}, None, not should_disable_connection_verify(), None)
1080
1093
  _log_request(prepped)
@@ -1202,6 +1215,92 @@ def urlretrieve(url):
1202
1215
  return req.read()
1203
1216
 
1204
1217
 
1218
+ def _remove_dot_segments(path):
1219
+ """Remove ``.`` and ``..`` segments from a URL path (RFC 3986 section 5.2.4) and collapse
1220
+ empty segments, so that ``/a/b/../c`` becomes ``/a/c`` and ``//attacker.example/leak``
1221
+ becomes ``/attacker.example/leak``.
1222
+ """
1223
+ leading_slash = path.startswith('/')
1224
+ trailing_slash = path.endswith('/')
1225
+ segments = []
1226
+ for segment in path.split('/'):
1227
+ # Empty segments are dropped so that a path can never be re-interpreted as an authority
1228
+ # (protocol-relative URL) by a downstream parser, proxy or gateway.
1229
+ if segment in ('', '.'):
1230
+ continue
1231
+ if segment == '..':
1232
+ if segments:
1233
+ segments.pop()
1234
+ continue
1235
+ segments.append(segment)
1236
+ new_path = '/'.join(segments)
1237
+ if leading_slash:
1238
+ new_path = '/' + new_path
1239
+ if trailing_slash and not new_path.endswith('/'):
1240
+ new_path += '/'
1241
+ return new_path
1242
+
1243
+
1244
+ def normalize_url(url):
1245
+ """Normalize a URL so that it is parsed the same way by the CLI and by any downstream
1246
+ consumer (requests/urllib3, proxies, gateways, servers).
1247
+
1248
+ Validating a URL that is not normalized is unsafe, because the validator and the consumer
1249
+ may disagree on which host the request is actually sent to. This function:
1250
+
1251
+ - removes control characters, which are silently stripped by many URL parsers, and trims
1252
+ leading/trailing whitespace;
1253
+ - lowercases the scheme and the host;
1254
+ - converts backslashes in the authority to ``/`` (WHATWG URL parsers treat ``\\`` as ``/``),
1255
+ moving anything after them into the path;
1256
+ - removes ``.``/``..`` segments and collapses empty segments in the path, so that
1257
+ ``https://management.azure.com//attacker.example/leak`` is normalized to
1258
+ ``https://management.azure.com/attacker.example/leak``.
1259
+
1260
+ :param url: The URL to normalize.
1261
+ :return: The normalized URL, or the input unchanged if it is not a parsable string.
1262
+ :rtype: str
1263
+ """
1264
+ from urllib.parse import urlsplit, urlunsplit
1265
+
1266
+ if not isinstance(url, str):
1267
+ return url
1268
+
1269
+ # Strip C0/DEL control characters. Browsers and urllib strip some of them (\t, \r, \n), so a
1270
+ # validator must not consider them part of the host.
1271
+ # Note: the space character (U+0020) is *not* removed from the middle of the URL, as it is a
1272
+ # meaningful character that downstream consumers percent-encode as '%20' rather than drop.
1273
+ # Only leading and trailing whitespace is trimmed.
1274
+ cleaned = ''.join(c for c in url if ord(c) >= 0x20 and ord(c) != 0x7f).strip()
1275
+
1276
+ try:
1277
+ parts = urlsplit(cleaned)
1278
+ except ValueError:
1279
+ return cleaned
1280
+
1281
+ scheme = parts.scheme.lower()
1282
+ netloc = parts.netloc
1283
+ path = parts.path
1284
+
1285
+ if netloc:
1286
+ # `urlsplit` doesn't treat '\' as a delimiter, but WHATWG parsers do. Anything after it
1287
+ # belongs to the path, not to the authority.
1288
+ netloc = netloc.replace('\\', '/')
1289
+ if '/' in netloc:
1290
+ netloc, _, rest = netloc.partition('/')
1291
+ path = '/' + rest + path
1292
+ # The host is case-insensitive, but userinfo isn't, so only lowercase the host part.
1293
+ userinfo, sep, hostport = netloc.rpartition('@')
1294
+ netloc = userinfo + sep + hostport.lower()
1295
+
1296
+ if path:
1297
+ path = _remove_dot_segments(path)
1298
+ elif netloc:
1299
+ path = '/'
1300
+
1301
+ return urlunsplit((scheme, netloc, path, parts.query, parts.fragment))
1302
+
1303
+
1205
1304
  def is_same_origin(url, endpoint):
1206
1305
  """Check whether ``url`` and ``endpoint`` share the same origin (scheme + host + port).
1207
1306
 
@@ -1211,6 +1310,9 @@ def is_same_origin(url, endpoint):
1211
1310
  URL points to a trusted endpoint before sensitive data (e.g., an Azure access token) is sent
1212
1311
  to it.
1213
1312
 
1313
+ The URLs are normalized with :func:`normalize_url` first, so that tricks relying on control
1314
+ characters or backslashes in the authority can't hide the real host.
1315
+
1214
1316
  :param url: The URL to validate, e.g., ``https://management.azure.com/subscriptions/...``.
1215
1317
  :param endpoint: The trusted endpoint to validate against, e.g., ``https://management.azure.com/``.
1216
1318
  :return: ``True`` if both share the same origin, otherwise ``False``.
@@ -1222,8 +1324,8 @@ def is_same_origin(url, endpoint):
1222
1324
  return False
1223
1325
 
1224
1326
  try:
1225
- url_parts = urlparse(url)
1226
- endpoint_parts = urlparse(endpoint)
1327
+ url_parts = urlparse(normalize_url(url))
1328
+ endpoint_parts = urlparse(normalize_url(endpoint))
1227
1329
 
1228
1330
  except (TypeError, ValueError):
1229
1331
  return False
@@ -1280,11 +1382,19 @@ def match_cloud_endpoint(url, cli_ctx):
1280
1382
  def is_trusted_cloud_endpoint(url, cli_ctx):
1281
1383
  """Check whether ``url`` shares the same origin as any endpoint of the active cloud.
1282
1384
 
1385
+ The URL must already be in normalized form (see :func:`normalize_url`). A URL that is not
1386
+ normalized is rejected, because the CLI and the downstream consumer (requests, a proxy or the
1387
+ server) may not resolve it to the same host, e.g.
1388
+ ``https://management.azure.com//attacker.example/leak``, whose path can be re-interpreted as
1389
+ a protocol-relative URL.
1390
+
1283
1391
  :param url: The URL to validate, e.g., ``https://management.azure.com/subscriptions/...``.
1284
1392
  :param cli_ctx: The CLI context whose active cloud's endpoints are treated as trusted.
1285
1393
  :return: ``True`` if ``url`` shares the same origin as any cloud endpoint, otherwise ``False``.
1286
1394
  :rtype: bool
1287
1395
  """
1396
+ if not isinstance(url, str) or normalize_url(url) != url:
1397
+ return False
1288
1398
  return match_cloud_endpoint(url, cli_ctx) is not None
1289
1399
 
1290
1400
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azure-cli-core
3
- Version: 2.89.1
3
+ Version: 2.91.0
4
4
  Summary: Microsoft Azure Command-Line Tools Core Module
5
5
  Home-page: https://github.com/Azure/azure-cli
6
6
  Author: Microsoft Corporation
@@ -30,8 +30,8 @@ Requires-Dist: jmespath
30
30
  Requires-Dist: knack~=0.14.0
31
31
  Requires-Dist: microsoft-security-utilities-secret-masker~=1.0.0b4
32
32
  Requires-Dist: msal-extensions==1.3.1
33
- Requires-Dist: msal[broker]==1.36.0; sys_platform == "win32"
34
- Requires-Dist: msal==1.36.0; sys_platform != "win32"
33
+ Requires-Dist: msal[broker]==1.39.0; sys_platform == "win32" or sys_platform == "darwin"
34
+ Requires-Dist: msal==1.39.0; sys_platform != "win32" and sys_platform != "darwin"
35
35
  Requires-Dist: packaging>=20.9
36
36
  Requires-Dist: pkginfo>=1.12.0
37
37
  Requires-Dist: psutil>=5.9; sys_platform != "cygwin"
@@ -18,11 +18,11 @@ requests[socks]
18
18
  [:sys_platform != "cygwin"]
19
19
  psutil>=5.9
20
20
 
21
- [:sys_platform != "win32"]
22
- msal==1.36.0
21
+ [:sys_platform != "win32" and sys_platform != "darwin"]
22
+ msal==1.39.0
23
23
 
24
24
  [:sys_platform == "linux"]
25
25
  distro
26
26
 
27
- [:sys_platform == "win32"]
28
- msal[broker]==1.36.0
27
+ [:sys_platform == "win32" or sys_platform == "darwin"]
28
+ msal[broker]==1.39.0
@@ -8,7 +8,7 @@
8
8
  from codecs import open
9
9
  from setuptools import setup, find_packages
10
10
 
11
- VERSION = "2.89.1"
11
+ VERSION = "2.91.0"
12
12
 
13
13
  # If we have source, validate that our version numbers match
14
14
  # This should prevent uploading releases with mismatched versions.
@@ -56,8 +56,8 @@ DEPENDENCIES = [
56
56
  'knack~=0.14.0',
57
57
  'microsoft-security-utilities-secret-masker~=1.0.0b4',
58
58
  'msal-extensions==1.3.1',
59
- 'msal[broker]==1.36.0; sys_platform == "win32"',
60
- 'msal==1.36.0; sys_platform != "win32"',
59
+ 'msal[broker]==1.39.0; sys_platform == "win32" or sys_platform == "darwin"',
60
+ 'msal==1.39.0; sys_platform != "win32" and sys_platform != "darwin"',
61
61
  'packaging>=20.9',
62
62
  # pkginfo>=1.12.0 reads the spec-defined wheel METADATA / unpacked .dist-info
63
63
  # layout produced by modern wheel/setuptools (no metadata.json). Required so