license_scout 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +13 -5
- data/bin/license_scout +39 -1
- data/bin/rebar_lock_json +0 -0
- data/erl_src/rebar_lock_json/README.md +17 -0
- data/erl_src/rebar_lock_json/rebar.config +19 -0
- data/erl_src/rebar_lock_json/rebar.lock +36 -0
- data/erl_src/rebar_lock_json/src/rebar_lock_json.app.src +17 -0
- data/erl_src/rebar_lock_json/src/rebar_lock_json.erl +20 -0
- data/lib/license_scout/canonical_licenses/BSD-2-Clause.txt +19 -0
- data/lib/license_scout/canonical_licenses/BSD-3-Clause.txt +27 -0
- data/lib/license_scout/canonical_licenses/Chef-MLSA.txt +5 -0
- data/lib/license_scout/collector.rb +1 -1
- data/lib/license_scout/dependency_manager/base.rb +8 -1
- data/lib/license_scout/dependency_manager/berkshelf.rb +1 -1
- data/lib/license_scout/dependency_manager/bundler.rb +1 -1
- data/lib/license_scout/dependency_manager/cpanm.rb +160 -0
- data/lib/license_scout/dependency_manager/dep.rb +87 -0
- data/lib/license_scout/dependency_manager/glide.rb +79 -0
- data/lib/license_scout/dependency_manager/godep.rb +71 -0
- data/lib/license_scout/dependency_manager/rebar.rb +6 -35
- data/lib/license_scout/dependency_manager.rb +5 -2
- data/lib/license_scout/license_file_analyzer/definitions.rb +8 -1
- data/lib/license_scout/license_file_analyzer/templates/Apache2.txt +0 -2
- data/lib/license_scout/license_file_analyzer/templates/Chef-MLSA.txt +5 -0
- data/lib/license_scout/net_fetcher.rb +1 -0
- data/lib/license_scout/options.rb +1 -1
- data/lib/license_scout/overrides.rb +553 -19
- data/lib/license_scout/version.rb +1 -1
- metadata +45 -13
- data/.gitignore +0 -9
- data/.rspec +0 -3
- data/.rubocop.yml +0 -4
- data/.travis.yml +0 -11
- data/Gemfile +0 -24
- data/Rakefile +0 -39
- data/appveyor.yml +0 -19
- data/bin/config_to_json +0 -0
- data/lib/license_scout/dependency_manager/cpan.rb +0 -322
- data/license_scout.gemspec +0 -54
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: license_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serdar Sutay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi-yajl
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: toml-rb
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +122,20 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: chefstyle
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: berkshelf
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,19 +158,20 @@ executables:
|
|
130
158
|
extensions: []
|
131
159
|
extra_rdoc_files: []
|
132
160
|
files:
|
133
|
-
- ".gitignore"
|
134
|
-
- ".rspec"
|
135
|
-
- ".rubocop.yml"
|
136
|
-
- ".travis.yml"
|
137
|
-
- Gemfile
|
138
161
|
- LICENSE
|
139
162
|
- README.md
|
140
|
-
- Rakefile
|
141
|
-
- appveyor.yml
|
142
|
-
- bin/config_to_json
|
143
163
|
- bin/license_scout
|
164
|
+
- bin/rebar_lock_json
|
165
|
+
- erl_src/rebar_lock_json/README.md
|
166
|
+
- erl_src/rebar_lock_json/rebar.config
|
167
|
+
- erl_src/rebar_lock_json/rebar.lock
|
168
|
+
- erl_src/rebar_lock_json/src/rebar_lock_json.app.src
|
169
|
+
- erl_src/rebar_lock_json/src/rebar_lock_json.erl
|
144
170
|
- lib/license_scout.rb
|
171
|
+
- lib/license_scout/canonical_licenses/BSD-2-Clause.txt
|
172
|
+
- lib/license_scout/canonical_licenses/BSD-3-Clause.txt
|
145
173
|
- lib/license_scout/canonical_licenses/BSD-4-Clause.txt
|
174
|
+
- lib/license_scout/canonical_licenses/Chef-MLSA.txt
|
146
175
|
- lib/license_scout/canonical_licenses/ISC.txt
|
147
176
|
- lib/license_scout/canonical_licenses/MIT.txt
|
148
177
|
- lib/license_scout/collector.rb
|
@@ -153,7 +182,10 @@ files:
|
|
153
182
|
- lib/license_scout/dependency_manager/bundler.rb
|
154
183
|
- lib/license_scout/dependency_manager/bundler/LICENSE.md
|
155
184
|
- lib/license_scout/dependency_manager/bundler/_bundler_script.rb
|
156
|
-
- lib/license_scout/dependency_manager/
|
185
|
+
- lib/license_scout/dependency_manager/cpanm.rb
|
186
|
+
- lib/license_scout/dependency_manager/dep.rb
|
187
|
+
- lib/license_scout/dependency_manager/glide.rb
|
188
|
+
- lib/license_scout/dependency_manager/godep.rb
|
157
189
|
- lib/license_scout/dependency_manager/json/README.md
|
158
190
|
- lib/license_scout/dependency_manager/manual.rb
|
159
191
|
- lib/license_scout/dependency_manager/npm.rb
|
@@ -172,6 +204,7 @@ files:
|
|
172
204
|
- lib/license_scout/license_file_analyzer/templates/BSD-3-Clause-alt-format.txt
|
173
205
|
- lib/license_scout/license_file_analyzer/templates/BSD-3-Clause.txt
|
174
206
|
- lib/license_scout/license_file_analyzer/templates/BSD.txt
|
207
|
+
- lib/license_scout/license_file_analyzer/templates/Chef-MLSA.txt
|
175
208
|
- lib/license_scout/license_file_analyzer/templates/EPLICENSE.txt
|
176
209
|
- lib/license_scout/license_file_analyzer/templates/GPL-2.0.txt
|
177
210
|
- lib/license_scout/license_file_analyzer/templates/GPL-3.0.txt
|
@@ -187,7 +220,6 @@ files:
|
|
187
220
|
- lib/license_scout/overrides.rb
|
188
221
|
- lib/license_scout/reporter.rb
|
189
222
|
- lib/license_scout/version.rb
|
190
|
-
- license_scout.gemspec
|
191
223
|
homepage: https://github.com/chef/license_scout
|
192
224
|
licenses:
|
193
225
|
- Apache-2.0
|
@@ -208,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
208
240
|
version: '0'
|
209
241
|
requirements: []
|
210
242
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.
|
243
|
+
rubygems_version: 2.7.4
|
212
244
|
signing_key:
|
213
245
|
specification_version: 4
|
214
246
|
summary: Discovers license files of a project's dependencies.
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright 2016, Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
source "https://rubygems.org"
|
19
|
-
|
20
|
-
gemspec
|
21
|
-
|
22
|
-
group(:development, :test) do
|
23
|
-
gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
|
24
|
-
end
|
data/Rakefile
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright 2016, Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "bundler/gem_tasks"
|
19
|
-
require "rspec/core/rake_task"
|
20
|
-
|
21
|
-
task default: :test
|
22
|
-
|
23
|
-
desc "Run specs"
|
24
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
25
|
-
spec.pattern = "spec/**/*_spec.rb"
|
26
|
-
end
|
27
|
-
|
28
|
-
begin
|
29
|
-
require "chefstyle"
|
30
|
-
require "rubocop/rake_task"
|
31
|
-
RuboCop::RakeTask.new(:style) do |task|
|
32
|
-
task.options += ["--display-cop-names", "--no-color"]
|
33
|
-
end
|
34
|
-
rescue LoadError
|
35
|
-
puts "chefstyle/rubocop is not available. gem install chefstyle to do style checking."
|
36
|
-
end
|
37
|
-
|
38
|
-
desc "Run all tests"
|
39
|
-
task test: [:style, :spec]
|
data/appveyor.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
os: Windows Server 2012 R2
|
2
|
-
platform:
|
3
|
-
- x64
|
4
|
-
|
5
|
-
skip_tags: true
|
6
|
-
branches:
|
7
|
-
only:
|
8
|
-
- master
|
9
|
-
|
10
|
-
install:
|
11
|
-
- set PATH=C:\Ruby22\bin;%PATH%
|
12
|
-
- appveyor DownloadFile http://curl.haxx.se/ca/cacert.pem -FileName C:\cacert.pem
|
13
|
-
- set SSL_CERT_FILE=C:\cacert.pem
|
14
|
-
|
15
|
-
build_script:
|
16
|
-
- bundle install || bundle install || bundle install
|
17
|
-
|
18
|
-
test_script:
|
19
|
-
- bundle exec rake spec
|
data/bin/config_to_json
DELETED
Binary file
|
@@ -1,322 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright 2016, Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
require "rexml/document"
|
19
|
-
|
20
|
-
require "ffi_yajl"
|
21
|
-
require "psych"
|
22
|
-
require "mixlib/shellout"
|
23
|
-
|
24
|
-
require "license_scout/dependency_manager/base"
|
25
|
-
require "license_scout/net_fetcher"
|
26
|
-
require "license_scout/exceptions"
|
27
|
-
require "license_scout/dependency"
|
28
|
-
|
29
|
-
module LicenseScout
|
30
|
-
module DependencyManager
|
31
|
-
class CPAN < Base
|
32
|
-
|
33
|
-
class CPANDependency
|
34
|
-
|
35
|
-
LICENSE_TYPE_MAP = {
|
36
|
-
"perl_5" => "Perl-5",
|
37
|
-
"perl" => "Perl-5",
|
38
|
-
"apache_2_0" => "Apache-2.0",
|
39
|
-
"artistic_2" => "Artistic-2.0",
|
40
|
-
"gpl_3" => "GPL-3.0",
|
41
|
-
}.freeze
|
42
|
-
|
43
|
-
attr_reader :module_name
|
44
|
-
attr_reader :dist
|
45
|
-
attr_reader :version
|
46
|
-
attr_reader :cpanfile
|
47
|
-
|
48
|
-
attr_reader :license_files
|
49
|
-
attr_reader :license
|
50
|
-
|
51
|
-
attr_reader :cache_root
|
52
|
-
|
53
|
-
attr_reader :overrides
|
54
|
-
|
55
|
-
def initialize(module_name:, dist:, version:, cpanfile:, cache_root:, overrides:)
|
56
|
-
@module_name = module_name
|
57
|
-
@dist = dist
|
58
|
-
@version = version
|
59
|
-
@cpanfile = cpanfile
|
60
|
-
@cache_root = cache_root
|
61
|
-
@overrides = overrides
|
62
|
-
|
63
|
-
@deps_list = nil
|
64
|
-
|
65
|
-
@license = nil
|
66
|
-
@license_files = []
|
67
|
-
end
|
68
|
-
|
69
|
-
def desc
|
70
|
-
"#{module_name} in #{dist} (#{version}) [#{license}]"
|
71
|
-
end
|
72
|
-
|
73
|
-
def to_dep
|
74
|
-
Dependency.new(
|
75
|
-
# we use dist for the name because there can be multiple modules in
|
76
|
-
# a dist, but the dist is the unit of packaging and licensing
|
77
|
-
dist,
|
78
|
-
version,
|
79
|
-
license,
|
80
|
-
license_files,
|
81
|
-
"perl_cpan"
|
82
|
-
)
|
83
|
-
end
|
84
|
-
|
85
|
-
def collect_licenses
|
86
|
-
ensure_cached
|
87
|
-
Dir.mktmpdir do |tmpdir|
|
88
|
-
FileUtils.cp(distribution_fullpath, tmpdir)
|
89
|
-
Dir.chdir(tmpdir) do
|
90
|
-
untar!
|
91
|
-
distribution_unpack_fullpath = File.join(tmpdir, distribution_unpack_relpath)
|
92
|
-
collect_licenses_in(distribution_unpack_fullpath)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def ensure_cached
|
98
|
-
cache_path = File.join(dist_cache_root, cpanfile)
|
99
|
-
|
100
|
-
# CPAN download URL is like:
|
101
|
-
# http://www.cpan.org/authors/id/R/RJ/RJBS/Sub-Install-0.928.tar.gz
|
102
|
-
# cpanfile is like:
|
103
|
-
# R/RJ/RJBS/Sub-Install-0.928.tar.gz
|
104
|
-
unless File.exist?(cache_path)
|
105
|
-
|
106
|
-
url = "http://www.cpan.org/authors/id/#{cpanfile}"
|
107
|
-
tmp_path = NetFetcher.cache(url)
|
108
|
-
|
109
|
-
FileUtils.mkdir_p(File.dirname(cache_path))
|
110
|
-
FileUtils.cp(tmp_path, cache_path)
|
111
|
-
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def distribution_filename
|
116
|
-
File.basename(cpanfile)
|
117
|
-
end
|
118
|
-
|
119
|
-
def distribution_unpack_relpath
|
120
|
-
# Most packages have tar.gz extension but some have .tgz like
|
121
|
-
# IO-Pager-0.36.tgz
|
122
|
-
[".tar.gz", ".tgz"].each do |ext|
|
123
|
-
if distribution_filename.end_with?(ext)
|
124
|
-
return File.basename(distribution_filename, ext)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def distribution_fullpath
|
130
|
-
File.join(dist_cache_root, cpanfile)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Untar the distribution.
|
134
|
-
#
|
135
|
-
# NOTE: On some platforms, you only get a usable version of tar as
|
136
|
-
# `gtar`, and on windows, symlinks break a lot of stuff. We (Chef
|
137
|
-
# Software) currently only use perl in server products, which we only
|
138
|
-
# build for a handful of Linux distros, so this is sufficient.
|
139
|
-
def untar!
|
140
|
-
s = Mixlib::ShellOut.new("tar zxf #{distribution_filename}")
|
141
|
-
s.run_command
|
142
|
-
s.error!
|
143
|
-
s.stdout
|
144
|
-
end
|
145
|
-
|
146
|
-
def collect_licenses_in(unpack_path)
|
147
|
-
collect_license_info_in(unpack_path)
|
148
|
-
collect_license_files_info_in(unpack_path)
|
149
|
-
end
|
150
|
-
|
151
|
-
def collect_license_info_in(unpack_path)
|
152
|
-
# Notice that we use "dist" as the dependency name
|
153
|
-
# See #to_dep for details.
|
154
|
-
@license = overrides.license_for("perl_cpan", dist, version) || begin
|
155
|
-
metadata = if File.exist?(meta_json_in(unpack_path))
|
156
|
-
slurp_meta_json_in(unpack_path)
|
157
|
-
elsif File.exist?(meta_yaml_in(unpack_path))
|
158
|
-
slurp_meta_yaml_in(unpack_path)
|
159
|
-
end
|
160
|
-
|
161
|
-
if metadata && metadata.key?("license")
|
162
|
-
given_type = Array(metadata["license"]).reject { |l| l == "unknown" }.first
|
163
|
-
normalize_license_type(given_type)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
def collect_license_files_info_in(unpack_path)
|
169
|
-
override_license_files = overrides.license_files_for("perl_cpan", dist, version)
|
170
|
-
|
171
|
-
license_files = if override_license_files.empty?
|
172
|
-
find_license_files_in(unpack_path)
|
173
|
-
else
|
174
|
-
override_license_files.resolve_locations(unpack_path)
|
175
|
-
end
|
176
|
-
|
177
|
-
license_files.each do |f|
|
178
|
-
@license_files << cache_license_file(f)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
# Copy license file to the cache. We unpack the CPAN dists in a tempdir
|
183
|
-
# and throw it away after we've inspected the contents, so we need to
|
184
|
-
# put the license file somewhere it can be copied from later.
|
185
|
-
def cache_license_file(unpacked_file)
|
186
|
-
basename = File.basename(unpacked_file)
|
187
|
-
license_cache_path = File.join(license_cache_root, "#{dist}-#{basename}")
|
188
|
-
FileUtils.mkdir_p(license_cache_root)
|
189
|
-
FileUtils.cp(unpacked_file, license_cache_path)
|
190
|
-
# In some cases, the license files get unpacked with 0444
|
191
|
-
# permissions which could make a re-run fail on the `cp` step.
|
192
|
-
FileUtils.chmod(0644, license_cache_path)
|
193
|
-
license_cache_path
|
194
|
-
end
|
195
|
-
|
196
|
-
def slurp_meta_yaml_in(unpack_path)
|
197
|
-
Psych.safe_load(File.read(meta_yaml_in(unpack_path)))
|
198
|
-
end
|
199
|
-
|
200
|
-
def slurp_meta_json_in(unpack_path)
|
201
|
-
FFI_Yajl::Parser.parse(File.read(meta_json_in(unpack_path)))
|
202
|
-
end
|
203
|
-
|
204
|
-
def license_cache_root
|
205
|
-
File.join(cache_root, "cpan-licenses")
|
206
|
-
end
|
207
|
-
|
208
|
-
def dist_cache_root
|
209
|
-
File.join(cache_root, "cpan-dists")
|
210
|
-
end
|
211
|
-
|
212
|
-
def normalize_license_type(given_type)
|
213
|
-
LICENSE_TYPE_MAP[given_type] || given_type
|
214
|
-
end
|
215
|
-
|
216
|
-
def meta_json_in(unpack_path)
|
217
|
-
File.join(unpack_path, "META.json")
|
218
|
-
end
|
219
|
-
|
220
|
-
def mymeta_json_in(unpack_path)
|
221
|
-
File.join(unpack_path, "MYMETA.json")
|
222
|
-
end
|
223
|
-
|
224
|
-
def meta_yaml_in(unpack_path)
|
225
|
-
File.join(unpack_path, "META.yml")
|
226
|
-
end
|
227
|
-
|
228
|
-
def find_license_files_in(unpack_path)
|
229
|
-
Dir["#{unpack_path}/*"].select do |f|
|
230
|
-
CPAN::POSSIBLE_LICENSE_FILES.include?(File.basename(f))
|
231
|
-
end
|
232
|
-
end
|
233
|
-
|
234
|
-
end
|
235
|
-
|
236
|
-
def initialize(*args, &block)
|
237
|
-
super
|
238
|
-
@dependencies = nil
|
239
|
-
end
|
240
|
-
|
241
|
-
def name
|
242
|
-
"perl_cpan"
|
243
|
-
end
|
244
|
-
|
245
|
-
def dependencies
|
246
|
-
return @dependencies if @dependencies
|
247
|
-
@dependencies = deps_list.map do |d|
|
248
|
-
d.collect_licenses
|
249
|
-
d.to_dep
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
def deps_list
|
254
|
-
return @deps_list if @deps_list
|
255
|
-
|
256
|
-
xml_doc = REXML::Document.new(dependency_graph_xml)
|
257
|
-
|
258
|
-
root = xml_doc.root
|
259
|
-
|
260
|
-
deps = root.get_elements("//dependency")
|
261
|
-
|
262
|
-
@deps_list = []
|
263
|
-
|
264
|
-
deps.each do |dep|
|
265
|
-
dep_module_name = dep.get_text("module").to_s
|
266
|
-
next if dep_module_name == module_name
|
267
|
-
@deps_list << CPANDependency.new(
|
268
|
-
module_name: dep_module_name,
|
269
|
-
dist: dep.get_text("dist").to_s,
|
270
|
-
version: dep.get_text("distversion").to_s,
|
271
|
-
cpanfile: dep.get_text("cpanfile").to_s,
|
272
|
-
cache_root: options.cpan_cache,
|
273
|
-
overrides: options.overrides
|
274
|
-
)
|
275
|
-
end
|
276
|
-
|
277
|
-
@deps_list
|
278
|
-
end
|
279
|
-
|
280
|
-
def dependency_graph_xml
|
281
|
-
@dependency_graph_xml ||=
|
282
|
-
begin
|
283
|
-
dependency_graph_xml_file = NetFetcher.cache(dependency_graph_url)
|
284
|
-
raw_xml = File.read(dependency_graph_xml_file)
|
285
|
-
FileUtils.rm_f(dependency_graph_xml_file)
|
286
|
-
raw_xml
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
# NOTE: there's no SSL version available. Take care handling any
|
291
|
-
# data/code referenced in responses from this site.
|
292
|
-
def dependency_graph_url
|
293
|
-
"http://deps.cpantesters.org/?xml=1;module=#{module_name};perl=5.24.0;os=any%20OS;pureperl=0"
|
294
|
-
end
|
295
|
-
|
296
|
-
# Infers the module name from the directory name. For Chef Server, the
|
297
|
-
# two perl packages we use are:
|
298
|
-
# * "App-Sqitch-VERSION" => "App::Sqitch"
|
299
|
-
# * "DBD-Pg-VERSION" => "DBD::Pg"
|
300
|
-
#
|
301
|
-
# NOTE: Distributions may contain multiple modules that would each have
|
302
|
-
# their own dependency graphs and it's possible to get a perl project
|
303
|
-
# that doesn't obey this convention (e.g., if you git clone it). But this
|
304
|
-
# meets our immediate needs.
|
305
|
-
def module_name
|
306
|
-
File.basename(project_dir).split("-")[0...-1].join("::")
|
307
|
-
end
|
308
|
-
|
309
|
-
# NOTE: it's possible that projects won't have a META.yml, but the two
|
310
|
-
# that we care about for Chef Server do have one. As of 2015, 84% of perl
|
311
|
-
# distribution packages have one: http://neilb.org/2015/10/18/spotters-guide.html
|
312
|
-
def detected?
|
313
|
-
File.exist?(meta_yml_path)
|
314
|
-
end
|
315
|
-
|
316
|
-
def meta_yml_path
|
317
|
-
File.join(project_dir, "META.yml")
|
318
|
-
end
|
319
|
-
|
320
|
-
end
|
321
|
-
end
|
322
|
-
end
|
data/license_scout.gemspec
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright 2016, Chef Software Inc.
|
3
|
-
# License:: Apache License, Version 2.0
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
#
|
17
|
-
|
18
|
-
lib = File.expand_path("../lib", __FILE__)
|
19
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
20
|
-
require "license_scout/version"
|
21
|
-
|
22
|
-
Gem::Specification.new do |spec|
|
23
|
-
spec.name = "license_scout"
|
24
|
-
spec.version = LicenseScout::VERSION
|
25
|
-
spec.authors = [ "Serdar Sutay" ]
|
26
|
-
spec.email = [ "serdar@chef.io" ]
|
27
|
-
spec.license = "Apache-2.0"
|
28
|
-
|
29
|
-
spec.summary = "Discovers license files of a project's dependencies."
|
30
|
-
spec.description = "Discovers license files of a project's dependencies."
|
31
|
-
spec.homepage = "https://github.com/chef/license_scout"
|
32
|
-
|
33
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
-
spec.bindir = "bin"
|
35
|
-
spec.executables = %w{license_scout}
|
36
|
-
spec.require_paths = %w{lib}
|
37
|
-
|
38
|
-
spec.add_dependency "ffi-yajl", "~> 2.2"
|
39
|
-
spec.add_dependency "mixlib-shellout", "~> 2.2"
|
40
|
-
|
41
|
-
spec.add_development_dependency "bundler", "~> 1.12"
|
42
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
43
|
-
spec.add_development_dependency "rspec"
|
44
|
-
spec.add_development_dependency "pry"
|
45
|
-
spec.add_development_dependency "rb-readline"
|
46
|
-
|
47
|
-
# We do not have berkshelf as a dependency because some of its dependencies
|
48
|
-
# can not be installed on uncommon platforms like Solaris which we need to
|
49
|
-
# support. If a project needs to collect license information for a berkshelf
|
50
|
-
# project it needs to include it seperately in its gem bundle. We have a nice
|
51
|
-
# error message when they do not. But we add berkshelf as a development
|
52
|
-
# dependency so that we can run our tests.
|
53
|
-
spec.add_development_dependency "berkshelf", "~> 4.3"
|
54
|
-
end
|