eng: Remove PFXs from codebase (#2219)

* Squashed commit of the following:

commit a7d403386e3df430edf67d89ca23f81313022d2d
Author: Tian Liao <tilia@microsoft.com>
Date:   Mon Aug 12 16:58:30 2024 +0800

    remove pfx from ignore list

commit 26ffa46d9a92dcbadc9d9d471715fdec10c6f013
Author: Tian Liao <tilia@microsoft.com>
Date:   Mon Aug 12 16:58:07 2024 +0800

    Remove PFXs

* fix yaml

* fix gh action

* fix gh action
This commit is contained in:
Tian L. 2024-08-13 09:52:35 +08:00 committed by GitHub
parent 3782412791
commit b30ece5c03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 59 additions and 50 deletions

View file

@ -1,13 +0,0 @@
{
"tool": "Credential Scanner",
"suppressions": [
{
"file": "\\src\\Calculator\\WindowsDev_TemporaryKey.pfx",
"_justification": "This is an untrusted, self-signed certificate which is used only during development. Its private key is not intended to be secret."
},
{
"file": "\\src\\CalculatorUnitTests\\WindowsDev_TemporaryKey.pfx",
"_justification": "This is an untrusted, self-signed certificate which is used only during development. Its private key is not intended to be secret."
}
]
}

View file

@ -91,6 +91,10 @@ jobs:
with: with:
name: Build-${{ matrix.platform }} name: Build-${{ matrix.platform }}
path: ${{ github.workspace }}/output path: ${{ github.workspace }}/output
- uses: actions/upload-artifact@v4
with:
name: Tools-${{ matrix.platform }}
path: ${{ github.workspace }}/build/scripts/SignTestApp.ps1
unitTests: unitTests:
needs: [defineBuilds, build] needs: [defineBuilds, build]
@ -107,10 +111,13 @@ jobs:
with: with:
name: Build-${{ matrix.platform }} name: Build-${{ matrix.platform }}
path: ${{ github.workspace }}/download path: ${{ github.workspace }}/download
- uses: actions/download-artifact@v4
name: Download tools
with:
name: Tools-${{ matrix.platform }}
path: ${{ github.workspace }}/download/tools
- run: | - run: |
${{ env.testDir }}/Add-AppDevPackage.ps1 ` ${{ github.workspace }}/download/tools/SignTestApp.ps1 -AppToSign ${{ env.testDir }}/CalculatorUnitTests.msix
-CertificatePath ${{ env.testDir }}/CalculatorUnitTests.cer `
-Force
shell: pwsh shell: pwsh
name: Install test certificate name: Install test certificate
- uses: ilammy/msvc-dev-cmd@v1 # this is a workaround because microsoft/vstest-action is broken. - uses: ilammy/msvc-dev-cmd@v1 # this is a workaround because microsoft/vstest-action is broken.
@ -131,16 +138,18 @@ jobs:
with: with:
name: Build-x64 name: Build-x64
path: ${{ github.workspace }}/download path: ${{ github.workspace }}/download
- uses: actions/download-artifact@v4
name: Download tools
with:
name: Tools-x64
path: ${{ github.workspace }}/download/tools
- run: | - run: |
Set-DisplayResolution -Width 1920 -Height 1080 -Force Set-DisplayResolution -Width 1920 -Height 1080 -Force
shell: pwsh shell: pwsh
name: Set screen resolution name: Set screen resolution
- run: | - run: |
${{ env.appDir }}/Add-AppDevPackage.ps1 ` ${{ github.workspace }}/download/tools/SignTestApp.ps1 -AppToSign '${{ env.appDir }}/Calculator_*.msixbundle'
-CertificatePath ${{ env.appDir }}/Calculator*.cer ` ${{ env.appDir }}/Add-AppDevPackage.ps1 -Force
-Force
${{ env.appDir }}/Add-AppDevPackage.ps1 `
-Force
shell: powershell shell: powershell
name: Install app name: Install app
- run: | - run: |

3
.gitignore vendored
View file

@ -200,7 +200,6 @@ ClientBin/
*.dbmdl *.dbmdl
*.dbproj.schemaview *.dbproj.schemaview
*.jfm *.jfm
*.pfx
*.publishsettings *.publishsettings
orleans.codegen.cs orleans.codegen.cs
@ -294,8 +293,6 @@ __pycache__/
Generated Files/ Generated Files/
src/GraphControl/GraphingImplOverrides.props src/GraphControl/GraphingImplOverrides.props
src/CalcViewModel/DataLoaders/DataLoaderConstants.h src/CalcViewModel/DataLoaders/DataLoaderConstants.h
!src/Calculator/WindowsDev_TemporaryKey.pfx
!src/CalculatorUnitTests/WindowsDev_TemporaryKey.pfx
!src/x64 !src/x64
!src/x86 !src/x86
!src/out !src/out

View file

@ -42,17 +42,10 @@ jobs:
Calculator/AppPackages/** Calculator/AppPackages/**
publish/** publish/**
- task: PowerShell@2 - powershell: |
displayName: Install certificate $(Build.SourcesDirectory)/build/scripts/SignTestApp.ps1 -AppToSign '$(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_*_Test/Calculator_*.msixbundle'
inputs: $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_*_Test/Add-AppDevPackage.ps1 -Force
filePath: $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
arguments: -CertificatePath $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Calculator_$(Build.BuildNumber)_${{ parameters.platform }}.cer -Force
- task: PowerShell@2
displayName: Install app displayName: Install app
inputs:
filePath: $(Pipeline.Workspace)/$(DropName)/Calculator/AppPackages/Calculator_$(Build.BuildNumber)_Test/Add-AppDevPackage.ps1
arguments: -Force
- task: VSTest@2 - task: VSTest@2
displayName: Run CalculatorUITests displayName: Run CalculatorUITests

View file

@ -13,18 +13,17 @@ jobs:
skipComponentGovernanceDetection: true skipComponentGovernanceDetection: true
UnitTestsDir: $(Pipeline.Workspace)\drop-${{ parameters.platform }}\CalculatorUnitTests\AppPackages\CalculatorUnitTests_Test UnitTestsDir: $(Pipeline.Workspace)\drop-${{ parameters.platform }}\CalculatorUnitTests\AppPackages\CalculatorUnitTests_Test
steps: steps:
- checkout: none - checkout: self
fetchDepth: 1
- download: current - download: current
displayName: Download CalculatorUnitTests displayName: Download CalculatorUnitTests
artifact: drop-${{ parameters.platform }} artifact: drop-${{ parameters.platform }}
patterns: '**/CalculatorUnitTests_Test/**' patterns: '**/CalculatorUnitTests_Test/**'
- task: PowerShell@2 - powershell: |
displayName: Install Certificate $(Build.SourcesDirectory)/build/scripts/SignTestApp.ps1 -AppToSign '$(UnitTestsDir)\CalculatorUnitTests.msix'
inputs: displayName: Sign unit tests
filePath: $(UnitTestsDir)\Add-AppDevPackage.ps1
arguments: -CertificatePath $(UnitTestsDir)\CalculatorUnitTests.cer -Force
- task: VSTest@2 - task: VSTest@2
displayName: Run CalculatorUnitTests displayName: Run CalculatorUnitTests

View file

@ -0,0 +1,33 @@
#requires -RunAsAdministrator
param(
[Parameter(Position = 0, Mandatory = $true)][string]$AppToSign,
[string]$SignTool = "C:\Program Files (x86)\Windows Kits\10\bin\10.*\x64\signtool.exe"
)
$AppToSign = (Resolve-Path -Path $AppToSign)[-1]
Write-Host "AppToSign: $AppToSign"
$SignTool = (Resolve-Path -Path $SignTool)[-1]
Write-Host "SignTool: $SignTool"
if ((Test-Path -Path $SignTool -PathType Leaf) -ne $true) {
Write-Error "signtool is not found with the given argument: $SignTool" -ErrorAction Stop
}
$codeSignOid = New-Object -TypeName "System.Security.Cryptography.Oid" -ArgumentList @("1.3.6.1.5.5.7.3.3")
$oidColl = New-Object -TypeName "System.Security.Cryptography.OidCollection"
$oidColl.Add($codeSignOid) > $null
$publisher = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
$certReq = New-Object -TypeName "System.Security.Cryptography.X509Certificates.CertificateRequest" `
-ArgumentList @($publisher, ([System.Security.Cryptography.ECDsa]::Create()), "SHA256")
$certReq.CertificateExtensions.Add((New-Object -TypeName "System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension" `
-ArgumentList @($oidColl, $false)))
$now = Get-Date
$cert = $certReq.CreateSelfSigned($now, $now.AddHours(1))
$pfxFile = "$($env:TEMP)\$(New-Guid).pfx"
[System.IO.File]::WriteAllBytes($pfxFile, $cert.Export("Pfx"))
Write-Host "Exported PFX: $pfxFile"
& $SignTool sign /fd SHA256 /a /f $pfxFile $AppToSign
Write-Host "Certificate Thumbprint: $($cert.Thumbprint.ToLower())"
Import-PfxCertificate -CertStoreLocation 'Cert:\LocalMachine\TrustedPeople' -FilePath $pfxFile > $null

View file

@ -24,8 +24,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> <ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview> <WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled> <AppxPackageSigningEnabled>False</AppxPackageSigningEnabled>
<PackageCertificateKeyFile>WindowsDev_TemporaryKey.pfx</PackageCertificateKeyFile>
<AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled> <AppxSymbolPackageEnabled>False</AppxSymbolPackageEnabled>
<AppxBundle>Always</AppxBundle> <AppxBundle>Always</AppxBundle>
<GenerateProjectSpecificOutputFolder>true</GenerateProjectSpecificOutputFolder> <GenerateProjectSpecificOutputFolder>true</GenerateProjectSpecificOutputFolder>
@ -817,7 +816,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Assets\CalculatorIcons.ttf" /> <Content Include="Assets\CalculatorIcons.ttf" />
<None Include="WindowsDev_TemporaryKey.pfx" />
</ItemGroup> </ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' "> <PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion> <VisualStudioVersion>14.0</VisualStudioVersion>

View file

@ -16,7 +16,6 @@
<!-- We want to automatic replace of MinVersion/MaxVersionTested for unit tests. --> <!-- We want to automatic replace of MinVersion/MaxVersionTested for unit tests. -->
<AppxOSMinVersionReplaceManifestVersion>true</AppxOSMinVersionReplaceManifestVersion> <AppxOSMinVersionReplaceManifestVersion>true</AppxOSMinVersionReplaceManifestVersion>
<AppxOSMaxVersionTestedReplaceManifestVersion>true</AppxOSMaxVersionTestedReplaceManifestVersion> <AppxOSMaxVersionTestedReplaceManifestVersion>true</AppxOSMaxVersionTestedReplaceManifestVersion>
<PackageCertificateKeyFile>WindowsDev_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
@ -289,9 +288,6 @@
<Project>{cc9b4fa7-d746-4f52-9401-0ad1b4d6b16d}</Project> <Project>{cc9b4fa7-d746-4f52-9401-0ad1b4d6b16d}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="WindowsDev_TemporaryKey.pfx" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View file

@ -79,7 +79,4 @@
<UniqueIdentifier>{d3ec8922-022d-4531-8744-f65a872f3841}</UniqueIdentifier> <UniqueIdentifier>{d3ec8922-022d-4531-8744-f65a872f3841}</UniqueIdentifier>
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="WindowsDev_TemporaryKey.pfx" />
</ItemGroup>
</Project> </Project>