license_finder 5.4.1 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +18 -12
- data/Dockerfile +7 -4
- data/README.md +15 -14
- data/Rakefile +9 -1
- data/bin/license_finder +1 -0
- data/ci/pipelines/{pipeline.yml.erb → pull-request.yml.erb} +25 -37
- data/ci/pipelines/release.yml.erb +199 -0
- data/ci/scripts/run-rubocop.sh +1 -1
- data/ci/scripts/run-tests.sh +0 -14
- data/ci/tasks/run-tests.yml +10 -0
- data/dlf +2 -2
- data/lib/license_finder.rb +2 -0
- data/lib/license_finder/cli.rb +2 -0
- data/lib/license_finder/cli/approvals.rb +2 -0
- data/lib/license_finder/cli/base.rb +2 -0
- data/lib/license_finder/cli/blacklist.rb +2 -0
- data/lib/license_finder/cli/dependencies.rb +2 -0
- data/lib/license_finder/cli/ignored_dependencies.rb +2 -0
- data/lib/license_finder/cli/ignored_groups.rb +2 -0
- data/lib/license_finder/cli/licenses.rb +2 -0
- data/lib/license_finder/cli/main.rb +3 -0
- data/lib/license_finder/cli/makes_decisions.rb +2 -0
- data/lib/license_finder/cli/patched_thor.rb +2 -0
- data/lib/license_finder/cli/project_name.rb +2 -0
- data/lib/license_finder/cli/whitelist.rb +2 -0
- data/lib/license_finder/configuration.rb +3 -0
- data/lib/license_finder/core.rb +3 -1
- data/lib/license_finder/decision_applier.rb +2 -0
- data/lib/license_finder/decisions.rb +2 -0
- data/lib/license_finder/decisions_factory.rb +2 -0
- data/lib/license_finder/diff.rb +5 -3
- data/lib/license_finder/license.rb +2 -0
- data/lib/license_finder/license/any_matcher.rb +2 -0
- data/lib/license_finder/license/definitions.rb +2 -0
- data/lib/license_finder/license/header_matcher.rb +2 -0
- data/lib/license_finder/license/matcher.rb +2 -0
- data/lib/license_finder/license/none_matcher.rb +2 -0
- data/lib/license_finder/license/template.rb +2 -0
- data/lib/license_finder/license/text.rb +2 -0
- data/lib/license_finder/license_aggregator.rb +4 -0
- data/lib/license_finder/logger.rb +6 -2
- data/lib/license_finder/package.rb +3 -0
- data/lib/license_finder/package_delta.rb +3 -1
- data/lib/license_finder/package_manager.rb +5 -1
- data/lib/license_finder/package_managers/bower.rb +2 -0
- data/lib/license_finder/package_managers/bundler.rb +3 -0
- data/lib/license_finder/package_managers/cargo.rb +3 -0
- data/lib/license_finder/package_managers/carthage.rb +2 -0
- data/lib/license_finder/package_managers/cocoa_pods.rb +2 -0
- data/lib/license_finder/package_managers/conan.rb +2 -0
- data/lib/license_finder/package_managers/dep.rb +2 -0
- data/lib/license_finder/package_managers/glide.rb +2 -0
- data/lib/license_finder/package_managers/go_15vendorexperiment.rb +4 -0
- data/lib/license_finder/package_managers/go_dep.rb +26 -20
- data/lib/license_finder/package_managers/go_modules.rb +62 -0
- data/lib/license_finder/package_managers/go_workspace.rb +6 -0
- data/lib/license_finder/package_managers/govendor.rb +15 -3
- data/lib/license_finder/package_managers/gradle.rb +2 -0
- data/lib/license_finder/package_managers/gvt.rb +5 -1
- data/lib/license_finder/package_managers/maven.rb +2 -0
- data/lib/license_finder/package_managers/mix.rb +2 -0
- data/lib/license_finder/package_managers/npm.rb +4 -0
- data/lib/license_finder/package_managers/nuget.rb +5 -0
- data/lib/license_finder/package_managers/pip.rb +4 -1
- data/lib/license_finder/package_managers/rebar.rb +2 -0
- data/lib/license_finder/package_managers/sbt.rb +2 -0
- data/lib/license_finder/package_managers/yarn.rb +6 -2
- data/lib/license_finder/package_utils/activation.rb +2 -0
- data/lib/license_finder/package_utils/conan_info_parser.rb +3 -0
- data/lib/license_finder/package_utils/gradle_dependency_finder.rb +2 -0
- data/lib/license_finder/package_utils/license_files.rb +4 -1
- data/lib/license_finder/package_utils/licensing.rb +5 -3
- data/lib/license_finder/package_utils/maven_dependency_finder.rb +2 -0
- data/lib/license_finder/package_utils/possible_license_file.rb +2 -0
- data/lib/license_finder/package_utils/sbt_dependency_finder.rb +2 -0
- data/lib/license_finder/packages/bower_package.rb +2 -0
- data/lib/license_finder/packages/bundler_package.rb +2 -0
- data/lib/license_finder/packages/cargo_package.rb +2 -0
- data/lib/license_finder/packages/carthage_package.rb +2 -0
- data/lib/license_finder/packages/cocoa_pods_package.rb +2 -0
- data/lib/license_finder/packages/conan_package.rb +2 -0
- data/lib/license_finder/packages/go_package.rb +4 -0
- data/lib/license_finder/packages/gradle_package.rb +2 -0
- data/lib/license_finder/packages/manual_package.rb +2 -0
- data/lib/license_finder/packages/maven_package.rb +2 -0
- data/lib/license_finder/packages/merged_package.rb +2 -0
- data/lib/license_finder/packages/mix_package.rb +2 -0
- data/lib/license_finder/packages/npm_package.rb +5 -0
- data/lib/license_finder/packages/nuget_package.rb +2 -0
- data/lib/license_finder/packages/pip_package.rb +4 -0
- data/lib/license_finder/packages/rebar_package.rb +2 -0
- data/lib/license_finder/packages/sbt_package.rb +2 -0
- data/lib/license_finder/packages/yarn_package.rb +2 -0
- data/lib/license_finder/platform.rb +2 -0
- data/lib/license_finder/project_finder.rb +3 -0
- data/lib/license_finder/report.rb +2 -0
- data/lib/license_finder/scanner.rb +3 -1
- data/lib/license_finder/shared_helpers/cmd.rb +2 -0
- data/lib/license_finder/shared_helpers/common_path.rb +8 -6
- data/lib/license_finder/version.rb +3 -1
- data/license_finder.gemspec +5 -2
- metadata +21 -5
- data/ci/pipelines/release.yml +0 -112
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module LicenseFinder
|
@@ -23,6 +25,7 @@ module LicenseFinder
|
|
23
25
|
Dir.chdir(path) do
|
24
26
|
stdout, _stderr, status = Cmd.run('git rev-list --max-count 1 HEAD')
|
25
27
|
raise 'git rev-list failed' unless status.success?
|
28
|
+
|
26
29
|
stdout.strip
|
27
30
|
end
|
28
31
|
end
|
@@ -55,6 +58,7 @@ module LicenseFinder
|
|
55
58
|
val, _stderr, status = Cmd.run('go list -f "{{join .Deps \"\n\"}}" ./...')
|
56
59
|
ENV['GOPATH'] = orig_gopath
|
57
60
|
return [] unless status.success?
|
61
|
+
|
58
62
|
# Select non-standard packages. `go list std` returns the list of standard
|
59
63
|
# dependencies. We then filter those dependencies out of the full list of
|
60
64
|
# dependencies.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module LicenseFinder
|
@@ -8,20 +10,8 @@ module LicenseFinder
|
|
8
10
|
end
|
9
11
|
|
10
12
|
def current_packages
|
11
|
-
|
13
|
+
packages_from_json(detected_package_path.read)
|
12
14
|
# godep includes subpackages as a seperate dependency, we can de-dup that
|
13
|
-
|
14
|
-
dependencies_info = json['Deps'].map do |dep_json|
|
15
|
-
{
|
16
|
-
'Homepage' => homepage(dep_json),
|
17
|
-
'ImportPath' => import_path(dep_json),
|
18
|
-
'InstallPath' => dep_json['InstallPath'],
|
19
|
-
'Rev' => dep_json['Rev']
|
20
|
-
}
|
21
|
-
end
|
22
|
-
dependencies_info.uniq.map do |info|
|
23
|
-
GoPackage.from_dependency(info, install_prefix, @full_version)
|
24
|
-
end
|
25
15
|
end
|
26
16
|
|
27
17
|
def self.takes_priority_over
|
@@ -51,15 +41,31 @@ module LicenseFinder
|
|
51
41
|
project_path.join('Godeps/_workspace')
|
52
42
|
end
|
53
43
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
44
|
+
def packages_from_json(json_string)
|
45
|
+
all_packages = JSON.parse(json_string)['Deps']
|
46
|
+
packages_grouped_by_revision = all_packages.group_by { |package| package['Rev'] }
|
47
|
+
|
48
|
+
result = []
|
49
|
+
packages_grouped_by_revision.each do |_sha, packages_in_group|
|
50
|
+
all_paths_in_group = packages_in_group.map { |p| p['ImportPath'] }
|
51
|
+
common_paths = CommonPathHelper.longest_common_paths(all_paths_in_group)
|
52
|
+
package_info = packages_in_group.first
|
57
53
|
|
58
|
-
|
59
|
-
|
60
|
-
|
54
|
+
common_paths.each do |common_path|
|
55
|
+
dependency_info_hash = {
|
56
|
+
'Homepage' => common_path,
|
57
|
+
'ImportPath' => common_path,
|
58
|
+
'InstallPath' => package_info['InstallPath'],
|
59
|
+
'Rev' => package_info['Rev']
|
60
|
+
}
|
61
|
+
|
62
|
+
result << GoPackage.from_dependency(dependency_info_hash,
|
63
|
+
install_prefix,
|
64
|
+
@full_version)
|
65
|
+
end
|
66
|
+
end
|
61
67
|
|
62
|
-
|
68
|
+
result
|
63
69
|
end
|
64
70
|
end
|
65
71
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'license_finder/packages/go_package'
|
4
|
+
|
5
|
+
module LicenseFinder
|
6
|
+
class GoModules < PackageManager
|
7
|
+
PACKAGES_FILE = 'go.sum'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def takes_priority_over
|
11
|
+
Go15VendorExperiment
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare_command
|
15
|
+
'go mod vendor'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def active?
|
20
|
+
sum_files?
|
21
|
+
end
|
22
|
+
|
23
|
+
def current_packages
|
24
|
+
sum_file_paths.uniq.map do |file_path|
|
25
|
+
read_sum(file_path)
|
26
|
+
end.flatten
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def sum_files?
|
32
|
+
sum_file_paths.any?
|
33
|
+
end
|
34
|
+
|
35
|
+
def sum_file_paths
|
36
|
+
Dir[project_path.join(PACKAGES_FILE)]
|
37
|
+
end
|
38
|
+
|
39
|
+
def read_sum(file_path)
|
40
|
+
contents = File.read(file_path)
|
41
|
+
contents.each_line.map do |line|
|
42
|
+
line.include?('go.mod') ? nil : read_package(file_path, line)
|
43
|
+
end.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
def read_package(file_path, line)
|
47
|
+
parts = line.split(' ')
|
48
|
+
install_path = File.dirname(file_path)
|
49
|
+
|
50
|
+
name = parts[0]
|
51
|
+
version = parts[1]
|
52
|
+
|
53
|
+
info = {
|
54
|
+
'ImportPath' => name,
|
55
|
+
'InstallPath' => install_path,
|
56
|
+
'Rev' => version
|
57
|
+
}
|
58
|
+
|
59
|
+
GoPackage.from_dependency(info, nil, true)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
module LicenseFinder
|
3
5
|
class GoWorkspace < PackageManager
|
@@ -23,6 +25,7 @@ module LicenseFinder
|
|
23
25
|
submodule.install_path =~ /#{repo_name(gp)}$/
|
24
26
|
end.first
|
25
27
|
next unless import_path
|
28
|
+
|
26
29
|
dependency_info = {
|
27
30
|
'ImportPath' => repo_name(import_path),
|
28
31
|
'Homepage' => repo_name(import_path),
|
@@ -43,6 +46,7 @@ module LicenseFinder
|
|
43
46
|
|
44
47
|
def active?
|
45
48
|
return false if @strict_matching
|
49
|
+
|
46
50
|
godep = LicenseFinder::GoDep.new(project_path: Pathname(project_path))
|
47
51
|
# go workspace is only active if GoDep wasn't. There are some projects
|
48
52
|
# that will use the .envrc and have a Godep folder as well.
|
@@ -76,6 +80,7 @@ module LicenseFinder
|
|
76
80
|
val, _stderr, status = Cmd.run('go list -f "{{join .Deps \"\n\"}}" ./...')
|
77
81
|
ENV['GOPATH'] = orig_gopath
|
78
82
|
raise 'go list failed' unless status.success?
|
83
|
+
|
79
84
|
# Select non-standard packages. `go list std` returns the list of standard
|
80
85
|
# dependencies. We then filter those dependencies out of the full list of
|
81
86
|
# dependencies.
|
@@ -93,6 +98,7 @@ module LicenseFinder
|
|
93
98
|
Dir.chdir(detected_package_path) do |_d|
|
94
99
|
result, _stderr, status = Cmd.run('git submodule status')
|
95
100
|
raise 'git submodule status failed' unless status.success?
|
101
|
+
|
96
102
|
result.lines.map do |l|
|
97
103
|
columns = l.split.map(&:strip)
|
98
104
|
Submodule.new File.join(detected_package_path, columns[1]), columns[0]
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'license_finder/shared_helpers/common_path'
|
2
4
|
require 'json'
|
3
5
|
|
@@ -38,24 +40,34 @@ module LicenseFinder
|
|
38
40
|
packages = data['package']
|
39
41
|
|
40
42
|
packages_by_sha = {}
|
43
|
+
packages_with_no_sha = []
|
41
44
|
|
42
45
|
packages.each do |package|
|
43
46
|
package_path = package['path']
|
44
47
|
package_revision = package['revision']
|
45
|
-
|
48
|
+
|
49
|
+
if !package_is_versioned?(package)
|
50
|
+
packages_with_no_sha << { sha: '', path: package_path }
|
51
|
+
elsif packages_by_sha[package_revision].nil?
|
46
52
|
packages_by_sha[package_revision] = [package_path]
|
47
53
|
else
|
48
54
|
packages_by_sha[package_revision] << package_path
|
49
55
|
end
|
50
56
|
end
|
51
57
|
|
52
|
-
result =
|
58
|
+
result = packages_with_no_sha
|
53
59
|
packages_by_sha.each do |sha, paths|
|
54
|
-
common_paths = CommonPathHelper.
|
60
|
+
common_paths = CommonPathHelper.longest_common_paths(paths)
|
55
61
|
common_paths.each { |cp| result << { sha: sha, path: cp } }
|
56
62
|
end
|
57
63
|
|
58
64
|
result
|
59
65
|
end
|
66
|
+
|
67
|
+
def package_is_versioned?(package)
|
68
|
+
package_revision = package['revision']
|
69
|
+
|
70
|
+
!package_revision.nil? && !package_revision.empty?
|
71
|
+
end
|
60
72
|
end
|
61
73
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'license_finder/shared_helpers/common_path'
|
2
4
|
module LicenseFinder
|
3
5
|
class Gvt < PackageManager
|
@@ -22,6 +24,7 @@ module LicenseFinder
|
|
22
24
|
split_package_path = detected_package_path.to_s.split('/')
|
23
25
|
vendor_dir_depth = split_package_path.index('vendor')
|
24
26
|
return [] if vendor_dir_depth.nil?
|
27
|
+
|
25
28
|
vendor_dir_parent_depth = vendor_dir_depth - 1
|
26
29
|
|
27
30
|
is_project_root_parent_of_vendor_dir = project_root_depth == vendor_dir_parent_depth
|
@@ -37,6 +40,7 @@ module LicenseFinder
|
|
37
40
|
|
38
41
|
stdout, _stderr, status = Cmd.run(shell_command)
|
39
42
|
return [] unless status.success?
|
43
|
+
|
40
44
|
packages_from_output(stdout, path)
|
41
45
|
end
|
42
46
|
|
@@ -62,7 +66,7 @@ module LicenseFinder
|
|
62
66
|
|
63
67
|
result = []
|
64
68
|
packages_by_sha.each do |sha, info|
|
65
|
-
paths = CommonPathHelper.
|
69
|
+
paths = CommonPathHelper.longest_common_paths(info['paths'])
|
66
70
|
|
67
71
|
paths.each { |p| result << [sha, p, info['repo']] }
|
68
72
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'tempfile'
|
3
5
|
|
@@ -23,6 +25,7 @@ module LicenseFinder
|
|
23
25
|
prep_cmd = "#{NPM.prepare_command}#{production_flag}"
|
24
26
|
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(prep_cmd) }
|
25
27
|
return if status.success?
|
28
|
+
|
26
29
|
log_errors stderr
|
27
30
|
raise "Prepare command '#{prep_cmd}' failed" unless @prepare_no_fail
|
28
31
|
end
|
@@ -39,6 +42,7 @@ module LicenseFinder
|
|
39
42
|
|
40
43
|
def production_flag
|
41
44
|
return '' if @ignored_groups.nil?
|
45
|
+
|
42
46
|
@ignored_groups.include?('devDependencies') ? ' --production' : ''
|
43
47
|
end
|
44
48
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rexml/document'
|
2
4
|
require 'zip'
|
3
5
|
|
@@ -57,6 +59,7 @@ module LicenseFinder
|
|
57
59
|
def license_urls(dep)
|
58
60
|
files = Dir["**/#{dep.name}.#{dep.version}.nupkg"]
|
59
61
|
return nil if files.empty?
|
62
|
+
|
60
63
|
file = files.first
|
61
64
|
Zip::File.open file do |zipfile|
|
62
65
|
content = zipfile.read(dep.name + '.nuspec')
|
@@ -71,6 +74,7 @@ module LicenseFinder
|
|
71
74
|
|
72
75
|
def self.package_management_command
|
73
76
|
return 'nuget' if LicenseFinder::Platform.windows?
|
77
|
+
|
74
78
|
'mono /usr/local/bin/nuget.exe'
|
75
79
|
end
|
76
80
|
|
@@ -90,6 +94,7 @@ module LicenseFinder
|
|
90
94
|
|
91
95
|
def self.nuget_check
|
92
96
|
return 'where nuget' if LicenseFinder::Platform.windows?
|
97
|
+
|
93
98
|
'which mono && ls /usr/local/bin/nuget.exe'
|
94
99
|
end
|
95
100
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
require 'net/http'
|
3
5
|
|
@@ -33,6 +35,7 @@ module LicenseFinder
|
|
33
35
|
prep_cmd = "#{Pip.prepare_command} -r #{@requirements_path}"
|
34
36
|
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(prep_cmd) }
|
35
37
|
return if status.success?
|
38
|
+
|
36
39
|
log_errors stderr
|
37
40
|
raise "Prepare command '#{prep_cmd}' failed" unless @prepare_no_fail
|
38
41
|
end
|
@@ -65,7 +68,7 @@ module LicenseFinder
|
|
65
68
|
http.use_ssl = true
|
66
69
|
response = http.get(uri.request_uri).response
|
67
70
|
|
68
|
-
response.is_a?(Net::HTTPRedirection) && limit
|
71
|
+
response.is_a?(Net::HTTPRedirection) && limit.positive? ? pypi_request(response['location'], limit - 1) : response
|
69
72
|
end
|
70
73
|
end
|
71
74
|
end
|
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LicenseFinder
|
2
4
|
class Yarn < PackageManager
|
3
|
-
SHELL_COMMAND = 'yarn licenses list --no-progress --json'
|
5
|
+
SHELL_COMMAND = 'yarn licenses list --no-progress --json'
|
4
6
|
|
5
7
|
def possible_package_paths
|
6
8
|
[project_path.join('yarn.lock')]
|
@@ -40,6 +42,7 @@ module LicenseFinder
|
|
40
42
|
prep_cmd = "#{Yarn.prepare_command}#{production_flag}"
|
41
43
|
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(prep_cmd) }
|
42
44
|
return if status.success?
|
45
|
+
|
43
46
|
log_errors stderr
|
44
47
|
raise "Prepare command '#{prep_cmd}' failed" unless @prepare_no_fail
|
45
48
|
end
|
@@ -70,7 +73,7 @@ module LicenseFinder
|
|
70
73
|
|
71
74
|
valid_packages.map do |package_hash|
|
72
75
|
YarnPackage.new(package_hash['Name'], package_hash['Version'], spec_licenses: [package_hash['License']],
|
73
|
-
|
76
|
+
homepage: package_hash['VendorUrl'])
|
74
77
|
end
|
75
78
|
end
|
76
79
|
|
@@ -83,6 +86,7 @@ module LicenseFinder
|
|
83
86
|
|
84
87
|
def production_flag
|
85
88
|
return '' if @ignored_groups.nil?
|
89
|
+
|
86
90
|
@ignored_groups.include?('devDependencies') ? ' --production' : ''
|
87
91
|
end
|
88
92
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module LicenseFinder
|
2
4
|
class ConanInfoParser
|
3
5
|
def parse(info)
|
@@ -9,6 +11,7 @@ module LicenseFinder
|
|
9
11
|
@current_key = nil # current key to be associated with the current val
|
10
12
|
while (line = @lines.shift)
|
11
13
|
next if line == ''
|
14
|
+
|
12
15
|
case @state
|
13
16
|
when :project_level
|
14
17
|
@current_project = {}
|