From d221bdf874f948cb41ce8f74db557781e2b0bf65 Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Fri, 19 Aug 2022 14:09:40 +0100 Subject: [PATCH] Add files import from SPDX --- sbom.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sbom.go b/sbom.go index aa64195..02c2350 100644 --- a/sbom.go +++ b/sbom.go @@ -36,6 +36,7 @@ type Package struct { DownloadURL string HomepageURL string License []string + Files []string CPEs []string } @@ -113,6 +114,15 @@ func addSPDX(img *Image, doc *spdx.Document2_2) { } for _, p := range doc.Packages { + var files []string + for _, f := range p.Files { + if f == nil { + // HACK: the SPDX parser is broken with multiple files in hasFiles + continue + } + files = append(files, f.FileName) + } + pkg := Package{ Name: p.PackageName, Version: p.PackageVersion, @@ -121,6 +131,7 @@ func addSPDX(img *Image, doc *spdx.Document2_2) { HomepageURL: p.PackageHomePage, DownloadURL: p.PackageDownloadLocation, License: strings.Split(p.PackageLicenseConcluded, " AND "), + Files: files, } typ := pkgTypeUnknown