Documentation ¶
Index ¶
- Constants
- Variables
- func AddLicense(id string, ll *LicenseLibrary) error
- func AddPrimaryPatternAndSource(fileContents string, filePath string, l *License) error
- func GenerateMatchingPatternFromSourceText(pp *PrimaryPatterns) (*regexp.Regexp, error)
- func GenerateRegexFromNormalizedText(normalizedText string) (*regexp.Regexp, error)
- func List(config *viper.Viper) (lics []Detail, deprecatedLics []Detail, exceptions []Exception, ...)
- func ReadSPDXLicenseLists(r *resources.Resources) (licenseList SPDXLicenceList, exceptionsList SPDXLicenceList, err error)
- type Detail
- type Exception
- type License
- type LicenseInfo
- type LicenseLibrary
- type LicenseMap
- type LicensePatternKey
- type LicensePreChecks
- type LicenseText
- type PatternsMap
- type PrimaryPatternPreCheckMap
- type PrimaryPatterns
- type PrimaryPatternsSources
- type SPDXExceptionInfo
- type SPDXLicenceInfo
- type SPDXLicenceList
- type SliceOfStrings
Constants ¶
View Source
const ( LicenseInfoJSON = "license_info.json" PreChecksPattern = "prechecks_" PrimaryPattern = "license_" AssociatedPattern = "associated_" OptionalPattern = "optional_" AcceptablePatterns = "acceptable_patterns" )
Variables ¶
View Source
var ( Logger = log.NewLogger(log.INFO) RegexUnsafePattern = regexp.MustCompile(`([\\.*+?^${}()|[\]])`) )
Functions ¶
func AddLicense ¶
func AddLicense(id string, ll *LicenseLibrary) error
func GenerateMatchingPatternFromSourceText ¶
func GenerateMatchingPatternFromSourceText(pp *PrimaryPatterns) (*regexp.Regexp, error)
GenerateMatchingPatternFromSourceText normalizes and compiles a pattern once with sync
func ReadSPDXLicenseLists ¶ added in v0.10.0
func ReadSPDXLicenseLists(r *resources.Resources) (licenseList SPDXLicenceList, exceptionsList SPDXLicenceList, err error)
Types ¶
type License ¶
type License struct { // SPDX License ID if applicable, for example, "Apache-2.0" SPDXLicenseID string LicenseInfo LicenseInfo PrimaryPatterns []*PrimaryPatterns PrimaryPatternsSources []PrimaryPatternsSources AssociatedPatterns []*PrimaryPatterns AssociatedPatternsSources []PrimaryPatternsSources // Aliases (and names and IDs) can be used like primary patterns (unless disabled), but are simple strings not regex. They also require word boundaries. Aliases []string // URLs can be used like primary patterns (unless disabled), but are simple strings not regex with URL matching. URLs []string // license text or an expression Text LicenseText }
License holds the specification of each license
type LicenseInfo ¶
type LicenseInfo struct { Name string `json:"name"` Family string `json:"family"` SPDXStandard bool `json:"spdx_standard"` SPDXException bool `json:"spdx_exception"` OSIApproved bool `json:"osi_approved"` IgnoreIDMatch bool `json:"ignore_id_match"` IgnoreNameMatch bool `json:"ignore_name_match"` Aliases SliceOfStrings `json:"aliases"` URLs SliceOfStrings `json:"urls"` EligibleLicenses SliceOfStrings `json:"eligible_licenses"` IsMutator bool `json:"is_mutator"` IsDeprecated bool `json:"is_deprecated"` IsFSFLibre bool `json:"is_fsf_libre"` }
func ReadLicenseInfoJSON ¶ added in v0.10.0
func ReadLicenseInfoJSON(fileContents []byte) (*LicenseInfo, error)
ReadLicenseInfoJSON unmarshalls the json bytes into LicenseInfo
type LicenseLibrary ¶
type LicenseLibrary struct { SPDXVersion string LicenseMap LicenseMap PrimaryPatternPreCheckMap PrimaryPatternPreCheckMap AcceptablePatternsMap PatternsMap Config *viper.Viper Resources *resources.Resources }
func NewLicenseLibrary ¶
func NewLicenseLibrary(config *viper.Viper) (*LicenseLibrary, error)
func (*LicenseLibrary) AddAll ¶
func (ll *LicenseLibrary) AddAll() error
func (*LicenseLibrary) AddAllCustom ¶ added in v0.10.0
func (ll *LicenseLibrary) AddAllCustom() error
func (*LicenseLibrary) AddAllSPDX ¶
func (ll *LicenseLibrary) AddAllSPDX() error
func (*LicenseLibrary) AddCustomLicenses ¶ added in v0.10.0
func (ll *LicenseLibrary) AddCustomLicenses() error
AddCustomLicenses initializes the license data set to scan the input license file against all the possible licenses available in the resources are read
type LicenseMap ¶
type LicensePatternKey ¶
type LicensePatternKey struct {
FilePath string // Each ID may have multiple license_*.txt primary patterns
}
type LicensePreChecks ¶
type LicensePreChecks struct {
StaticBlocks []string
}
type LicenseText ¶
type LicenseText struct { // content type of the license, for example, "text/plain" ContentType string // any encoding if the license text is encoded in any particular format, for example, "base64" Encoding string // license text encoded in the format specified Content string }
LicenseText contains the content type along with the content
type PatternsMap ¶
type PrimaryPatternPreCheckMap ¶
type PrimaryPatternPreCheckMap map[LicensePatternKey]*LicensePreChecks
type PrimaryPatterns ¶
type PrimaryPatterns struct { Text string CaptureGroups []*normalizer.CaptureGroup FileName string // contains filtered or unexported fields }
type PrimaryPatternsSources ¶
type SPDXExceptionInfo ¶
type SPDXLicenceInfo ¶
type SPDXLicenceList ¶
type SPDXLicenceList struct { LicenseListVersion string `json:"licenseListVersion"` Licenses []SPDXLicenceInfo `json:"licenses"` Exceptions []SPDXExceptionInfo `json:"exceptions"` }
func ReadSPDXLicenseListJSON ¶
func ReadSPDXLicenseListJSON(fileContents []byte) (*SPDXLicenceList, error)
ReadSPDXLicenseListJSON unmarshalls the json bytes into SPDXLicenseList
type SliceOfStrings ¶
type SliceOfStrings []string
SliceOfStrings gives us []string with special UnmarshalJSON
func (*SliceOfStrings) UnmarshalJSON ¶
func (stringArray *SliceOfStrings) UnmarshalJSON(b []byte) error
UnmarshalJSON reads string or array of strings into []string when json.Unmarshal encounters a SliceOfStrings
Click to show internal directories.
Click to hide internal directories.