Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
afdesk committed Aug 30, 2024
1 parent 0a5090f commit eaaf98b
Showing 1 changed file with 9 additions and 9 deletions.
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

0 comments on commit eaaf98b

Please sign in to comment.