license_finder 5.8.0 → 5.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,8 +61,10 @@ module LicenseFinder
61
61
 
62
62
  ## DESCRIPTION
63
63
 
64
+ attr_accessor :homepage
65
+
64
66
  attr_reader :name, :version, :authors,
65
- :summary, :description, :homepage,
67
+ :summary, :description,
66
68
  :children, :parents, :groups
67
69
 
68
70
  ## APPROVAL
@@ -193,3 +195,4 @@ require 'license_finder/packages/conan_package'
193
195
  require 'license_finder/packages/yarn_package'
194
196
  require 'license_finder/packages/sbt_package'
195
197
  require 'license_finder/packages/cargo_package'
198
+ require 'license_finder/packages/composer_package'
@@ -160,5 +160,6 @@ require 'license_finder/package_managers/dep'
160
160
  require 'license_finder/package_managers/conan'
161
161
  require 'license_finder/package_managers/sbt'
162
162
  require 'license_finder/package_managers/cargo'
163
+ require 'license_finder/package_managers/composer'
163
164
 
164
165
  require 'license_finder/package'
@@ -28,7 +28,7 @@ module LicenseFinder
28
28
  end
29
29
 
30
30
  def possible_package_paths
31
- [project_path.join('Gemfile')]
31
+ [project_path.join(gemfile)]
32
32
  end
33
33
 
34
34
  private
@@ -38,7 +38,7 @@ module LicenseFinder
38
38
  def definition
39
39
  # DI
40
40
  ENV['BUNDLE_PATH'] = project_path.to_s
41
- ENV['BUNDLE_GEMFILE'] = "#{project_path}/Gemfile"
41
+ ENV['BUNDLE_GEMFILE'] = "#{project_path}/#{gemfile}"
42
42
 
43
43
  @definition ||= ::Bundler::Definition.build(detected_package_path, lockfile_path, nil)
44
44
  end
@@ -53,7 +53,7 @@ module LicenseFinder
53
53
  def gem_details
54
54
  return @gem_details if @gem_details
55
55
 
56
- # clear gem paths before runninng specs_for
56
+ # clear gem paths before running specs_for
57
57
  Gem.clear_paths
58
58
  if File.exist?(bundler_config_path)
59
59
  ::Bundler.reset!
@@ -71,7 +71,7 @@ module LicenseFinder
71
71
  end
72
72
 
73
73
  def lockfile_path
74
- project_path.join('Gemfile.lock')
74
+ project_path.join(lockfile)
75
75
  end
76
76
 
77
77
  def bundler_config_path
@@ -89,5 +89,13 @@ module LicenseFinder
89
89
  end
90
90
  end
91
91
  end
92
+
93
+ def gemfile
94
+ File.basename(ENV['BUNDLE_GEMFILE'])
95
+ end
96
+
97
+ def lockfile
98
+ "#{gemfile}.lock"
99
+ end
92
100
  end
93
101
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module LicenseFinder
6
+ class Composer < PackageManager
7
+ SHELL_COMMAND = 'composer licenses --format=json'
8
+
9
+ def possible_package_paths
10
+ [project_path.join('composer.lock'), project_path.join('composer.json')]
11
+ end
12
+
13
+ def current_packages
14
+ dependency_list.map do |name, dependency|
15
+ ComposerPackage.new(name, dependency['version'], spec_licenses: dependency['license'])
16
+ end
17
+ end
18
+
19
+ def prepare
20
+ _stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(Composer.prepare_command) }
21
+ return if status.success?
22
+
23
+ log_errors stderr
24
+ raise "Prepare command '#{Composer.prepare_command}' failed" unless @prepare_no_fail
25
+ end
26
+
27
+ def self.package_management_command
28
+ 'composer'
29
+ end
30
+
31
+ def self.prepare_command
32
+ 'composer install'
33
+ end
34
+
35
+ def package_path
36
+ project_path.join('composer.json')
37
+ end
38
+
39
+ def lockfile_path
40
+ project_path.join('composer.lock')
41
+ end
42
+
43
+ def dependency_list
44
+ json ||= composer_json
45
+ json.fetch('dependencies', {}).reject { |_, d| d.is_a?(String) }
46
+ end
47
+
48
+ def composer_json
49
+ stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(Composer::SHELL_COMMAND) }
50
+ raise "Command '#{Composer::SHELL_COMMAND}' failed to execute: #{stderr}" unless status.success?
51
+
52
+ JSON(stdout)
53
+ end
54
+ end
55
+ end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'license_finder/shared_helpers/common_path'
4
+
4
5
  module LicenseFinder
5
6
  class Gvt < PackageManager
6
7
  def possible_package_paths
7
- potential_path_list = Dir.glob project_path.join('*', 'vendor', 'manifest')
8
- potential_path_list << project_path.join('vendor', 'manifest')
9
- potential_path_list.map { |path| Pathname path }
8
+ potential_path = project_path.join('vendor', 'manifest')
9
+ [Pathname(potential_path)]
10
10
  end
11
11
 
12
12
  def self.package_management_command
@@ -18,25 +18,8 @@ module LicenseFinder
18
18
  end
19
19
 
20
20
  def current_packages
21
- split_project_path = project_path.to_s.split('/')
22
- project_root_depth = split_project_path.length - 1
23
-
24
- split_package_path = detected_package_path.to_s.split('/')
25
- vendor_dir_depth = split_package_path.index('vendor')
26
- return [] if vendor_dir_depth.nil?
27
-
28
- vendor_dir_parent_depth = vendor_dir_depth - 1
29
-
30
- is_project_root_parent_of_vendor_dir = project_root_depth == vendor_dir_parent_depth
31
-
32
- if is_project_root_parent_of_vendor_dir
33
- shell_command = 'gvt list -f "{{.Importpath}} {{.Revision}} {{.Repository}}"'
34
- path = project_path.join('vendor')
35
- else
36
- vendor_dir_parent = split_package_path[vendor_dir_parent_depth]
37
- shell_command = "cd #{vendor_dir_parent} && gvt list -f \"{{.Importpath}} {{.Revision}} {{.Repository}}\""
38
- path = project_path.join(vendor_dir_parent, 'vendor')
39
- end
21
+ shell_command = "cd #{project_path} && gvt list -f \"{{.Importpath}} {{.Revision}} {{.Repository}}\""
22
+ path = project_path.join(project_path, 'vendor')
40
23
 
41
24
  stdout, _stderr, status = Cmd.run(shell_command)
42
25
  return [] unless status.success?
@@ -24,6 +24,7 @@ module LicenseFinder
24
24
  def prepare
25
25
  prep_cmd = "#{NPM.prepare_command}#{production_flag}"
26
26
  _stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(prep_cmd) }
27
+
27
28
  return if status.success?
28
29
 
29
30
  log_errors stderr
@@ -35,7 +36,8 @@ module LicenseFinder
35
36
  def npm_json
36
37
  command = "#{NPM.package_management_command} list --json --long#{production_flag}"
37
38
  stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
38
- raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
39
+ # we can try and continue if we got an exit status 1 - unmet peer dependency
40
+ raise "Command '#{command}' failed to execute: #{stderr}" if !status.success? && status.exitstatus != 1
39
41
 
40
42
  JSON.parse(stdout)
41
43
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LicenseFinder
4
+ class ComposerPackage < Package
5
+ def package_manager
6
+ 'Composer'
7
+ end
8
+ end
9
+ end
@@ -9,6 +9,12 @@ module LicenseFinder
9
9
  @packages = flattened_dependencies(npm_json)
10
10
  package_json = PackageJson.new(package_path)
11
11
  populate_groups(package_json)
12
+ @packages.reject! do |_identifier, package|
13
+ package.name.empty? &&
14
+ package.version.empty? &&
15
+ package.licenses.length == 1 &&
16
+ package.licenses.first.name == 'unknown'
17
+ end
12
18
  @packages.values
13
19
  end
14
20
 
@@ -3,7 +3,7 @@
3
3
  module LicenseFinder
4
4
  class Scanner
5
5
  PACKAGE_MANAGERS = [GoModules, GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Trash, Dep, Bundler, NPM, Pip,
6
- Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet].freeze
6
+ Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer].freeze
7
7
 
8
8
  def initialize(config = { project_path: Pathname.new('') })
9
9
  @config = config
@@ -23,6 +23,7 @@ module LicenseFinder
23
23
  active_pm_classes = []
24
24
  PACKAGE_MANAGERS.each do |pm_class|
25
25
  active = pm_class.new(@config).active?
26
+
26
27
  if active
27
28
  @logger.info pm_class, 'is active', color: :green
28
29
  active_pm_classes << pm_class
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  ]
32
32
 
33
33
  s.email = ['labs-commoncode@pivotal.io']
34
- s.homepage = 'https://github.com/pivotal-legacy/LicenseFinder'
34
+ s.homepage = 'https://github.com/pivotal/LicenseFinder'
35
35
  s.summary = "Audit the OSS licenses of your application's dependencies."
36
36
 
37
37
  s.description = <<-DESCRIPTION
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  s.add_development_dependency 'rake'
60
60
  s.add_development_dependency 'rspec', '~> 3'
61
61
  s.add_development_dependency 'rspec-its'
62
- s.add_development_dependency 'rubocop', '~> 0.70.0'
62
+ s.add_development_dependency 'rubocop', '~> 0.71.0'
63
63
  s.add_development_dependency 'rubocop-performance', '~> 1.3.0'
64
64
  s.add_development_dependency 'webmock', '~> 3.5'
65
65
 
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: 5.8.0
4
+ version: 5.9.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: 2019-05-22 00:00:00.000000000 Z
30
+ date: 2019-06-10 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
@@ -231,14 +231,14 @@ dependencies:
231
231
  requirements:
232
232
  - - "~>"
233
233
  - !ruby/object:Gem::Version
234
- version: 0.70.0
234
+ version: 0.71.0
235
235
  type: :development
236
236
  prerelease: false
237
237
  version_requirements: !ruby/object:Gem::Requirement
238
238
  requirements:
239
239
  - - "~>"
240
240
  - !ruby/object:Gem::Version
241
- version: 0.70.0
241
+ version: 0.71.0
242
242
  - !ruby/object:Gem::Dependency
243
243
  name: rubocop-performance
244
244
  requirement: !ruby/object:Gem::Requirement
@@ -366,13 +366,16 @@ files:
366
366
  - lib/license_finder/license/matcher.rb
367
367
  - lib/license_finder/license/none_matcher.rb
368
368
  - lib/license_finder/license/template.rb
369
+ - lib/license_finder/license/templates/Apache1_1.txt
369
370
  - lib/license_finder/license/templates/Apache2.txt
370
371
  - lib/license_finder/license/templates/BSD.txt
371
372
  - lib/license_finder/license/templates/CC01.txt
373
+ - lib/license_finder/license/templates/EPL1.txt
372
374
  - lib/license_finder/license/templates/GPLv2.txt
373
375
  - lib/license_finder/license/templates/GPLv3.txt
374
376
  - lib/license_finder/license/templates/ISC.txt
375
377
  - lib/license_finder/license/templates/LGPL.txt
378
+ - lib/license_finder/license/templates/LGPL2_1.txt
376
379
  - lib/license_finder/license/templates/MIT.txt
377
380
  - lib/license_finder/license/templates/MPL2.txt
378
381
  - lib/license_finder/license/templates/NewBSD.txt
@@ -390,6 +393,7 @@ files:
390
393
  - lib/license_finder/package_managers/cargo.rb
391
394
  - lib/license_finder/package_managers/carthage.rb
392
395
  - lib/license_finder/package_managers/cocoa_pods.rb
396
+ - lib/license_finder/package_managers/composer.rb
393
397
  - lib/license_finder/package_managers/conan.rb
394
398
  - lib/license_finder/package_managers/dep.rb
395
399
  - lib/license_finder/package_managers/dotnet.rb
@@ -424,6 +428,7 @@ files:
424
428
  - lib/license_finder/packages/cargo_package.rb
425
429
  - lib/license_finder/packages/carthage_package.rb
426
430
  - lib/license_finder/packages/cocoa_pods_package.rb
431
+ - lib/license_finder/packages/composer_package.rb
427
432
  - lib/license_finder/packages/conan_package.rb
428
433
  - lib/license_finder/packages/go_package.rb
429
434
  - lib/license_finder/packages/gradle_package.rb
@@ -459,7 +464,7 @@ files:
459
464
  - lib/license_finder/version.rb
460
465
  - license_finder.gemspec
461
466
  - release/instructions.md
462
- homepage: https://github.com/pivotal-legacy/LicenseFinder
467
+ homepage: https://github.com/pivotal/LicenseFinder
463
468
  licenses:
464
469
  - MIT
465
470
  metadata: {}