github.com/anchore/syft@v1.38.2/syft/pkg/cataloger/swipl/package.go (about)

     1  package swipl
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/anchore/packageurl-go"
     7  	"github.com/anchore/syft/syft/file"
     8  	"github.com/anchore/syft/syft/pkg"
     9  	"github.com/anchore/syft/syft/pkg/cataloger/internal/licenses"
    10  )
    11  
    12  func newSwiplPackPackage(ctx context.Context, resolver file.Resolver, m pkg.SwiplPackEntry, locations ...file.Location) pkg.Package {
    13  	p := pkg.Package{
    14  		Name:      m.Name,
    15  		Version:   m.Version,
    16  		PURL:      swiplpackPackageURL(m.Name, m.Version),
    17  		Locations: file.NewLocationSet(locations...),
    18  		Licenses:  pkg.NewLicenseSet(licenses.FindRelativeToLocations(ctx, resolver, locations...)...),
    19  		Type:      pkg.SwiplPackPkg,
    20  		Language:  pkg.Swipl,
    21  		Metadata:  m,
    22  	}
    23  
    24  	p.SetID()
    25  
    26  	return p
    27  }
    28  
    29  func swiplpackPackageURL(name, version string) string {
    30  	var qualifiers packageurl.Qualifiers
    31  
    32  	return packageurl.NewPackageURL(
    33  		"swiplpack",
    34  		"",
    35  		name,
    36  		version,
    37  		qualifiers,
    38  		"",
    39  	).ToString()
    40  }