File tree 4 files changed +69
-0
lines changed
E2E/Azure.Functions.PowerShellWorker.E2E/Azure.Functions.PowerShellWorker.E2E 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 49
49
- pwsh : ./build.ps1 -NoBuild -Bootstrap
50
50
displayName : ' Running ./build.ps1 -NoBuild -Bootstrap'
51
51
52
+ - pwsh : ./Check-CsprojVulnerabilities.ps1
53
+ displayName : ' Check for security vulnerabilities'
54
+
52
55
- pwsh : |
53
56
$ErrorActionPreference = "Stop"
54
57
Original file line number Diff line number Diff line change 13
13
<PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.4.1" />
14
14
<PackageReference Include =" Newtonsoft.Json" Version =" 13.0.2" />
15
15
<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" />
16
18
<PackageReference Include =" xunit" Version =" 2.4.2" />
17
19
<PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.5" />
18
20
</ItemGroup >
Original file line number Diff line number Diff line change 12
12
<PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.5" />
13
13
<PackageReference Include =" Microsoft.PowerShell.SDK" Version =" 7.4.0" />
14
14
<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" />
15
17
</ItemGroup >
16
18
17
19
<ItemGroup >
You can’t perform that action at this time.
0 commit comments