1// Copyright 2017 Google Inc. 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package licenseclassifier 16 17// *** NOTE: Update this file when adding a new license. You need to: 18// 19// 1. Add the canonical name to the list, and 20// 2. Categorize the license. 21 22import "github.com/google/licenseclassifier/internal/sets" 23 24// Canonical names of the licenses. 25const ( 26 // The names come from the https://spdx.org/licenses website, and are 27 // also the filenames of the licenses in licenseclassifier/licenses. 28 AFL11 = "AFL-1.1" 29 AFL12 = "AFL-1.2" 30 AFL20 = "AFL-2.0" 31 AFL21 = "AFL-2.1" 32 AFL30 = "AFL-3.0" 33 AGPL10 = "AGPL-1.0" 34 AGPL30 = "AGPL-3.0" 35 Apache10 = "Apache-1.0" 36 Apache11 = "Apache-1.1" 37 Apache20 = "Apache-2.0" 38 APSL10 = "APSL-1.0" 39 APSL11 = "APSL-1.1" 40 APSL12 = "APSL-1.2" 41 APSL20 = "APSL-2.0" 42 Artistic10cl8 = "Artistic-1.0-cl8" 43 Artistic10Perl = "Artistic-1.0-Perl" 44 Artistic10 = "Artistic-1.0" 45 Artistic20 = "Artistic-2.0" 46 BCL = "BCL" 47 Beerware = "Beerware" 48 BSD2ClauseFreeBSD = "BSD-2-Clause-FreeBSD" 49 BSD2ClauseNetBSD = "BSD-2-Clause-NetBSD" 50 BSD2Clause = "BSD-2-Clause" 51 BSD3ClauseAttribution = "BSD-3-Clause-Attribution" 52 BSD3ClauseClear = "BSD-3-Clause-Clear" 53 BSD3ClauseLBNL = "BSD-3-Clause-LBNL" 54 BSD3Clause = "BSD-3-Clause" 55 BSD4Clause = "BSD-4-Clause" 56 BSD4ClauseUC = "BSD-4-Clause-UC" 57 BSDProtection = "BSD-Protection" 58 BSL10 = "BSL-1.0" 59 CC010 = "CC0-1.0" 60 CCBY10 = "CC-BY-1.0" 61 CCBY20 = "CC-BY-2.0" 62 CCBY25 = "CC-BY-2.5" 63 CCBY30 = "CC-BY-3.0" 64 CCBY40 = "CC-BY-4.0" 65 CCBYNC10 = "CC-BY-NC-1.0" 66 CCBYNC20 = "CC-BY-NC-2.0" 67 CCBYNC25 = "CC-BY-NC-2.5" 68 CCBYNC30 = "CC-BY-NC-3.0" 69 CCBYNC40 = "CC-BY-NC-4.0" 70 CCBYNCND10 = "CC-BY-NC-ND-1.0" 71 CCBYNCND20 = "CC-BY-NC-ND-2.0" 72 CCBYNCND25 = "CC-BY-NC-ND-2.5" 73 CCBYNCND30 = "CC-BY-NC-ND-3.0" 74 CCBYNCND40 = "CC-BY-NC-ND-4.0" 75 CCBYNCSA10 = "CC-BY-NC-SA-1.0" 76 CCBYNCSA20 = "CC-BY-NC-SA-2.0" 77 CCBYNCSA25 = "CC-BY-NC-SA-2.5" 78 CCBYNCSA30 = "CC-BY-NC-SA-3.0" 79 CCBYNCSA40 = "CC-BY-NC-SA-4.0" 80 CCBYND10 = "CC-BY-ND-1.0" 81 CCBYND20 = "CC-BY-ND-2.0" 82 CCBYND25 = "CC-BY-ND-2.5" 83 CCBYND30 = "CC-BY-ND-3.0" 84 CCBYND40 = "CC-BY-ND-4.0" 85 CCBYSA10 = "CC-BY-SA-1.0" 86 CCBYSA20 = "CC-BY-SA-2.0" 87 CCBYSA25 = "CC-BY-SA-2.5" 88 CCBYSA30 = "CC-BY-SA-3.0" 89 CCBYSA40 = "CC-BY-SA-4.0" 90 CDDL10 = "CDDL-1.0" 91 CDDL11 = "CDDL-1.1" 92 CommonsClause = "Commons-Clause" 93 CPAL10 = "CPAL-1.0" 94 CPL10 = "CPL-1.0" 95 eGenix = "eGenix" 96 EPL10 = "EPL-1.0" 97 EPL20 = "EPL-2.0" 98 EUPL10 = "EUPL-1.0" 99 EUPL11 = "EUPL-1.1" 100 Facebook2Clause = "Facebook-2-Clause" 101 Facebook3Clause = "Facebook-3-Clause" 102 FacebookExamples = "Facebook-Examples" 103 FreeImage = "FreeImage" 104 FTL = "FTL" 105 GPL10 = "GPL-1.0" 106 GPL20 = "GPL-2.0" 107 GPL20withautoconfexception = "GPL-2.0-with-autoconf-exception" 108 GPL20withbisonexception = "GPL-2.0-with-bison-exception" 109 GPL20withclasspathexception = "GPL-2.0-with-classpath-exception" 110 GPL20withfontexception = "GPL-2.0-with-font-exception" 111 GPL20withGCCexception = "GPL-2.0-with-GCC-exception" 112 GPL30 = "GPL-3.0" 113 GPL30withautoconfexception = "GPL-3.0-with-autoconf-exception" 114 GPL30withGCCexception = "GPL-3.0-with-GCC-exception" 115 GUSTFont = "GUST-Font-License" 116 ImageMagick = "ImageMagick" 117 IPL10 = "IPL-1.0" 118 ISC = "ISC" 119 LGPL20 = "LGPL-2.0" 120 LGPL21 = "LGPL-2.1" 121 LGPL30 = "LGPL-3.0" 122 LGPLLR = "LGPLLR" 123 Libpng = "Libpng" 124 Lil10 = "Lil-1.0" 125 LinuxOpenIB = "Linux-OpenIB" 126 LPL102 = "LPL-1.02" 127 LPL10 = "LPL-1.0" 128 LPPL13c = "LPPL-1.3c" 129 MIT = "MIT" 130 MPL10 = "MPL-1.0" 131 MPL11 = "MPL-1.1" 132 MPL20 = "MPL-2.0" 133 MSPL = "MS-PL" 134 NCSA = "NCSA" 135 NPL10 = "NPL-1.0" 136 NPL11 = "NPL-1.1" 137 OFL11 = "OFL-1.1" 138 OpenSSL = "OpenSSL" 139 OpenVision = "OpenVision" 140 OSL10 = "OSL-1.0" 141 OSL11 = "OSL-1.1" 142 OSL20 = "OSL-2.0" 143 OSL21 = "OSL-2.1" 144 OSL30 = "OSL-3.0" 145 PHP301 = "PHP-3.01" 146 PHP30 = "PHP-3.0" 147 PIL = "PIL" 148 PostgreSQL = "PostgreSQL" 149 Python20complete = "Python-2.0-complete" 150 Python20 = "Python-2.0" 151 QPL10 = "QPL-1.0" 152 Ruby = "Ruby" 153 SGIB10 = "SGI-B-1.0" 154 SGIB11 = "SGI-B-1.1" 155 SGIB20 = "SGI-B-2.0" 156 SISSL12 = "SISSL-1.2" 157 SISSL = "SISSL" 158 Sleepycat = "Sleepycat" 159 UnicodeTOU = "Unicode-TOU" 160 UnicodeDFS2015 = "Unicode-DFS-2015" 161 UnicodeDFS2016 = "Unicode-DFS-2016" 162 Unlicense = "Unlicense" 163 UPL10 = "UPL-1.0" 164 W3C19980720 = "W3C-19980720" 165 W3C20150513 = "W3C-20150513" 166 W3C = "W3C" 167 WTFPL = "WTFPL" 168 X11 = "X11" 169 Xnet = "Xnet" 170 Zend20 = "Zend-2.0" 171 ZeroBSD = "0BSD" 172 ZlibAcknowledgement = "zlib-acknowledgement" 173 Zlib = "Zlib" 174 ZPL11 = "ZPL-1.1" 175 ZPL20 = "ZPL-2.0" 176 ZPL21 = "ZPL-2.1" 177) 178 179var ( 180 // Licenses Categorized by Type 181 182 // restricted - Licenses in this category require mandatory source 183 // distribution if we ships a product that includes third-party code 184 // protected by such a license. 185 restrictedType = sets.NewStringSet( 186 BCL, 187 CCBYND10, 188 CCBYND20, 189 CCBYND25, 190 CCBYND30, 191 CCBYND40, 192 CCBYSA10, 193 CCBYSA20, 194 CCBYSA25, 195 CCBYSA30, 196 CCBYSA40, 197 GPL10, 198 GPL20, 199 GPL20withautoconfexception, 200 GPL20withbisonexception, 201 GPL20withclasspathexception, 202 GPL20withfontexception, 203 GPL20withGCCexception, 204 GPL30, 205 GPL30withautoconfexception, 206 GPL30withGCCexception, 207 LGPL20, 208 LGPL21, 209 LGPL30, 210 NPL10, 211 NPL11, 212 OSL10, 213 OSL11, 214 OSL20, 215 OSL21, 216 OSL30, 217 QPL10, 218 Sleepycat, 219 ) 220 221 // reciprocal - These licenses allow usage of software made available 222 // under such licenses freely in *unmodified* form. If the third-party 223 // source code is modified in any way these modifications to the 224 // original third-party source code must be made available. 225 reciprocalType = sets.NewStringSet( 226 APSL10, 227 APSL11, 228 APSL12, 229 APSL20, 230 CDDL10, 231 CDDL11, 232 CPL10, 233 EPL10, 234 EPL20, 235 FreeImage, 236 IPL10, 237 MPL10, 238 MPL11, 239 MPL20, 240 Ruby, 241 ) 242 243 // notice - These licenses contain few restrictions, allowing original 244 // or modified third-party software to be shipped in any product 245 // without endangering or encumbering our source code. All of the 246 // licenses in this category do, however, have an "original Copyright 247 // notice" or "advertising clause", wherein any external distributions 248 // must include the notice or clause specified in the license. 249 noticeType = sets.NewStringSet( 250 AFL11, 251 AFL12, 252 AFL20, 253 AFL21, 254 AFL30, 255 Apache10, 256 Apache11, 257 Apache20, 258 Artistic10cl8, 259 Artistic10Perl, 260 Artistic10, 261 Artistic20, 262 BSL10, 263 BSD2ClauseFreeBSD, 264 BSD2ClauseNetBSD, 265 BSD2Clause, 266 BSD3ClauseAttribution, 267 BSD3ClauseClear, 268 BSD3ClauseLBNL, 269 BSD3Clause, 270 BSD4Clause, 271 BSD4ClauseUC, 272 BSDProtection, 273 CCBY10, 274 CCBY20, 275 CCBY25, 276 CCBY30, 277 CCBY40, 278 FTL, 279 ISC, 280 ImageMagick, 281 Libpng, 282 Lil10, 283 LinuxOpenIB, 284 LPL102, 285 LPL10, 286 MSPL, 287 MIT, 288 NCSA, 289 OpenSSL, 290 PHP301, 291 PHP30, 292 PIL, 293 Python20, 294 Python20complete, 295 PostgreSQL, 296 SGIB10, 297 SGIB11, 298 SGIB20, 299 UnicodeDFS2015, 300 UnicodeDFS2016, 301 UnicodeTOU, 302 UPL10, 303 W3C19980720, 304 W3C20150513, 305 W3C, 306 X11, 307 Xnet, 308 Zend20, 309 ZlibAcknowledgement, 310 Zlib, 311 ZPL11, 312 ZPL20, 313 ZPL21, 314 ) 315 316 // permissive - These licenses can be used in (relatively rare) cases 317 // where third-party software is under a license (not "Public Domain" 318 // or "free for any use" like 'unencumbered') that is even more lenient 319 // than a 'notice' license. Use the 'permissive' license type when even 320 // a copyright notice is not required for license compliance. 321 permissiveType = sets.NewStringSet() 322 323 // unencumbered - Licenses that basically declare that the code is "free for any use". 324 unencumberedType = sets.NewStringSet( 325 CC010, 326 Unlicense, 327 ZeroBSD, 328 ) 329 330 // byexceptiononly - Licenses that are incompatible with all (or most) 331 // uses in combination with our source code. Commercial third-party 332 // packages that are purchased and licensed only for a specific use 333 // fall into this category. 334 byExceptionOnlyType = sets.NewStringSet( 335 Beerware, 336 OFL11, 337 OpenVision, 338 ) 339 340 // forbidden - Licenses that are forbidden to be used. 341 forbiddenType = sets.NewStringSet( 342 AGPL10, 343 AGPL30, 344 CCBYNC10, 345 CCBYNC20, 346 CCBYNC25, 347 CCBYNC30, 348 CCBYNC40, 349 CCBYNCND10, 350 CCBYNCND20, 351 CCBYNCND25, 352 CCBYNCND30, 353 CCBYNCND40, 354 CCBYNCSA10, 355 CCBYNCSA20, 356 CCBYNCSA25, 357 CCBYNCSA30, 358 CCBYNCSA40, 359 CommonsClause, 360 Facebook2Clause, 361 Facebook3Clause, 362 FacebookExamples, 363 WTFPL, 364 ) 365 366 // LicenseTypes is a set of the types of licenses Google recognizes. 367 LicenseTypes = sets.NewStringSet( 368 "restricted", 369 "reciprocal", 370 "notice", 371 "permissive", 372 "unencumbered", 373 "by_exception_only", 374 ) 375) 376 377// LicenseType returns the type the license has. 378func LicenseType(name string) string { 379 switch { 380 case restrictedType.Contains(name): 381 return "restricted" 382 case reciprocalType.Contains(name): 383 return "reciprocal" 384 case noticeType.Contains(name): 385 return "notice" 386 case permissiveType.Contains(name): 387 return "permissive" 388 case unencumberedType.Contains(name): 389 return "unencumbered" 390 case forbiddenType.Contains(name): 391 return "FORBIDDEN" 392 } 393 return "" 394} 395