| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 
 | function Invoke-SupplyChainScan {param(
 [Parameter(Mandatory=$true)]
 [string]$ImageName,
 [string]$OutputFormat = 'table',
 [string]$SeverityLevel = 'HIGH,CRITICAL'
 )
 
 
 if (-not (Get-Command trivy -ErrorAction SilentlyContinue)) {
 winget install aquasecurity.trivy
 }
 
 try {
 
 $result = trivy image --format $OutputFormat --severity $SeverityLevel $ImageName
 
 
 $htmlReport = "$env:TEMP\scan_report_$(Get-Date -Format yyyyMMddHHmmss).html"
 trivy image --format template --template "@contrib/html.tpl" -o $htmlReport $ImageName
 
 [PSCustomObject]@{
 ScanTarget = $ImageName
 VulnerabilitiesFound = $result.Count
 CriticalCount = ($result | Where-Object { $_ -match 'CRITICAL' }).Count
 HighCount = ($result | Where-Object { $_ -match 'HIGH' }).Count
 HTMLReportPath = $htmlReport
 }
 }
 catch {
 Write-Error "漏洞扫描失败:$_"
 }
 }
 
 |