From e0fa3ec7c904cb55aa097ae2b83e69cbc20b5ef2 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Wed, 22 May 2024 10:51:58 -0700 Subject: [PATCH] Avoid panic if no external config file ref Signed-off-by: Jon Johnson --- pkg/build/build.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pkg/build/build.go b/pkg/build/build.go index 743322be0..7829397b1 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -737,10 +737,12 @@ func (b *Build) BuildPackage(ctx context.Context) error { return fmt.Errorf("failed to create ExternalRef for configfile: %w", err) } - // In SPDX v3 there is dedicate field for this - // https://spdx.github.io/spdx-spec/v3.0/model/Build/Properties/configSourceUri/ - log.Infof("adding external ref %s for ConfigFile", configFileRef) - externalRefs = append(externalRefs, *configFileRef) + if configFileRef != nil { + // In SPDX v3 there is dedicate field for this + // https://spdx.github.io/spdx-spec/v3.0/model/Build/Properties/configSourceUri/ + log.Infof("adding external ref %s for ConfigFile", configFileRef) + externalRefs = append(externalRefs, *configFileRef) + } if b.EmptyWorkspace { log.Infof("empty workspace requested")