Skip to content

Commit 7533296

Browse files
committed
Hide transitive vulnerabilities in tests during cibuild
1 parent cc42b96 commit 7533296

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/scan-vulnerable-dependencies.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)