fix(spdx): add workaround for no src packages (#4118)

This commit is contained in:
Masahiro331
2023-04-28 13:16:21 +09:00
committed by GitHub
parent 45bc9e0de4
commit 1be1e2e638
2 changed files with 4 additions and 1 deletions

View File

@@ -392,6 +392,9 @@ func (e *Marshaler) reportToCdxComponent(r types.Report) (*cdx.Component, error)
component.BOMRef = p.ToString()
component.PackageURL = p.ToString()
}
case ftypes.ArtifactVM:
component.Type = cdx.ComponentTypeContainer
component.BOMRef = e.newUUID().String()
case ftypes.ArtifactFilesystem, ftypes.ArtifactRemoteRepository:
component.Type = cdx.ComponentTypeApplication
component.BOMRef = e.newUUID().String()

View File

@@ -319,7 +319,7 @@ func (m *Marshaler) pkgToSpdxPackage(t, pkgDownloadLocation string, class types.
}
var pkgSrcInfo string
if class == types.ClassOSPkg {
if class == types.ClassOSPkg && pkg.SrcName != "" {
pkgSrcInfo = fmt.Sprintf("%s: %s %s", SourcePackagePrefix, pkg.SrcName, utils.FormatSrcVersion(pkg))
}