Skip to content

Commit a4ed442

Browse files
authored
Updating build to check for vulnerabilities (#9650)
1 parent 2778028 commit a4ed442

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
inputs:
5353
filePath: '$(Build.Repository.LocalPath)\build\build-extensions.ps1'
5454
arguments: '-buildNumber "$(buildNumber)" -suffix "$(suffix)"'
55+
- task: PowerShell@2
56+
displayName: "Check for security vulnerabilities"
57+
inputs:
58+
filePath: '$(Build.Repository.LocalPath)\build\check-vulnerabilities.ps1'
5559
- task: PowerShell@2
5660
condition: eq(variables['RUNBUILDFORINTEGRATIONTESTS'], 'True')
5761
displayName: "Update host references"

build/check-vulnerabilities.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$projectPath = "$PSScriptRoot\..\src\WebJobs.Script.WebHost\WebJobs.Script.WebHost.csproj"
2+
$logFilePath = "$PSScriptRoot\..\build.log"
3+
if (-not (Test-Path $projectPath))
4+
{
5+
throw "Project path '$projectPath' does not exist."
6+
}
7+
8+
$cmd = "list", $projectPath, "package", "--include-transitive", "--vulnerable"
9+
Write-Host "dotnet $cmd"
10+
dotnet $cmd | Tee-Object build.log
11+
12+
$result = Get-content $logFilePath | select-string "has no vulnerable packages given the current sources"
13+
14+
$logFileExists = Test-Path $logFilePath -PathType Leaf
15+
if ($logFileExists)
16+
{
17+
Remove-Item $logFilePath
18+
}
19+
20+
if (!$result)
21+
{
22+
Write-Host "Vulnerabilities found"
23+
Exit 1
24+
}

0 commit comments

Comments
 (0)