Skip to content

Commit 4e7e669

Browse files
authored
Cherrypick 1ES pipelines to 7.0 (#1076)
* Add code-mirror.yml * Convert build pipeline to 1ES (#1061) - Remove old pipeline - Changes to build.ps1 for new pipeline * Remove NuGet Config (#1074) * Updating build to check for vulnerabilities (#1026) * Add Check-CsprojVulnerabilities.ps1 script * Update test projects dependencies
1 parent e010fe1 commit 4e7e669

File tree

12 files changed

+248
-176
lines changed

12 files changed

+248
-176
lines changed

Check-CsprojVulnerabilities.ps1

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
param
2+
(
3+
[String[]]
4+
$CsprojFilePath,
5+
6+
[switch]
7+
$PrintReport
8+
)
9+
10+
if (-not $CsprojFilePath)
11+
{
12+
$CsprojFilePath = @(
13+
"$PSScriptRoot/src/Microsoft.Azure.Functions.PowerShellWorker.csproj"
14+
"$PSScriptRoot/test/Unit/Microsoft.Azure.Functions.PowerShellWorker.Test.csproj"
15+
"$PSScriptRoot/test/E2E/Azure.Functions.PowerShellWorker.E2E/Azure.Functions.PowerShellWorker.E2E/Azure.Functions.PowerShellWorker.E2E.csproj"
16+
)
17+
}
18+
19+
$logFilePath = "$PSScriptRoot/build.log"
20+
21+
try
22+
{
23+
foreach ($projectFilePath in $CsprojFilePath)
24+
{
25+
Write-Host "Analyzing '$projectFilePath' for vulnerabilities..."
26+
27+
$projectFolder = Split-Path $projectFilePath
28+
29+
Push-Location $projectFolder
30+
& { dotnet restore $projectFilePath }
31+
& { dotnet list $projectFilePath package --include-transitive --vulnerable } 3>&1 2>&1 > $logFilePath
32+
Pop-Location
33+
34+
# Check and report if vulnerabilities are found
35+
$report = Get-Content $logFilePath -Raw
36+
$result = $report | Select-String "has no vulnerable packages given the current sources"
37+
38+
if ($result)
39+
{
40+
Write-Host "No vulnerabilities found"
41+
}
42+
else
43+
{
44+
$output = [System.Environment]::NewLine + "Vulnerabilities found!"
45+
if ($PrintReport.IsPresent)
46+
{
47+
$output += $report
48+
}
49+
50+
Write-Host $output -ForegroundColor Red
51+
Exit 1
52+
}
53+
Write-Host ""
54+
}
55+
}
56+
finally
57+
{
58+
if (Test-Path $logFilePath)
59+
{
60+
Remove-Item $logFilePath -Force
61+
}
62+
}

NuGet.config

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

azure-pipelines.yml

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

build.ps1

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ param(
2828
$Configuration = "Debug",
2929

3030
[string]
31-
$BuildNumber = '0',
32-
33-
[switch]
34-
$AddSBOM,
35-
36-
[string]
37-
$SBOMUtilSASUrl
31+
$BuildNumber = '0'
3832
)
3933

4034
#Requires -Version 6.0
@@ -68,35 +62,6 @@ function Get-FunctionsCoreToolsDir {
6862
}
6963
}
7064

71-
function Install-SBOMUtil
72-
{
73-
if ([string]::IsNullOrEmpty($SBOMUtilSASUrl))
74-
{
75-
throw "The `$SBOMUtilSASUrl parameter cannot be null or empty when specifying the `$AddSBOM switch"
76-
}
77-
78-
$MANIFESTOOLNAME = "ManifestTool"
79-
Write-Host "Installing $MANIFESTOOLNAME..."
80-
81-
$MANIFESTOOL_DIRECTORY = Join-Path $PSScriptRoot $MANIFESTOOLNAME
82-
Remove-Item -Recurse -Force $MANIFESTOOL_DIRECTORY -ErrorAction Ignore
83-
84-
Invoke-RestMethod -Uri $SBOMUtilSASUrl -OutFile "$MANIFESTOOL_DIRECTORY.zip"
85-
Expand-Archive "$MANIFESTOOL_DIRECTORY.zip" -DestinationPath $MANIFESTOOL_DIRECTORY
86-
87-
$dllName = "Microsoft.ManifestTool.dll"
88-
$manifestToolPath = "$MANIFESTOOL_DIRECTORY/$dllName"
89-
90-
if (-not (Test-Path $manifestToolPath))
91-
{
92-
throw "$MANIFESTOOL_DIRECTORY does not contain '$dllName'"
93-
}
94-
95-
Write-Host 'Done.'
96-
97-
return $manifestToolPath
98-
}
99-
10065
function Deploy-PowerShellWorker {
10166
$ErrorActionPreference = 'Stop'
10267

@@ -170,28 +135,6 @@ if (!$NoBuild.IsPresent) {
170135

171136
dotnet publish -c $Configuration "/p:BuildNumber=$BuildNumber" $PSScriptRoot
172137

173-
if ($AddSBOM)
174-
{
175-
# Install manifest tool
176-
$manifestTool = Install-SBOMUtil
177-
Write-Log "manifestTool: $manifestTool "
178-
179-
# Generate manifest
180-
$buildPath = "$PSScriptRoot/src/bin/$Configuration/$TargetFramework/publish"
181-
$telemetryFilePath = Join-Path $PSScriptRoot ((New-Guid).Guid + ".json")
182-
$packageName = "Microsoft.Azure.Functions.PowerShellWorker.nuspec"
183-
184-
# Delete the manifest folder if it exists
185-
$manifestFolderPath = Join-Path $buildPath "_manifest"
186-
if (Test-Path $manifestFolderPath)
187-
{
188-
Remove-Item $manifestFolderPath -Recurse -Force -ErrorAction Ignore
189-
}
190-
191-
Write-Log "Running: dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath"
192-
& { dotnet $manifestTool generate -BuildDropPath $buildPath -BuildComponentPath $buildPath -Verbosity Information -t $telemetryFilePath -PackageName $packageName }
193-
}
194-
195138
dotnet pack -c $Configuration "/p:BuildNumber=$BuildNumber" "$PSScriptRoot/package"
196139
}
197140

eng/ci/code-mirror.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
trigger:
2+
branches:
3+
include:
4+
# Below branches are examples for Azure/azure-functions-host. Replace with appropriate branches for your repository.
5+
# Keep this set limited as appropriate (don't mirror individual user branches).
6+
- dev
7+
- v4.x/*
8+
- v3.x/*
9+
10+
resources:
11+
repositories:
12+
- repository: eng
13+
type: git
14+
name: engineering
15+
ref: refs/tags/release
16+
17+
variables:
18+
- template: ci/variables/cfs.yml@eng
19+
20+
extends:
21+
template: ci/code-mirror.yml@eng

eng/ci/official.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
trigger:
2+
batch: true
3+
branches:
4+
include:
5+
- v4.x/*
6+
- v3.x/*
7+
8+
# CI only, does not trigger on PRs.
9+
pr: none
10+
11+
resources:
12+
repositories:
13+
- repository: 1es
14+
type: git
15+
name: 1ESPipelineTemplates/1ESPipelineTemplates
16+
ref: refs/tags/release
17+
18+
variables:
19+
Configuration: Release
20+
buildNumber: $[ counter('build', 4000) ] # Start higher than the versions from the previous pipeline. Every build (pr or branch) will increment.
21+
22+
extends:
23+
template: v1/1ES.Official.PipelineTemplate.yml@1es
24+
parameters:
25+
pool:
26+
name: 1es-pool-azfunc
27+
image: 1es-windows-2022
28+
os: windows
29+
30+
stages:
31+
- stage: WindowsUnitTests
32+
dependsOn: []
33+
jobs:
34+
- template: /eng/ci/templates/test.yml@self
35+
36+
- stage: LinuxUnitTests
37+
dependsOn: []
38+
jobs:
39+
- template: /eng/ci/templates/test.yml@self
40+
pool:
41+
name: 1es-pool-azfunc
42+
image: 1es-ubuntu-22.04
43+
os: linux
44+
45+
- stage: Build
46+
dependsOn: [WindowsUnitTests, LinuxUnitTests]
47+
jobs:
48+
- template: /eng/ci/templates/build.yml@self

eng/ci/public.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
trigger:
2+
batch: true
3+
branches:
4+
include:
5+
- dev
6+
7+
resources:
8+
repositories:
9+
- repository: 1es
10+
type: git
11+
name: 1ESPipelineTemplates/1ESPipelineTemplates
12+
ref: refs/tags/release
13+
14+
extends:
15+
template: v1/1ES.Unofficial.PipelineTemplate.yml@1es
16+
parameters:
17+
pool:
18+
name: 1es-pool-azfunc-public
19+
image: 1es-windows-2022
20+
os: windows
21+
22+
stages:
23+
- stage: WindowsUnitTests
24+
dependsOn: []
25+
jobs:
26+
- template: /eng/ci/templates/test.yml@self
27+
pool:
28+
name: 1es-pool-azfunc-public
29+
30+
- stage: LinuxUnitTests
31+
dependsOn: []
32+
jobs:
33+
- template: /eng/ci/templates/test.yml@self
34+
pool:
35+
name: 1es-pool-azfunc-public
36+
image: 1es-ubuntu-22.04
37+
os: linux

0 commit comments

Comments
 (0)