license_finder 6.2.0 → 6.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -0
  3. data/CHANGELOG.md +61 -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 +15 -5
  9. data/ci/tasks/rubocop.yml +1 -1
  10. data/lib/license_finder/cli.rb +1 -0
  11. data/lib/license_finder/cli/base.rb +1 -0
  12. data/lib/license_finder/cli/inherited_decisions.rb +50 -0
  13. data/lib/license_finder/cli/main.rb +3 -1
  14. data/lib/license_finder/configuration.rb +4 -0
  15. data/lib/license_finder/decision_applier.rb +8 -4
  16. data/lib/license_finder/decisions.rb +83 -20
  17. data/lib/license_finder/license.rb +36 -0
  18. data/lib/license_finder/license/definitions.rb +48 -1
  19. data/lib/license_finder/license/templates/0BSD.txt +10 -0
  20. data/lib/license_finder/license/templates/OFL.txt +91 -0
  21. data/lib/license_finder/license/templates/SimplifiedBSD.txt +0 -4
  22. data/lib/license_finder/license/templates/WTFPL.txt +14 -0
  23. data/lib/license_finder/license/text.rb +24 -2
  24. data/lib/license_finder/logger.rb +2 -0
  25. data/lib/license_finder/package.rb +2 -1
  26. data/lib/license_finder/package_manager.rb +6 -2
  27. data/lib/license_finder/package_managers/bundler.rb +1 -3
  28. data/lib/license_finder/package_managers/cargo.rb +2 -1
  29. data/lib/license_finder/package_managers/composer.rb +5 -1
  30. data/lib/license_finder/package_managers/dotnet.rb +2 -1
  31. data/lib/license_finder/package_managers/go_15vendorexperiment.rb +1 -1
  32. data/lib/license_finder/package_managers/go_modules.rb +11 -4
  33. data/lib/license_finder/package_managers/nuget.rb +51 -4
  34. data/lib/license_finder/package_managers/pipenv.rb +1 -1
  35. data/lib/license_finder/package_managers/sbt.rb +3 -1
  36. data/lib/license_finder/package_managers/yarn.rb +16 -2
  37. data/lib/license_finder/package_utils/license_files.rb +2 -2
  38. data/lib/license_finder/packages/bower_package.rb +7 -0
  39. data/lib/license_finder/packages/bundler_package.rb +4 -0
  40. data/lib/license_finder/packages/cargo_package.rb +4 -0
  41. data/lib/license_finder/packages/cocoa_pods_package.rb +4 -0
  42. data/lib/license_finder/packages/composer_package.rb +4 -0
  43. data/lib/license_finder/packages/conan_package.rb +4 -0
  44. data/lib/license_finder/packages/go_package.rb +5 -1
  45. data/lib/license_finder/packages/gradle_package.rb +4 -0
  46. data/lib/license_finder/packages/maven_package.rb +6 -1
  47. data/lib/license_finder/packages/merged_package.rb +1 -1
  48. data/lib/license_finder/packages/mix_package.rb +4 -0
  49. data/lib/license_finder/packages/npm_package.rb +4 -0
  50. data/lib/license_finder/packages/nuget_package.rb +4 -0
  51. data/lib/license_finder/packages/pip_package.rb +13 -2
  52. data/lib/license_finder/packages/rebar_package.rb +4 -0
  53. data/lib/license_finder/packages/yarn_package.rb +4 -0
  54. data/lib/license_finder/reports/csv_report.rb +7 -3
  55. data/lib/license_finder/reports/json_report.rb +2 -0
  56. metadata +7 -3
@@ -10,7 +10,8 @@ module LicenseFinder
10
10
  name,
11
11
  spec['version'],
12
12
  options.merge(
13
- spec_licenses: Array(spec['licenses']).map { |l| l['name'] }
13
+ spec_licenses: Array(spec['licenses']).map { |l| l['name'] },
14
+ groups: Array(spec['groupId'])
14
15
  )
15
16
  )
16
17
  end
@@ -18,5 +19,9 @@ module LicenseFinder
18
19
  def package_manager
19
20
  'Maven'
20
21
  end
22
+
23
+ def package_url
24
+ "https://search.maven.org/artifact/#{CGI.escape(groups.first)}/#{CGI.escape(name.split(':').last)}/#{CGI.escape(version)}/jar"
25
+ end
21
26
  end
22
27
  end
@@ -11,7 +11,7 @@ module LicenseFinder
11
11
  super(package.name, package.version)
12
12
  end
13
13
 
14
- def_delegators :@dependency, :name, :version, :authors, :summary, :description, :homepage, :children, :parents,
14
+ def_delegators :@dependency, :name, :version, :authors, :summary, :description, :homepage, :package_url, :children, :parents,
15
15
  :groups, :permitted, :restricted, :manual_approval, :install_path, :licenses, :approved_manually?,
16
16
  :approved_manually!, :approved?, :permitted!, :permitted?, :restricted!, :restricted?, :hash,
17
17
  :activations, :missing, :license_names_from_spec, :decided_licenses, :licensing, :decide_on_license,
@@ -5,5 +5,9 @@ module LicenseFinder
5
5
  def package_manager
6
6
  'Mix'
7
7
  end
8
+
9
+ def package_url
10
+ "https://hex.pm/packages/#{CGI.escape(name)}/#{CGI.escape(version)}"
11
+ end
8
12
  end
9
13
  end
@@ -89,6 +89,10 @@ module LicenseFinder
89
89
  'Npm'
90
90
  end
91
91
 
92
+ def package_url
93
+ "https://www.npmjs.com/package/#{CGI.escape(name)}/v/#{CGI.escape(version)}"
94
+ end
95
+
92
96
  private
93
97
 
94
98
  def deps_from_json
@@ -5,5 +5,9 @@ module LicenseFinder
5
5
  def package_manager
6
6
  'Nuget'
7
7
  end
8
+
9
+ def package_url
10
+ "https://www.nuget.org/packages/#{CGI.escape(name)}/#{CGI.escape(version)}"
11
+ end
8
12
  end
9
13
  end
@@ -8,9 +8,16 @@ module LicenseFinder
8
8
  INVALID_LICENSES = ['', 'UNKNOWN'].to_set
9
9
 
10
10
  def self.license_names_from_spec(spec)
11
- license = spec['license'].to_s.strip
11
+ license_names = spec['license'].to_s.strip.split(' or ')
12
+ has_unrecognized_license = false
12
13
 
13
- return [license] unless INVALID_LICENSES.include?(license)
14
+ license_names.each do |license_name|
15
+ license = License.find_by_name(license_name.strip)
16
+
17
+ has_unrecognized_license ||= license.unrecognized_matcher?
18
+ end
19
+
20
+ return license_names if !license_names.empty? && !has_unrecognized_license
14
21
 
15
22
  spec
16
23
  .fetch('classifiers', [])
@@ -35,5 +42,9 @@ module LicenseFinder
35
42
  def package_manager
36
43
  'Pip'
37
44
  end
45
+
46
+ def package_url
47
+ "https://pypi.org/project/#{CGI.escape(name)}/#{CGI.escape(version)}/"
48
+ end
38
49
  end
39
50
  end
@@ -5,5 +5,9 @@ module LicenseFinder
5
5
  def package_manager
6
6
  'Rebar'
7
7
  end
8
+
9
+ def package_url
10
+ "https://hex.pm/packages/#{CGI.escape(name)}/#{CGI.escape(version)}"
11
+ end
8
12
  end
9
13
  end
@@ -5,5 +5,9 @@ module LicenseFinder
5
5
  def package_manager
6
6
  'Yarn'
7
7
  end
8
+
9
+ def package_url
10
+ "https://yarn.pm/#{CGI.escape(name)}"
11
+ end
8
12
  end
9
13
  end
@@ -3,6 +3,7 @@ require 'csv'
3
3
  module LicenseFinder
4
4
  class CsvReport < Report
5
5
  COMMA_SEP = ','.freeze
6
+ NEWLINE_SEP = '\@NL'.freeze
6
7
  AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups texts notice].freeze
7
8
  MISSING_DEPENDENCY_TEXT = 'This package is not installed. Please install to determine licenses.'.freeze
8
9
 
@@ -10,10 +11,11 @@ module LicenseFinder
10
11
  super
11
12
  options[:columns] ||= %w[name version licenses]
12
13
  @columns = Array(options[:columns]) & self.class::AVAILABLE_COLUMNS
14
+ @write_headers = options[:write_headers] || false
13
15
  end
14
16
 
15
17
  def to_s
16
- CSV.generate(col_sep: self.class::COMMA_SEP) do |csv|
18
+ CSV.generate(col_sep: self.class::COMMA_SEP, headers: @columns, write_headers: @write_headers) do |csv|
17
19
  sorted_dependencies.each do |s|
18
20
  csv << format_dependency(s)
19
21
  end
@@ -29,11 +31,13 @@ module LicenseFinder
29
31
  end
30
32
 
31
33
  def format_texts(dep)
32
- dep.license_files.map { |file| file.text.split(/[\n\r]+/).join("\\@NL") }.join("\\@NL").force_encoding("ISO-8859-1").encode("UTF-8")
34
+ dep.license_files.map { |file| file.text.split(/[\n\r]+/).join(self.class::NEWLINE_SEP) }
35
+ .join(self.class::NEWLINE_SEP).force_encoding("ISO-8859-1").encode("UTF-8")
33
36
  end
34
37
 
35
38
  def format_notice(dep)
36
- dep.notice_files.map { |file| file.text.split(/[\n\r]+/).join("\\@NL") }.join("\\@NL").force_encoding("ISO-8859-1").encode("UTF-8")
39
+ dep.notice_files.map { |file| file.text.split(/[\n\r]+/).join(self.class::NEWLINE_SEP) }
40
+ .join(self.class::NEWLINE_SEP).force_encoding("ISO-8859-1").encode("UTF-8")
37
41
  end
38
42
 
39
43
  def format_name(dep)
@@ -2,6 +2,8 @@ require 'csv'
2
2
 
3
3
  module LicenseFinder
4
4
  class JsonReport < CsvReport
5
+ NEWLINE_SEP = "\n".freeze
6
+
5
7
  def initialize(dependencies, options)
6
8
  super(dependencies, options)
7
9
  end
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.2.0
4
+ version: 6.6.1
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: 2020-04-07 00:00:00.000000000 Z
30
+ date: 2020-06-30 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
@@ -358,6 +358,7 @@ files:
358
358
  - lib/license_finder/cli/dependencies.rb
359
359
  - lib/license_finder/cli/ignored_dependencies.rb
360
360
  - lib/license_finder/cli/ignored_groups.rb
361
+ - lib/license_finder/cli/inherited_decisions.rb
361
362
  - lib/license_finder/cli/licenses.rb
362
363
  - lib/license_finder/cli/main.rb
363
364
  - lib/license_finder/cli/makes_decisions.rb
@@ -378,6 +379,7 @@ files:
378
379
  - lib/license_finder/license/matcher.rb
379
380
  - lib/license_finder/license/none_matcher.rb
380
381
  - lib/license_finder/license/template.rb
382
+ - lib/license_finder/license/templates/0BSD.txt
381
383
  - lib/license_finder/license/templates/Apache1_1.txt
382
384
  - lib/license_finder/license/templates/Apache2.txt
383
385
  - lib/license_finder/license/templates/BSD.txt
@@ -392,9 +394,11 @@ files:
392
394
  - lib/license_finder/license/templates/MIT.txt
393
395
  - lib/license_finder/license/templates/MPL2.txt
394
396
  - lib/license_finder/license/templates/NewBSD.txt
397
+ - lib/license_finder/license/templates/OFL.txt
395
398
  - lib/license_finder/license/templates/Python.txt
396
399
  - lib/license_finder/license/templates/Ruby.txt
397
400
  - lib/license_finder/license/templates/SimplifiedBSD.txt
401
+ - lib/license_finder/license/templates/WTFPL.txt
398
402
  - lib/license_finder/license/text.rb
399
403
  - lib/license_finder/license_aggregator.rb
400
404
  - lib/license_finder/logger.rb
@@ -498,7 +502,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
498
502
  - !ruby/object:Gem::Version
499
503
  version: '0'
500
504
  requirements: []
501
- rubygems_version: 3.1.2
505
+ rubygems_version: 3.1.4
502
506
  signing_key:
503
507
  specification_version: 4
504
508
  summary: Audit the OSS licenses of your application's dependencies.