File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,11 +47,36 @@ jobs:
4747 $output = dotnet list ${{ env.SOLUTION_FILE }} package --vulnerable --include-transitive --format json --output-version 1 2>&1
4848 $text = ($output | Out-String).TrimEnd()
4949 $json = $text | ConvertFrom-Json
50+ $hasVulnerabilities = $false
5051
5152 foreach ($project in $json.projects) {
52- if ($project.frameworks) {
53- Write-Host 'Vulnerable package references were found.'
54- dotnet list ${{ env.SOLUTION_FILE }} package --vulnerable --include-transitive
55- exit 1
53+ if (-not $project.frameworks) {
54+ continue
5655 }
56+
57+ $isTestProject = $project.path -like '*/test/*'
58+
59+ foreach ($framework in $project.frameworks) {
60+ foreach ($package in $framework.topLevelPackages) {
61+ $hasVulnerabilities = $true
62+
63+ foreach ($vulnerability in $package.vulnerabilities) {
64+ Write-Host "$($project.path) ($($framework.framework)): top-level $($package.id) $($package.resolvedVersion) – $($vulnerability.severity): $($vulnerability.advisoryurl)"
65+ }
66+ }
67+
68+ if (-not $isTestProject) {
69+ foreach ($package in $framework.transitivePackages) {
70+ $hasVulnerabilities = $true
71+
72+ foreach ($vulnerability in $package.vulnerabilities) {
73+ Write-Host "$($project.path) ($($framework.framework)): transitive $($package.id) $($package.resolvedVersion) – $($vulnerability.severity): $($vulnerability.advisoryurl)"
74+ }
75+ }
76+ }
77+ }
78+ }
79+
80+ if ($hasVulnerabilities) {
81+ exit 1
5782 }
You can’t perform that action at this time.
0 commit comments