Skip to content

Commit 416a4b1

Browse files
authored
Enable SBOM creation for script analyzer (#1762)
* Add SBOM creation to PSSA build. * remove extraneous displayname * change logic for copying manifest. fix build repository URL. * improve debugging output * move to buildRoot before looking for _manifest * copy manifest recursively. * remove MacOS Mojave from test matrix. image removed from Azure devops in December 2021
1 parent 77ba74b commit 416a4b1

File tree

4 files changed

+40
-3
lines changed

4 files changed

+40
-3
lines changed

.azure-pipelines-ci/ci.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ stages:
2626
vmImage: ubuntu-18.04
2727
Ubuntu_20_04:
2828
vmImage: ubuntu-20.04
29-
macOS_10_14_Mojave:
30-
vmImage: macOS-10.14
3129
macOS_10_15_Catalina:
3230
vmImage: macOS-10.15
3331
Windows_Server2016_PowerShell_Core:

.ci/releaseBuild.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,17 @@ stages:
136136
**/Pluralize*.dll
137137
**/Newtonsoft*.dll
138138
139+
# Create the manifest for the module
140+
- template: Sbom.yml@ComplianceRepo
141+
parameters:
142+
BuildDropPath: $(signOutPath)
143+
Build_Repository_Uri: 'https://github.com/powershell/PSScriptAnalyzer'
144+
139145
# now create the nupkg which we will use to publish the module
140146
# to the powershell gallery (not part of this yaml)
141147
- pwsh: |
142148
Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
143-
./build -BuildNupkg -signed
149+
./build -BuildNupkg -CopyManifest -signed
144150
displayName: Create nupkg for publishing
145151
146152
# finally publish the parts of the build which will be used in the next stages

build.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ param(
4242
[Parameter(ParameterSetName='Package')]
4343
[switch] $BuildNupkg,
4444

45+
[Parameter(ParameterSetName='Package')]
46+
[switch] $CopyManifest,
47+
4548
[Parameter(ParameterSetName='Package')]
4649
[switch] $Signed
4750

@@ -92,6 +95,9 @@ END {
9295
return
9396
}
9497
"Package" {
98+
if($CopyManifest) {
99+
Copy-Manifest -signed:$Signed
100+
}
95101
Start-CreatePackage -signed:$Signed
96102
}
97103
"Test" {

build.psm1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,32 @@ function Copy-CrossCompatibilityModule
767767
}
768768
}
769769

770+
# copy the manifest into the module if is present
771+
function Copy-Manifest
772+
{
773+
param ( [switch]$signed )
774+
if ( $signed ) {
775+
$buildRoot = "signed"
776+
}
777+
else {
778+
$buildRoot = "out"
779+
}
780+
$analyzerVersion = Get-AnalyzerVersion
781+
# location where analyzer goes
782+
# debugging
783+
(Get-ChildItem -File -Recurse)|ForEach-Object {Write-Verbose -Verbose -Message $_}
784+
$modBaseDir = [io.path]::Combine($projectRoot,${buildRoot},"${analyzerName}", $analyzerVersion)
785+
# copy the manifest files
786+
Push-Location $buildRoot
787+
if ( Test-Path _manifest ) {
788+
Copy-Item -Recurse -Path _manifest -Destination $modBaseDir -Verbose
789+
}
790+
else {
791+
Write-Warning -Message "_manifest not found in $PWD"
792+
}
793+
Pop-Location
794+
}
795+
770796
# creates the nuget package which can be used for publishing to the gallery
771797
function Start-CreatePackage
772798
{
@@ -783,6 +809,7 @@ function Start-CreatePackage
783809
$nupkgDir = Join-Path $PSScriptRoot $buildRoot
784810
$null = Register-PSRepository -Name $repoName -InstallationPolicy Trusted -SourceLocation $nupkgDir
785811
Push-Location $nupkgDir
812+
786813
Publish-Module -Path $PWD/PSScriptAnalyzer -Repository $repoName
787814
}
788815
finally {

0 commit comments

Comments
 (0)