Skip to content

Require trust confirmation when adding template sources - #21418

Merged
Mitch Denny (mitchdenny) merged 2 commits into
mainfrom
mitchdenny-template-source-trust
Oct 30, 2026
Merged

Mitch Denny (mitchdenny) merged 2 commits into
mainfrom
mitchdenny-template-source-trust

Conversation

@mitchdenny

@mitchdenny Mitch Denny (mitchdenny) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

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 add now 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 / -y trusts 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-interactive flag.

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 after y, 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/templates
Templates can run code. Do you trust template source 'company' (https://example.com/templates)? [y/N]:

Automation must explicitly trust the source:

aspire template source add company --repository https://example.com/templates --non-interactive --yes

Relevant output from this branch's template source add --help:

Description:
  Add a named template source to global configuration after confirming you trust it.

Usage:
  aspire template source add <name> [options]

Arguments:
  <name>  The name of the template source.

Options:
  -y, --yes  Trust the template source and skip confirmation.

Screenshots / Recordings

This PR includes UI changes. Please add screenshots or screen recordings so reviewers can evaluate the visual changes without running locally.

  • For before/after comparisons, place them side-by-side or label them clearly.
  • For interactive changes (animations, transitions, new flows), prefer a short screen recording (GIF or video).
  • If you cannot capture visuals now, note what scenario to test and mark this section as TODO.

Trust confirmation captured from this branch's built CLI:

Template source trust confirmation

Validation

  • Passed (129 tests): 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'.
  • Passed (448 tests): 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'.
  • Passed: dotnet build /t:UpdateXlf src/Aspire.Cli/Aspire.Cli.csproj (0 warnings, 0 errors).
  • Passed: dotnet artifacts/bin/Aspire.Cli/Debug/net11.0/aspire.dll template source add --help.
  • Manually verified the interactive trust prompt using the built CLI in an isolated terminal.
  • Passed: dotnet build tests/Aspire.Cli.EndToEnd.Tests/Aspire.Cli.EndToEnd.Tests.csproj (0 warnings, 0 errors).
  • Passed (1 Docker E2E scenario, 28 seconds): 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'. Set ASPIRE_E2E_ARCHIVE to this branch's locally built linux-arm64 LocalHive archive. Built with --skip-bundle because 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. --yes is an explicit trust bypass for automation. Source names and locations are escaped before rendering the prompt.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21418

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21418"

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 / -y for 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>
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector

3 / 100 PR test projects · 4 PR jobs, from 19 changed files.

Selected PR test projects (3 / 100)

Aspire.Cli.EndToEnd.Tests, Aspire.Cli.Tests, Infrastructure.Tests

Selected PR jobs (4)

cli-starter-validation, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

📦 affected project Aspire.Cli
→ 1 test: Aspire.Cli.EndToEnd.Tests

🔧 src/Aspire.Cli/Resources/NewCommandStrings.resx (changed source)
→ 1 directly: Infrastructure.Tests

🧪 tests/Aspire.Cli.EndToEnd.Tests/CustomTemplateTests.cs (changed test)
→ 1 directly: Aspire.Cli.EndToEnd.Tests

🧪 tests/Aspire.Cli.Tests/Commands/NewCommandLocalTemplateTests.SourceManagement.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

🧪 tests/Aspire.Cli.Tests/Commands/TemplateSourceStartupTests.cs (changed test)
→ 1 directly: Aspire.Cli.Tests

Job reasons

Job Triggered by
cli-starter-validation affected project Aspire.Cli
extension-e2e • src/Aspire.Cli/Commands/TemplateManagementCommand.cs, src/Aspire.Cli/Resources/NewCommandStrings.Designer.cs, src/Aspire.Cli/Resources/NewCommandStrings.resx, src/Aspire.Cli/Resources/xlf/NewCommandStrings.cs.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.de.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.es.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.fr.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.it.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.ja.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.ko.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.pl.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.pt-BR.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.ru.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.tr.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.zh-Hans.xlf, src/Aspire.Cli/Resources/xlf/NewCommandStrings.zh-Hant.xlf
• affected project Aspire.Cli
polyglot affected project Aspire.Cli
typescript-api-compat affected project Aspire.Cli

Selection computed for commit af943f3.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found.

@mitchdenny
Mitch Denny (mitchdenny) merged commit 6999802 into main Oct 30, 2026
416 of 420 checks passed
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 17.0 milestone Oct 30, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1983

Generated by PR Documentation Check · copilot · auto · 23.6 AIC · ⌖ 1.04 AIC · ⊞ 7.1K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1983 targeting release/17.0.

Added new aspire template source add CLI reference page covering the trust prompt (default No) and --yes/-y. Signals: cli_command_file_changed (TemplateManagementCommand.cs), cli_option_added (--yes), cli_resource_strings_changed (NewCommandStrings.resx), pr_body_has_cli_flag_mention, pr_body_has_user_facing_section. Sidebar entry not added since no other template command pages exist.

Note

This draft PR needs human review before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants