Skip to content

Commit 244b845

Browse files
committed
fix
1 parent ed89ab3 commit 244b845

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

contrib/trivy/pkg/converter.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,16 +212,23 @@ func Convert(results types.Results, artifactType ftypes.ArtifactType, artifactNa
212212
sv = fmt.Sprintf("%d:%s", p.SrcEpoch, sv)
213213
}
214214

215-
existing := srcPkgs[p.SrcName]
216-
existing.AddBinaryName(p.Name)
217-
if existing.Name == "" || compareVersions(trivyResult.Type, sv, existing.Version) >= 0 {
215+
if existing, ok := srcPkgs[p.SrcName]; ok {
216+
existing.AddBinaryName(p.Name)
217+
if compareVersions(trivyResult.Type, sv, existing.Version) >= 0 {
218+
srcPkgs[p.SrcName] = models.SrcPackage{
219+
Name: p.SrcName,
220+
Version: sv,
221+
BinaryNames: existing.BinaryNames,
222+
}
223+
} else {
224+
srcPkgs[p.SrcName] = existing
225+
}
226+
} else {
218227
srcPkgs[p.SrcName] = models.SrcPackage{
219228
Name: p.SrcName,
220229
Version: sv,
221-
BinaryNames: existing.BinaryNames,
230+
BinaryNames: []string{p.Name},
222231
}
223-
} else {
224-
srcPkgs[p.SrcName] = existing
225232
}
226233
}
227234
case types.ClassLangPkg:

0 commit comments

Comments
 (0)