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

     1  package wordpress
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/anchore/syft/syft/file"
     7  	"github.com/anchore/syft/syft/pkg"
     8  	"github.com/anchore/syft/syft/pkg/cataloger/internal/licenses"
     9  )
    10  
    11  func newWordpressPluginPackage(ctx context.Context, resolver file.Resolver, name, version string, m pluginData, location file.Location) pkg.Package {
    12  	meta := pkg.WordpressPluginEntry{
    13  		PluginInstallDirectory: m.PluginInstallDirectory,
    14  		Author:                 m.Author,
    15  		AuthorURI:              m.AuthorURI,
    16  	}
    17  
    18  	p := pkg.Package{
    19  		Name:      name,
    20  		Version:   version,
    21  		Locations: file.NewLocationSet(location.WithAnnotation(pkg.EvidenceAnnotationKey, pkg.PrimaryEvidenceAnnotation)),
    22  		Language:  pkg.PHP,
    23  		Type:      pkg.WordpressPluginPkg,
    24  		Metadata:  meta,
    25  	}
    26  
    27  	if len(m.Licenses) > 0 {
    28  		p.Licenses = pkg.NewLicenseSet(pkg.NewLicenseWithContext(ctx, m.Licenses[0]))
    29  	} else {
    30  		p = licenses.RelativeToPackage(ctx, resolver, p)
    31  	}
    32  
    33  	p.SetID()
    34  
    35  	return p
    36  }