license_finder 6.15.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +9 -0
  3. data/.rubocop.yml +12 -2
  4. data/CHANGELOG.md +18 -1
  5. data/Dockerfile +21 -2
  6. data/README.md +6 -6
  7. data/Rakefile +2 -2
  8. data/VERSION +1 -1
  9. data/ci/pipelines/release.yml.erb +1 -1
  10. data/ci/scripts/pushscript.sh +2 -3
  11. data/ci/scripts/run-tests.sh +4 -3
  12. data/ci/tasks/rubocop.yml +1 -1
  13. data/lib/license_finder/cli/approvals.rb +2 -2
  14. data/lib/license_finder/cli/base.rb +9 -5
  15. data/lib/license_finder/cli/dependencies.rb +4 -4
  16. data/lib/license_finder/cli/ignored_dependencies.rb +3 -3
  17. data/lib/license_finder/cli/ignored_groups.rb +3 -3
  18. data/lib/license_finder/cli/inherited_decisions.rb +5 -5
  19. data/lib/license_finder/cli/licenses.rb +2 -2
  20. data/lib/license_finder/cli/main.rb +17 -11
  21. data/lib/license_finder/cli/permitted_licenses.rb +3 -3
  22. data/lib/license_finder/cli/project_name.rb +4 -4
  23. data/lib/license_finder/cli/restricted_licenses.rb +3 -3
  24. data/lib/license_finder/configuration.rb +6 -3
  25. data/lib/license_finder/core.rb +2 -1
  26. data/lib/license_finder/decisions.rb +9 -5
  27. data/lib/license_finder/license/definitions.rb +22 -0
  28. data/lib/license_finder/license/text.rb +3 -3
  29. data/lib/license_finder/license.rb +8 -2
  30. data/lib/license_finder/logger.rb +1 -1
  31. data/lib/license_finder/package.rb +3 -11
  32. data/lib/license_finder/package_delta.rb +1 -1
  33. data/lib/license_finder/package_manager.rb +1 -0
  34. data/lib/license_finder/package_managers/cocoa_pods.rb +14 -9
  35. data/lib/license_finder/package_managers/conda.rb +1 -1
  36. data/lib/license_finder/package_managers/glide.rb +7 -1
  37. data/lib/license_finder/package_managers/go_15vendorexperiment.rb +2 -2
  38. data/lib/license_finder/package_managers/go_dep.rb +1 -1
  39. data/lib/license_finder/package_managers/go_workspace.rb +1 -1
  40. data/lib/license_finder/package_managers/nuget.rb +1 -1
  41. data/lib/license_finder/package_managers/pub.rb +86 -0
  42. data/lib/license_finder/package_managers/sbt.rb +1 -5
  43. data/lib/license_finder/package_managers/yarn.rb +2 -2
  44. data/lib/license_finder/package_utils/license_files.rb +2 -2
  45. data/lib/license_finder/packages/bower_package.rb +5 -2
  46. data/lib/license_finder/packages/erlangmk_package.rb +2 -4
  47. data/lib/license_finder/packages/npm_package.rb +1 -0
  48. data/lib/license_finder/packages/pubspec_package.rb +18 -0
  49. data/lib/license_finder/printer.rb +39 -0
  50. data/lib/license_finder/report.rb +2 -1
  51. data/lib/license_finder/reports/csv_report.rb +1 -1
  52. data/lib/license_finder/reports/erb_report.rb +7 -3
  53. data/lib/license_finder/reports/json_report.rb +2 -1
  54. data/lib/license_finder/reports/junit_report.rb +5 -1
  55. data/lib/license_finder/reports/xml_report.rb +5 -1
  56. data/lib/license_finder/scanner.rb +1 -1
  57. data/license_finder.gemspec +15 -13
  58. metadata +58 -26
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class PubPackage < Package
5
+ def initialize(name, version, license_text, options = {})
6
+ super(name, version, options)
7
+ @license = License.find_by_text(license_text.to_s)
8
+ end
9
+
10
+ def licenses_from_spec
11
+ [@license].compact
12
+ end
13
+
14
+ def package_manager
15
+ 'Pub'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class Printer
5
+ attr_reader :padding
6
+
7
+ def initialize #:nodoc:
8
+ @base = nil
9
+ @mute = false
10
+ @padding = 0
11
+ @always_force = false
12
+ end
13
+
14
+ def say(message = '', color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
15
+ buffer = prepare_message(message, *color)
16
+ buffer << "\n" if force_new_line && !message.to_s.end_with?("\n")
17
+
18
+ stdout.print(buffer)
19
+ stdout.flush
20
+ end
21
+
22
+ def prepare_message(message, *color)
23
+ spaces = ' ' * padding
24
+ spaces + set_color(message.to_s, *color)
25
+ end
26
+
27
+ def set_color(string, *) #:nodoc:
28
+ string
29
+ end
30
+
31
+ def padding=(value)
32
+ @padding = [0, value].max
33
+ end
34
+
35
+ def stdout
36
+ $stdout
37
+ end
38
+ end
39
+ end
@@ -9,11 +9,12 @@ module LicenseFinder
9
9
  def initialize(dependencies, options)
10
10
  @dependencies = dependencies
11
11
  @project_name = options[:project_name]
12
+ @use_spdx_id = options[:use_spdx_id]
12
13
  end
13
14
 
14
15
  private
15
16
 
16
- attr_reader :dependencies, :project_name
17
+ attr_reader :dependencies, :project_name, :use_spdx_id
17
18
 
18
19
  def sorted_dependencies
19
20
  dependencies.sort
@@ -60,7 +60,7 @@ module LicenseFinder
60
60
  if dep.missing?
61
61
  MISSING_DEPENDENCY_TEXT
62
62
  else
63
- dep.licenses.map(&:name).join(self.class::COMMA_SEP)
63
+ dep.licenses.map(&@use_spdx_id ? :standard_id : :name).join(self.class::COMMA_SEP)
64
64
  end
65
65
  end
66
66
 
@@ -5,7 +5,11 @@ module LicenseFinder
5
5
  TEMPLATE_PATH = ROOT_PATH.join('reports', 'templates')
6
6
 
7
7
  def to_s(filename = TEMPLATE_PATH.join("#{template_name}.erb"))
8
- template = ERB.new(filename.read, nil, '-')
8
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6.0')
9
+ template = ERB.new(filename.read, nil, '-')
10
+ else
11
+ template = ERB.new(filename.read, trim_mode: '-')
12
+ end
9
13
  template.result(binding)
10
14
  end
11
15
 
@@ -22,7 +26,7 @@ module LicenseFinder
22
26
  end
23
27
 
24
28
  def link_to_license(license)
25
- link_to_maybe license.name, license.url
29
+ link_to_maybe (@use_spdx_id ? license.standard_id : license.name), license.url
26
30
  end
27
31
 
28
32
  def link_to_dependency(dependency)
@@ -42,7 +46,7 @@ module LicenseFinder
42
46
  end
43
47
 
44
48
  def license_names(dependency)
45
- dependency.licenses.map(&:name).sort.join ', '
49
+ dependency.licenses.map(&@use_spdx_id? :standard_id : :name).sort.join ', '
46
50
  end
47
51
 
48
52
  def license_links(dependency)
@@ -24,7 +24,8 @@ module LicenseFinder
24
24
  end
25
25
 
26
26
  def format_licenses(dep)
27
- dep.missing? ? [] : dep.licenses.map(&:name)
27
+ dep.missing? ? [] :
28
+ dep.licenses.map(&(@use_spdx_id ? :standard_id : :name))
28
29
  end
29
30
  end
30
31
  end
@@ -6,7 +6,11 @@ module LicenseFinder
6
6
  TEMPLATE_PATH = ROOT_PATH.join('templates')
7
7
 
8
8
  def to_s(filename = TEMPLATE_PATH.join("#{template_name}.erb"))
9
- template = ERB.new(filename.read, nil, '-')
9
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6.0')
10
+ template = ERB.new(filename.read, nil, '-')
11
+ else
12
+ template = ERB.new(filename.read, trim_mode: '-')
13
+ end
10
14
  template.result(binding)
11
15
  end
12
16
 
@@ -6,7 +6,11 @@ module LicenseFinder
6
6
  TEMPLATE_PATH = ROOT_PATH.join('templates')
7
7
 
8
8
  def to_s(filename = TEMPLATE_PATH.join("#{template_name}.erb"))
9
- template = ERB.new(filename.read, nil, '-')
9
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.6.0')
10
+ template = ERB.new(filename.read, nil, '-')
11
+ else
12
+ template = ERB.new(filename.read, trim_mode: '-')
13
+ end
10
14
  template.result(binding)
11
15
  end
12
16
 
@@ -5,7 +5,7 @@ module LicenseFinder
5
5
  PACKAGE_MANAGERS = [
6
6
  GoModules, GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Trash, Dep, Bundler, NPM, Pip,
7
7
  Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Erlangmk, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer, Pipenv,
8
- Conda, Spm
8
+ Conda, Spm, Pub
9
9
  ].freeze
10
10
 
11
11
  class << self
@@ -3,7 +3,7 @@
3
3
  version = File.read(File.expand_path('VERSION', __dir__)).strip
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.required_ruby_version = '>= 2.3.3'
6
+ s.required_ruby_version = '>= 2.4.0'
7
7
  s.name = 'license_finder'
8
8
  s.version = version
9
9
 
@@ -45,26 +45,28 @@ Gem::Specification.new do |s|
45
45
 
46
46
  s.add_dependency 'bundler'
47
47
  s.add_dependency 'rubyzip', '>=1', '<3'
48
- s.add_dependency 'thor', '~> 1.0.1'
48
+ s.add_dependency 'thor', '~> 1.2'
49
49
  s.add_dependency 'tomlrb', '>= 1.3', '< 2.1'
50
50
  s.add_dependency 'with_env', '1.1.0'
51
- s.add_dependency 'xml-simple', '~> 1.1.5'
51
+ s.add_dependency 'xml-simple', '~> 1.1.9'
52
52
 
53
53
  s.add_development_dependency 'addressable', '2.8.0'
54
- s.add_development_dependency 'capybara', '~> 3.15.0'
55
- s.add_development_dependency 'cocoapods', '>= 1.0.0' if RUBY_PLATFORM =~ /darwin/
56
- s.add_development_dependency 'fakefs', '~> 1.2.0'
57
- s.add_development_dependency 'mime-types', '3.3.1'
58
- s.add_development_dependency 'pry', '~> 0.14.0'
59
- s.add_development_dependency 'rake', '~> 13.0.1'
54
+ s.add_development_dependency 'capybara', '~> 3.32.2'
55
+ s.add_development_dependency 'cocoapods', '>= 1.0.0' if RUBY_PLATFORM.match?(/darwin/)
56
+ s.add_development_dependency 'e2mmap', '~> 0.1.0'
57
+ s.add_development_dependency 'fakefs', '~> 1.4.1'
58
+ s.add_development_dependency 'matrix', '~> 0.1.0'
59
+ s.add_development_dependency 'mime-types', '3.4.1'
60
+ s.add_development_dependency 'pry', '~> 0.14.1'
61
+ s.add_development_dependency 'rake', '~> 13.0.6'
60
62
  s.add_development_dependency 'rspec', '~> 3'
61
63
  s.add_development_dependency 'rspec-its', '~> 1.3.0'
62
- s.add_development_dependency 'rubocop', '~> 0.81.0'
63
- s.add_development_dependency 'rubocop-performance', '~> 1.5.0'
64
- s.add_development_dependency 'webmock', '~> 3.5'
64
+ s.add_development_dependency 'rubocop', '~> 1.12.1'
65
+ s.add_development_dependency 'rubocop-performance', '~> 1.10.2'
66
+ s.add_development_dependency 'webmock', '~> 3.14'
65
67
 
66
68
  s.add_development_dependency 'nokogiri', '~>1.10'
67
- s.add_development_dependency 'rack', '~> 2.2.2'
69
+ s.add_development_dependency 'rack', '~> 2.2.3'
68
70
  s.add_development_dependency 'rack-test', '~> 1.1.0', '> 0.7'
69
71
 
70
72
  s.files = `git ls-files`.split("\n").reject { |f| f.start_with?('spec', 'features') }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: license_finder
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.15.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Collins
@@ -27,7 +27,7 @@ authors:
27
27
  autorequire:
28
28
  bindir: bin
29
29
  cert_chain: []
30
- date: 2021-12-17 00:00:00.000000000 Z
30
+ date: 2022-03-04 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
@@ -69,14 +69,14 @@ dependencies:
69
69
  requirements:
70
70
  - - "~>"
71
71
  - !ruby/object:Gem::Version
72
- version: 1.0.1
72
+ version: '1.2'
73
73
  type: :runtime
74
74
  prerelease: false
75
75
  version_requirements: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: 1.0.1
79
+ version: '1.2'
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: tomlrb
82
82
  requirement: !ruby/object:Gem::Requirement
@@ -117,14 +117,14 @@ dependencies:
117
117
  requirements:
118
118
  - - "~>"
119
119
  - !ruby/object:Gem::Version
120
- version: 1.1.5
120
+ version: 1.1.9
121
121
  type: :runtime
122
122
  prerelease: false
123
123
  version_requirements: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - "~>"
126
126
  - !ruby/object:Gem::Version
127
- version: 1.1.5
127
+ version: 1.1.9
128
128
  - !ruby/object:Gem::Dependency
129
129
  name: addressable
130
130
  requirement: !ruby/object:Gem::Requirement
@@ -145,70 +145,98 @@ dependencies:
145
145
  requirements:
146
146
  - - "~>"
147
147
  - !ruby/object:Gem::Version
148
- version: 3.15.0
148
+ version: 3.32.2
149
149
  type: :development
150
150
  prerelease: false
151
151
  version_requirements: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - "~>"
154
154
  - !ruby/object:Gem::Version
155
- version: 3.15.0
155
+ version: 3.32.2
156
+ - !ruby/object:Gem::Dependency
157
+ name: e2mmap
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - "~>"
161
+ - !ruby/object:Gem::Version
162
+ version: 0.1.0
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: 0.1.0
156
170
  - !ruby/object:Gem::Dependency
157
171
  name: fakefs
158
172
  requirement: !ruby/object:Gem::Requirement
159
173
  requirements:
160
174
  - - "~>"
161
175
  - !ruby/object:Gem::Version
162
- version: 1.2.0
176
+ version: 1.4.1
177
+ type: :development
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: 1.4.1
184
+ - !ruby/object:Gem::Dependency
185
+ name: matrix
186
+ requirement: !ruby/object:Gem::Requirement
187
+ requirements:
188
+ - - "~>"
189
+ - !ruby/object:Gem::Version
190
+ version: 0.1.0
163
191
  type: :development
164
192
  prerelease: false
165
193
  version_requirements: !ruby/object:Gem::Requirement
166
194
  requirements:
167
195
  - - "~>"
168
196
  - !ruby/object:Gem::Version
169
- version: 1.2.0
197
+ version: 0.1.0
170
198
  - !ruby/object:Gem::Dependency
171
199
  name: mime-types
172
200
  requirement: !ruby/object:Gem::Requirement
173
201
  requirements:
174
202
  - - '='
175
203
  - !ruby/object:Gem::Version
176
- version: 3.3.1
204
+ version: 3.4.1
177
205
  type: :development
178
206
  prerelease: false
179
207
  version_requirements: !ruby/object:Gem::Requirement
180
208
  requirements:
181
209
  - - '='
182
210
  - !ruby/object:Gem::Version
183
- version: 3.3.1
211
+ version: 3.4.1
184
212
  - !ruby/object:Gem::Dependency
185
213
  name: pry
186
214
  requirement: !ruby/object:Gem::Requirement
187
215
  requirements:
188
216
  - - "~>"
189
217
  - !ruby/object:Gem::Version
190
- version: 0.14.0
218
+ version: 0.14.1
191
219
  type: :development
192
220
  prerelease: false
193
221
  version_requirements: !ruby/object:Gem::Requirement
194
222
  requirements:
195
223
  - - "~>"
196
224
  - !ruby/object:Gem::Version
197
- version: 0.14.0
225
+ version: 0.14.1
198
226
  - !ruby/object:Gem::Dependency
199
227
  name: rake
200
228
  requirement: !ruby/object:Gem::Requirement
201
229
  requirements:
202
230
  - - "~>"
203
231
  - !ruby/object:Gem::Version
204
- version: 13.0.1
232
+ version: 13.0.6
205
233
  type: :development
206
234
  prerelease: false
207
235
  version_requirements: !ruby/object:Gem::Requirement
208
236
  requirements:
209
237
  - - "~>"
210
238
  - !ruby/object:Gem::Version
211
- version: 13.0.1
239
+ version: 13.0.6
212
240
  - !ruby/object:Gem::Dependency
213
241
  name: rspec
214
242
  requirement: !ruby/object:Gem::Requirement
@@ -243,42 +271,42 @@ dependencies:
243
271
  requirements:
244
272
  - - "~>"
245
273
  - !ruby/object:Gem::Version
246
- version: 0.81.0
274
+ version: 1.12.1
247
275
  type: :development
248
276
  prerelease: false
249
277
  version_requirements: !ruby/object:Gem::Requirement
250
278
  requirements:
251
279
  - - "~>"
252
280
  - !ruby/object:Gem::Version
253
- version: 0.81.0
281
+ version: 1.12.1
254
282
  - !ruby/object:Gem::Dependency
255
283
  name: rubocop-performance
256
284
  requirement: !ruby/object:Gem::Requirement
257
285
  requirements:
258
286
  - - "~>"
259
287
  - !ruby/object:Gem::Version
260
- version: 1.5.0
288
+ version: 1.10.2
261
289
  type: :development
262
290
  prerelease: false
263
291
  version_requirements: !ruby/object:Gem::Requirement
264
292
  requirements:
265
293
  - - "~>"
266
294
  - !ruby/object:Gem::Version
267
- version: 1.5.0
295
+ version: 1.10.2
268
296
  - !ruby/object:Gem::Dependency
269
297
  name: webmock
270
298
  requirement: !ruby/object:Gem::Requirement
271
299
  requirements:
272
300
  - - "~>"
273
301
  - !ruby/object:Gem::Version
274
- version: '3.5'
302
+ version: '3.14'
275
303
  type: :development
276
304
  prerelease: false
277
305
  version_requirements: !ruby/object:Gem::Requirement
278
306
  requirements:
279
307
  - - "~>"
280
308
  - !ruby/object:Gem::Version
281
- version: '3.5'
309
+ version: '3.14'
282
310
  - !ruby/object:Gem::Dependency
283
311
  name: nokogiri
284
312
  requirement: !ruby/object:Gem::Requirement
@@ -299,14 +327,14 @@ dependencies:
299
327
  requirements:
300
328
  - - "~>"
301
329
  - !ruby/object:Gem::Version
302
- version: 2.2.2
330
+ version: 2.2.3
303
331
  type: :development
304
332
  prerelease: false
305
333
  version_requirements: !ruby/object:Gem::Requirement
306
334
  requirements:
307
335
  - - "~>"
308
336
  - !ruby/object:Gem::Version
309
- version: 2.2.2
337
+ version: 2.2.3
310
338
  - !ruby/object:Gem::Dependency
311
339
  name: rack-test
312
340
  requirement: !ruby/object:Gem::Requirement
@@ -341,6 +369,7 @@ extensions: []
341
369
  extra_rdoc_files: []
342
370
  files:
343
371
  - ".force-build"
372
+ - ".github/dependabot.yml"
344
373
  - ".gitignore"
345
374
  - ".rspec"
346
375
  - ".rubocop.yml"
@@ -456,6 +485,7 @@ files:
456
485
  - lib/license_finder/package_managers/nuget.rb
457
486
  - lib/license_finder/package_managers/pip.rb
458
487
  - lib/license_finder/package_managers/pipenv.rb
488
+ - lib/license_finder/package_managers/pub.rb
459
489
  - lib/license_finder/package_managers/rebar.rb
460
490
  - lib/license_finder/package_managers/sbt.rb
461
491
  - lib/license_finder/package_managers/spm.rb
@@ -489,11 +519,13 @@ files:
489
519
  - lib/license_finder/packages/npm_package.rb
490
520
  - lib/license_finder/packages/nuget_package.rb
491
521
  - lib/license_finder/packages/pip_package.rb
522
+ - lib/license_finder/packages/pubspec_package.rb
492
523
  - lib/license_finder/packages/rebar_package.rb
493
524
  - lib/license_finder/packages/sbt_package.rb
494
525
  - lib/license_finder/packages/spm_package.rb
495
526
  - lib/license_finder/packages/yarn_package.rb
496
527
  - lib/license_finder/platform.rb
528
+ - lib/license_finder/printer.rb
497
529
  - lib/license_finder/project_finder.rb
498
530
  - lib/license_finder/report.rb
499
531
  - lib/license_finder/reports/csv_report.rb
@@ -530,14 +562,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
530
562
  requirements:
531
563
  - - ">="
532
564
  - !ruby/object:Gem::Version
533
- version: 2.3.3
565
+ version: 2.4.0
534
566
  required_rubygems_version: !ruby/object:Gem::Requirement
535
567
  requirements:
536
568
  - - ">="
537
569
  - !ruby/object:Gem::Version
538
570
  version: '0'
539
571
  requirements: []
540
- rubygems_version: 3.2.33
572
+ rubygems_version: 3.3.8
541
573
  signing_key:
542
574
  specification_version: 4
543
575
  summary: Audit the OSS licenses of your application's dependencies.