Skip to content

Commit

Permalink
fix(spdx): add workaround for no src packages (#4118)
Browse files Browse the repository at this point in the history
  • Loading branch information
masahiro331 authored Apr 28, 2023
1 parent 45bc9e0 commit 1be1e2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/sbom/cyclonedx/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pkg/sbom/spdx/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit 1be1e2e

Please sign in to comment.