Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable SBOM creation for script analyzer #1762

Merged
merged 7 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .azure-pipelines-ci/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ stages:
vmImage: ubuntu-18.04
Ubuntu_20_04:
vmImage: ubuntu-20.04
macOS_10_14_Mojave:
vmImage: macOS-10.14
macOS_10_15_Catalina:
vmImage: macOS-10.15
Windows_Server2016_PowerShell_Core:
Expand Down
8 changes: 7 additions & 1 deletion .ci/releaseBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,17 @@ stages:
**/Pluralize*.dll
**/Newtonsoft*.dll

# Create the manifest for the module
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: $(signOutPath)
Build_Repository_Uri: 'https://github.com/powershell/PSScriptAnalyzer'

# now create the nupkg which we will use to publish the module
# to the powershell gallery (not part of this yaml)
- pwsh: |
Set-Location "$(Build.SourcesDirectory)/OSS_Microsoft_PSSA"
./build -BuildNupkg -signed
./build -BuildNupkg -CopyManifest -signed
displayName: Create nupkg for publishing

# finally publish the parts of the build which will be used in the next stages
Expand Down
6 changes: 6 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ param(
[Parameter(ParameterSetName='Package')]
[switch] $BuildNupkg,

[Parameter(ParameterSetName='Package')]
[switch] $CopyManifest,

[Parameter(ParameterSetName='Package')]
[switch] $Signed

Expand Down Expand Up @@ -92,6 +95,9 @@ END {
return
}
"Package" {
if($CopyManifest) {
Copy-Manifest -signed:$Signed
}
Start-CreatePackage -signed:$Signed
}
"Test" {
Expand Down
27 changes: 27 additions & 0 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,32 @@ function Copy-CrossCompatibilityModule
}
}

# copy the manifest into the module if is present
function Copy-Manifest
{
param ( [switch]$signed )
if ( $signed ) {
$buildRoot = "signed"
}
else {
$buildRoot = "out"
}
$analyzerVersion = Get-AnalyzerVersion
# location where analyzer goes
# debugging
(Get-ChildItem -File -Recurse)|ForEach-Object {Write-Verbose -Verbose -Message $_}
$modBaseDir = [io.path]::Combine($projectRoot,${buildRoot},"${analyzerName}", $analyzerVersion)
# copy the manifest files
Push-Location $buildRoot
if ( Test-Path _manifest ) {
Copy-Item -Recurse -Path _manifest -Destination $modBaseDir -Verbose
}
else {
Write-Warning -Message "_manifest not found in $PWD"
}
Pop-Location
}

# creates the nuget package which can be used for publishing to the gallery
function Start-CreatePackage
{
Expand All @@ -783,6 +809,7 @@ function Start-CreatePackage
$nupkgDir = Join-Path $PSScriptRoot $buildRoot
$null = Register-PSRepository -Name $repoName -InstallationPolicy Trusted -SourceLocation $nupkgDir
Push-Location $nupkgDir

Publish-Module -Path $PWD/PSScriptAnalyzer -Repository $repoName
}
finally {
Expand Down