Skip to content

Commit 29e44b6

Browse files
Merge pull request #1408 from PowerShell/andschwa/esrp
Rewrite release signing pipeline
2 parents 2936b4b + dd83921 commit 29e44b6

File tree

6 files changed

+88
-207
lines changed

6 files changed

+88
-207
lines changed

.vsts-ci/azure-pipelines-release.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ trigger:
3232
- /LICENSE
3333
- /CODE_OF_CONDUCT.md
3434

35+
resources:
36+
repositories:
37+
- repository: ComplianceRepo
38+
type: github
39+
endpoint: ComplianceGHRepo
40+
name: PowerShell/compliance
41+
3542
jobs:
3643

3744
- job: 'ReleaseBuild'
@@ -45,7 +52,9 @@ jobs:
4552
displayName: Signing Build
4653
dependsOn: 'ReleaseBuild'
4754
pool:
48-
name: 'Package ES CodeHub Lab E'
55+
name: 'Package ES Standard Build'
4956
demands: DotNetFramework
57+
variables:
58+
- group: ESRP
5059
steps:
5160
- template: templates/release-general.yml
+63-141
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,71 @@
11
steps:
2-
- powershell: |
3-
Write-Host "Installing pwsh..."
4-
if (Get-Command pwsh -ErrorAction Ignore)
5-
{
6-
Write-Host "pwsh already installed, skipping"
7-
return
8-
}
9-
$powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell'
10-
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1
11-
./install-powershell.ps1 -Destination $powerShellPath
12-
$vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH"
13-
Write-Host "sending " + $vstsCommandString
14-
Write-Host "##$vstsCommandString"
15-
displayName: Install PowerShell Core
16-
17-
- pwsh: |
18-
Get-ChildItem -Path env:
19-
displayName: Capture environment
20-
condition: succeededOrFailed()
21-
22-
- task: PkgESSetupBuild@10
23-
displayName: 'Package ES - Setup Build'
24-
inputs:
25-
productName: PowerShellEditorServices
26-
useDfs: false
272

283
- task: DownloadBuildArtifacts@0
294
displayName: 'Download Build Artifacts'
305
inputs:
316
downloadType: specific
327

33-
- task: PowerShell@1
34-
displayName: 'Extract build zip'
35-
inputs:
36-
scriptType: inlineScript
37-
inlineScript: |
38-
$dest = New-Item -ItemType Directory $env:BUILD_ARTIFACTSTAGINGDIRECTORY/release/out/PowerShellEditorServices
39-
$psesZip = Get-ChildItem $env:BUILD_ARTIFACTSTAGINGDIRECTORY/PowerShellEditorServices-CI/PowerShellEditorServices*.zip -ErrorAction Stop
40-
$psesZip | Expand-Archive -DestinationPath $dest -Force -Verbose
41-
$psesZip | Remove-Item -Recurse -Force
42-
43-
- task: PkgESCodeSign@10
44-
displayName: 'CodeSign tools/releaseBuild/signing.xml'
45-
env:
46-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
47-
inputs:
48-
signConfigXml: tools/releaseBuild/signing.xml
49-
inPathRoot: '$(Build.ArtifactStagingDirectory)'
50-
outPathRoot: '$(Build.ArtifactStagingDirectory)\Signed'
51-
52-
- task: PowerShell@1
53-
displayName: 'Copy signed items into output'
54-
inputs:
55-
scriptType: inlineScript
56-
inlineScript: |
57-
$signed="$(Build.ArtifactStagingDirectory)\Signed\PowerShellEditorServices\*"
58-
$notSigned="$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices"
59-
Copy-Item $signed $notSigned -Recurse -Force
60-
61-
- task: PowerShell@1
62-
displayName: 'Create catalog files'
63-
inputs:
64-
scriptType: inlineScript
65-
inlineScript: |
66-
$dir = "$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices"
67-
New-FileCatalog -CatalogFilePath "$(Build.ArtifactStagingDirectory)\PowerShellEditorServices.cat" -Path $dir
68-
69-
$dir = "$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices\PowerShellEditorServices.VSCode"
70-
New-FileCatalog -CatalogFilePath "$(Build.ArtifactStagingDirectory)\PowerShellEditorServices.VSCode.cat" -Path $dir
71-
72-
- task: PkgESCodeSign@10
73-
displayName: 'CodeSign tools/releaseBuild/FileCatalogSigning.xml'
74-
env:
75-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
76-
inputs:
77-
signConfigXml: tools/releaseBuild/FileCatalogSigning.xml
78-
inPathRoot: '$(Build.ArtifactStagingDirectory)'
79-
outPathRoot: '$(Build.ArtifactStagingDirectory)'
80-
81-
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
82-
displayName: 'Component Detection'
83-
84-
- task: AntiMalware@3
85-
inputs:
86-
InputType: 'Basic'
87-
ScanType: 'CustomScan'
88-
FileDirPath: '$(Build.ArtifactStagingDirectory)'
89-
EnableServices: false
90-
SupportLogOnError: false
91-
TreatSignatureUpdateFailureAs: 'Warning'
92-
SignatureFreshness: 'UpToDate'
93-
TreatStaleSignatureAs: 'Error'
94-
95-
- task: PoliCheck@1
96-
condition: succeededOrFailed()
97-
inputs:
98-
targetType: F
99-
optionsFC: 0
100-
optionsXS: 0
101-
optionsPE: '1|2|3|4'
102-
optionsHMENABLE: 0
103-
optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml'
104-
# toolVersion: 5.8.2.1
105-
106-
- task: CredScan@2
107-
condition: succeededOrFailed()
108-
109-
# - task: BinSkim@3
110-
# condition: succeededOrFailed()
111-
# inputs:
112-
# InputType: 'Basic'
113-
# Function: 'analyze'
114-
# AnalyzeRecurse: true
115-
# AnalyzeTarget: '$(Build.ArtifactStagingDirectory)\release;$(Build.ArtifactStagingDirectory)\OutGridView*.dll'
116-
117-
# Publish results as artifacts
118-
- task: PublishSecurityAnalysisLogs@3
119-
condition: succeededOrFailed()
120-
inputs:
121-
ArtifactName: 'CodeAnalysisLogs'
122-
ArtifactType: 'Container'
123-
124-
# Publish to TSA server
125-
- task: TSAUpload@1
126-
condition: succeededOrFailed()
127-
continueOnError: true
128-
inputs:
129-
tsaVersion: 'TsaV2'
130-
codebase: 'Existing'
131-
tsaEnvironment: 'PROD'
132-
codeBaseName: 'PowerShell_PowerShellEditorServices_20190917'
133-
uploadAPIScan: false
134-
uploadBinSkim: false
135-
uploadCredScan: true
136-
uploadFortifySCA: false
137-
uploadFxCop: false
138-
uploadModernCop: false
139-
uploadPoliCheck: true
140-
uploadPREfast: false
141-
uploadRoslyn: false
142-
uploadTSLint: false
143-
uploadAsync: true
144-
145-
- task: PowerShell@1
146-
displayName: 'Upload artifacts'
8+
- task: ExtractFiles@1
9+
displayName: 'Extract Build Zip'
14710
inputs:
148-
scriptType: inlineScript
149-
inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=PowerShellEditorServices;artifactname=PowerShellEditorServices]$(Build.ArtifactStagingDirectory)\release\out\PowerShellEditorServices"'
11+
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices-CI/PowerShellEditorServices*.zip'
12+
destinationFolder: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
13+
14+
- checkout: ComplianceRepo
15+
displayName: 'Checkout the ComplianceRepo'
16+
17+
- template: EsrpSign.yml@ComplianceRepo
18+
parameters:
19+
buildOutputPath: '$(Build.ArtifactStagingDirectory)/PowerShellEditorServices'
20+
signOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
21+
certificateId: 'CP-230012' # Authenticode certificate
22+
useMinimatch: true # This enables the use of globbing
23+
pattern: |
24+
# PowerShellEditorServices Script
25+
PowerShellEditorServices/*.{ps1,psd1,psm1,ps1xml}
26+
PowerShellEditorServices/Commands/**/*.{ps1,psd1,psm1,ps1xml}
27+
# PowerShellEditorServices Binaries
28+
PowerShellEditorServices/**/Microsoft.PowerShell.EditorServices*.dll
29+
# PowerShellEditorServices.VSCode Script
30+
PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.psd1
31+
# PowerShellEditorServices.VSCode Binary
32+
PowerShellEditorServices.VSCode/bin/Microsoft.PowerShell.EditorServices.VSCode.dll
33+
34+
- template: EsrpSign.yml@ComplianceRepo
35+
parameters:
36+
buildOutputPath: '$(Build.ArtifactStagingDirectory)/FirstPartySigned'
37+
signOutputPath: '$(Build.ArtifactStagingDirectory)/ThirdPartySigned'
38+
certificateId: 'CP-231522' # Third-party certificate
39+
useMinimatch: true # This enables the use of globbing
40+
pattern: |
41+
**/MediatR.dll
42+
**/Nerdbank.Streams.dll
43+
**/Newtonsoft.Json.dll
44+
**/OmniSharp*.dll
45+
**/Serilog*.dll
46+
**/UnixConsoleEcho.dll
47+
48+
- publish: $(Build.ArtifactStagingDirectory)/ThirdPartySigned
49+
artifact: PowerShellEditorServices
50+
displayName: 'Publish signed (and unsigned) artifacts'
51+
52+
- checkout: self
53+
54+
- template: assembly-module-compliance.yml@ComplianceRepo
55+
parameters:
56+
# binskim
57+
AnalyzeTarget: '$(Build.ArtifactStagingDirectory)/*.dll'
58+
AnalyzeSymPath: 'SRV*'
59+
# component-governance
60+
sourceScanPath: '$(Build.SourcesDirectory)/PowerShellEditorServices'
61+
# credscan
62+
suppressionsFile: ''
63+
# TermCheck AKA PoliCheck
64+
targetArgument: '$(Build.SourcesDirectory)/PowerShellEditorServices'
65+
optionsUEPATH: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/UserExclusions.xml'
66+
optionsRulesDBPath: ''
67+
optionsFTPath: '$(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml'
68+
# tsa-upload
69+
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
70+
# selections
71+
APIScan: false

src/PowerShellEditorServices/Services/PowerShellContext/PowerShellContextService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ public async Task<IEnumerable<TResult>> ExecuteCommandAsync<TResult>(
635635

636636
if (shouldCancelReadLine && PromptNest.IsReadLineBusy())
637637
{
638-
// If a ReadLine pipeline is running in the debugger then we'll hang here
638+
// If a ReadLine pipeline is running in the debugger then we'll stop responding here
639639
// if we don't cancel it. Typically we can rely on OnExecutionStatusChanged but
640640
// the pipeline request won't even start without clearing the current task.
641641
this.ConsoleReader?.StopCommandLoop();
@@ -1895,7 +1895,7 @@ private void PowerShellContext_RunspaceChangedAsync(object sender, RunspaceChang
18951895

18961896

18971897
// TODO: Refactor this, RunspaceDetails, PowerShellVersion, and PowerShellVersionDetails
1898-
// It's crazy that this is 4 different types.
1898+
// It's odd that this is 4 different types.
18991899
// P.S. MinifiedRunspaceDetails use to be called RunspaceDetails... as in, there were 2 DIFFERENT
19001900
// RunspaceDetails types in this codebase but I've changed it to be minified since the type is
19011901
// slightly simpler than the other RunspaceDetails.

test/PowerShellEditorServices.Test/Debugging/DebugServiceTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// TODO: Fix these tests which cause the test runner to hang...
1+
// TODO: Fix these tests which cause the test runner to stop responding...
22

33
// //
44
// // Copyright (c) Microsoft. All rights reserved.

tools/releaseBuild/signing.xml

-62
This file was deleted.

tools/terms/UserExclusions.xml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<PoliCheckExclusions>
2+
<!-- All strings must be UPPER CASE -->
3+
<!--Each of these exclusions is a folder name -if \[name]\exists in the file path, it will be skipped -->
4+
<!--<Exclusion Type="FolderPathFull">ABC|XYZ</Exclusion>-->
5+
<Exclusion Type="FolderPathFull">.GIT</Exclusion>
6+
<!--Each of these exclusions is a folder name -if any folder or file starts with "\[name]", it will be skipped -->
7+
<!--<Exclusion Type="FolderPathStart">ABC|XYZ</Exclusion>-->
8+
<!--Each of these file types will be completely skipped for the entire scan -->
9+
<!--<Exclusion Type="FileType">.ABC|.XYZ</Exclusion>-->
10+
<!--The specified file names will be skipped during the scan regardless which folder they are in -->
11+
<!--<Exclusion Type="FileName">ABC.TXT|XYZ.CS</Exclusion>-->
12+
</PoliCheckExclusions>

0 commit comments

Comments
 (0)