Skip to content

Commit

Permalink
fix(spdx): init pkgFilePaths map for all formats (#8380)
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriyLewen authored Feb 17, 2025
1 parent 9637286 commit 72ea4b0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/sbom/spdx/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ func (s *SPDX) UnmarshalJSON(b []byte) error {
if s.BOM == nil {
s.BOM = core.NewBOM(core.Options{})
}
if s.pkgFilePaths == nil {
s.pkgFilePaths = make(map[common.ElementID]string)
}

spdxDocument, err := json.Read(bytes.NewReader(b))
if err != nil {
Expand All @@ -71,6 +68,10 @@ func (s *SPDX) UnmarshalJSON(b []byte) error {
func (s *SPDX) unmarshal(spdxDocument *spdx.Document) error {
s.trivySBOM = s.isTrivySBOM(spdxDocument)

if s.pkgFilePaths == nil {
s.pkgFilePaths = make(map[common.ElementID]string)
}

// Parse files and find file paths for packages
s.parseFiles(spdxDocument)

Expand Down

0 comments on commit 72ea4b0

Please sign in to comment.