Skip to content

Conversation

@eerhardt
Copy link
Member

Description

Our python starter template has an Authenitcode signature block in its .py files. These aren't wanted because users are meant to change these templates.

Fix #13004

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • No
  • Did you add public API?
    • No
  • Does the change make any security assumptions or guarantees?
    • No
  • Does the change require an update in our Aspire docs?
    • No

Our python starter template has an Authenitcode signature block in its .py files. These aren't wanted because users are meant to change these templates.

Fix dotnet#13004
@github-actions
Copy link
Contributor

github-actions bot commented Nov 17, 2025

🚀 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/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13005

Or

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

Copilot finished reviewing on behalf of eerhardt November 17, 2025 16:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes Python files from Authenticode signing to allow users to modify template files without signature validation issues.

  • Excludes .py files from the signing configuration
  • Preserves PowerShell file signing with the Microsoft400 certificate
  • Addresses issue #13004 where template Python files were incorrectly signed

<FileExtensionSignInfo Include=".msi" CertificateName="MicrosoftDotNet500" Condition="!@(FileExtensionSignInfo->AnyHaveMetadataValue('Identity', '.msi'))" />

<!-- Remove .py files from being signed. See https://github.com/dotnet/aspire/issues/13004 -->
<FileExtensionSignInfo Remove=".ps1;.psd1;.psm1;.psc1;.py" />
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to remove then re-include the non-.py file extensions?

Copy link
Member Author

Choose a reason for hiding this comment

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

In MSBuild you can't change an "Include" on an Item as that's it's ID. In order to modify the "Include", you need to remove the whole Item, and then readd it with the updated value.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, I'm a bit worried about this here as we would be potentially exposed to any change of this list in a future arcade update. I wonder if with a bit more code but we could just instead calculate on the fly what the Include value is based on searching for .py, and then adding it back but replacing the .py with empty string would work?

Copy link
Member

Choose a reason for hiding this comment

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

Let me know if you want me to work on the above

Copy link
Member Author

Choose a reason for hiding this comment

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

I think a more maintainable solution would be for us to get arcade updated to support this scenario. Similar to Do not sign .js files by default (dotnet/arcade#15760).

cc @ellahathaway

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

What's the SLA for things like this plus us taking a new arcade version (that we frequently revert?)

Copy link
Member

Choose a reason for hiding this comment

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

In MSBuild you can't change an "Include" on an Item as that's it's ID. In order to modify the "Include", you need to remove the whole Item, and then readd it with the updated value.

Are you sure about that? AFAIU, with the ; the items will get split up, and they will become individual items. What do you get if you print the items with %(Identity)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call @radical. I tested it in an isolated csproj:

    <ItemGroup>
        <FileExtensionSignInfo Include=".ps1;.psd1;.psm1;.psc1;.py" Foo="bar" />
        <FileExtensionSignInfo Remove=".py" />
    </ItemGroup>

    <Target Name="PrintInfo" BeforeTargets="Build">
      <Message Importance="High" Text="FileExtensionSignInfo items:" />
      <Message Importance="High" Text="  @(FileExtensionSignInfo->'%(Identity) - %(Foo)')" />
    </Target>

Produces

image

@eerhardt eerhardt enabled auto-merge (squash) November 18, 2025 16:36
@eerhardt
Copy link
Member Author

/backport to release/13.0

@github-actions
Copy link
Contributor

Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19473676064

@github-actions
Copy link
Contributor

@eerhardt backporting to "release/13.0" failed, the patch most likely resulted in conflicts:

$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Patch format detection failed.
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@eerhardt eerhardt merged commit 6b8213b into dotnet:main Nov 18, 2025
582 of 585 checks passed
@eerhardt eerhardt deleted the UnsignPythonFiles branch November 18, 2025 16:40
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 18, 2025
eerhardt added a commit to eerhardt/aspire that referenced this pull request Nov 18, 2025
* Remove .py files from being signed

Our python starter template has an Authenitcode signature block in its .py files. These aren't wanted because users are meant to change these templates.

Fix dotnet#13004

* PR feedback
joperezr pushed a commit that referenced this pull request Nov 21, 2025
…13032)

* Remove .py files from being signed (#13005)

* Remove .py files from being signed

Our python starter template has an Authenitcode signature block in its .py files. These aren't wanted because users are meant to change these templates.

Fix #13004

* PR feedback

* Don't sign JS files

We have .js files in our templates that are currently getting signed in our official builds. We don't want this, nor signing .py files. Exclude them both the same way - Update + CertificateName=None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python starter template has signed py files

5 participants