Skip to content

Commit f76ccb5

Browse files
Merge pull request #3162 from PowerShell/andschwa/esrp
Rewrite release signing pipeline
2 parents 822bb40 + 73879c8 commit f76ccb5

File tree

10 files changed

+122
-148
lines changed

10 files changed

+122
-148
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"recommendations": [
55
"editorconfig.editorconfig",
66
"msjsdiag.debugger-for-chrome",
7+
"ms-azure-devops.azure-pipelines",
78
"ms-vscode.powershell",
89
"ms-vscode.vscode-typescript-tslint-plugin",
910
"davidanson.vscode-markdownlint"

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,21 @@ 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'
3845
displayName: 'Build release'
3946
pool:
40-
name: 'Package ES CodeHub Lab E'
47+
name: 'Package ES Standard Build'
4148
demands: DotNetFramework
49+
variables:
50+
- group: ESRP
4251
steps:
4352
- template: templates/release-general.yml

.vsts-ci/templates/ci-general.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ steps:
2828
git clone --single-branch --branch $env:PSES_BRANCH https://github.com/$env:PSES_FORK/PowerShellEditorServices.git ../PowerShellEditorServices
2929
Install-Module InvokeBuild -Scope CurrentUser -Force
3030
Install-Module PlatyPS -Scope CurrentUser -Force
31+
New-Item -ItemType Directory $(Build.ArtifactStagingDirectory)/vscode-powershell
3132
# Build
3233
- pwsh: Invoke-Build
3334
- task: PublishTestResults@2
@@ -38,7 +39,7 @@ steps:
3839
- task: PublishBuildArtifacts@1
3940
inputs:
4041
ArtifactName: vscode-powershell
41-
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
42+
PathtoPublish: '$(Build.ArtifactStagingDirectory)/vscode-powershell'
4243
# Rich Navigation
4344
- task: RichCodeNavIndexer@0
4445
# Note, for now, this is Windows only.
Lines changed: 53 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
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
2+
- checkout: self
163

174
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
185
displayName: Set Build Name for Non-PR
@@ -23,122 +10,81 @@ steps:
2310
displayName: Capture environment
2411
condition: succeededOrFailed()
2512

26-
- task: PkgESSetupBuild@10
27-
displayName: 'Package ES - Setup Build'
28-
inputs:
29-
productName: vscode-powershell
30-
useDFS: false
31-
13+
# TODO: Use modern resources for these variables.
3214
- task: PowerShell@2
3315
displayName: 'Set environment variables for VSTS (Phase 1)'
3416
inputs:
3517
targetType: filePath
36-
filePath: ./tools/releaseBuild/setVstsVariables.ps1
18+
filePath: ./vscode-powershell/tools/releaseBuild/setVstsVariables.ps1
3719

20+
# TODO: Replace this with an upstream trigger.
3821
- task: PowerShell@2
3922
displayName: 'Find PowerShellEditorServices build'
4023
env:
4124
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
4225
inputs:
4326
targetType: filePath
44-
filePath: ./tools/releaseBuild/findPsesBuild.ps1
27+
filePath: ./vscode-powershell/tools/releaseBuild/findPsesBuild.ps1
4528

46-
- task: DownloadBuildArtifacts@0
47-
displayName: 'Download Build Artifacts from PowerShell Editor Services'
29+
- task: DownloadPipelineArtifact@2
30+
displayName: 'Download Artifacts from PowerShell Editor Services'
4831
inputs:
49-
buildType: specific
32+
source: specific
5033
project: '8e2735c1-3674-408a-bcab-87f089ea29d5'
5134
pipeline: 1056
52-
buildVersionToDownload: specific
53-
buildId: '$(PSES_BUILDID)'
54-
downloadType: single
55-
artifactName: 'PowerShellEditorServices'
56-
downloadPath: '$(Build.SourcesDirectory)'
35+
preferTriggeringPipeline: true
36+
runVersion: specific
37+
runId: '$(PSES_BUILDID)'
38+
artifact: 'PowerShellEditorServices'
39+
path: '$(Build.SourcesDirectory)/PowerShellEditorServices/module/'
5740

5841
- pwsh: |
42+
New-Item -ItemType Directory $(Build.ArtifactStagingDirectory)/vscode-powershell
5943
Install-Module InvokeBuild -Force
6044
Invoke-Build Release
45+
workingDirectory: '$(Build.SourcesDirectory)/vscode-powershell'
6146

6247
- task: PublishTestResults@2
6348
inputs:
6449
testRunner: JUnit
6550
testResultsFiles: '**/test-results.xml'
6651
condition: succeededOrFailed()
6752

68-
- task: PkgESCodeSign@10
69-
displayName: 'CodeSign tools/releaseBuild/signing.xml'
70-
env:
71-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
72-
inputs:
73-
signConfigXml: tools/releaseBuild/signing.xml
74-
inPathRoot: '$(Build.ArtifactStagingDirectory)'
75-
outPathRoot: '$(Build.ArtifactStagingDirectory)\Signed'
76-
77-
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
78-
displayName: 'Component Detection'
79-
80-
- task: AntiMalware@3
81-
inputs:
82-
InputType: 'Basic'
83-
ScanType: 'CustomScan'
84-
FileDirPath: '$(Build.ArtifactStagingDirectory)'
85-
EnableServices: false
86-
SupportLogOnError: false
87-
TreatSignatureUpdateFailureAs: 'Warning'
88-
SignatureFreshness: 'UpToDate'
89-
TreatStaleSignatureAs: 'Error'
90-
91-
- task: PoliCheck@1
92-
condition: succeededOrFailed()
93-
inputs:
94-
targetType: F
95-
optionsFC: 0
96-
optionsXS: 0
97-
optionsPE: '1|2|3|4'
98-
optionsHMENABLE: 0
99-
optionsFTPATH: '$(Build.SourcesDirectory)\tools\terms\FileTypeSet.xml'
100-
# toolVersion: 5.8.2.1
101-
102-
- pwsh: |
103-
Get-ChildItem -Exclude node_modules | Get-ChildItem -Recurse | ForEach-Object FullName > "$env:BUILD_SOURCESDIRECTORY/credscan.tsv"
104-
displayName: Create credscan.tsv as the list of files to scan
105-
106-
- task: CredScan@2
107-
condition: succeededOrFailed()
108-
inputs:
109-
debugMode: false
110-
scanFolder: '$(Build.SourcesDirectory)/credscan.tsv'
111-
112-
# Publish results as artifacts
113-
- task: PublishSecurityAnalysisLogs@3
114-
condition: succeededOrFailed()
115-
inputs:
116-
ArtifactName: 'CodeAnalysisLogs'
117-
ArtifactType: 'Container'
118-
119-
# Publish to TSA server
120-
- task: TSAUpload@1
121-
condition: succeededOrFailed()
122-
continueOnError: true
123-
inputs:
124-
tsaVersion: 'TsaV2'
125-
codebase: 'Existing'
126-
tsaEnvironment: 'PROD'
127-
codeBaseName: 'PowerShell_PowerShellEditorServices_20190917'
128-
uploadAPIScan: false
129-
uploadBinSkim: false
130-
uploadCredScan: true
131-
uploadFortifySCA: false
132-
uploadFxCop: false
133-
uploadModernCop: false
134-
uploadPoliCheck: true
135-
uploadPREfast: false
136-
uploadRoslyn: false
137-
uploadTSLint: false
138-
uploadAsync: true
139-
140-
- task: PowerShell@1
141-
displayName: 'Upload artifacts'
142-
inputs:
143-
scriptType: inlineScript
144-
inlineScript: 'Write-Host "##vso[artifact.upload containerfolder=vscode-powershell;artifactname=vscode-powershell]$(System.ArtifactsDirectory)\Signed"'
53+
- checkout: ComplianceRepo
54+
55+
- template: EsrpSign.yml@ComplianceRepo
56+
parameters:
57+
buildOutputPath: '$(Build.ArtifactStagingDirectory)/vscode-powershell'
58+
signOutputPath: '$(Build.ArtifactStagingDirectory)/Signed'
59+
alwaysCopy: true # So publishing works
60+
certificateId: 'CP-230012' # Authenticode certificate
61+
useMinimatch: true # This enables the use of globbing
62+
# NOTE: Code AKA *.vsix files are not signed
63+
pattern: |
64+
Install-VSCode.ps1
65+
66+
- template: EsrpScan.yml@ComplianceRepo
67+
parameters:
68+
scanPath: $(Build.ArtifactStagingDirectory)/Signed
69+
pattern: |
70+
*.vsix
71+
72+
- publish: $(Build.ArtifactStagingDirectory)/Signed
73+
artifact: vscode-powershell
74+
displayName: 'Publish signed (and unsigned) artifacts'
75+
76+
- template: script-module-compliance.yml@ComplianceRepo
77+
parameters:
78+
# component-governance
79+
sourceScanPath: '$(Build.SourcesDirectory)/vscode-powershell'
80+
# credscan
81+
suppressionsFile: '$(Build.SourcesDirectory)/vscode-powershell/tools/credScan/suppress.json'
82+
# TermCheck AKA PoliCheck
83+
targetArgument: '$(Build.SourcesDirectory)/vscode-powershell'
84+
optionsUEPATH: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/UserExclusions.xml'
85+
optionsRulesDBPath: ''
86+
optionsFTPath: '$(Build.SourcesDirectory)/vscode-powershell/tools/terms/FileTypeSet.xml'
87+
# tsa-upload
88+
codeBaseName: 'PowerShell_PowerShellEditorServices_20210201'
89+
# We don't use any Windows APIs directly, so we don't need API scan
90+
APIScan: false

docs/development.md

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,52 @@
55
You'll need to clone two repositories and set up your development environment
66
to before you can proceed.
77

8-
1. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [vscode-powershell repository](https://github.com/PowerShell/vscode-powershell)
8+
1. [Fork and clone][fork] the [vscode-powershell repository](https://github.com/PowerShell/vscode-powershell)
99

10-
2. [Fork and clone](https://help.github.com/articles/fork-a-repo/) the [PowerShell Editor Services (PSES) repository](https://github.com/PowerShell/PowerShellEditorServices)
10+
2. [Fork and clone][fork] the [PowerShell Editor Services (PSES) repository](https://github.com/PowerShell/PowerShellEditorServices)
11+
> The `vscode-powershell` folder and the `PowerShellEditorServices` folder should be next to each other on the file
12+
> system. Code in `vscode-powershell` looks for PSES at `../PowerShellEditorServices` if you're building locally so
13+
> PSES must be in that location.
1114
12-
> NOTE: the `vscode-powershell` folder and the `PowerShellEditorServices` folder should be next to each other on the file system. Code in `vscode-powershell` looks for PSES at `../PowerShellEditorServices` if you're building locally so PSES must be in that location.
13-
14-
3. Follow the [development instructions](https://github.com/PowerShell/PowerShellEditorServices#development) for PowerShell Editor Services. **You will need to complete this step before proceeding**.
15+
3. Follow the [development instructions](https://github.com/PowerShell/PowerShellEditorServices#development) for
16+
PowerShell Editor Services. **You will need to complete this step before proceeding**.
1517

1618
4. Install the latest [Visual Studio Code Insiders release](https://code.visualstudio.com/insiders)
17-
- You can also use the [standard Visual Studio Code release](https://code.visualstudio.com/). Both will work, but using VSCode
18-
Insiders means the extension can be developed ready for new features
19-
and changes in the next VSCode release.
19+
> You can also use the [standard Visual Studio Code release](https://code.visualstudio.com/). Both will work, but
20+
> using VSCode Insiders means the extension can be developed ready for new features and changes in the next VSCode
21+
> release.
2022
2123
5. Install [Node.js](https://nodejs.org/en/) 10.x or higher.
2224

23-
## Building the Code
25+
[fork]: https://help.github.com/articles/fork-a-repo/
26+
27+
### Building the Code
2428

25-
#### From Visual Studio Code:
29+
#### From Visual Studio Code
2630

27-
Press <kbd>Ctrl</kbd>+<kbd>P</kbd> and type `task build`
31+
> Press <kbd>Ctrl</kbd>+<kbd>P</kbd> and type `task build`
2832
2933
This will compile the TypeScript files in the project to JavaScript files.
3034

31-
#### From a PowerShell prompt:
35+
#### From a PowerShell prompt
3236

33-
```
37+
```powershell
3438
Invoke-Build Build
3539
```
3640

37-
## Launching the extension
41+
### Launching the extension
3842

39-
#### From Visual Studio Code:
43+
#### From Visual Studio Code
4044

41-
To debug the extension, press <kbd>F5</kbd>. To run the extension without debugging,
42-
press <kbd>Ctrl</kbd>+<kbd>F5</kbd> or <kbd>Cmd</kbd>+<kbd>F5</kbd> on macOS.
45+
> To debug the extension, press <kbd>F5</kbd>. To run the extension without debugging, press
46+
> <kbd>Ctrl</kbd>+<kbd>F5</kbd> or <kbd>Cmd</kbd>+<kbd>F5</kbd> on macOS.
4347
44-
#### From a command prompt:
48+
#### From a command prompt
4549

46-
```
50+
```cmd
4751
code --extensionDevelopmentPath="c:\path\to\vscode-powershell" .
4852
```
4953

5054
## Contributing Snippets
5155

52-
For more information on contributing snippets please read our [snippet requirements](https://github.com/PowerShell/vscode-powershell/blob/master/docs/community_snippets.md#contributing).
56+
For more information on contributing snippets please read our [snippet requirements](https://github.com/PowerShell/vscode-powershell/blob/master/docs/community_snippets.md#contributing).

extension-dev.code-workspace

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
],
1010
"settings": {
1111
"files.associations": {
12-
"**/snippets/*.json": "jsonc"
12+
"**/snippets/*.json": "jsonc",
13+
"**/.vsts-ci/**/*.yml": "azure-pipelines",
1314
},
1415
"typescript.tsdk": "./node_modules/typescript/lib"
1516
}

tools/credScan/suppress.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"tool": "Credential Scanner",
3+
"suppressions": [
4+
{
5+
"folder": "node_modules",
6+
"_justification": "Third-party code must not be scanned"
7+
},
8+
{
9+
"folder": "PSScriptAnalyzer",
10+
"_justification": "Bundled upstream project with false-positives"
11+
}
12+
]
13+
}

tools/releaseBuild/signing.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

tools/terms/UserExclusions.xml

Lines changed: 12 additions & 0 deletions
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|NODE_MODULES</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)