syft/syft/file/license.go
Gijs Calis 9d40d1152e
feat: improved java maven property resolution (#2769)
Signed-off-by: Gijs Calis <51088038+GijsCalis@users.noreply.github.com>
Signed-off-by: Keith Zantow <kzantow@gmail.com>
Co-authored-by: Keith Zantow <kzantow@gmail.com>
2024-08-05 11:30:47 -04:00

33 lines
685 B
Go

package file
import (
"github.com/anchore/syft/internal/log"
"github.com/anchore/syft/syft/license"
)
type License struct {
Value string
SPDXExpression string
Type license.Type
LicenseEvidence *LicenseEvidence // evidence from license classifier
}
type LicenseEvidence struct {
Confidence int
Offset int
Extent int
}
func NewLicense(value string) License {
spdxExpression, err := license.ParseExpression(value)
if err != nil {
log.WithFields("error", err, "value", value).Trace("unable to parse license expression")
}
return License{
Value: value,
SPDXExpression: spdxExpression,
Type: license.Concluded,
}
}