func mergeOccurrences()

in pkg/vul/import.go [157:175]


func mergeOccurrences(occurrences []*g.Occurrence) *g.Occurrence {
	if len(occurrences) == 0 {
		return nil
	}
	if len(occurrences) == 1 {
		return occurrences[0]
	}

	// Take the first one as parent and only take the PackageIssue from the others
	// This assumes that all other information in the occ is the same.
	parent := occurrences[0]

	for i := 1; i < len(occurrences); i++ {
		packageIssues := occurrences[i].GetVulnerability().GetPackageIssue()
		parent.GetVulnerability().PackageIssue = append(parent.GetVulnerability().PackageIssue, packageIssues...)
	}

	return parent
}