syft/syft/pkg/cataloger/lua/package.go
Christopher Angelo Phillips f77d503892
detect license ID from full text when incidentally provided as a value (#3876)
---------
Signed-off-by: Christopher Phillips <32073428+spiffcs@users.noreply.github.com>
Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com>
Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
2025-05-13 16:37:18 -04:00

48 lines
1.1 KiB
Go

package lua
import (
"context"
"github.com/anchore/packageurl-go"
"github.com/anchore/syft/syft/file"
"github.com/anchore/syft/syft/pkg"
)
func newLuaRocksPackage(ctx context.Context, u luaRocksPackage, indexLocation file.Location) pkg.Package {
license := pkg.NewLicensesFromLocationWithContext(ctx, indexLocation, u.License)
p := pkg.Package{
Name: u.Name,
Version: u.Version,
PURL: packageURL(u.Name, u.Version),
Locations: file.NewLocationSet(indexLocation),
Language: pkg.Lua,
Licenses: pkg.NewLicenseSet(license...),
Type: pkg.LuaRocksPkg,
Metadata: pkg.LuaRocksPackage{
Name: u.Name,
Version: u.Version,
License: u.License,
Homepage: u.Homepage,
Description: u.Description,
URL: u.Repository.URL,
Dependencies: u.Dependencies,
},
}
p.SetID()
return p
}
// packageURL returns the PURL for the specific Lua Rock package (see https://github.com/package-url/purl-spec)
func packageURL(name, version string) string {
return packageurl.NewPackageURL(
packageurl.TypeLuaRocks,
"",
name,
version,
nil,
"",
).ToString()
}