From 9fb3ff1a272259f0301c58f3dc770b18fff6327c Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Mon, 9 Jan 2023 19:03:23 +0000 Subject: [PATCH] inspect: change additional spdxs to not have duplicates Signed-off-by: Justin Chadwell (cherry picked from commit 484823c97d8155f4ff7d454ff394dd9595c642a3) --- util/imagetools/loader.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/imagetools/loader.go b/util/imagetools/loader.go index dc5a3163..86f5a745 100644 --- a/util/imagetools/loader.go +++ b/util/imagetools/loader.go @@ -255,8 +255,8 @@ func (l *loader) scanConfig(ctx context.Context, fetcher remotes.Fetcher, desc o } type sbomStub struct { - SPDX interface{} `json:",omitempty"` - SPDXs []interface{} `json:",omitempty"` + SPDX interface{} `json:",omitempty"` + AdditionalSPDXs []interface{} `json:",omitempty"` } func (l *loader) scanSBOM(ctx context.Context, fetcher remotes.Fetcher, r *result, refs []digest.Digest, as *asset) error { @@ -286,8 +286,9 @@ func (l *loader) scanSBOM(ctx context.Context, fetcher remotes.Fetcher, r *resul if as.sbom == nil { as.sbom = &sbomStub{} as.sbom.SPDX = spdx.Predicate + } else { + as.sbom.AdditionalSPDXs = append(as.sbom.AdditionalSPDXs, spdx.Predicate) } - as.sbom.SPDXs = append(as.sbom.SPDXs, spdx.Predicate) } } }