Skip to content

Fix DivideByZero error when the input is only one vulnerability#183

Open
latsku wants to merge 1 commit intomicrosoft:mainfrom
latsku:patch-1
Open

Fix DivideByZero error when the input is only one vulnerability#183
latsku wants to merge 1 commit intomicrosoft:mainfrom
latsku:patch-1

Conversation

@latsku
Copy link
Copy Markdown

@latsku latsku commented May 8, 2026

Cast the input to array to handle the special case of input being only one vulnerability object.

Following example code returns divide by zero error as the input is an object instead of array of objects:

$cvrfDoc = Get-MsrcCvrfDocument -ID 2016-Nov
$HT = @{
	Vulnerability = ($cvrfDoc.Vulnerability | Where-Object {$_.CVE -In @('CVE-2016-0026')})
	ProductTree   = $cvrfDoc.ProductTree
}
Get-MsrcVulnerabilityReportHtml @HT | Out-File -FilePath Cvrf-CVE-Summary.html

Cast the input to array to handle be special case of input being only one vulnerability object.

Following example code returns divide by zero error as the input is an object instead of array of objects:
```
$cvrfDoc = Get-MsrcCvrfDocument -ID 2016-Nov
$HT = @{
	Vulnerability = ($cvrfDoc.Vulnerability | Where-Object {$_.CVE -In @('CVE-2016-0026')})
	ProductTree   = $cvrfDoc.ProductTree
}
Get-MsrcVulnerabilityReportHtml @ht | Out-File -FilePath Cvrf-CVE-Summary.html
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant