license_finder 6.1.2 → 6.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/CHANGELOG.md +64 -0
  4. data/Dockerfile +23 -15
  5. data/README.md +24 -2
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/ci/pipelines/release.yml.erb +8 -19
  9. data/ci/scripts/pushscript.sh +1 -1
  10. data/ci/scripts/updateChangelog.sh +8 -1
  11. data/ci/tasks/build-and-push-gem.yml +2 -2
  12. data/ci/tasks/rubocop.yml +1 -1
  13. data/ci/tasks/update-changelog.yml +2 -2
  14. data/lib/license_finder/cli.rb +1 -0
  15. data/lib/license_finder/cli/base.rb +1 -0
  16. data/lib/license_finder/cli/inherited_decisions.rb +32 -0
  17. data/lib/license_finder/cli/main.rb +3 -1
  18. data/lib/license_finder/configuration.rb +4 -0
  19. data/lib/license_finder/decision_applier.rb +8 -4
  20. data/lib/license_finder/decisions.rb +63 -20
  21. data/lib/license_finder/license/definitions.rb +48 -1
  22. data/lib/license_finder/license/templates/0BSD.txt +10 -0
  23. data/lib/license_finder/license/templates/OFL.txt +91 -0
  24. data/lib/license_finder/license/templates/SimplifiedBSD.txt +0 -4
  25. data/lib/license_finder/license/templates/WTFPL.txt +14 -0
  26. data/lib/license_finder/license/text.rb +24 -2
  27. data/lib/license_finder/logger.rb +2 -0
  28. data/lib/license_finder/package.rb +2 -1
  29. data/lib/license_finder/package_manager.rb +6 -2
  30. data/lib/license_finder/package_managers/bundler.rb +5 -3
  31. data/lib/license_finder/package_managers/cargo.rb +2 -1
  32. data/lib/license_finder/package_managers/composer.rb +5 -1
  33. data/lib/license_finder/package_managers/dep.rb +2 -2
  34. data/lib/license_finder/package_managers/dotnet.rb +2 -1
  35. data/lib/license_finder/package_managers/glide.rb +2 -7
  36. data/lib/license_finder/package_managers/go_15vendorexperiment.rb +1 -1
  37. data/lib/license_finder/package_managers/go_modules.rb +11 -4
  38. data/lib/license_finder/package_managers/go_workspace.rb +5 -1
  39. data/lib/license_finder/package_managers/nuget.rb +37 -3
  40. data/lib/license_finder/package_managers/pipenv.rb +1 -1
  41. data/lib/license_finder/package_managers/sbt.rb +3 -1
  42. data/lib/license_finder/package_managers/yarn.rb +16 -2
  43. data/lib/license_finder/package_utils/license_files.rb +2 -2
  44. data/lib/license_finder/packages/bower_package.rb +7 -0
  45. data/lib/license_finder/packages/bundler_package.rb +4 -0
  46. data/lib/license_finder/packages/cargo_package.rb +4 -0
  47. data/lib/license_finder/packages/cocoa_pods_package.rb +4 -0
  48. data/lib/license_finder/packages/composer_package.rb +4 -0
  49. data/lib/license_finder/packages/conan_package.rb +4 -0
  50. data/lib/license_finder/packages/go_package.rb +5 -1
  51. data/lib/license_finder/packages/gradle_package.rb +4 -0
  52. data/lib/license_finder/packages/maven_package.rb +6 -1
  53. data/lib/license_finder/packages/merged_package.rb +1 -1
  54. data/lib/license_finder/packages/mix_package.rb +4 -0
  55. data/lib/license_finder/packages/npm_package.rb +4 -0
  56. data/lib/license_finder/packages/nuget_package.rb +4 -0
  57. data/lib/license_finder/packages/pip_package.rb +4 -0
  58. data/lib/license_finder/packages/rebar_package.rb +4 -0
  59. data/lib/license_finder/packages/yarn_package.rb +4 -0
  60. data/lib/license_finder/reports/csv_report.rb +7 -3
  61. data/lib/license_finder/reports/json_report.rb +2 -0
  62. data/license_finder.gemspec +5 -5
  63. metadata +20 -22
@@ -140,6 +140,7 @@ module LicenseFinder
140
140
  desc 'report', "Print a report of the project's dependencies to stdout"
141
141
  shared_options
142
142
  format_option
143
+ method_option :write_headers, type: :boolean, desc: 'Write exported columns as header row (csv).', default: false, required: false
143
144
  method_option :save, desc: "Save report to a file. Default: 'license_report.csv' in project root.", lazy_default: 'license_report'
144
145
 
145
146
  def report
@@ -171,6 +172,7 @@ module LicenseFinder
171
172
  subcommand 'permitted_licenses', PermittedLicenses, 'Automatically approve any dependency that has a permitted license'
172
173
  subcommand 'restricted_licenses', RestrictedLicenses, 'Forbid approval of any dependency whose licenses are all restricted'
173
174
  subcommand 'project_name', ProjectName, 'Set the project name, for display in reports'
175
+ subcommand 'inherited_decisions', InheritedDecisions, 'Add or remove decision files you want to inherit from'
174
176
 
175
177
  private
176
178
 
@@ -203,7 +205,7 @@ module LicenseFinder
203
205
  def report_of(content)
204
206
  report = FORMATS[config.format] || FORMATS['text']
205
207
  report = MergedReport if report == CsvReport && config.aggregate_paths
206
- report.of(content, columns: config.columns, project_name: decisions.project_name || config.project_path.basename.to_s)
208
+ report.of(content, columns: config.columns, project_name: decisions.project_name || config.project_path.basename.to_s, write_headers: config.write_headers)
207
209
  end
208
210
 
209
211
  def save?
@@ -109,6 +109,10 @@ module LicenseFinder
109
109
  get(:prepare_no_fail)
110
110
  end
111
111
 
112
+ def write_headers
113
+ get(:write_headers)
114
+ end
115
+
112
116
  def save_file
113
117
  get(:save)
114
118
  end
@@ -4,7 +4,7 @@ module LicenseFinder
4
4
  class DecisionApplier
5
5
  def initialize(options)
6
6
  @decisions = options.fetch(:decisions)
7
- @all_packages = decisions.packages + options.fetch(:packages)
7
+ @all_packages = options.fetch(:packages).to_set + @decisions.packages.to_set
8
8
  @acknowledged = apply_decisions
9
9
  end
10
10
 
@@ -28,10 +28,14 @@ module LicenseFinder
28
28
 
29
29
  def apply_decisions
30
30
  all_packages
31
- .map { |package| with_decided_licenses(package) }
32
- .map { |package| with_approval(package) }
33
- .map { |package| with_homepage(package) }
34
31
  .reject { |package| ignored?(package) }
32
+ .map do |package|
33
+ with_homepage(
34
+ with_approval(
35
+ with_decided_licenses(package)
36
+ )
37
+ )
38
+ end
35
39
  end
36
40
 
37
41
  def ignored?(package)
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open-uri'
4
+
3
5
  module LicenseFinder
4
6
  class Decisions
5
7
  ######
6
8
  # READ
7
9
  ######
8
10
 
9
- attr_reader :packages, :permitted, :restricted, :ignored, :ignored_groups, :project_name
11
+ attr_reader :packages, :permitted, :restricted, :ignored, :ignored_groups, :project_name, :inherited_decisions
10
12
 
11
13
  def licenses_of(name)
12
14
  @licenses[name]
@@ -72,40 +74,41 @@ module LicenseFinder
72
74
  @restricted = Set.new
73
75
  @ignored = Set.new
74
76
  @ignored_groups = Set.new
77
+ @inherited_decisions = Set.new
75
78
  end
76
79
 
77
80
  def add_package(name, version, txn = {})
78
- @decisions << [:add_package, name, version, txn]
81
+ add_decision [:add_package, name, version, txn]
79
82
  @packages << ManualPackage.new(name, version)
80
83
  self
81
84
  end
82
85
 
83
86
  def remove_package(name, txn = {})
84
- @decisions << [:remove_package, name, txn]
87
+ add_decision [:remove_package, name, txn]
85
88
  @packages.delete(ManualPackage.new(name))
86
89
  self
87
90
  end
88
91
 
89
92
  def license(name, lic, txn = {})
90
- @decisions << [:license, name, lic, txn]
93
+ add_decision [:license, name, lic, txn]
91
94
  @licenses[name] << License.find_by_name(lic)
92
95
  self
93
96
  end
94
97
 
95
98
  def unlicense(name, lic, txn = {})
96
- @decisions << [:unlicense, name, lic, txn]
99
+ add_decision [:unlicense, name, lic, txn]
97
100
  @licenses[name].delete(License.find_by_name(lic))
98
101
  self
99
102
  end
100
103
 
101
104
  def homepage(name, homepage, txn = {})
102
- @decisions << [:homepage, name, homepage, txn]
105
+ add_decision [:homepage, name, homepage, txn]
103
106
  @homepages[name] = homepage
104
107
  self
105
108
  end
106
109
 
107
110
  def approve(name, txn = {})
108
- @decisions << [:approve, name, txn]
111
+ add_decision [:approve, name, txn]
109
112
 
110
113
  versions = []
111
114
  versions = @approvals[name][:safe_versions] if @approvals.key?(name)
@@ -115,71 +118,112 @@ module LicenseFinder
115
118
  end
116
119
 
117
120
  def unapprove(name, txn = {})
118
- @decisions << [:unapprove, name, txn]
121
+ add_decision [:unapprove, name, txn]
119
122
  @approvals.delete(name)
120
123
  self
121
124
  end
122
125
 
123
126
  def permit(lic, txn = {})
124
- @decisions << [:permit, lic, txn]
127
+ add_decision [:permit, lic, txn]
125
128
  @permitted << License.find_by_name(lic)
126
129
  self
127
130
  end
128
131
 
129
132
  def unpermit(lic, txn = {})
130
- @decisions << [:unpermit, lic, txn]
133
+ add_decision [:unpermit, lic, txn]
131
134
  @permitted.delete(License.find_by_name(lic))
132
135
  self
133
136
  end
134
137
 
135
138
  def restrict(lic, txn = {})
136
- @decisions << [:restrict, lic, txn]
139
+ add_decision [:restrict, lic, txn]
137
140
  @restricted << License.find_by_name(lic)
138
141
  self
139
142
  end
140
143
 
141
144
  def unrestrict(lic, txn = {})
142
- @decisions << [:unrestrict, lic, txn]
145
+ add_decision [:unrestrict, lic, txn]
143
146
  @restricted.delete(License.find_by_name(lic))
144
147
  self
145
148
  end
146
149
 
147
150
  def ignore(name, txn = {})
148
- @decisions << [:ignore, name, txn]
151
+ add_decision [:ignore, name, txn]
149
152
  @ignored << name
150
153
  self
151
154
  end
152
155
 
153
156
  def heed(name, txn = {})
154
- @decisions << [:heed, name, txn]
157
+ add_decision [:heed, name, txn]
155
158
  @ignored.delete(name)
156
159
  self
157
160
  end
158
161
 
159
162
  def ignore_group(name, txn = {})
160
- @decisions << [:ignore_group, name, txn]
163
+ add_decision [:ignore_group, name, txn]
161
164
  @ignored_groups << name
162
165
  self
163
166
  end
164
167
 
165
168
  def heed_group(name, txn = {})
166
- @decisions << [:heed_group, name, txn]
169
+ add_decision [:heed_group, name, txn]
167
170
  @ignored_groups.delete(name)
168
171
  self
169
172
  end
170
173
 
171
174
  def name_project(name, txn = {})
172
- @decisions << [:name_project, name, txn]
175
+ add_decision [:name_project, name, txn]
173
176
  @project_name = name
174
177
  self
175
178
  end
176
179
 
177
180
  def unname_project(txn = {})
178
- @decisions << [:unname_project, txn]
181
+ add_decision [:unname_project, txn]
179
182
  @project_name = nil
180
183
  self
181
184
  end
182
185
 
186
+ def inherit_from(filepath)
187
+ decisions =
188
+ if filepath =~ %r{^https?://}
189
+ open_uri(filepath).read
190
+ else
191
+ Pathname(filepath).read
192
+ end
193
+
194
+ add_decision [:inherit_from, filepath]
195
+ @inherited_decisions << filepath
196
+ restore_inheritance(decisions)
197
+ end
198
+
199
+ def remove_inheritance(filepath)
200
+ @decisions -= [[:inherit_from, filepath]]
201
+ @inherited_decisions.delete(filepath)
202
+ self
203
+ end
204
+
205
+ def add_decision(decision)
206
+ @decisions << decision unless @inherited
207
+ end
208
+
209
+ def restore_inheritance(decisions)
210
+ @inherited = true
211
+ self.class.restore(decisions, self)
212
+ @inherited = false
213
+ self
214
+ end
215
+
216
+ def open_uri(uri)
217
+ # ruby < 2.5.0 URI.open is private
218
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0')
219
+ # rubocop:disable Security/Open
220
+ open(uri)
221
+ # rubocop:enable Security/Open
222
+ else
223
+ URI.open(uri)
224
+ end
225
+ end
226
+
183
227
  #########
184
228
  # PERSIST
185
229
  #########
@@ -192,8 +236,7 @@ module LicenseFinder
192
236
  write!(persist, file)
193
237
  end
194
238
 
195
- def self.restore(persisted)
196
- result = new
239
+ def self.restore(persisted, result = new)
197
240
  return result unless persisted
198
241
 
199
242
  actions = YAML.load(persisted)
@@ -21,9 +21,12 @@ module LicenseFinder
21
21
  mit,
22
22
  mpl2,
23
23
  newbsd,
24
+ ofl,
24
25
  python,
25
26
  ruby,
26
- simplifiedbsd
27
+ simplifiedbsd,
28
+ wtfpl,
29
+ zerobsd
27
30
  ]
28
31
  end
29
32
 
@@ -234,6 +237,17 @@ module LicenseFinder
234
237
  )
235
238
  end
236
239
 
240
+ def ofl
241
+ License.new(
242
+ short_name: 'OFL',
243
+ pretty_name: 'SIL OPEN FONT LICENSE Version 1.1',
244
+ other_names: [
245
+ 'OPEN FONT LICENSE Version 1.1'
246
+ ],
247
+ url: 'https://opensource.org/licenses/OFL-1.1'
248
+ )
249
+ end
250
+
237
251
  def python
238
252
  License.new(
239
253
  short_name: 'Python',
@@ -277,6 +291,39 @@ module LicenseFinder
277
291
  url: 'http://opensource.org/licenses/bsd-license'
278
292
  )
279
293
  end
294
+
295
+ def wtfpl
296
+ License.new(
297
+ short_name: 'WTFPL',
298
+ pretty_name: 'WTFPL',
299
+ other_names: [
300
+ 'WTFPL V2',
301
+ 'Do What The Fuck You Want To Public License'
302
+ ],
303
+ url: 'http://www.wtfpl.net/'
304
+ )
305
+ end
306
+
307
+ def zerobsd
308
+ matcher = AnyMatcher.new(
309
+ Matcher.from_template(Template.named('0BSD'))
310
+ )
311
+
312
+ License.new(
313
+ short_name: '0BSD',
314
+ pretty_name: 'BSD Zero Clause License',
315
+ other_names: [
316
+ '0-Clause BSD',
317
+ 'Zero-Clause BSD',
318
+ 'BSD-0-Clause',
319
+ 'BSD-Zero-Clause',
320
+ 'BSD 0-Clause',
321
+ 'BSD Zero-Clause'
322
+ ],
323
+ url: 'https://opensource.org/licenses/0BSD',
324
+ matcher: matcher
325
+ )
326
+ end
280
327
  end
281
328
  end
282
329
  end
@@ -0,0 +1,10 @@
1
+ Permission to use, copy, modify, and/or distribute this software for any
2
+ purpose with or without fee is hereby granted.
3
+
4
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
5
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
6
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
7
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
8
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
9
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,91 @@
1
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
2
+ This license is copied below, and is also available with a FAQ at:
3
+ http://scripts.sil.org/OFL
4
+
5
+
6
+ -----------------------------------------------------------
7
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
8
+ -----------------------------------------------------------
9
+
10
+ PREAMBLE
11
+ The goals of the Open Font License (OFL) are to stimulate worldwide
12
+ development of collaborative font projects, to support the font creation
13
+ efforts of academic and linguistic communities, and to provide a free and
14
+ open framework in which fonts may be shared and improved in partnership
15
+ with others.
16
+
17
+ The OFL allows the licensed fonts to be used, studied, modified and
18
+ redistributed freely as long as they are not sold by themselves. The
19
+ fonts, including any derivative works, can be bundled, embedded,
20
+ redistributed and/or sold with any software provided that any reserved
21
+ names are not used by derivative works. The fonts and derivatives,
22
+ however, cannot be released under any other type of license. The
23
+ requirement for fonts to remain under this license does not apply
24
+ to any document created using the fonts or their derivatives.
25
+
26
+ DEFINITIONS
27
+ "Font Software" refers to the set of files released by the Copyright
28
+ Holder(s) under this license and clearly marked as such. This may
29
+ include source files, build scripts and documentation.
30
+
31
+ "Reserved Font Name" refers to any names specified as such after the
32
+ copyright statement(s).
33
+
34
+ "Original Version" refers to the collection of Font Software components as
35
+ distributed by the Copyright Holder(s).
36
+
37
+ "Modified Version" refers to any derivative made by adding to, deleting,
38
+ or substituting -- in part or in whole -- any of the components of the
39
+ Original Version, by changing formats or by porting the Font Software to a
40
+ new environment.
41
+
42
+ "Author" refers to any designer, engineer, programmer, technical
43
+ writer or other person who contributed to the Font Software.
44
+
45
+ PERMISSION & CONDITIONS
46
+ Permission is hereby granted, free of charge, to any person obtaining
47
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
48
+ redistribute, and sell modified and unmodified copies of the Font
49
+ Software, subject to the following conditions:
50
+
51
+ 1) Neither the Font Software nor any of its individual components,
52
+ in Original or Modified Versions, may be sold by itself.
53
+
54
+ 2) Original or Modified Versions of the Font Software may be bundled,
55
+ redistributed and/or sold with any software, provided that each copy
56
+ contains the above copyright notice and this license. These can be
57
+ included either as stand-alone text files, human-readable headers or
58
+ in the appropriate machine-readable metadata fields within text or
59
+ binary files as long as those fields can be easily viewed by the user.
60
+
61
+ 3) No Modified Version of the Font Software may use the Reserved Font
62
+ Name(s) unless explicit written permission is granted by the corresponding
63
+ Copyright Holder. This restriction only applies to the primary font name as
64
+ presented to the users.
65
+
66
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
67
+ Software shall not be used to promote, endorse or advertise any
68
+ Modified Version, except to acknowledge the contribution(s) of the
69
+ Copyright Holder(s) and the Author(s) or with their explicit written
70
+ permission.
71
+
72
+ 5) The Font Software, modified or unmodified, in part or in whole,
73
+ must be distributed entirely under this license, and must not be
74
+ distributed under any other license. The requirement for fonts to
75
+ remain under this license does not apply to any document created
76
+ using the Font Software.
77
+
78
+ TERMINATION
79
+ This license becomes null and void if any of the above conditions are
80
+ not met.
81
+
82
+ DISCLAIMER
83
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
84
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
85
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
86
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
87
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
88
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
89
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
90
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
91
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -17,7 +17,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17
17
  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18
18
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19
19
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20
-
21
- The views and conclusions contained in the software and documentation are those
22
- of the authors and should not be interpreted as representing official policies,
23
- either expressed or implied, of the FreeBSD Project.
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+