-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker_license.go
105 lines (96 loc) · 2.55 KB
/
checker_license.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package k6lint
import (
"context"
"sort"
"github.com/go-enry/go-license-detector/v4/licensedb"
)
func checkerLicense(_ context.Context, dir string) *checkResult {
results := licensedb.Analyse(dir)
const minConfidence = 0.9
for _, result := range results {
sort.Slice(result.Matches, func(i, j int) bool {
return result.Matches[i].Confidence > result.Matches[j].Confidence
})
for _, match := range result.Matches {
if match.Confidence < minConfidence {
continue
}
if _, found := validLicenses[match.License]; found {
return checkPassed("found `%s` as `%s` license", match.File, match.License)
}
}
}
return checkFailed("no valid license found")
}
// source: https://spdx.org/licenses/
// both FSF Free and OSI Approved licenses
var validLicenses = map[string]struct{}{ //nolint:gochecknoglobals
"AFL-1.1": {},
"AFL-1.2": {},
"AFL-2.0": {},
"AFL-2.1": {},
"AFL-3.0": {},
"AGPL-3.0": {},
"AGPL-3.0-only": {},
"AGPL-3.0-or-later": {},
"Apache-1.1": {},
"Apache-2.0": {},
"APSL-2.0": {},
"Artistic-2.0": {},
"BSD-2-Clause": {},
"BSD-3-Clause": {},
"BSL-1.0": {},
"CDDL-1.0": {},
"CPAL-1.0": {},
"CPL-1.0": {},
"ECL-2.0": {},
"EFL-2.0": {},
"EPL-1.0": {},
"EPL-2.0": {},
"EUDatagrid": {},
"EUPL-1.1": {},
"EUPL-1.2": {},
"GPL-2.0-only": {},
"GPL-2.0": {},
"GPL-2.0-or-later": {},
"GPL-3.0-only": {},
"GPL-3.0": {},
"GPL-3.0-or-later": {},
"HPND": {},
"Intel": {},
"IPA": {},
"IPL-1.0": {},
"ISC": {},
"LGPL-2.1": {},
"LGPL-2.1-only": {},
"LGPL-2.1-or-later": {},
"LGPL-3.0": {},
"LGPL-3.0-only": {},
"LGPL-3.0-or-later": {},
"LPL-1.02": {},
"MIT": {},
"MPL-1.1": {},
"MPL-2.0": {},
"MS-PL": {},
"MS-RL": {},
"NCSA": {},
"Nokia": {},
"OFL-1.1": {},
"OSL-1.0": {},
"OSL-2.0": {},
"OSL-2.1": {},
"OSL-3.0": {},
"PHP-3.01": {},
"Python-2.0": {},
"QPL-1.0": {},
"RPSL-1.0": {},
"SISSL": {},
"Sleepycat": {},
"SPL-1.0": {},
"Unlicense": {},
"UPL-1.0": {},
"W3C": {},
"Zlib": {},
"ZPL-2.0": {},
"ZPL-2.1": {},
}