Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
packages/source-control-azure-devops
Steps to reproduce
az expands file references in every argument before it parses the command (_expand_file_prefixed_files in azure/cli/core/commands/__init__.py, azure-cli 2.90.0). An argument is replaced by the contents of a file when it starts with @, or when the text after its first = starts with @. A path that does not exist is left as written. azure-cli has no escape for this.
T3 Code passes free text to az inline:
AzureDevOpsCli.createPullRequestpasses the generated title as--title <title>.AzureDevOpsPullRequestCli.updatePullRequestpasses--title=<title>and--description=<body>.createPullRequestpasses the source branch as written, and git accepts a branch named@name.
- In an Azure DevOps checkout, create a file
notes.txtthat containsfrom the file. - Edit an open pull request in T3 Code and set its title to
@notes.txt.
Expected behavior
The pull request title on Azure DevOps is @notes.txt.
Actual behavior
The title is from the file. A title such as [email protected] gives a=from the file.
Proposed fix
- One check before every az run. All 19 az calls go through
AzureDevOpsCli.execute. It refuses, before spawning, any argument that az would expand: one that starts with@, or whose text after the first=starts with@. A new call site that forgets the rule then fails in a test instead of reading a file. - Free text travels in files. A small helper in
AzureDevOpsCliwrites a value to a temporary file, returns--title @<file>style arguments that the check lets through, and removes the file afterwards.createPullRequestalready sends the description this way (@${bodyFile}); title and theupdatePullRequestfields use the same helper. az does not expand the file's contents again. - Branches as full refs.
createPullRequestpassesrefs/heads/<name>for the source and target branch. az accepts full refs, so no branch value starts with@.listPullRequestsalready percent-encodes the branch, which turns@into%40.
Not proposed: refusing titles that start with @ (a title like @team please review is fine once it goes through a file), moving the calls to az devops invoke, or an escape character (az has none).
Tests
AzureDevOpsCli.test.ts:executerefuses["--title", "@x"],["--title=@x"]and["--title", "a=@x"]and spawns nothing.AzureDevOpsPullRequestCli.test.ts:updatePullRequestwith the title@notes.txtpasses a file whose content is exactly@notes.txt. The existing case at line 446 that expects--description=- rewrote the page...changes with it.
Impact
Minor bug or occasional failure
Version or commit
main at 2cb2fa1, azure-cli 2.90.0
Activity
fix(azure-devops): send `@` text to az on stdin so Windows az under W…
fix(azure-devops): a new pull request's `@path` description is saved …