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 17import "regexp" 18 19var ( 20 reCCBYNC = regexp.MustCompile(`(?i).*\bAttribution NonCommercial\b.*`) 21 reCCBYNCND = regexp.MustCompile(`(?i).*\bAttribution NonCommercial NoDerivs\b.*`) 22 reCCBYNCSA = regexp.MustCompile(`(?i).*\bAttribution NonCommercial ShareAlike\b.*`) 23 24 // forbiddenRegexps are regular expressions we expect to find in 25 // forbidden licenses. If we think we have a forbidden license but 26 // don't find the equivalent phrase, then it's probably just a 27 // misclassification. 28 forbiddenRegexps = map[string]*regexp.Regexp{ 29 AGPL10: regexp.MustCompile(`(?i).*\bAFFERO GENERAL PUBLIC LICENSE\b.*`), 30 AGPL30: regexp.MustCompile(`(?i).*\bGNU AFFERO GENERAL PUBLIC LICENSE\b.*`), 31 CCBYNC10: reCCBYNC, 32 CCBYNC20: reCCBYNC, 33 CCBYNC25: reCCBYNC, 34 CCBYNC30: reCCBYNC, 35 CCBYNC40: reCCBYNC, 36 CCBYNCND10: regexp.MustCompile(`(?i).*\bAttribution NoDerivs NonCommercial\b.*`), 37 CCBYNCND20: reCCBYNCND, 38 CCBYNCND25: reCCBYNCND, 39 CCBYNCND30: reCCBYNCND, 40 CCBYNCND40: regexp.MustCompile(`(?i).*\bAttribution NonCommercial NoDerivatives\b.*`), 41 CCBYNCSA10: reCCBYNCSA, 42 CCBYNCSA20: reCCBYNCSA, 43 CCBYNCSA25: reCCBYNCSA, 44 CCBYNCSA30: reCCBYNCSA, 45 CCBYNCSA40: reCCBYNCSA, 46 WTFPL: regexp.MustCompile(`(?i).*\bDO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE\b.*`), 47 } 48) 49