Skip to content

Commit dcdb71c

Browse files
authored
Update to latest compliance template (#315)
1 parent 01d51cb commit dcdb71c

File tree

4 files changed

+26
-438
lines changed

4 files changed

+26
-438
lines changed

.ci/ci.yml

Lines changed: 26 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ pr:
1212
#- master
1313
- development
1414

15-
variables:
16-
- group: ESRP
15+
resources:
16+
repositories:
17+
- repository: ComplianceRepo
18+
type: github
19+
endpoint: ComplianceGHRepo
20+
name: PowerShell/compliance
1721

1822
stages:
1923
- stage: Build
@@ -22,7 +26,7 @@ stages:
2226
- job: BuildPkg
2327
displayName: Build Package
2428
pool:
25-
vmImage: windows-2019
29+
vmImage: windows-latest
2630

2731
steps:
2832
- powershell: |
@@ -96,196 +100,14 @@ stages:
96100
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
97101
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
98102
Import-Module -Name $modPath -Force
99-
100-
$config = Get-PSPackageProjectConfiguration
101-
102-
# Created files signing directory
103-
$srcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
104-
$createdSignSrcPath = "$($config.BuildOutputPath)\CreatedFiles"
105-
if (! (Test-Path -Path $createdSignSrcPath)) {
106-
$null = New-Item -Path $createdSignSrcPath -ItemType Directory -Verbose
107-
}
108-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "PowerShellGet.psd1") -Dest $createdSignSrcPath -Force -Verbose
109-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "PSModule.psm1") -Dest $createdSignSrcPath -Force -Verbose
110-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "DscResources") -Dest $createdSignSrcPath -Recurse -Force -Verbose
111-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "Modules") -Dest $createdSignSrcPath -Recurse -Force -Verbose
112-
113-
$net472Path = Join-Path -Path $createdSignSrcPath -ChildPath "net472"
114-
if (! (Test-Path -Path $net472Path)) {
115-
$null = New-Item -Path $net472Path -ItemType Directory -Verbose
116-
}
117-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "net472\PowerShellGet.*") -Dest $net472Path -Force -Verbose
118-
119-
$netStandardPath = Join-Path -Path $createdSignSrcPath -ChildPath "netstandard2.0"
120-
if (! (Test-Path -Path $netStandardPath)) {
121-
$null = New-Item -Path $netStandardPath -ItemType Directory -Verbose
122-
}
123-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "netstandard2.0\PowerShellGet.*") -Dest $netStandardPath -Force -Verbose
124-
125-
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
126-
if (! (Test-Path -Path $signOutPath)) {
127-
$null = New-Item -Path $signOutPath -ItemType Directory
128-
}
129-
130-
# Set signing src path variable
131-
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${createdSignSrcPath}"
132-
Write-Host "sending " + $vstsCommandString
133-
Write-Host "##$vstsCommandString"
134-
135-
$outSignPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
136-
if (! (Test-Path -Path $outSignPath)) {
137-
$null = New-Item -Path $outSignPath -ItemType Directory -Verbose
138-
}
139-
140-
# Set signing out path variable
141-
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${outSignPath}"
142-
Write-Host "sending " + $vstsCommandString
143-
Write-Host "##$vstsCommandString"
144-
displayName: Set up for module created files code signing
145-
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
146-
147-
- template: ./templates/sign.yml
148-
parameters:
149-
buildOutputPath: $(signSrcPath)
150-
signOutputPath: $(signOutPath)
151-
certificateId: "CP-230012"
152-
pattern: '*.dll,*.psd1,*.psm1,*.ps1xml,*.mof'
153-
154-
- pwsh: |
155-
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
156-
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
157-
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
158-
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
159-
Import-Module -Name $modPath -Force
160-
161103
$config = Get-PSPackageProjectConfiguration
162-
163-
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
164-
if (! (Test-Path -Path $signOutPath)) {
165-
$null = New-Item -Path $signOutPath -ItemType Directory
166-
}
167-
168-
# Third party files signing directory
169-
$srcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
170-
$thirdPartySignSrcPath = "$($config.BuildOutputPath)\ThirdParty"
171-
if (! (Test-Path -Path $thirdPartySignSrcPath)) {
172-
$null = New-Item -Path $thirdPartySignSrcPath -ItemType Directory -Verbose
173-
}
174-
175-
# Net472 directory
176-
$net472Path = Join-Path -Path $thirdPartySignSrcPath -ChildPath "net472"
177-
if (! (Test-Path -Path $net472Path)) {
178-
$null = New-Item -Path $net472Path -ItemType Directory -Verbose
179-
}
180-
Get-ChildItem -Path (Join-Path -Path $srcPath -ChildPath "net472") -Filter '*.dll' | Foreach-Object {
181-
if ($_.Name -ne 'PowerShellGet.dll') {
182-
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
183-
if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notlike '*Microsoft*' -or $sig.SignerCertificate.Issuer -notlike '*Microsoft Code Signing PCA*') {
184-
# Copy for third party signing
185-
Copy-Item -Path $_.FullName -Dest $net472Path -Force -Verbose
186-
}
187-
}
188-
}
189-
190-
# NetStandard directory
191-
$netStandardPath = Join-Path -Path $thirdPartySignSrcPath -ChildPath "netstandard2.0"
192-
if (! (Test-Path -Path $netStandardPath)) {
193-
$null = New-Item -Path $netStandardPath -ItemType Directory -Verbose
194-
}
195-
Get-ChildItem -Path (Join-Path -Path $srcPath -ChildPath "netstandard2.0") -Filter '*.dll' | Foreach-Object {
196-
if ($_.Name -ne 'PowerShellGet.dll') {
197-
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
198-
if ($sig.Status -ne 'Valid' -or $sig.SignerCertificate.Subject -notlike '*Microsoft*' -or $sig.SignerCertificate.Issuer -notlike '*Microsoft Code Signing PCA*') {
199-
# Copy for third party signing
200-
Copy-Item -Path $_.FullName -Dest $netStandardPath -Force -Verbose
201-
}
202-
}
203-
}
204-
205-
# Set signing src path variable
206-
$vstsCommandString = "vso[task.setvariable variable=signSrcPath]${thirdPartySignSrcPath}"
207-
Write-Host "sending " + $vstsCommandString
208-
Write-Host "##$vstsCommandString"
209-
210-
# Set signing out path variable
211-
$vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}"
212-
Write-Host "sending " + $vstsCommandString
213-
Write-Host "##$vstsCommandString"
214-
displayName: Set up for module third party files code signing
215-
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
216-
217-
- template: ./templates/sign.yml
218-
parameters:
219-
buildOutputPath: $(signSrcPath)
220-
signOutputPath: $(signOutPath)
221-
certificateId: "CP-231522"
222-
pattern: '*.dll'
223-
224-
- pwsh: |
225-
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
226-
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
227-
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
228-
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
229-
Import-Module -Name $modPath -Force
230-
231-
$config = Get-PSPackageProjectConfiguration
232-
233-
$srcPath = "$($config.BuildOutputPath)\$($config.ModuleName)"
234-
$signOutPath = "$($config.SignedOutputPath)\$($config.ModuleName)"
235-
if (! (Test-Path -Path $signOutPath)) {
236-
$null = New-Item -Path $signOutPath -ItemType Directory
237-
}
238-
239-
# en-US
240-
Copy-Item -Path (Join-Path -Path $srcPath -ChildPath "en-US") -Dest $signOutPath -Recurse
241-
242-
# Net472 directory
243-
$net472SignedOutPath = Join-Path -Path $signOutPath -ChildPath "net472"
244-
if (! (Test-Path -Path $net472SignedOutPath)) {
245-
$null = New-Item -Path $net472SignedOutPath -ItemType Directory -Verbose
246-
}
247-
Get-ChildItem -Path (Join-Path -Path $srcPath -ChildPath "net472") -Filter '*.dll' | Foreach-Object {
248-
if ($_.Name -ne 'PowerShellGet.dll') {
249-
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
250-
if ($sig.Status -eq 'Valid' -and ($sig.SignerCertificate.Subject -like '*Microsoft*' -and $sig.SignerCertificate.Issuer -like '*Microsoft Code Signing PCA*')) {
251-
# Copy already signed files directly to output
252-
Copy-Item -Path $_.FullName -Dest $net472SignedOutPath -Force -Verbose
253-
}
254-
}
255-
}
256-
257-
# NetStandard directory
258-
$netStandardSignedOutPath = Join-Path -Path $signOutPath -ChildPath "netstandard2.0"
259-
if (! (Test-Path -Path $netStandardSignedOutPath)) {
260-
$null = New-Item -Path $netStandardSignedOutPath -ItemType Directory -Verbose
261-
}
262-
Get-ChildItem -Path (Join-Path -Path $srcPath -ChildPath "netstandard2.0") -Filter '*.dll' | Foreach-Object {
263-
if ($_.Name -ne 'PowerShellGet.dll') {
264-
$sig = Get-AuthenticodeSignature -FilePath $_.FullName
265-
if ($sig.Status -eq 'Valid' -and ($sig.SignerCertificate.Subject -like '*Microsoft*' -and $sig.SignerCertificate.Issuer -like '*Microsoft Code Signing PCA*')) {
266-
# Copy already signed files directly to output
267-
Copy-Item -Path $_.FullName -Dest $netStandardSignedOutPath -Force -Verbose
268-
}
269-
}
270-
}
271-
displayName: Copy already properly signed third party files
272-
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True'))
273-
274-
- pwsh: |
275-
$modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules'
276-
$env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath
277-
$modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject
278-
Write-Verbose -Verbose "Importing PSPackageProject from: $modPath"
279-
Import-Module -Name $modPath -Force
280104
#
281-
if ($env:SkipSigning -eq 'True')
282-
{
283-
$(Build.SourcesDirectory)/build.ps1 -Publish
284-
}
285-
else
286-
{
287-
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
288-
}
105+
$srcModulePath = Resolve-Path -Path "$($config.BuildOutputPath)/$($config.ModuleName)"
106+
Get-ChildItem $srcModulePath
107+
$artifactName = "$($config.ModuleName)"
108+
Write-Host "##vso[artifact.upload containerfolder=$artifactName;artifactname=$artifactName;]$srcModulePath"
109+
#
110+
$(Build.SourcesDirectory)/build.ps1 -Publish
289111
displayName: Create module artifact
290112
291113
- stage: Compliance
@@ -294,9 +116,18 @@ stages:
294116
jobs:
295117
- job: ComplianceJob
296118
pool:
297-
vmImage: windows-2019
119+
vmImage: windows-latest
298120
steps:
299-
- template: compliance.yml
121+
- checkout: self
122+
clean: true
123+
- checkout: ComplianceRepo
124+
clean: true
125+
- download: current
126+
artifact: 'PowerShellGet'
127+
- template: ci-compliance.yml@ComplianceRepo
128+
parameters:
129+
# credscan
130+
suppressionsFile: ''
300131

301132
- stage: Test
302133
displayName: Test Package
@@ -306,13 +137,13 @@ stages:
306137
parameters:
307138
jobName: TestPkgWin
308139
displayName: PowerShell Core on Windows
309-
imageName: windows-2019
140+
imageName: windows-latest
310141

311142
- template: test.yml
312143
parameters:
313144
jobName: TestPkgWinPS
314145
displayName: Windows PowerShell on Windows
315-
imageName: windows-2019
146+
imageName: windows-latest
316147
powershellExecutable: powershell
317148

318149
# - template: test.yml
@@ -326,9 +157,3 @@ stages:
326157
# jobName: TestPkgWinMacOS
327158
# displayName: PowerShell Core on macOS
328159
# imageName: macOS-10.14
329-
330-
- stage: Release
331-
displayName: Release Package
332-
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), eq(variables['Publish'], 'True'))
333-
jobs:
334-
- template: release.yml

.ci/compliance.yml

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

0 commit comments

Comments
 (0)