From 7f370f4b44a24664ed1057dda05d367a13ceb726 Mon Sep 17 00:00:00 2001 From: "ritesh.noronha" Date: Tue, 9 Apr 2024 15:12:07 -0700 Subject: [PATCH] Fix off by one error --- pkg/scorer/ntia.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/scorer/ntia.go b/pkg/scorer/ntia.go index 5dc8b2f..b79cb0e 100644 --- a/pkg/scorer/ntia.go +++ b/pkg/scorer/ntia.go @@ -98,8 +98,11 @@ func compWithUniqIDCheck(d sbom.Document, c *check) score { return *s } - compIDs := lo.Map(d.Components(), func(c sbom.Component, i int) string { - return strings.Join([]string{d.Spec().Namespace(), c.ID()}, "") + compIDs := lo.FilterMap(d.Components(), func(c sbom.Component, i int) (string, bool) { + if c.ID() == "" { + return "", false + } + return strings.Join([]string{d.Spec().Namespace(), c.ID()}, ""), true }) uniqComps := lo.Uniq(compIDs)