Skip to content

Commit

Permalink
fix: ensure vulnerabilities key is always available (#536)
Browse files Browse the repository at this point in the history
Trivy will omit the array of vulnerabilities if none were found. We do want to display the result anyway, so we add the key if it is missing.

Co-authored-by: Nya <[email protected]>
  • Loading branch information
Skatinger and Anyffen authored Jan 7, 2025
1 parent ad15982 commit c71c2e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/DataInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ const extractTargetsFromReport = (parsedReport: Version1OrVersion2) => {
// validate report format
if (
!vulnerabilityTargets.every((i) => {
/* Trivy omits the Vulnerabilities array if there are no vulnerabilities,
* so we add it as an empty array to allow showing it in the UI report as empty. */
i.Vulnerabilities = i.Vulnerabilities || []
const targetValid =
i.Target && i.Vulnerabilities && Array.isArray(i.Vulnerabilities)
const vulnerabilitiesValid = i.Vulnerabilities?.every((v) => {
Expand Down

0 comments on commit c71c2e5

Please sign in to comment.