Repository navigation
[Ssh] Fix #8994: az ssh cert: Allow skipping certificate file permissions on ACL-less filesystems - #10505
Conversation
…permissions on ACL-less filesystems Root cause: src/ssh/azext_ssh/custom.py:_write_cert_file writes and closes the public certificate, then unconditionally calls oschmod.set_mode(cert_file, 0o644). oschmod 0.3.12 dereferences a missing Windows DACL in _win_set_permissions, aborting az ssh cert after successful output. ssh_cert and _params.py:load_arguments had no permission bypass. Change: Added cert-only --skip-cert-file-permissions (short alias --skip-cert-perms to satisfy the CLI option-length rule), default false, threaded from ssh_cert through _get_and_write_certificate to _write_cert_file. Explicit skip writes the certificate normally, avoids oschmod, and warns that file permissions were not adjusted. Default behavior still sets mode 0644; a finally block localized to permission setting emits retry guidance on any permission exception without catching or replacing it. Actual write errors are outside that block and still fail. Added real-file and … Alternatives considered: - Silently tolerate permission errors: rejected because users must explicitly choose to retain filesystem-provided permissions and unrelated failures must still surface. - Patch oschmod or replace its Windows ACL implementation: rejected because the extension can explicitly avoid the unsupported operation without modifying a dependency or weakening other SSH commands. Verified: - Trusted validation passed (1 command). - New or changed tests fail on the base revision and pass with the change: `src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_cli_argument_and_help`, `src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_default_permissions`, `src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_permission_errors_preserved_with_retry_guidance`. - Unit tests: 37 executed, 0 skipped. - flake8, pylint and the breaking change check passed. - Pre-publication gates passed: release-artifact, generated-ownership, command-help, regression-test, independent-review. - Repository CI and live tests run on this PR. Fixes Azure#8994
X Engineering Agent ReportReview — Comments No confirmed findings in the bounded semantic review.
Test validation
Risk assessment — 47/100 · MediumThe Medium rating is driven by public CLI behavior, dependency or supply chain, failure-handling behavior.
Posted by x-engineering-agent (Reviewer) Live test — Passed (37/37)PASS Selectors: Changed test files runWorkflow run: https://github.com/Azure/issue-sentinel/actions/runs/39729330465 Last 80 lines of azdev outputPosted by x-engineering-agent (Tester) |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
🟢 Approval recommended
The narrowly scoped, opt-in bypass preserves existing defaults and error propagation, with focused regression coverage and no unresolved findings.
No open issues 🎉
What changed in this PR
Addresses #8994 by adding an opt-in permission bypass to az ssh cert, allowing public certificates to be written on filesystems without access control list (ACL) support.
Changes:
- Adds
--skip-cert-file-permissionsand its shorter alias while preserving default permission enforcement and write-error propagation. - Adds warnings, retry guidance, help examples, and regression tests.
- Updates the SSH extension to version 2.0.10 and records the change.
| File | Description |
|---|---|
| src/ssh/setup.py | Bumps the extension version to 2.0.10. |
| src/ssh/HISTORY.rst | Documents the permission bypass and preserved defaults. |
| src/ssh/azext_ssh/tests/latest/test_custom.py | Tests bypass behavior, defaults, errors, and CLI registration. |
| src/ssh/azext_ssh/custom.py | Threads the bypass option through certificate writing and adds warnings. |
| src/ssh/azext_ssh/_params.py | Registers the cert-only option and alias. |
| src/ssh/azext_ssh/_help.py | Adds a usage example for filesystems without ACL support. |
Review effort: Balanced
There was a problem hiding this comment.
Aditya Pujara (@a0x1ab) Ready for human review. See the X Engineering Agent Report.
|
Please fix CI issues |
🤖 PR Validation —⚠️ Review suggested
Description
Fixes #8994.
Allow skipping certificate file permissions on ACL-less filesystems.
Root cause: src/ssh/azext_ssh/custom.py:_write_cert_file writes and closes the public certificate, then unconditionally calls oschmod.set_mode(cert_file, 0o644). oschmod 0.3.12 dereferences a missing Windows DACL in _win_set_permissions, aborting az ssh cert after successful output. ssh_cert and _params.py:load_arguments had no permission bypass.
Fix: Added cert-only --skip-cert-file-permissions (short alias --skip-cert-perms to satisfy the CLI option-length rule), default false, threaded from ssh_cert through _get_and_write_certificate to _write_cert_file. Explicit skip writes the certificate normally, avoids oschmod, and warns that file permissions were not adjusted. Default behavior still sets mode 0644; a finally block localized to permission setting emits retry guidance on any permission exception without catching or replacing it. Actual write errors are outside that block and still fail. Added real-file and …
How verified (trusted validation output):
src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_cli_argument_and_help,src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_default_permissions,src/ssh/azext_ssh/tests/latest/test_custom.py::SshCertPermissionsTest::test_ssh_cert_permission_errors_preserved_with_retry_guidance.Risks and limitations (from the job report):
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az ssh certGeneral Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install azdevrequired)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.Independent review: an independent reviewer checked this change against 7 acceptance criteria derived from the issue (5 required); every required criterion is backed by evidence in the diff.