diff --git a/Src/NuGetDefense.Lib/VulnerabilityReporter.cs b/Src/NuGetDefense.Lib/VulnerabilityReporter.cs index 2de1ee6b..6ee556eb 100644 --- a/Src/NuGetDefense.Lib/VulnerabilityReporter.cs +++ b/Src/NuGetDefense.Lib/VulnerabilityReporter.cs @@ -28,13 +28,19 @@ public void BuildVulnerabilityReport( var distinctPackages = new List(); foreach (var package in projects.Values.SelectMany(x => x)) if (distinctPackages.All(x => !string.Equals(x.PackageUrl, package.PackageUrl, StringComparison.CurrentCultureIgnoreCase))) + { distinctPackages.Add(package); + } + } Report = new() { VulnerabilitiesCount = vulnerabilityDictionary.Sum(x => x.Value.Count), Packages = distinctPackages.OrderBy(x => x.Id).ThenBy(x => x.Version) - .Where(p => p.LineNumber != null && vulnerabilityDictionary.ContainsKey(p.PackageUrl.ToLower())) + .Where(p => p.LineNumber != null + && vulnerabilityDictionary.ContainsKey(p.PackageUrl.ToLower()) + && vulnerabilityDictionary[p.PackageUrl.ToLower()].Any() + ) .Select(p => new VulnerableNuGetPackage { Id = p.Id,