@@ -100,63 +100,27 @@ jobs:
100100 displayName : Publish Image Info File Artifact
101101 internalProjectName : ${{ parameters.internalProjectName }}
102102 publicProjectName : ${{ parameters.publicProjectName }}
103- - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }} :
104- # The following task depends on the SBOM Manifest Generator task installed on the agent.
105- # This task is auto-injected by 1ES Pipeline Templates so we don't need to install it ourselves.
103+ - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest'), eq(parameters.dockerClientOS, 'linux')) }} :
106104 - powershell : |
107105 $images = "$(BuildImages.builtImages)"
108106 if (-not $images) { return 0 }
109-
110- # There can be leftover versions of the task left on the agent if it's not fresh. So find the latest version.
111- $taskDir = $(Get-ChildItem -Recurse -Directory -Filter "ManifestGeneratorTask*" -Path '$(Agent.WorkFolder)')[-1].FullName
112-
113- # There may be multiple version directories within the task directory. Use the latest.
114- $taskVersionDir = $(Get-ChildItem -Directory $taskDir | Sort-Object)[-1].FullName
115-
116- $manifestToolDllPath = $(Get-ChildItem -Recurse -File -Filter "Microsoft.ManifestTool.dll" -Path $taskVersionDir).FullName
117-
118- # Check whether the manifest task installed its own version of .NET.
119- # To be more robust, we'll handle varying implementations that it's had.
120- # First check for a dotnet folder in the task location
121- $dotnetDir = $(Get-ChildItem -Recurse -Directory -Filter "dotnet-*" -Path $taskVersionDir).FullName
122- if (-not $dotnetDir) {
123- # If it's not there, check in the agent tools location
124- $dotnetDir = $(Get-ChildItem -Recurse -Directory -Filter "*dotnet-*" -Path "$(Agent.ToolsDirectory)").FullName
125- }
126-
127- # If the manifest task installed its own version of .NET use that; otherwise it's reusing an existing install of .NET
128- # which is executable by default.
129- if ($dotnetDir) {
130- $dotnetPath = "$dotnetDir/dotnet"
131- }
132- else {
133- $dotnetPath = "dotnet"
134- }
135-
136- # Call the manifest tool for each image to produce seperate SBOMs
137- # Manifest tool docs: https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/custom-sbom-generation-workflows
107+ $syftImageName = "${{ parameters.publishConfig.publicMirrorAcr.server }}/$(imageNames.syft)"
108+ & $(engCommonPath)/Pull-Image.ps1 $syftImageName
138109 $images -Split ',' | ForEach-Object {
139110 echo "Generating SBOM for $_";
140- $formattedImageName = $_.Replace('${{ parameters.publishConfig.buildAcr.server }}/${{ parameters.publishConfig.buildAcr.repoPrefix }}', "").Replace('/', '_').Replace(':', '_');
111+ $targetImageName = "$_";
112+ $formattedImageName = $targetImageName.Replace('${{ parameters.publishConfig.buildAcr.server }}/${{ parameters.publishConfig.buildAcr.repoPrefix }}', "").Replace('/', '_').Replace(':', '_');
141113 $sbomChildDir = "$(sbomDirectory)/$formattedImageName";
142114 New-Item -Type Directory -Path $sbomChildDir > $null;
143- & $dotnetPath "$manifestToolDllPath" `
144- Generate `
145- -BuildDropPath '$(Build.ArtifactStagingDirectory)' `
146- -BuildComponentPath '$(Agent.BuildDirectory)' `
147- -PackageName '.NET' `
148- -PackageVersion '$(Build.BuildNumber)' `
149- -ManifestDirPath $sbomChildDir `
150- -DockerImagesToScan $_ `
151- -Verbosity Information
115+ docker build --output=$sbomChildDir -f $(engCommonPath)/Dockerfile.syft --build-arg SYFT_IMAGE_NAME=$syftImageName --build-arg TARGET_IMAGE_NAME=$targetImageName -t syft-sbom $(engCommonPath);
152116 }
153117 displayName: Generate SBOMs
154118 condition: and(succeeded(), ne(variables['BuildImages.builtImages'], ''))
155119 - ${{ if eq(variables['Build.Reason'], 'PullRequest') }} :
156120 - template : /eng/common/templates/jobs/${{ format('../steps/test-images-{0}-client.yml', parameters.dockerClientOS) }}@self
157121 parameters :
158122 condition : ne(variables.testScriptPath, '')
159- - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest')) }} :
123+ - ${{ if and(eq(variables['System.TeamProject'], parameters.internalProjectName), ne(variables['Build.Reason'], 'PullRequest'), eq(parameters.dockerClientOS, 'linux') ) }} :
160124 - template : /eng/common/templates/steps/publish-artifact.yml@self
161125 parameters :
162126 path : $(sbomDirectory)
0 commit comments