Documentation
¶
Index ¶
- Constants
- Variables
- func Classify(filePath string, r io.Reader, confidenceLevel float64) (*types.LicenseFile, error)
- func LaxSplitLicenses(str string) []string
- func NormalizeLicenseExpression(exp expr.Expression) expr.Expression
- func NormalizeLicenseURL(u string) string
- func NormalizeLicenses(licenses []string) []string
- func SPDXLicenseIDByURL(rawURL string) (string, bool)
- func SplitLicenses(str string) []string
- func TrimLicenseText(text string) string
- type Scanner
Constants ¶
const ( LicenseTextPrefix = "text://" LicenseFilePrefix = "file://" CustomLicensePrefix = "CUSTOM License" )
Variables ¶
var LicenseFileNames = set.NewCaseInsensitive("license", "licence", "copyright")
LicenseFileNames are the base names (case-insensitive, without extension) of files commonly used to hold a license, e.g. LICENSE, LICENCE, COPYRIGHT.
Functions ¶
func LaxSplitLicenses ¶ added in v0.56.0
Split license string considering spaces as separator e.g. MPL 2.0 GPL2+ => {"MPL2.0", "GPL2+"}
func NormalizeLicenseExpression ¶ added in v0.69.0
func NormalizeLicenseExpression(exp expr.Expression) expr.Expression
func NormalizeLicenseURL ¶ added in v0.74.0
NormalizeLicenseURL builds a matching key for a license URL. It drops an http or https scheme, a "www." prefix, a trailing slash and a document extension. It also unifies opensource.org's "/licenses/" and "/license/" paths. A Wayback Machine snapshot is replaced by the URL it captured. Only the host is lowercased. RFC 3986, section 6.2.2.1 makes the path, query and fragment case-sensitive.
func NormalizeLicenses ¶ added in v0.69.0
func SPDXLicenseIDByURL ¶ added in v0.74.0
SPDXLicenseIDByURL maps an upstream license URL (e.g. from an OSGi Bundle-License header or a pom <url>) to its canonical SPDX license ID, and returns false if no SPDX license claims that URL. The URL is normalized here, so it is passed in as it appears in the metadata.
func SplitLicenses ¶ added in v0.44.0
func TrimLicenseText ¶ added in v0.56.0
Types ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
func NewScanner ¶
func NewScanner(categories map[types.LicenseCategory][]string) Scanner
func (*Scanner) ScanTextLicense ¶ added in v0.63.0
func (s *Scanner) ScanTextLicense(licenseText string) (types.LicenseCategory, string)
ScanTextLicense checks license names from `categories` as glob patterns and matches licenseText against those patterns. If a match is found, it returns `unknown` category and severity.