[ACR] az acr login: harden binary resolution and credential passing#33373
[ACR] az acr login: harden binary resolution and credential passing#33373lizMSFT wants to merge 3 commits into
Conversation
️✔️AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
There was a problem hiding this comment.
Pull request overview
Hardens az acr login by validating the resolved docker/podman binary path (rejecting binaries located directly in CWD) and switching credential passing from --password (CLI arg, visible in process listings) to --password-stdin (piped via stdin). The get_docker_command flow is also refactored into smaller helpers and a DOCKER_COMMAND env var is honored as a trusted absolute-path override.
Changes:
- Switch
_perform_registry_loginto--password-stdinwithBrokenPipeError/OSErrorhandling and an updated wincred retry path. - Add
_validate_command_pathto refuse binaries resolved from CWD, with a diagnostics-mode soft path; integrate it into a new_resolve_docker_commandhelper plus_try_wsl_exe_fallback. - Add a unit test module covering CWD-block, system-path-allow, Windows-path, diagnostics, and symlink-bypass cases.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/acr/custom.py | Refactors get_docker_command, adds CWD path validation, switches docker login to --password-stdin. |
| src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_docker_path_validation.py | New unit tests covering _validate_command_path behavior on POSIX, Windows, diagnostics, and symlink scenarios. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dffabd8 to
e1e8b72
Compare
e1e8b72 to
493af3a
Compare
2c53fa9 to
d3f7fd7
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
Hi @lizMSFT |
|
LGTM as agreed upon |
d3f7fd7 to
d92cc66
Compare
|
@yanzhudd yes the pr is ready. Could you re-trigger the test, thanks |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Check both abspath (where PATH found the binary) and realpath (where the symlink ultimately points) against the CWD. This blocks both: - A symlink in CWD pointing elsewhere (caught by abspath) - A binary elsewhere that symlinks into the CWD (caught by realpath) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
38d50bd to
29ca45b
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
Related command
az acr loginDescription
Harden Docker/Podman binary resolution and credential passing in
az acr login:--password(command-line argument) to--password-stdin(stdin pipe)DOCKER_COMMANDenvironment variable support for specifying a trusted absolute path to the binaryget_docker_command()into smaller helper functions for clarityTesting Guide
History Notes
[ACR]
az acr login: Harden binary resolution and credential passingThis 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.