license_finder 6.8.2 → 6.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/CONTRIBUTING.md +5 -4
- data/Dockerfile +20 -5
- data/README.md +26 -11
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ci/pipelines/pull-request.yml.erb +2 -0
- data/ci/pipelines/release.yml.erb +3 -1
- data/ci/tasks/rubocop.yml +2 -0
- data/ci/tasks/update-changelog.yml +2 -0
- data/examples/Gemfile +4 -0
- data/examples/custom_erb_template.rb +24 -0
- data/examples/extract_license_data.rb +63 -0
- data/examples/sample_template.erb +7 -0
- data/lib/license_finder/cli/base.rb +8 -1
- data/lib/license_finder/cli/main.rb +5 -1
- data/lib/license_finder/configuration.rb +12 -0
- data/lib/license_finder/core.rb +5 -2
- data/lib/license_finder/decisions.rb +16 -4
- data/lib/license_finder/license.rb +11 -4
- data/lib/license_finder/package.rb +1 -0
- data/lib/license_finder/package_manager.rb +10 -5
- data/lib/license_finder/package_managers/composer.rb +8 -4
- data/lib/license_finder/package_managers/conda.rb +131 -0
- data/lib/license_finder/package_managers/dep.rb +6 -1
- data/lib/license_finder/package_managers/go_15vendorexperiment.rb +6 -1
- data/lib/license_finder/package_managers/go_dep.rb +15 -8
- data/lib/license_finder/package_managers/go_modules.rb +9 -2
- data/lib/license_finder/package_managers/npm.rb +1 -1
- data/lib/license_finder/package_managers/trash.rb +6 -1
- data/lib/license_finder/package_managers/yarn.rb +1 -1
- data/lib/license_finder/packages/conda_package.rb +74 -0
- data/lib/license_finder/report.rb +1 -0
- data/lib/license_finder/reports/junit_report.rb +19 -0
- data/lib/license_finder/reports/templates/junit_report.erb +41 -0
- data/lib/license_finder/scanner.rb +25 -2
- data/license_finder.gemspec +3 -2
- metadata +37 -9
@@ -30,9 +30,14 @@ module LicenseFinder
|
|
30
30
|
GoPackage.from_dependency({
|
31
31
|
'ImportPath' => import_path,
|
32
32
|
'InstallPath' => license_path,
|
33
|
-
'Rev' => package_hash.fetch('version')
|
33
|
+
'Rev' => package_hash.fetch('version'),
|
34
|
+
'Homepage' => repo_name(import_path)
|
34
35
|
}, nil, true)
|
35
36
|
end
|
36
37
|
end
|
38
|
+
|
39
|
+
def repo_name(name)
|
40
|
+
name.split('/')[0..2].join('/')
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class CondaPackage < Package
|
5
|
+
attr_accessor :identifier, :json
|
6
|
+
|
7
|
+
def initialize(conda_json)
|
8
|
+
@json = conda_json
|
9
|
+
@identifier = Identifier.from_hash(conda_json)
|
10
|
+
super(@identifier.name,
|
11
|
+
@identifier.version,
|
12
|
+
spec_licenses: Package.license_names_from_standard_spec(conda_json),
|
13
|
+
children: children)
|
14
|
+
end
|
15
|
+
|
16
|
+
def ==(other)
|
17
|
+
other.is_a?(CondaPackage) && @identifier == other.identifier
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@identifier.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def package_manager
|
25
|
+
'Conda'
|
26
|
+
end
|
27
|
+
|
28
|
+
def package_url
|
29
|
+
@json['url']
|
30
|
+
end
|
31
|
+
|
32
|
+
def children
|
33
|
+
@json.fetch('depends', []).map { |constraint| constraint.split.first }
|
34
|
+
end
|
35
|
+
|
36
|
+
class Identifier
|
37
|
+
attr_accessor :name, :version
|
38
|
+
|
39
|
+
def initialize(name, version)
|
40
|
+
@name = name
|
41
|
+
@version = version
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.from_hash(hash)
|
45
|
+
name = hash['name']
|
46
|
+
version = hash['version']
|
47
|
+
return nil if name.nil? || version.nil?
|
48
|
+
|
49
|
+
Identifier.new(name, version)
|
50
|
+
end
|
51
|
+
|
52
|
+
def ==(other)
|
53
|
+
other.is_a?(Identifier) && @name == other.name && @version == other.version
|
54
|
+
end
|
55
|
+
|
56
|
+
def eql?(other)
|
57
|
+
self == other
|
58
|
+
end
|
59
|
+
|
60
|
+
def hash
|
61
|
+
[@name, @version].hash
|
62
|
+
end
|
63
|
+
|
64
|
+
def <=>(other)
|
65
|
+
sort_name = @name <=> other.name
|
66
|
+
sort_name.zero? ? @version <=> other.version : sort_name
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_s
|
70
|
+
"#{@name} - #{@version}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'license_finder/reports/erb_report'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class JunitReport < ErbReport
|
5
|
+
ROOT_PATH = Pathname.new(__FILE__).dirname
|
6
|
+
TEMPLATE_PATH = ROOT_PATH.join('templates')
|
7
|
+
|
8
|
+
def to_s(filename = TEMPLATE_PATH.join("#{template_name}.erb"))
|
9
|
+
template = ERB.new(filename.read, nil, '-')
|
10
|
+
template.result(binding)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def template_name
|
16
|
+
'junit_report'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<testsuites failures="<%= unapproved_dependencies.size %>" name="<%= project_name %>" tests="<%= dependencies.size %>">
|
3
|
+
<% sorted_dependencies.each_with_index do |dependency, i| -%>
|
4
|
+
<testsuite failures="<%= dependency.approved? ? "0" : "1" -%>" id="<%= i %>" name="<%= dependency.name %>" package="Gemfile.lock" skipped="0" tests="1" timestamp="<%= Time.now.strftime("%Y-%m-%dT%H:%M:%S:%6N") %>">
|
5
|
+
<testcase classname="<%= license_names(dependency) %>" name="<%= dependency.name %>"<%= dependency.approved? ? " /" : "" %>>
|
6
|
+
<%- unless dependency.approved? -%>
|
7
|
+
<failure message="Unapproved license in '<%= dependency.name %>' <%= dependency.version %>">
|
8
|
+
Name: <%= dependency.name %>
|
9
|
+
Version: <%= dependency.version %>
|
10
|
+
Licence:
|
11
|
+
<%- if dependency.licenses.any? -%>
|
12
|
+
<%- dependency.licenses.each do |license| -%>- <%=license.name %>: <%=license.url %><% end %>
|
13
|
+
<%- end -%>
|
14
|
+
URL: <%= dependency.package_url %>
|
15
|
+
Homepage: <%= dependency.homepage %>
|
16
|
+
Summary: <%= REXML::Text.new(dependency.summary, false, nil, false) %>
|
17
|
+
Description: <%= REXML::Text.new(dependency.description, false, nil, false) %>
|
18
|
+
<% if dependency.parents.any? %>
|
19
|
+
Dependencies:
|
20
|
+
<% dependency.parents.to_a.each do |dep| -%>
|
21
|
+
- <%= dep %>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
<%- if dependency.children.any? -%>
|
25
|
+
Requirements:
|
26
|
+
<%- dependency.children.each do |req| -%>
|
27
|
+
- <%= req %>
|
28
|
+
<% end -%>
|
29
|
+
<% end -%>
|
30
|
+
</failure>
|
31
|
+
<system-out>
|
32
|
+
stdout
|
33
|
+
</system-out>
|
34
|
+
<system-err>
|
35
|
+
stderr
|
36
|
+
</system-err>
|
37
|
+
</testcase>
|
38
|
+
<%- end -%>
|
39
|
+
</testsuite>
|
40
|
+
<% end -%>
|
41
|
+
</testsuites>
|
@@ -4,7 +4,8 @@ module LicenseFinder
|
|
4
4
|
class Scanner
|
5
5
|
PACKAGE_MANAGERS = [
|
6
6
|
GoModules, GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Trash, Dep, Bundler, NPM, Pip,
|
7
|
-
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Erlangmk, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer, Pipenv
|
7
|
+
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Erlangmk, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer, Pipenv,
|
8
|
+
Conda
|
8
9
|
].freeze
|
9
10
|
|
10
11
|
class << self
|
@@ -12,6 +13,10 @@ module LicenseFinder
|
|
12
13
|
paths.reject { |path| subproject?(Pathname(path)) }
|
13
14
|
end
|
14
15
|
|
16
|
+
def supported_package_manager_ids
|
17
|
+
PACKAGE_MANAGERS.map(&:id)
|
18
|
+
end
|
19
|
+
|
15
20
|
private
|
16
21
|
|
17
22
|
def subproject?(path)
|
@@ -28,6 +33,7 @@ module LicenseFinder
|
|
28
33
|
@config = config
|
29
34
|
@project_path = @config[:project_path]
|
30
35
|
@logger = @config[:logger]
|
36
|
+
@enabled_package_manager_ids = @config[:enabled_package_manager_ids]
|
31
37
|
end
|
32
38
|
|
33
39
|
def active_packages
|
@@ -40,7 +46,7 @@ module LicenseFinder
|
|
40
46
|
return @package_managers if @package_managers
|
41
47
|
|
42
48
|
active_pm_classes = []
|
43
|
-
|
49
|
+
enabled_package_managers.each do |pm_class|
|
44
50
|
active = pm_class.new(@config).active?
|
45
51
|
|
46
52
|
if active
|
@@ -56,5 +62,22 @@ module LicenseFinder
|
|
56
62
|
active_pm_classes -= active_pm_classes.map(&:takes_priority_over)
|
57
63
|
@package_managers = active_pm_classes.map { |pm_class| pm_class.new(@config) }
|
58
64
|
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def enabled_package_managers
|
69
|
+
enabled_pm_ids = @enabled_package_manager_ids
|
70
|
+
|
71
|
+
return PACKAGE_MANAGERS unless enabled_pm_ids
|
72
|
+
|
73
|
+
enabled_pm_classes = PACKAGE_MANAGERS.select { |pm_class| enabled_pm_ids.include?(pm_class.id) }
|
74
|
+
|
75
|
+
if enabled_pm_classes.length != enabled_pm_ids.length
|
76
|
+
unsupported_pm_ids = enabled_pm_ids - self.class.supported_package_manager_ids
|
77
|
+
raise "Unsupported package manager: #{unsupported_pm_ids.join(', ')}"
|
78
|
+
end
|
79
|
+
|
80
|
+
enabled_pm_classes
|
81
|
+
end
|
59
82
|
end
|
60
83
|
end
|
data/license_finder.gemspec
CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
s.add_dependency 'bundler'
|
47
47
|
s.add_dependency 'rubyzip', '>=1', '<3'
|
48
48
|
s.add_dependency 'thor', '~> 1.0.1'
|
49
|
-
s.add_dependency 'tomlrb', '
|
49
|
+
s.add_dependency 'tomlrb', '>= 1.3', '< 2.1'
|
50
50
|
s.add_dependency 'with_env', '1.1.0'
|
51
51
|
s.add_dependency 'xml-simple', '~> 1.1.5'
|
52
52
|
|
@@ -55,7 +55,7 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.add_development_dependency 'cocoapods', '>= 1.0.0' if RUBY_PLATFORM =~ /darwin/
|
56
56
|
s.add_development_dependency 'fakefs', '~> 1.2.0'
|
57
57
|
s.add_development_dependency 'mime-types', '3.3.1'
|
58
|
-
s.add_development_dependency 'pry', '~> 0.
|
58
|
+
s.add_development_dependency 'pry', '~> 0.14.0'
|
59
59
|
s.add_development_dependency 'rake', '~> 13.0.1'
|
60
60
|
s.add_development_dependency 'rspec', '~> 3'
|
61
61
|
s.add_development_dependency 'rspec-its', '~> 1.3.0'
|
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
|
|
63
63
|
s.add_development_dependency 'rubocop-performance', '~> 1.5.0'
|
64
64
|
s.add_development_dependency 'webmock', '~> 3.5'
|
65
65
|
|
66
|
+
s.add_development_dependency 'nokogiri', '~>1.10'
|
66
67
|
s.add_development_dependency 'rack', '~> 2.2.2'
|
67
68
|
s.add_development_dependency 'rack-test', '~> 1.1.0', '> 0.7'
|
68
69
|
|
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.
|
4
|
+
version: 6.12.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:
|
30
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
31
31
|
dependencies:
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: bundler
|
@@ -81,16 +81,22 @@ dependencies:
|
|
81
81
|
name: tomlrb
|
82
82
|
requirement: !ruby/object:Gem::Requirement
|
83
83
|
requirements:
|
84
|
-
- - "
|
84
|
+
- - ">="
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 1.3
|
86
|
+
version: '1.3'
|
87
|
+
- - "<"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.1'
|
87
90
|
type: :runtime
|
88
91
|
prerelease: false
|
89
92
|
version_requirements: !ruby/object:Gem::Requirement
|
90
93
|
requirements:
|
91
|
-
- - "
|
94
|
+
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.3
|
96
|
+
version: '1.3'
|
97
|
+
- - "<"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.1'
|
94
100
|
- !ruby/object:Gem::Dependency
|
95
101
|
name: with_env
|
96
102
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,14 +187,14 @@ dependencies:
|
|
181
187
|
requirements:
|
182
188
|
- - "~>"
|
183
189
|
- !ruby/object:Gem::Version
|
184
|
-
version: 0.
|
190
|
+
version: 0.14.0
|
185
191
|
type: :development
|
186
192
|
prerelease: false
|
187
193
|
version_requirements: !ruby/object:Gem::Requirement
|
188
194
|
requirements:
|
189
195
|
- - "~>"
|
190
196
|
- !ruby/object:Gem::Version
|
191
|
-
version: 0.
|
197
|
+
version: 0.14.0
|
192
198
|
- !ruby/object:Gem::Dependency
|
193
199
|
name: rake
|
194
200
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,6 +279,20 @@ dependencies:
|
|
273
279
|
- - "~>"
|
274
280
|
- !ruby/object:Gem::Version
|
275
281
|
version: '3.5'
|
282
|
+
- !ruby/object:Gem::Dependency
|
283
|
+
name: nokogiri
|
284
|
+
requirement: !ruby/object:Gem::Requirement
|
285
|
+
requirements:
|
286
|
+
- - "~>"
|
287
|
+
- !ruby/object:Gem::Version
|
288
|
+
version: '1.10'
|
289
|
+
type: :development
|
290
|
+
prerelease: false
|
291
|
+
version_requirements: !ruby/object:Gem::Requirement
|
292
|
+
requirements:
|
293
|
+
- - "~>"
|
294
|
+
- !ruby/object:Gem::Version
|
295
|
+
version: '1.10'
|
276
296
|
- !ruby/object:Gem::Dependency
|
277
297
|
name: rack
|
278
298
|
requirement: !ruby/object:Gem::Requirement
|
@@ -351,6 +371,10 @@ files:
|
|
351
371
|
- ci/tasks/run-tests.yml
|
352
372
|
- ci/tasks/update-changelog.yml
|
353
373
|
- dlf
|
374
|
+
- examples/Gemfile
|
375
|
+
- examples/custom_erb_template.rb
|
376
|
+
- examples/extract_license_data.rb
|
377
|
+
- examples/sample_template.erb
|
354
378
|
- lib/license_finder.rb
|
355
379
|
- lib/license_finder/cli.rb
|
356
380
|
- lib/license_finder/cli/approvals.rb
|
@@ -413,6 +437,7 @@ files:
|
|
413
437
|
- lib/license_finder/package_managers/cocoa_pods.rb
|
414
438
|
- lib/license_finder/package_managers/composer.rb
|
415
439
|
- lib/license_finder/package_managers/conan.rb
|
440
|
+
- lib/license_finder/package_managers/conda.rb
|
416
441
|
- lib/license_finder/package_managers/dep.rb
|
417
442
|
- lib/license_finder/package_managers/dotnet.rb
|
418
443
|
- lib/license_finder/package_managers/erlangmk.rb
|
@@ -451,6 +476,7 @@ files:
|
|
451
476
|
- lib/license_finder/packages/cocoa_pods_package.rb
|
452
477
|
- lib/license_finder/packages/composer_package.rb
|
453
478
|
- lib/license_finder/packages/conan_package.rb
|
479
|
+
- lib/license_finder/packages/conda_package.rb
|
454
480
|
- lib/license_finder/packages/erlangmk_package.rb
|
455
481
|
- lib/license_finder/packages/go_package.rb
|
456
482
|
- lib/license_finder/packages/gradle_package.rb
|
@@ -472,10 +498,12 @@ files:
|
|
472
498
|
- lib/license_finder/reports/erb_report.rb
|
473
499
|
- lib/license_finder/reports/html_report.rb
|
474
500
|
- lib/license_finder/reports/json_report.rb
|
501
|
+
- lib/license_finder/reports/junit_report.rb
|
475
502
|
- lib/license_finder/reports/markdown_report.rb
|
476
503
|
- lib/license_finder/reports/merged_report.rb
|
477
504
|
- lib/license_finder/reports/templates/bootstrap.css
|
478
505
|
- lib/license_finder/reports/templates/html_report.erb
|
506
|
+
- lib/license_finder/reports/templates/junit_report.erb
|
479
507
|
- lib/license_finder/reports/templates/markdown_report.erb
|
480
508
|
- lib/license_finder/reports/templates/xml_report.erb
|
481
509
|
- lib/license_finder/reports/text_report.rb
|
@@ -505,7 +533,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
505
533
|
- !ruby/object:Gem::Version
|
506
534
|
version: '0'
|
507
535
|
requirements: []
|
508
|
-
rubygems_version: 3.
|
536
|
+
rubygems_version: 3.2.13
|
509
537
|
signing_key:
|
510
538
|
specification_version: 4
|
511
539
|
summary: Audit the OSS licenses of your application's dependencies.
|