Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sbom): export bom-ref when converting a package to a component #7340

Merged
merged 18 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
afdesk committed Aug 30, 2024
commit eaaf98b9d607fbc7d171b9d76f2a29015e482f34
18 changes: 9 additions & 9 deletions pkg/sbom/cyclonedx/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ func (b *BOM) parseComponent(c cdx.Component) (*core.Component, error) {
return nil, xerrors.Errorf("failed to unmarshal component type: %w", err)
}

identifier := ftypes.PkgIdentifier{
BOMRef: c.BOMRef,
}

// Parse PURL
var purl *packageurl.PackageURL
if c.PackageURL != "" {
purl = &packageurl.PackageURL{}
*purl, err = packageurl.FromString(c.PackageURL)
purl, err := packageurl.FromString(c.PackageURL)
if err != nil {
return nil, xerrors.Errorf("failed to parse PURL: %w", err)
}
identifier.PURL = &purl
}

component := &core.Component{
Expand All @@ -149,12 +152,9 @@ func (b *BOM) parseComponent(c cdx.Component) (*core.Component, error) {
Digests: b.unmarshalHashes(c.Hashes),
},
},
PkgIdentifier: ftypes.PkgIdentifier{
PURL: purl,
BOMRef: c.BOMRef,
},
Supplier: b.unmarshalSupplier(c.Supplier),
Properties: b.unmarshalProperties(c.Properties),
PkgIdentifier: identifier,
Supplier: b.unmarshalSupplier(c.Supplier),
Properties: b.unmarshalProperties(c.Properties),
}

return component, nil
Expand Down