license_finder 5.5.2 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +2 -0
- data/Dockerfile +12 -5
- data/README.md +2 -2
- data/Rakefile +24 -14
- data/lib/license_finder/cli/main.rb +3 -1
- data/lib/license_finder/package.rb +5 -0
- data/lib/license_finder/package_manager.rb +10 -2
- data/lib/license_finder/package_managers/dotnet.rb +82 -0
- data/lib/license_finder/package_managers/go_modules.rb +11 -17
- data/lib/license_finder/package_managers/go_workspace.rb +5 -2
- data/lib/license_finder/package_managers/gradle.rb +7 -0
- data/lib/license_finder/package_managers/npm.rb +1 -1
- data/lib/license_finder/package_managers/nuget.rb +8 -2
- data/lib/license_finder/package_utils/notice_files.rb +40 -0
- data/lib/license_finder/packages/merged_package.rb +1 -1
- data/lib/license_finder/project_finder.rb +0 -1
- data/lib/license_finder/report.rb +2 -0
- data/lib/license_finder/reports/csv_report.rb +9 -1
- data/lib/license_finder/reports/json_report.rb +28 -0
- data/lib/license_finder/reports/templates/xml_report.erb +19 -0
- data/lib/license_finder/reports/xml_report.rb +19 -0
- data/lib/license_finder/scanner.rb +1 -1
- data/lib/license_finder/version.rb +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6265bc6c40071582ff338579c90cef91431722b4eb3f8926ed99b8e95b651cd0
|
4
|
+
data.tar.gz: c9a797ef497cabb668299216bd332848f991539bee726afedd7e0abcbf897318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bbc661bf9b969a3e5deacde655e948877424baa2c602198740b35f9bbf3785392310012ab1a62229ba3012612a46ba47e6078e63701961d48cd0b9e98e29a69
|
7
|
+
data.tar.gz: b1c6470777caa3adc876c16d04344d97b07356309e1ae6245b15800f8dbdc6d466bd7bbfd1be58106ca5a5071dc06bd1d4cc878d09b9c47229da9e90b067a76e
|
data/CONTRIBUTING.md
CHANGED
@@ -89,6 +89,8 @@ To successfully run the test suite, you will need the following installed:
|
|
89
89
|
- Carthage (requires homebrew)
|
90
90
|
- Mix (requires Elixir)
|
91
91
|
- Conan
|
92
|
+
- NuGet
|
93
|
+
- dotnet
|
92
94
|
|
93
95
|
The [LicenseFinder docker image](https://hub.docker.com/r/licensefinder/license_finder/) already contains these dependencies.
|
94
96
|
|
data/Dockerfile
CHANGED
@@ -2,10 +2,10 @@ FROM ubuntu:xenial
|
|
2
2
|
|
3
3
|
# Versioning
|
4
4
|
ENV PIP_INSTALL_VERSION 10.0.1
|
5
|
-
ENV GO_LANG_VERSION 1.11
|
5
|
+
ENV GO_LANG_VERSION 1.11.2
|
6
6
|
ENV MAVEN_VERSION 3.5.3
|
7
7
|
ENV SBT_VERSION 1.1.1
|
8
|
-
ENV GRADLE_VERSION 4.
|
8
|
+
ENV GRADLE_VERSION 4.10
|
9
9
|
ENV RUBY_VERSION 2.5.1
|
10
10
|
ENV MIX_VERSION 1.0
|
11
11
|
|
@@ -35,10 +35,10 @@ RUN npm install -g bower && \
|
|
35
35
|
#install java 8
|
36
36
|
#http://askubuntu.com/questions/521145/how-to-install-oracle-java-on-ubuntu-14-04
|
37
37
|
RUN cd /tmp && \
|
38
|
-
wget --quiet --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/
|
38
|
+
wget --quiet --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u192-b12/750e1c8617c5452694857ad95c3ee230/jdk-8u192-linux-x64.tar.gz -O jdk-8.tgz && \
|
39
39
|
tar xf /tmp/jdk-8.tgz && \
|
40
40
|
mkdir -p /usr/lib/jvm && \
|
41
|
-
mv jdk1.8.
|
41
|
+
mv jdk1.8.0_192 /usr/lib/jvm/oracle_jdk8 && \
|
42
42
|
rm /tmp/jdk-8.tgz
|
43
43
|
|
44
44
|
ENV J2SDKDIR=/usr/lib/jvm/oracle_jdk8
|
@@ -106,7 +106,8 @@ ENV LANGUAGE=en_US:en
|
|
106
106
|
ENV LC_ALL=en_US.UTF-8
|
107
107
|
|
108
108
|
#install rvm
|
109
|
-
RUN
|
109
|
+
RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB && \
|
110
|
+
curl -sSL https://rvm.io/mpapis.asc | gpg --import && \
|
110
111
|
curl -sSL https://get.rvm.io | sudo bash -s stable --ruby=$RUBY_VERSION
|
111
112
|
ENV PATH=/usr/local/rvm/bin:$PATH
|
112
113
|
|
@@ -138,6 +139,12 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E03280
|
|
138
139
|
curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe &&\
|
139
140
|
echo "alias nuget=\"mono /usr/local/bin/nuget.exe\"" >> ~/.bash_aliases
|
140
141
|
|
142
|
+
# install dotnet core
|
143
|
+
RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb &&\
|
144
|
+
sudo dpkg -i packages-microsoft-prod.deb &&\
|
145
|
+
sudo apt-get update &&\
|
146
|
+
sudo apt-get install -y dotnet-runtime-2.1
|
147
|
+
|
141
148
|
# install license_finder
|
142
149
|
COPY . /LicenseFinder
|
143
150
|
RUN bash -lc "cd /LicenseFinder && bundle install -j4 && rake install"
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/pivotal-legacy/LicenseFinder.png)](https://codeclimate.com/github/pivotal-legacy/LicenseFinder)
|
4
4
|
|
5
5
|
Build status
|
6
|
-
* Ruby 2.3.
|
6
|
+
* Ruby 2.3.3 [![Ruby 2.3.3 build status](https://norsk.cf-app.com/api/v1/teams/main/pipelines/LicenseFinder/jobs/ruby-2.3.3/badge)](https://norsk.cf-app.com/teams/main/pipelines/LicenseFinder)
|
7
7
|
* Ruby 2.4.4 [![Ruby 2.4.4 build status](https://norsk.cf-app.com/api/v1/teams/main/pipelines/LicenseFinder/jobs/ruby-2.4.4/badge)](https://norsk.cf-app.com/teams/main/pipelines/LicenseFinder)
|
8
8
|
* Ruby 2.5.1 [![Ruby 2.5.1 build status](https://norsk.cf-app.com/api/v1/teams/main/pipelines/LicenseFinder/jobs/ruby-2.5.1/badge)](https://norsk.cf-app.com/teams/main/pipelines/LicenseFinder)
|
9
9
|
* JRuby 9.1.17.0 [![JRuby 9.1.17.0 build status](https://norsk.cf-app.com/api/v1/teams/main/pipelines/LicenseFinder/jobs/ruby-jruby-9.1.17.0/badge)](https://norsk.cf-app.com/teams/main/pipelines/LicenseFinder)
|
@@ -54,7 +54,7 @@ report.
|
|
54
54
|
|
55
55
|
## Installation
|
56
56
|
|
57
|
-
License Finder requires Ruby
|
57
|
+
License Finder requires Ruby 2.3.3 or greater to run. If you have an older
|
58
58
|
version of Ruby installed, you can update via Homebrew:
|
59
59
|
|
60
60
|
```sh
|
data/Rakefile
CHANGED
@@ -6,33 +6,42 @@ Bundler::GemHelper.install_tasks
|
|
6
6
|
require './lib/license_finder/platform'
|
7
7
|
require 'rspec/core/rake_task'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
RSpec::Core::RakeTask.new(:
|
9
|
+
namespace :spec do
|
10
|
+
desc 'Run test tagged \'focus\''
|
11
|
+
RSpec::Core::RakeTask.new(:focus) do |t|
|
12
12
|
t.fail_on_error = true
|
13
13
|
t.pattern = './spec/**/*_spec.rb'
|
14
|
-
t.rspec_opts = %w[--color]
|
14
|
+
t.rspec_opts = %w[--color --tag focus]
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
desc '
|
19
|
-
RSpec::Core::RakeTask.new(
|
18
|
+
desc 'Run all specs in spec/'
|
19
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
20
20
|
t.fail_on_error = true
|
21
|
-
t.pattern = './spec
|
21
|
+
t.pattern = './spec/**/*_spec.rb'
|
22
22
|
t.rspec_opts = %w[--color]
|
23
23
|
end
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
RSpec::Core::RakeTask.new(:
|
25
|
+
namespace :features do
|
26
|
+
desc 'Run test tagged \'focus\''
|
27
|
+
RSpec::Core::RakeTask.new(:focus) do |t|
|
28
28
|
t.fail_on_error = true
|
29
29
|
t.pattern = './features/**/*_spec.rb'
|
30
|
-
opts = %w[--color --format d]
|
30
|
+
opts = %w[--color --format d --tag focus]
|
31
31
|
opts += LicenseFinder::Platform.darwin? ? [] : %w[--tag ~ios]
|
32
32
|
t.rspec_opts = opts
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
desc 'Run all specs in features/'
|
37
|
+
RSpec::Core::RakeTask.new(:features) do |t|
|
38
|
+
t.fail_on_error = true
|
39
|
+
t.pattern = './features/**/*_spec.rb'
|
40
|
+
opts = %w[--color --format d]
|
41
|
+
opts += LicenseFinder::Platform.darwin? ? [] : %w[--tag ~ios]
|
42
|
+
t.rspec_opts = opts
|
43
|
+
end
|
44
|
+
|
36
45
|
desc 'Check for non-Ruby development dependencies.'
|
37
46
|
task :check_dependencies do
|
38
47
|
require './lib/license_finder'
|
@@ -54,7 +63,7 @@ task :update_pipeline, [:slack_url, :slack_channel] do |_, args|
|
|
54
63
|
puts 'Warning: You should provide slack channel and url to receive slack notifications on build failures'
|
55
64
|
end
|
56
65
|
|
57
|
-
ruby_versions = %w[2.5.1 2.4.4 2.3.
|
66
|
+
ruby_versions = %w[2.5.1 2.4.4 2.3.3 jruby-9.1.17.0 jruby-9.2.0.0]
|
58
67
|
|
59
68
|
params = []
|
60
69
|
params << "ruby_versions=#{ruby_versions.join(',')}"
|
@@ -77,7 +86,8 @@ task :update_release_pipeline do
|
|
77
86
|
system(cmd)
|
78
87
|
end
|
79
88
|
|
89
|
+
task default: %i[spec features]
|
80
90
|
task spec: :check_dependencies
|
81
91
|
task features: :check_dependencies
|
82
|
-
|
83
|
-
task
|
92
|
+
task 'spec:focus': :check_dependencies
|
93
|
+
task 'features:focus': :check_dependencies
|
@@ -16,7 +16,9 @@ module LicenseFinder
|
|
16
16
|
'text' => TextReport,
|
17
17
|
'html' => HtmlReport,
|
18
18
|
'markdown' => MarkdownReport,
|
19
|
-
'csv' => CsvReport
|
19
|
+
'csv' => CsvReport,
|
20
|
+
'xml' => XmlReport,
|
21
|
+
'json' => JsonReport
|
20
22
|
}.freeze
|
21
23
|
|
22
24
|
class_option :go_full_version, desc: 'Whether dependency version should include full version. Only meaningful if used with a Go project. Defaults to false.'
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'license_finder/package_utils/licensing'
|
4
4
|
require 'license_finder/package_utils/license_files'
|
5
|
+
require 'license_finder/package_utils/notice_files'
|
5
6
|
|
6
7
|
module LicenseFinder
|
7
8
|
# Super-class that adapts data from different package management
|
@@ -149,6 +150,10 @@ module LicenseFinder
|
|
149
150
|
LicenseFiles.find(install_path, logger: logger)
|
150
151
|
end
|
151
152
|
|
153
|
+
def notice_files
|
154
|
+
NoticeFiles.find(install_path, logger: logger)
|
155
|
+
end
|
156
|
+
|
152
157
|
def package_manager
|
153
158
|
'unknown'
|
154
159
|
end
|
@@ -80,7 +80,10 @@ module LicenseFinder
|
|
80
80
|
_stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(self.class.prepare_command) }
|
81
81
|
unless status.success?
|
82
82
|
log_errors stderr
|
83
|
-
|
83
|
+
|
84
|
+
error_message = "Prepare command '#{self.class.prepare_command}' failed\n#{stderr}"
|
85
|
+
|
86
|
+
raise error_message unless @prepare_no_fail
|
84
87
|
end
|
85
88
|
else
|
86
89
|
logger.debug self.class, 'no prepare step provided', color: :red
|
@@ -117,7 +120,11 @@ module LicenseFinder
|
|
117
120
|
|
118
121
|
def log_to_file(contents)
|
119
122
|
FileUtils.mkdir_p @log_directory
|
120
|
-
|
123
|
+
|
124
|
+
# replace whitespace with underscores and remove slashes
|
125
|
+
log_file_name = self.class.package_management_command&.gsub(/\s/, '_')&.gsub(%r{/}, '')
|
126
|
+
log_file = File.join(@log_directory, "prepare_#{log_file_name || 'errors'}.log")
|
127
|
+
|
121
128
|
File.open(log_file, 'w') do |f|
|
122
129
|
f.write("Prepare command \"#{self.class.prepare_command}\" failed with:\n")
|
123
130
|
f.write("#{contents}\n\n")
|
@@ -145,6 +152,7 @@ require 'license_finder/package_managers/carthage'
|
|
145
152
|
require 'license_finder/package_managers/gradle'
|
146
153
|
require 'license_finder/package_managers/rebar'
|
147
154
|
require 'license_finder/package_managers/nuget'
|
155
|
+
require 'license_finder/package_managers/dotnet'
|
148
156
|
require 'license_finder/package_managers/dep'
|
149
157
|
require 'license_finder/package_managers/conan'
|
150
158
|
require 'license_finder/package_managers/sbt'
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module LicenseFinder
|
7
|
+
class Dotnet < PackageManager
|
8
|
+
class AssetFile
|
9
|
+
def initialize(path)
|
10
|
+
@manifest = JSON.parse(File.read(path))
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependencies
|
14
|
+
libs = @manifest.fetch('libraries').reject do |_, v|
|
15
|
+
v.fetch('type') == 'project'
|
16
|
+
end
|
17
|
+
|
18
|
+
libs.keys.map do |name|
|
19
|
+
parts = name.split('/')
|
20
|
+
PackageMetadata.new(parts[0], parts[1], possible_spec_paths(name))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def possible_spec_paths(package_key)
|
25
|
+
lib = @manifest.fetch('libraries').fetch(package_key)
|
26
|
+
spec_filename = lib.fetch('files').find { |f| f.end_with?('.nuspec') }
|
27
|
+
return [] if spec_filename.nil?
|
28
|
+
|
29
|
+
@manifest.fetch('packageFolders').keys.map do |root|
|
30
|
+
Pathname(root).join(lib.fetch('path'), spec_filename).to_s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class PackageMetadata
|
36
|
+
attr_reader :name, :version, :possible_spec_paths
|
37
|
+
|
38
|
+
def initialize(name, version, possible_spec_paths)
|
39
|
+
@name = name
|
40
|
+
@version = version
|
41
|
+
@possible_spec_paths = possible_spec_paths
|
42
|
+
end
|
43
|
+
|
44
|
+
def read_license_urls
|
45
|
+
possible_spec_paths.flat_map do |path|
|
46
|
+
Nuget.nuspec_license_urls(File.read(path)) if File.exist? path
|
47
|
+
end.compact
|
48
|
+
end
|
49
|
+
|
50
|
+
def ==(other)
|
51
|
+
other.name == name && other.version == version && other.possible_spec_paths == possible_spec_paths
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def possible_package_paths
|
56
|
+
paths = Dir[project_path.join('**/*.csproj')]
|
57
|
+
paths.map { |p| Pathname(p) }
|
58
|
+
end
|
59
|
+
|
60
|
+
def current_packages
|
61
|
+
package_metadatas = asset_files
|
62
|
+
.flat_map { |path| AssetFile.new(path).dependencies }
|
63
|
+
.uniq { |d| [d.name, d.version] }
|
64
|
+
|
65
|
+
package_metadatas.map do |d|
|
66
|
+
NugetPackage.new(d.name, d.version, spec_licenses: d.read_license_urls)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def asset_files
|
71
|
+
Dir[project_path.join('**/project.assets.json')]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.package_management_command
|
75
|
+
'dotnet'
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.prepare_command
|
79
|
+
"#{package_management_command} restore"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -21,9 +21,16 @@ module LicenseFinder
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def current_packages
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
info_output, _stderr, _status = Cmd.run("GO111MODULE=on go list -m -mod=vendor -f '{{.Path}},{{.Version}},{{.Dir}}' all")
|
25
|
+
packages_info = info_output.split("\n")
|
26
|
+
packages = packages_info.map do |package|
|
27
|
+
name, version, install_path = package.split(',')
|
28
|
+
read_package(install_path, name, version)
|
29
|
+
end
|
30
|
+
packages.reject do |package|
|
31
|
+
Pathname(package.install_path).cleanpath == Pathname(project_path).cleanpath
|
32
|
+
end
|
33
|
+
# binding.pry
|
27
34
|
end
|
28
35
|
|
29
36
|
private
|
@@ -36,20 +43,7 @@ module LicenseFinder
|
|
36
43
|
Dir[project_path.join(PACKAGES_FILE)]
|
37
44
|
end
|
38
45
|
|
39
|
-
def
|
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
|
-
|
46
|
+
def read_package(install_path, name, version)
|
53
47
|
info = {
|
54
48
|
'ImportPath' => name,
|
55
49
|
'InstallPath' => install_path,
|
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'json'
|
4
4
|
module LicenseFinder
|
5
|
+
class GoWorkspacePackageManagerError < ::StandardError
|
6
|
+
end
|
7
|
+
|
5
8
|
class GoWorkspace < PackageManager
|
6
9
|
Submodule = Struct.new :install_path, :revision
|
7
10
|
ENVRC_REGEXP = /GOPATH|GO15VENDOREXPERIMENT/
|
@@ -77,9 +80,9 @@ module LicenseFinder
|
|
77
80
|
# with status code 1. Setting GOPATH to nil removes those warnings.
|
78
81
|
orig_gopath = ENV['GOPATH']
|
79
82
|
ENV['GOPATH'] = nil
|
80
|
-
val,
|
83
|
+
val, stderr, status = Cmd.run('go list -f "{{join .Deps \"\n\"}}" ./...')
|
81
84
|
ENV['GOPATH'] = orig_gopath
|
82
|
-
raise
|
85
|
+
raise GoWorkspacePackageManagerError, "go list failed:\n#{stderr}" unless status.success?
|
83
86
|
|
84
87
|
# Select non-standard packages. `go list std` returns the list of standard
|
85
88
|
# dependencies. We then filter those dependencies out of the full list of
|
@@ -48,6 +48,13 @@ module LicenseFinder
|
|
48
48
|
alternate_build_file = build_file_from_settings(project_path)
|
49
49
|
return alternate_build_file if alternate_build_file
|
50
50
|
|
51
|
+
build_gradle_file
|
52
|
+
end
|
53
|
+
|
54
|
+
def build_gradle_file
|
55
|
+
kotlin_gradle_path = project_path.join('build.gradle.kts')
|
56
|
+
return kotlin_gradle_path if File.exist? kotlin_gradle_path
|
57
|
+
|
51
58
|
project_path.join('build.gradle')
|
52
59
|
end
|
53
60
|
|
@@ -63,8 +63,7 @@ module LicenseFinder
|
|
63
63
|
file = files.first
|
64
64
|
Zip::File.open file do |zipfile|
|
65
65
|
content = zipfile.read(dep.name + '.nuspec')
|
66
|
-
|
67
|
-
REXML::XPath.match(xml, '//metadata//licenseUrl').map(&:get_text).map(&:to_s)
|
66
|
+
Nuget.nuspec_license_urls(content)
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
@@ -97,5 +96,12 @@ module LicenseFinder
|
|
97
96
|
|
98
97
|
'which mono && ls /usr/local/bin/nuget.exe'
|
99
98
|
end
|
99
|
+
|
100
|
+
def self.nuspec_license_urls(specfile_content)
|
101
|
+
xml = REXML::Document.new(specfile_content)
|
102
|
+
REXML::XPath.match(xml, '//metadata//licenseUrl')
|
103
|
+
.map(&:get_text)
|
104
|
+
.map(&:to_s)
|
105
|
+
end
|
100
106
|
end
|
101
107
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'license_finder/package_utils/possible_license_file'
|
4
|
+
|
5
|
+
module LicenseFinder
|
6
|
+
class NoticeFiles
|
7
|
+
CANDIDATE_FILE_NAMES = %w[NOTICE Notice].freeze
|
8
|
+
CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*"
|
9
|
+
|
10
|
+
def self.find(install_path, options = {})
|
11
|
+
new(install_path).find(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(install_path)
|
15
|
+
@install_path = install_path ? Pathname(install_path) : nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def find(options = {})
|
19
|
+
paths_of_candidate_files
|
20
|
+
.map { |path| PossibleLicenseFile.new(path, options) } # Not really possible license files, but that class has all we need.
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :install_path
|
26
|
+
|
27
|
+
def paths_of_candidate_files
|
28
|
+
candidate_files_and_dirs
|
29
|
+
.flat_map { |path| path.directory? ? path.children : path }
|
30
|
+
.reject(&:directory?)
|
31
|
+
.uniq
|
32
|
+
end
|
33
|
+
|
34
|
+
def candidate_files_and_dirs
|
35
|
+
return [] if install_path.nil?
|
36
|
+
|
37
|
+
Pathname.glob(install_path.join('**', CANDIDATE_PATH_WILDCARD))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -15,7 +15,7 @@ module LicenseFinder
|
|
15
15
|
:groups, :whitelisted, :blacklisted, :manual_approval, :install_path, :licenses, :approved_manually?,
|
16
16
|
:approved_manually!, :approved?, :whitelisted!, :whitelisted?, :blacklisted!, :blacklisted?, :hash,
|
17
17
|
:activations, :missing, :license_names_from_spec, :decided_licenses, :licensing, :decide_on_license,
|
18
|
-
:license_files, :package_manager, :missing?, :log_activation
|
18
|
+
:license_files, :package_manager, :missing?, :log_activation, :notice_files
|
19
19
|
|
20
20
|
def aggregate_paths
|
21
21
|
@aggregate_paths.map { |p| p.expand_path.to_s }
|
@@ -28,3 +28,5 @@ require 'license_finder/reports/diff_report'
|
|
28
28
|
require 'license_finder/reports/merged_report'
|
29
29
|
require 'license_finder/reports/html_report'
|
30
30
|
require 'license_finder/reports/markdown_report'
|
31
|
+
require 'license_finder/reports/xml_report'
|
32
|
+
require 'license_finder/reports/json_report'
|
@@ -3,7 +3,7 @@ require 'csv'
|
|
3
3
|
module LicenseFinder
|
4
4
|
class CsvReport < Report
|
5
5
|
COMMA_SEP = ','.freeze
|
6
|
-
AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups].freeze
|
6
|
+
AVAILABLE_COLUMNS = %w[name version authors licenses license_links approved summary description homepage install_path package_manager groups texts notice].freeze
|
7
7
|
MISSING_DEPENDENCY_TEXT = 'This package is not installed. Please install to determine licenses.'.freeze
|
8
8
|
|
9
9
|
def initialize(dependencies, options)
|
@@ -28,6 +28,14 @@ module LicenseFinder
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
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")
|
33
|
+
end
|
34
|
+
|
35
|
+
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")
|
37
|
+
end
|
38
|
+
|
31
39
|
def format_name(dep)
|
32
40
|
dep.name
|
33
41
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'csv'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class JsonReport < CsvReport
|
5
|
+
def initialize(dependencies, options)
|
6
|
+
super(dependencies, options)
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
{dependencies: build_deps}.to_json
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build_deps
|
16
|
+
sorted_dependencies.map do |dep|
|
17
|
+
@columns.inject({}) do |memo, column|
|
18
|
+
memo[column] = send("format_#{column}", dep)
|
19
|
+
memo
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def format_licenses(dep)
|
25
|
+
dep.missing? ? [] : dep.licenses.map(&:name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<licenseSummary>
|
3
|
+
<dependencies>
|
4
|
+
<% sorted_dependencies.each do |dependency| -%>
|
5
|
+
<dependency>
|
6
|
+
<packageName><%= dependency.name %></packageName>
|
7
|
+
<version><%= dependency.version %></version>
|
8
|
+
<licenses>
|
9
|
+
<% dependency.licenses.each do |license| -%>
|
10
|
+
<license>
|
11
|
+
<name><%= license.name %></name>
|
12
|
+
<url><%= license.url %></url>
|
13
|
+
</license>
|
14
|
+
<% end -%>
|
15
|
+
</licenses>
|
16
|
+
</dependency>
|
17
|
+
<% end -%>
|
18
|
+
</dependencies>
|
19
|
+
</licenseSummary>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'license_finder/reports/erb_report'
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class XmlReport < 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
|
+
'xml_report'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module LicenseFinder
|
4
4
|
class Scanner
|
5
5
|
PACKAGE_MANAGERS = [GoModules, GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Dep, Bundler, NPM, Pip,
|
6
|
-
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo].freeze
|
6
|
+
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet].freeze
|
7
7
|
|
8
8
|
def initialize(config = { project_path: Pathname.new('') })
|
9
9
|
@config = config
|
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.
|
4
|
+
version: 5.6.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: 2018-
|
30
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
31
31
|
dependencies:
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: bundler
|
@@ -379,6 +379,7 @@ files:
|
|
379
379
|
- lib/license_finder/package_managers/cocoa_pods.rb
|
380
380
|
- lib/license_finder/package_managers/conan.rb
|
381
381
|
- lib/license_finder/package_managers/dep.rb
|
382
|
+
- lib/license_finder/package_managers/dotnet.rb
|
382
383
|
- lib/license_finder/package_managers/glide.rb
|
383
384
|
- lib/license_finder/package_managers/go_15vendorexperiment.rb
|
384
385
|
- lib/license_finder/package_managers/go_dep.rb
|
@@ -401,6 +402,7 @@ files:
|
|
401
402
|
- lib/license_finder/package_utils/license_files.rb
|
402
403
|
- lib/license_finder/package_utils/licensing.rb
|
403
404
|
- lib/license_finder/package_utils/maven_dependency_finder.rb
|
405
|
+
- lib/license_finder/package_utils/notice_files.rb
|
404
406
|
- lib/license_finder/package_utils/possible_license_file.rb
|
405
407
|
- lib/license_finder/package_utils/sbt_dependency_finder.rb
|
406
408
|
- lib/license_finder/packages/bower_package.rb
|
@@ -428,12 +430,15 @@ files:
|
|
428
430
|
- lib/license_finder/reports/diff_report.rb
|
429
431
|
- lib/license_finder/reports/erb_report.rb
|
430
432
|
- lib/license_finder/reports/html_report.rb
|
433
|
+
- lib/license_finder/reports/json_report.rb
|
431
434
|
- lib/license_finder/reports/markdown_report.rb
|
432
435
|
- lib/license_finder/reports/merged_report.rb
|
433
436
|
- lib/license_finder/reports/templates/bootstrap.css
|
434
437
|
- lib/license_finder/reports/templates/html_report.erb
|
435
438
|
- lib/license_finder/reports/templates/markdown_report.erb
|
439
|
+
- lib/license_finder/reports/templates/xml_report.erb
|
436
440
|
- lib/license_finder/reports/text_report.rb
|
441
|
+
- lib/license_finder/reports/xml_report.rb
|
437
442
|
- lib/license_finder/scanner.rb
|
438
443
|
- lib/license_finder/shared_helpers/cmd.rb
|
439
444
|
- lib/license_finder/shared_helpers/common_path.rb
|
@@ -459,8 +464,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
459
464
|
- !ruby/object:Gem::Version
|
460
465
|
version: '0'
|
461
466
|
requirements: []
|
462
|
-
|
463
|
-
rubygems_version: 2.7.7
|
467
|
+
rubygems_version: 3.0.0
|
464
468
|
signing_key:
|
465
469
|
specification_version: 4
|
466
470
|
summary: Audit the OSS licenses of your application's dependencies.
|