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