File tree Expand file tree Collapse file tree 4 files changed +69
-0
lines changed
E2E/Azure.Functions.PowerShellWorker.E2E/Azure.Functions.PowerShellWorker.E2E Expand file tree Collapse file tree 4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 4949- pwsh : ./build.ps1 -NoBuild -Bootstrap
5050 displayName : ' Running ./build.ps1 -NoBuild -Bootstrap'
5151
52+ - pwsh : ./Check-CsprojVulnerabilities.ps1
53+ displayName : ' Check for security vulnerabilities'
54+
5255- pwsh : |
5356 $ErrorActionPreference = "Stop"
5457
Original file line number Diff line number Diff line change 1313 <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.4.1" />
1414 <PackageReference Include =" Newtonsoft.Json" Version =" 13.0.2" />
1515 <PackageReference Include =" WindowsAzure.Storage" Version =" 9.3.3" />
16+ <PackageReference Include =" System.Net.Http" Version =" 4.3.4" />
17+ <PackageReference Include =" System.Text.RegularExpressions" Version =" 4.3.1" />
1618 <PackageReference Include =" xunit" Version =" 2.4.2" />
1719 <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.5" />
1820 </ItemGroup >
Original file line number Diff line number Diff line change 1212 <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.5" />
1313 <PackageReference Include =" Microsoft.PowerShell.SDK" Version =" 7.4.0" />
1414 <PackageReference Include =" Microsoft.CodeAnalysis.CSharp" Version =" 4.8.0-2.final" />
15+ <PackageReference Include =" System.Text.RegularExpressions" Version =" 4.3.1" />
16+ <PackageReference Include =" System.Net.Http" Version =" 4.3.4" />
1517 </ItemGroup >
1618
1719 <ItemGroup >
You can’t perform that action at this time.
0 commit comments