Skip to content

Commit

Permalink
SPDX and CycloneDX marshal tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
Octogonapus committed Dec 6, 2023
1 parent 468539d commit cfd4711
Show file tree
Hide file tree
Showing 3 changed files with 1,531 additions and 1,646 deletions.
16 changes: 16 additions & 0 deletions pkg/purl/purl.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ func NewPackageURL(t ftypes.TargetType, metadata types.Metadata, pkg ftypes.Pack
return nil, nil
}
return &PackageURL{PackageURL: purl}, nil
case packageurl.TypeJulia:
var qs packageurl.Qualifiers
namespace, name, qs = parseJulia(name, pkg.ID) // for Julia, the ID is set to the package UUID
qualifiers = append(qualifiers, qs...)
}

return &PackageURL{
Expand Down Expand Up @@ -407,6 +411,18 @@ func parseNpm(pkgName string) (string, string) {
return parsePkgName(name)
}

// ref. https://github.com/package-url/purl-spec/blob/7759d1cf81629267742eeeb0cdfccf5ebd624cc5/PURL-TYPES.rst#julia
func parseJulia(pkgName string, pkgUUID string) (string, string, packageurl.Qualifiers) {
namespace, name := parsePkgName(pkgName)
qualifiers := packageurl.Qualifiers{
{
Key: "uuid",
Value: pkgUUID,
},
}
return namespace, name, qualifiers
}

func purlType(t ftypes.TargetType) string {
switch t {
case ftypes.Jar, ftypes.Pom, ftypes.Gradle:
Expand Down
Loading

0 comments on commit cfd4711

Please sign in to comment.