Skip to content

Preserve entitlements in MacOS signer #115800

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

jtschuster
Copy link
Member

Testing CI to preserve entitlements in the managed MacOS signer

- Write out the updated symtab command when writing Mach-O file
- Pass macosCodesign through to test CreateAppHost methods
- Remove redundant `codesign` checks
- Warn when bundler is told to sign the bundle for a non-macos target
- Allow macosCodesign to be true for non-mac bundles
- Allow some padding between string table and signature
- Use the same memory-mapped file instance for placeholder replacement
  and signing
- formatting changes
@github-actions github-actions bot added the area-HostModel Microsoft.NET.HostModel issues label May 20, 2025
Copy link
Contributor

Tagging subscribers to this area: @vitek-karas, @agocke
See info in area-owners.md if you want to be subscribed.

@jtschuster jtschuster requested a review from Copilot May 20, 2025 20:09
Copy link
Contributor

@Copilot 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 updates the MacOS signer to preserve entitlements in the code signature. Key changes include:

  • Enabling nullable reference types and updating signature-related types to support optional code signature blobs.
  • Incorporating entitlements and DER entitlements into signature creation with new size estimation logic.
  • Removing the signature-presence check in bundle creation to allow signatures with entitlements.

Reviewed Changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/installer/managed/Microsoft.NET.HostModel/MachO/MachObjectFile.cs Updated signature field types; added EmbeddedSignatureBlob getter; commented out a signature equivalence check.
src/installer/managed/Microsoft.NET.HostModel/MachO/MachObjectFile.CodeSignature.cs Modified signature creation to include entitlements; updated size estimation logic.
src/installer/managed/Microsoft.NET.HostModel/MachO/BinaryFormat/SymbolTableLoadCommand.cs Renamed structure usage from SymbolTableCommand to SymbolTableLoadCommand.
src/installer/managed/Microsoft.NET.HostModel/AppHost/HostWriter.cs Removed existing signature check before bundling.
Other files Adjusted or added blob handling to support entitlements and updated enums accordingly.
Comments suppressed due to low confidence (3)

src/installer/managed/Microsoft.NET.HostModel/MachO/MachObjectFile.CodeSignature.cs:279

  • The switch from GetCodeSignatureSize to GetLargestSizeEstimate must be validated to ensure that the new estimation accurately reflects the additional size needed for entitlements and related blobs.
return CodeSignature.GetLargestSizeEstimate(fileSize, identifier) + (AlignUp(fileSize, CodeSignatureAlignment) - fileSize);

src/installer/managed/Microsoft.NET.HostModel/AppHost/HostWriter.cs:244

  • The removal of the signature-presence check in HostWriter.cs should be reviewed to ensure that bypassing this validation does not allow unintended signed content into bundles.
if (machObjectFile.HasSignature)

src/installer/managed/Microsoft.NET.HostModel/MachO/MachObjectFile.cs:251

  • Commenting out the equivalence check for the code signature blob may allow mismatched signatures to be treated as equivalent. Confirm that disabling this check is an intentional change for preserving entitlements.
// if (!CodeSignature.AreEquivalent(a._codeSignatureBlob, b._codeSignatureBlob))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-HostModel Microsoft.NET.HostModel issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant