github.com/devseccon/trivy@v0.47.1-0.20231123133102-bd902a0bd996/pkg/fanal/types/license.go (about) 1 package types 2 3 import "github.com/samber/lo" 4 5 type LicenseType string 6 7 const ( 8 LicenseTypeDpkg LicenseType = "dpkg" // From /usr/share/doc/*/copyright 9 LicenseTypeHeader LicenseType = "header" // From file headers 10 LicenseTypeFile LicenseType = "license-file" // From LICENSE, COPYRIGHT, etc. 11 ) 12 13 type LicenseCategory string 14 15 const ( 16 CategoryForbidden LicenseCategory = "forbidden" 17 CategoryRestricted LicenseCategory = "restricted" 18 CategoryReciprocal LicenseCategory = "reciprocal" 19 CategoryNotice LicenseCategory = "notice" 20 CategoryPermissive LicenseCategory = "permissive" 21 CategoryUnencumbered LicenseCategory = "unencumbered" 22 CategoryUnknown LicenseCategory = "unknown" 23 ) 24 25 type LicenseFile struct { 26 Type LicenseType 27 FilePath string 28 PkgName string 29 Findings LicenseFindings 30 Layer Layer `json:",omitempty"` 31 } 32 33 type LicenseFindings []LicenseFinding 34 35 func (findings LicenseFindings) Len() int { 36 return len(findings) 37 } 38 39 func (findings LicenseFindings) Swap(i, j int) { 40 findings[i], findings[j] = findings[j], findings[i] 41 } 42 43 func (findings LicenseFindings) Less(i, j int) bool { 44 return findings[i].Name < findings[j].Name 45 } 46 47 func (findings LicenseFindings) Names() []string { 48 return lo.Map(findings, func(finding LicenseFinding, _ int) string { 49 return finding.Name 50 }) 51 } 52 53 type LicenseFinding struct { 54 Category LicenseCategory // such as "forbidden" 55 Name string 56 Confidence float64 57 Link string 58 }