Repository navigation
Require trust confirmation when adding template sources - #21418
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21418Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21418" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The new terminal consent flow lacks regression coverage for prompt details, default-No and explicit responses, and redirected stdin without --yes, leaving configuration-write safeguards unverified.
1 open issue
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
What changed in this PR
Adds an explicit trust decision before the Aspire CLI saves a global template source, warning that templates can run code.
Changes:
- Adds a default-No confirmation prompt and
--yes/-yfor explicit automated consent. - Adds tests for acceptance, cancellation, and non-interactive behavior; updates existing automated invocations.
- Updates help text, resource accessors, and localization entries.
| File | Description |
|---|---|
tests/Aspire.Cli.Tests/Commands/TemplateSourceStartupTests.cs |
Adds explicit consent to startup test commands. |
tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.SourceManagement.cs |
Tests trust decisions and non-interactive requirements. |
tests/Aspire.Cli.EndToEnd.Tests/CustomTemplateTests.cs |
Adds --yes to scripted source additions. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.zh-Hant.xlf |
Updates Traditional Chinese localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.zh-Hans.xlf |
Updates Simplified Chinese localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.tr.xlf |
Updates Turkish localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.ru.xlf |
Updates Russian localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.pt-BR.xlf |
Updates Brazilian Portuguese localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.pl.xlf |
Updates Polish localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.ko.xlf |
Updates Korean localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.ja.xlf |
Updates Japanese localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.it.xlf |
Updates Italian localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.fr.xlf |
Updates French localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.es.xlf |
Updates Spanish localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.de.xlf |
Updates German localization entries. |
src/Aspire.Cli/Resources/xlf/NewCommandStrings.cs.xlf |
Updates Czech localization entries. |
src/Aspire.Cli/Resources/NewCommandStrings.resx |
Defines trust prompt and revised help text. |
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs |
Exposes the new resource strings. |
src/Aspire.Cli/Commands/TemplateManagementCommand.cs |
Requires trust confirmation before saving a source. |
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Tests selector3 / 100 PR test projects · 4 PR jobs, from 19 changed files. Selected PR test projects (3 / 100)
Selected PR jobs (4)
How these were chosen — grouped by what changed📦 affected project 🔧 🧪 🧪 🧪 Job reasons
Selection computed for commit |
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change requiring explicit trust before saving a global template source.
1 open issue
1 file not reviewed
src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs: Generated file
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
James Newton-King (JamesNK)
left a comment
There was a problem hiding this comment.
No issues found.
|
Pull request created: #1983
|
|
📝 Documentation has been drafted in microsoft/aspire.dev#1983 targeting Added new Note This draft PR needs human review before merging. |

Description
Adding a template source currently saves it globally without asking whether the user trusts its content. Templates can run code, so adding a source should require an explicit trust decision.
aspire template source addnow asks whether the user trusts the named source, showing its repository URL or local path and defaulting to No. Declining cancels without changing configuration.--yes/-ytrusts the source and skips confirmation, following existing CLI conventions. Non-interactive invocations fail without--yes, including when interactive input is unavailable without an explicit--non-interactiveflag.Uses the existing confirmation binding and non-interactive validator. Updates localized resources and existing automated source-management invocations. The configured-template Hex1b E2E scenario now checks the source name/location and default-No prompt, unchanged configuration after Enter or
n, persistence aftery, and failure without writes when stdin is redirected without--yes.Fixes # (issue)
User-facing usage
Interactive:
aspire template source add company --repository https://example.com/templatesAutomation must explicitly trust the source:
aspire template source add company --repository https://example.com/templates --non-interactive --yesRelevant output from this branch's
template source add --help:Screenshots / Recordings
Trust confirmation captured from this branch's built CLI:
Validation
dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-method '*.TemplateSource*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'.dotnet test --project tests/Aspire.Cli.Tests/Aspire.Cli.Tests.csproj --no-launch-profile -- --filter-class '*.NewCommandLocalTemplateTests' --filter-class '*.TemplateSourceStartupTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'.dotnet build /t:UpdateXlf src/Aspire.Cli/Aspire.Cli.csproj(0 warnings, 0 errors).dotnet artifacts/bin/Aspire.Cli/Debug/net11.0/aspire.dll template source add --help.dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj(0 warnings, 0 errors).dotnet test --project tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj --no-launch-profile -- --filter-method '*.ConfiguredTemplateSourceCommandsAndSearchWithoutDotNetSdk' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true'. SetASPIRE_E2E_ARCHIVEto this branch's locally builtlinux-arm64LocalHive archive. Built with--skip-bundlebecause this SDK-free scenario does not need the Dashboard; the full cross-platform bundle build was blocked by missing native Dashboard symbol-stripping tooling on macOS.Security considerations
This adds a user-consent boundary before persisting a global template source. It does not sandbox templates, validate their publisher, or guarantee that their contents are safe.
--yesis an explicit trust bypass for automation. Source names and locations are escaped before rendering the prompt.Checklist
<remarks />and<code />elements on your triple slash comments?