Skip to content

Commit b771f07

Browse files
committed
Hide transitive vulnerabilities in tests during cibuild
1 parent 0481fb1 commit b771f07

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
@@ -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
}

0 commit comments

Comments
 (0)