Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .pipelines/templates/linux-package-build.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
parameters:
unsignedDrop: 'drop_linux_build_linux_x64'
signedeDrop: 'drop_linux_sign_linux_x64'
signedDrop: 'drop_linux_sign_linux_x64'
packageType: deb
jobName: 'deb'
signingProfile: 'CP-450779-pgpdetached'

jobs:
- job: ${{ parameters.jobName }}
Expand All @@ -20,6 +19,7 @@ jobs:
- name: skipNugetSecurityAnalysis
value: true
- group: DotNetPrivateBuildAccess
- group: certificate_logical_to_actual
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: ob_sdl_binskim_enabled
Expand All @@ -34,8 +34,16 @@ jobs:
value: $(Build.SourcesDirectory)/PowerShell/.config/tsaoptions.json
- name: ob_sdl_credscan_suppressionsFile
value: $(Build.SourcesDirectory)/PowerShell/.config/suppress.json
- name: SigningProfile
value: ${{ parameters.signingProfile }}
# PGP signing profile selection: Mariner (Azure Linux) packages ship through
# a different distribution channel and must be signed with the Mariner release
# key; all other Linux packages use the standard PowerShell Linux key. Both
# key codes come from the `certificate_logical_to_actual` variable group.
- ${{ if startsWith(parameters.jobName, 'mariner') }}:
- name: SigningProfile
value: $(pgp_release_cert_id)
- ${{ else }}:
- name: SigningProfile
value: $(pgp_linux_cert_id)

steps:
- checkout: self
Expand Down Expand Up @@ -196,6 +204,13 @@ jobs:
$pkgPath = Get-ChildItem -Path $(Pipeline.Workspace) -Filter $pkgFilter -Recurse -File | Select-Object -ExpandProperty FullName
Write-Verbose -Verbose "pkgPath: $pkgPath"
Copy-Item -Path $pkgPath -Destination '$(ob_outputDirectory)' -Force -Verbose

if ($pkgPath -like '*.tar.gz') {
$entry = & tar -tzvf $pkgPath | Where-Object { $_ -match '\spwsh$' } | Select-Object -First 1
if ($entry -notmatch '^-..x') {
throw "pwsh is not executable in $pkgPath : $entry"
}
}
displayName: 'Copy artifacts to output directory'
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
Expand Down
71 changes: 59 additions & 12 deletions .pipelines/templates/mac-package-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- name: skipNugetSecurityAnalysis
value: true
- group: DotNetPrivateBuildAccess
- group: certificate_logical_to_actual
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: ob_sdl_binskim_enabled
Expand Down Expand Up @@ -76,6 +77,14 @@ jobs:
# Diagnostics is not critical it passes every time it runs
continueOnError: true

- pwsh: |
$signedDir = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/drop_macos_sign_${{ parameters.buildArchitecture }}/Signed-${{ parameters.buildArchitecture }}"
Get-ChildItem $signedDir -Recurse -Include 'pwsh', '*.dylib' | ForEach-Object {
codesign --verify --deep --strict --verbose=4 $_.FullName
if ($LASTEXITCODE -ne 0) { throw "codesign verification failed for $($_.FullName)" }
}
displayName: 'Verify Apple codesign on signed binaries'

- pwsh: |
# Add -SkipReleaseChecks as a mitigation to unblock release.
# macos-10.15 does not allow creating a folder under root. Hence, moving the folder.
Expand Down Expand Up @@ -154,11 +163,20 @@ jobs:

foreach($t in $tarPkgPath) {
$file = $t.FullName
$entry = & tar -tzvf $file | Where-Object { $_ -match '\spwsh$' } | Select-Object -First 1
if ($entry -notmatch '^-..x') {
throw "pwsh is not executable in $file : $entry"
}
Write-Verbose -verbose "Uploading $file to macos-pkgs"
Write-Host "##vso[artifact.upload containerfolder=macos-pkgs;artifactname=macos-pkgs]$file"
}

$packageInfo = Get-MacOSPackageIdentifierInfo -Version '$(Version)' -LTS:$LTS
Write-Verbose -Verbose "BundleId: $($packageInfo.PackageIdentifier)"
Write-Host "##vso[task.setvariable variable=BundleId;isOutput=true]$($packageInfo.PackageIdentifier)"

displayName: 'Package ${{ parameters.buildArchitecture}}'
name: packageStep
env:
__DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)

Expand All @@ -170,6 +188,7 @@ jobs:
type: windows

variables:
- group: certificate_logical_to_actual
- name: ob_outputDirectory
value: '$(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
- name: ob_sdl_binskim_enabled
Expand All @@ -178,7 +197,8 @@ jobs:
value: $(Build.SourcesDirectory)/PowerShell/.config/suppress.json
- name: BuildArch
value: ${{ parameters.buildArchitecture }}
- group: mscodehub-macos-package-signing
- name: BundleId
value: $[ dependencies.package_macOS_${{ parameters.buildArchitecture }}.outputs['packageStep.BundleId'] ]

steps:
- download: current
Expand Down Expand Up @@ -216,32 +236,59 @@ jobs:
inline_operation: |
[
{
"KeyCode": "$(KeyCode)",
"KeyCode": "$(apple_cert_id)",
"OperationCode": "MacAppDeveloperSign",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {
"Hardening": "Enable",
"OpusInfo": "http://microsoft.com"
"Hardening": "--options=runtime"
}
}
]

- task: onebranch.pipeline.signing@1
displayName: 'OneBranch Notarize Package'
inputs:
command: 'sign'
files_to_sign: '**/*-osx-*.zip'
search_root: '$(Pipeline.Workspace)'
inline_operation: |
[
{
"KeyCode": "$(apple_cert_id)",
"OperationCode": "MacAppNotarize",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {
"BundleId": "$(BundleId)"
}
}
]
timeoutInMinutes: 120

- pwsh: |
$signedPkg = Get-ChildItem -Path $(Pipeline.Workspace) -Filter "*osx*.zip" -File

if (-not (Test-Path $(ob_outputDirectory))) {
$null = New-Item -Path $(ob_outputDirectory) -ItemType Directory
}

$expandDir = "$(Pipeline.Workspace)/pkgExpand"
$null = New-Item -Path $expandDir -ItemType Directory -Force

$signedPkg | ForEach-Object {
Write-Verbose -Verbose "Signed package zip: $_"
Expand-Archive -Path $_ -DestinationPath $expandDir -Verbose
}

if (-not (Test-Path $_)) {
throw "Package not found: $_"
}

if (-not (Test-Path $(ob_outputDirectory))) {
$null = New-Item -Path $(ob_outputDirectory) -ItemType Directory
}
# ESRP's signing pipeline nests the PKG inside a '<hash>.zip.unzipped' subfolder
$pkgFile = Get-ChildItem -Path $expandDir -Filter '*.pkg' -Recurse -File
if (-not $pkgFile) {
throw "Package not found in: $signedPkg"
}

Expand-Archive -Path $_ -DestinationPath $(ob_outputDirectory) -Verbose
$pkgFile | ForEach-Object {
Move-Item -Path $_ -Destination $(ob_outputDirectory) -Verbose
}

Write-Verbose -Verbose "Expanded pkg file:"
Expand Down
40 changes: 40 additions & 0 deletions .pipelines/templates/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ jobs:
$psOptPath = "$(OB_OUTPUTDIRECTORY)/psoptions.json"
Save-PSOptions -PSOptionsPath $psOptPath

$entitlements = "$(PowerShellRoot)/assets/macos-entitlements.plist"
$pwshBin = "$(OB_OUTPUTDIRECTORY)/pwsh"
Write-Verbose -Verbose "Applying entitlements to $pwshBin"
codesign --sign - --force --options runtime --entitlements $entitlements $pwshBin
if ($LASTEXITCODE -ne 0) {
throw "codesign failed with exit code $LASTEXITCODE"
}

# Since we are using custom pool for macOS, we need to use artifact.upload to publish the artifacts
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName]$(OB_OUTPUTDIRECTORY)"

Expand Down Expand Up @@ -144,4 +152,36 @@ jobs:
binPath: $(DropRootPath)
OfficialBuild: $(ps_official_build)

# Apple-sign the Mach-O binaries inside the signed output.
- pwsh: |
$signedDir = "$(ob_outputDirectory)/Signed-$(Runtime)"
$zipFile = "$(Pipeline.Workspace)/macho-$(BuildArchitecture).zip"
Compress-Archive -Path "$signedDir/*" -DestinationPath $zipFile -Force
displayName: Compress signed folder for Apple signing

- task: onebranch.pipeline.signing@1
displayName: Apple CodeSign Mach-O binaries
inputs:
command: 'sign'
files_to_sign: 'macho-$(BuildArchitecture).zip'
search_root: '$(Pipeline.Workspace)'
inline_operation: |
[
{
"KeyCode": "$(apple_cert_id)",
"OperationCode": "MacAppDeveloperSign",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {
"Hardening": "--options=runtime"
}
}
]

- pwsh: |
$signedDir = "$(ob_outputDirectory)/Signed-$(Runtime)"
$zipFile = "$(Pipeline.Workspace)/macho-$(BuildArchitecture).zip"
Expand-Archive -Path $zipFile -DestinationPath $signedDir -Force -Verbose
displayName: Expand Apple-signed Mach-O binaries into signed output

- template: /.pipelines/templates/step/finalize.yml@self
5 changes: 3 additions & 2 deletions .pipelines/templates/nupkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- group: mscodehub-feed-read-general
- group: mscodehub-feed-read-akv
- group: DotNetPrivateBuildAccess
- group: certificate_logical_to_actual

steps:
- checkout: self
Expand Down Expand Up @@ -208,7 +209,7 @@ jobs:
displayName: Sign nupkg files
inputs:
command: 'sign'
cp_code: 'CP-401405'
cp_code: '$(nuget_cert_id)'
files_to_sign: '**\*.nupkg'
search_root: '$(Pipeline.Workspace)\nupkg'

Expand Down Expand Up @@ -268,7 +269,7 @@ jobs:
displayName: Sign nupkg files
inputs:
command: 'sign'
cp_code: 'CP-401405'
cp_code: '$(nuget_cert_id)'
files_to_sign: '**\*.nupkg'
search_root: '$(Pipeline.Workspace)\globaltools'

Expand Down
2 changes: 1 addition & 1 deletion .pipelines/templates/release-validate-packagenames.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
- pwsh: |
$message = @()
Get-ChildItem $(System.ArtifactsDirectory)\* -recurse -filter *.deb | ForEach-Object {
if($_.Name -notmatch 'powershell(-preview|-lts)?_\d+\.\d+\.\d+([\-~][a-z]*.\d+)?-\d\.deb_amd64\.deb')
if($_.Name -notmatch 'powershell(-preview|-lts)?_\d+\.\d+\.\d+([\-~][a-z]*.\d+)?-\d\.deb_(amd64|arm64)\.deb')
{
$messageInstance = "$($_.Name) is not a valid package name"
$message += $messageInstance
Expand Down
6 changes: 3 additions & 3 deletions .pipelines/templates/shouldSign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ parameters:
steps:
- powershell: |
$shouldSign = $true
$authenticodeCert = 'CP-230012'
$msixCert = 'CP-230012'
$authenticodeCert = '$(authenticode_cert_id)'
$msixCert = '$(authenticode_cert_id)'
if($env:IS_DAILY -eq 'true')
{
$authenticodeCert = 'CP-460906'
$authenticodeCert = '$(authenticode_test_cert_id)'
}
if($env:SKIP_SIGNING -eq 'Yes')
{
Expand Down
2 changes: 0 additions & 2 deletions .pipelines/templates/stages/PowerShell-Packages-Stages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,13 @@ stages:
signedDrop: 'drop_linux_sign_linux_fxd_x64_mariner'
packageType: rpm-fxdependent #mariner-x64
jobName: mariner_x64
signingProfile: 'CP-459159-pgpdetached'

- template: /.pipelines/templates/linux-package-build.yml@self
parameters:
unsignedDrop: 'drop_linux_build_linux_fxd_arm64_mariner'
signedDrop: 'drop_linux_sign_linux_fxd_arm64_mariner'
packageType: rpm-fxdependent-arm64 #mariner-arm64
jobName: mariner_arm64
signingProfile: 'CP-459159-pgpdetached'

- template: /.pipelines/templates/linux-package-build.yml@self
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/templates/windows-hosted-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ jobs:
displayName: Sign nupkg files
inputs:
command: 'sign'
cp_code: 'CP-401405'
cp_code: '$(nuget_cert_id)'
files_to_sign: '**\*.nupkg'
search_root: '$(ob_outputDirectory)\globaltool'
condition: and(succeeded(), eq(variables['Architecture'], 'fxdependent'))
Expand Down
14 changes: 14 additions & 0 deletions assets/macos-entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
Loading
Loading