Skip to content

Commit 93b999f

Browse files
Compliance repo release build (#62)
1 parent 805a18d commit 93b999f

File tree

8 files changed

+118
-262
lines changed

8 files changed

+118
-262
lines changed

tools/releaseBuild/packagesigning.xml

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

tools/releaseBuild/signing.xml

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

tools/releaseBuild/updateSigning.ps1

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

tools/releaseBuild/yaml/compliance.yml

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

tools/releaseBuild/yaml/nuget.yml

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ steps:
4343
Get-ChildItem -Recurse $extractedRoot -File
4444
displayName: 'Extract All Zips'
4545

46-
- template: compliance.yml
47-
4846
- template: upload.yml
4947
parameters:
5048
fileName: 'x64_arm64-symbols.zip'
@@ -116,33 +114,27 @@ steps:
116114
- powershell: 'Get-Childitem $(NuGetPackagePath)'
117115
displayName: 'Capture nuget package'
118116

119-
- powershell: |
120-
## Get the nuget file paths
121-
$files = (Get-ChildItem $(NuGetPackagePath)\*.nupkg).FullName
122-
123-
if($files.Count -lt 1) { throw "No packages available to publish" }
124-
125-
& $(Build.SourcesDirectory)\tools\releaseBuild\generatePackgeSigning.ps1 -Path "$(NuGetPackagePath)\NugetSigning.xml" -NuPkgFiles $files
126-
127-
displayName: 'Generate signing file'
128-
129-
- powershell: 'Get-Content $(NuGetPackagePath)\NugetSigning.xml'
130-
displayName: 'Capture package signing file'
131-
132-
- task: PkgESCodeSign@10
133-
displayName: 'Package ES - CodeSign $(NuGetPackagePath)\NugetSigning.xml'
134-
env:
135-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
136-
inputs:
137-
signConfigXml: '$(NuGetPackagePath)\NugetSigning.xml'
138-
inPathRoot: ' $(NuGetPackagePath)'
139-
outPathRoot: '$(System.ArtifactsDirectory)\signed'
140-
condition: ne(variables['SKIP_SIGNING'], 'True')
117+
- template: EsrpSign.yml@ComplianceRepo
118+
parameters:
119+
# the folder which contains the binaries to sign
120+
buildOutputPath: $(NuGetPackagePath)
121+
# the location to put the signed output
122+
signOutputPath: '$(System.ArtifactsDirectory)\signed'
123+
# the certificate ID to use
124+
certificateId: "CP-401405"
125+
# The file pattern to use
126+
# If not using minimatch: comma separated, with * supported
127+
# If using minimatch: newline separated, with !, **, and * supported.
128+
# See link in the useMinimatch comments.
129+
pattern: '*.nupkg'
130+
# decides if the task should use minimatch for the pattern matching.
131+
# https://github.com/isaacs/minimatch#features
132+
useMinimatch: false
141133

142134
- powershell: |
143135
Copy-Item $(NuGetPackagePath)\*.nupkg -DestinationPath '$(System.ArtifactsDirectory)\signed' -Force -Verbose
144136
displayName: Copy unsigned nuget packge as signing is disabled
145-
condition: eq(variables['SKIP_SIGNING'], 'True')
137+
condition: eq(variables['SkipSigning'], 'True')
146138

147139
- powershell: |
148140
Import-Module $env:BUILD_SOURCESDIRECTORY\build.psm1 -Force

tools/releaseBuild/yaml/releaseBuild.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ variables:
66
NuGetPackagePath: '$(System.ArtifactsDirectory)/NuGetRelease'
77
PackageRoot: '$(System.ArtifactsDirectory)/Packages'
88

9+
resources:
10+
repositories:
11+
- repository: ComplianceRepo
12+
type: github
13+
endpoint: ComplianceGHRepo
14+
name: PowerShell/compliance
15+
916
stages:
1017
- stage: Build
1118
displayName: Build Native Binaries
@@ -31,6 +38,8 @@ stages:
3138
- job: SignWin
3239
pool: Package ES Standard Build
3340
displayName: Sign Windows
41+
variables:
42+
- group: ESRP
3443
dependsOn: BuildWin
3544
strategy:
3645
matrix:
@@ -75,10 +84,76 @@ stages:
7584
- BuildLinux
7685
- BuildMac
7786
pool: Package ES Standard Build
87+
variables:
88+
- group: ESRP
7889

7990
steps:
8091
- template: nuget.yml
8192

93+
- stage: compliance
94+
displayName: Compliance
95+
dependsOn: Build
96+
jobs:
97+
- job: Compliance_Job
98+
pool:
99+
name: Package ES Standard Build
100+
steps:
101+
- checkout: self
102+
clean: true
103+
- checkout: ComplianceRepo
104+
clean: true
105+
106+
- download: current
107+
artifact: release
108+
109+
- download: current
110+
artifact: signed
111+
112+
- powershell: |
113+
$null = New-Item $(PackageRoot) -ItemType Directory -Force -Verbose
114+
if(-not (Test-Path '$(Pipeline.Workspace)/release' ))
115+
{
116+
New-Item -ItemType Directory -Path '$(Pipeline.Workspace)/release' -Force
117+
}
118+
Invoke-WebRequest -Uri '$(PSRPBlobUrl)' -OutFile $(Pipeline.Workspace)/release/psrp.zip -Verbose
119+
displayName: 'Download PSRP package'
120+
121+
- powershell: 'Get-ChildItem $(Pipeline.Workspace)/release'
122+
displayName: 'Capture downloaded zips'
123+
124+
- powershell: |
125+
$extractedRoot = New-Item $(Pipeline.Workspace)/uncompressed -ItemType Directory -Force -Verbose
126+
Get-ChildItem $(Pipeline.Workspace)/release/*.zip | ForEach-Object {
127+
$baseName = $_.BaseName
128+
if($baseName -match 'x64_arm') {
129+
Write-Verbose "Skipping expanding file $_.Name" -Verbose
130+
}
131+
else {
132+
$folderPath = Join-Path $extractedRoot $baseName
133+
Expand-Archive $_.FullName -DestinationPath $folderPath -Force
134+
}
135+
}
136+
Write-Host "Extracted files:"
137+
Get-ChildItem -Recurse $extractedRoot -File
138+
displayName: 'Extract All Zips'
139+
140+
- template: assembly-module-compliance.yml@ComplianceRepo
141+
parameters:
142+
# binskim
143+
AnalyzeTarget: '$(Pipeline.Workspace)/uncompressed/*.dll'
144+
AnalyzeSymPath: 'SRV*'
145+
# component-governance
146+
sourceScanPath: '$(Build.SourcesDirectory)/powershell-native'
147+
# credscan
148+
suppressionsFile: ''
149+
# TermCheck
150+
optionsRulesDBPath: ''
151+
optionsFTPath: ''
152+
# tsa-upload
153+
codeBaseName: 'PowerShellNative'
154+
# selections
155+
APIScan: true # set to false when not using Windows APIs.
156+
82157
- template: publish.yml
83158
parameters:
84159
stageName: AzArtifactsFeed
Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
11
steps:
2-
- task: PkgESSetupBuild@10
3-
displayName: 'Initialize build'
4-
env:
5-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
6-
inputs:
7-
useDfs: false
8-
productName: PowerShellCore
9-
branchVersion: true
10-
disableWorkspace: true
11-
disableBuildTools: true
12-
disableNugetPack: true
13-
condition: and(succeeded(), eq(variables['Build.Reason'], 'Manual'))
14-
152
- task: DownloadBuildArtifacts@0
163
inputs:
174
buildType: current
@@ -28,42 +15,44 @@ steps:
2815
Write-Host "##$vstsCommandString"
2916
displayName: Expand artifact $(ARCHITECTURE)-symbols.zip
3017

31-
- task: PowerShell@2
32-
displayName: 'Update Signing Xml'
33-
inputs:
34-
targetType: filePath
35-
filePath: $(Build.SourcesDirectory)/tools/releaseBuild/updateSigning.ps1
18+
- powershell: |
19+
$vstsCommandString = "vso[task.setvariable variable=SignedOutput]$(System.ArtifactsDirectory)\Signed"
20+
Write-Host "sending " + $vstsCommandString
21+
Write-Host "##$vstsCommandString"
22+
displayName: Define signedOutput variable
3623

37-
- task: PkgESCodeSign@10
38-
displayName: 'CodeSign $(ARCHITECTURE)'
39-
env:
40-
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
41-
inputs:
42-
signConfigXml: '$(Build.SourcesDirectory)\tools\releaseBuild\signing.xml'
43-
inPathRoot: '$(Symbols)'
44-
outPathRoot: '$(Symbols)\Signed'
45-
condition: ne(variables['SKIP_SIGNING'], 'True')
24+
- template: EsrpSign.yml@ComplianceRepo
25+
parameters:
26+
# the folder which contains the binaries to sign
27+
buildOutputPath: $(Symbols)
28+
# the location to put the signed output
29+
signOutputPath: '$(SignedOutput)'
30+
# the certificate ID to use
31+
certificateId: "CP-230012"
32+
# The file pattern to use
33+
# If not using minimatch: comma separated, with * supported
34+
# If using minimatch: newline separated, with !, **, and * supported.
35+
# See link in the useMinimatch comments.
36+
pattern: '*.dll'
37+
# decides if the task should use minimatch for the pattern matching.
38+
# https://github.com/isaacs/minimatch#features
39+
useMinimatch: false
4640

4741
- powershell: |
48-
Compress-Archive -Path '$(Symbols)\Signed\*' -DestinationPath '$(Symbols)\Signed\win-$(ARCHITECTURE).zip'
42+
Compress-Archive -Path '$(SignedOutput)\*' -DestinationPath '$(SignedOutput)\win-$(ARCHITECTURE).zip'
4943
displayName: Compress signed binaries
50-
condition: ne(variables['SKIP_SIGNING'], 'True')
44+
condition: eq(variables['SkipSigning'], 'false')
5145

5246
- powershell: |
53-
Get-ChildItem -Path '$(Symbols)\*' -Recurse | Copy-Item -Destination '$(Symbols)\Signed' -Force -Verbose
47+
Get-ChildItem -Path '$(Symbols)\*' -Recurse | Copy-Item -Destination '$(SignedOutput)' -Force -Verbose
5448
displayName: Copy unsigned binaries as signing is skipped
55-
condition: eq(variables['SKIP_SIGNING'], 'True')
49+
condition: eq(variables['SkipSigning'], 'True')
5650

5751
- template: uploadArtifact.yml
5852
parameters:
59-
artifactPath: '$(Symbols)\Signed'
53+
artifactPath: '$(SignedOutput)'
6054
artifactFilter: 'win-*.zip'
6155
artifactName: 'signed'
6256

6357
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
6458
displayName: 'Run MpCmdRun.exe'
65-
66-
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
67-
displayName: 'Component Detection'
68-
inputs:
69-
sourceScanPath: '$(Build.SourcesDirectory)'

0 commit comments

Comments
 (0)