Skip to content

Commit f34a76c

Browse files
committed
Use dotnet list package --vulnerable --include-transitive to detect vulnerable packages
1 parent 7dafc8d commit f34a76c

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,19 @@ jobs:
4141
persist-credentials: false
4242

4343
- name: Report vulnerable dependencies
44-
run: dotnet restore ${{ env.SOLUTION_FILE }} /p:Configuration=Release /p:NuGetAudit=true /p:NuGetAuditMode=all /p:NuGetAuditLevel=low --verbosity minimal
44+
shell: pwsh
45+
run: |
46+
$ErrorActionPreference = 'Stop'
47+
$PSNativeCommandUseErrorActionPreference = $true
48+
49+
$output = dotnet list ${{ env.SOLUTION_FILE }} package --vulnerable --include-transitive --format json --output-version 1 2>&1
50+
$text = ($output | Out-String).TrimEnd()
51+
$json = $text | ConvertFrom-Json
52+
53+
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
58+
}
59+
}

0 commit comments

Comments
 (0)