license_scout 2.0.7 → 2.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/lib/license_scout/cli.rb +22 -5
- data/lib/license_scout/exceptions.rb +1 -0
- data/lib/license_scout/exporter.rb +51 -0
- data/lib/license_scout/exporter/csv.rb +76 -0
- data/lib/license_scout/spdx.rb +2 -1
- data/lib/license_scout/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f4c5bbed2fd2e2af64f8340ebb749ddd4769c5272160d96c945993c4ecd68cf
|
4
|
+
data.tar.gz: 858f07c4c6a5c158298f69da7c19bc58c4b316e29d5da0bfd85111ce9716669f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 772a4366a8b3d14e344c1bdc7968ecb6063118c0a233c532c42c5e5f476d92110fb305bd9682504863b6cd6d27bec7b8870db9454187f920305451a0366a9297
|
7
|
+
data.tar.gz: be2e31e7763fc433c5ccf07778158d8d1877f9c3ff857b6148fa2f9137641bf005d5ab0c1373bae3927281eb15903e9f988efbb76ff92a71a5d5fa5760c4fc33
|
data/README.md
CHANGED
@@ -179,6 +179,22 @@ license_content | A URL to a file where the raw text of the license can be downl
|
|
179
179
|
|
180
180
|
In addition to including any files Licensee identified as potential license files (but couldn't identify), License Scout will also include the Fallback License you specified in the Dependency Manifest.
|
181
181
|
|
182
|
+
## Exporting a Dependency Manifest to another format
|
183
|
+
|
184
|
+
By default, License Scout creates the Dependency Manifest as a JSON file. We do this because it provides a single document that can be easily processed into many different forms. License Scout has the ability to also export that JSON file into other formats.
|
185
|
+
|
186
|
+
### Usage
|
187
|
+
|
188
|
+
```
|
189
|
+
license_scout export [PATH_TO_JSON_FILE] --format FORMAT
|
190
|
+
```
|
191
|
+
### Support Formats
|
192
|
+
|
193
|
+
Format | Description
|
194
|
+
--- | ---
|
195
|
+
`csv` | Export the contents of the JSON file into a CSV.
|
196
|
+
|
197
|
+
|
182
198
|
## Configuration
|
183
199
|
|
184
200
|
Value | Description | Default
|
data/lib/license_scout/cli.rb
CHANGED
@@ -19,6 +19,7 @@ require "zlib" # Temporarily require before rugged to fix https://github.com/pro
|
|
19
19
|
|
20
20
|
require "mixlib/cli"
|
21
21
|
require "license_scout/config"
|
22
|
+
require "license_scout/exporter"
|
22
23
|
require "license_scout/collector"
|
23
24
|
require "license_scout/reporter"
|
24
25
|
|
@@ -41,10 +42,17 @@ module LicenseScout
|
|
41
42
|
description: "Comma-separated list of directories to scan",
|
42
43
|
proc: Proc.new { |d| d.split(",") }
|
43
44
|
|
45
|
+
option :format,
|
46
|
+
long: "--format FORMAT",
|
47
|
+
description: "When exporting a Dependency Manifest, export to this format",
|
48
|
+
in: LicenseScout::Exporter.supported_formats
|
49
|
+
|
44
50
|
option :log_level,
|
45
51
|
short: "-l LEVEL",
|
46
52
|
long: "--log-level LEVEL",
|
47
|
-
description: "Set the log level
|
53
|
+
description: "Set the log level",
|
54
|
+
in: [:debug, :info, :warn, :error, :fatal],
|
55
|
+
default: :info,
|
48
56
|
proc: Proc.new { |l| l.to_sym }
|
49
57
|
|
50
58
|
option :only_show_failures,
|
@@ -94,11 +102,20 @@ module LicenseScout
|
|
94
102
|
|
95
103
|
LicenseScout::Config.validate!
|
96
104
|
|
97
|
-
|
98
|
-
|
105
|
+
case cli_arguments[0]
|
106
|
+
when "export"
|
107
|
+
json_file = cli_arguments[1]
|
108
|
+
export_format = config[:format]
|
109
|
+
|
110
|
+
exporter = LicenseScout::Exporter.new(json_file, export_format)
|
111
|
+
exporter.export
|
112
|
+
else
|
113
|
+
collector = LicenseScout::Collector.new
|
114
|
+
collector.collect
|
99
115
|
|
100
|
-
|
101
|
-
|
116
|
+
reporter = LicenseScout::Reporter.new(collector.dependencies)
|
117
|
+
reporter.report
|
118
|
+
end
|
102
119
|
end
|
103
120
|
end
|
104
121
|
end
|
@@ -0,0 +1,51 @@
|
|
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 "license_scout/exporter/csv"
|
19
|
+
|
20
|
+
module LicenseScout
|
21
|
+
class Exporter
|
22
|
+
|
23
|
+
attr_reader :json_file
|
24
|
+
attr_reader :export_format
|
25
|
+
attr_reader :exporter
|
26
|
+
|
27
|
+
def initialize(json_file, export_format)
|
28
|
+
@json_file = json_file
|
29
|
+
@export_format = export_format
|
30
|
+
|
31
|
+
@exporter = case export_format
|
32
|
+
when "csv"
|
33
|
+
LicenseScout::Exporter::CSV.new(json_file)
|
34
|
+
else
|
35
|
+
# We shouldn't ever hit this, because the CLI filters out unsupported formats. But just in case...
|
36
|
+
raise LicenseScout::Exceptions::UnsupportedExporter.new("'#{export_format}' is not a supported format. Please use one of the following: #{supported_formats.join(", ")}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.supported_formats
|
41
|
+
[
|
42
|
+
"csv",
|
43
|
+
]
|
44
|
+
end
|
45
|
+
|
46
|
+
def export
|
47
|
+
LicenseScout::Log.info("[exporter] Exporting #{json_file} to '#{export_format}'")
|
48
|
+
exporter.export
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,76 @@
|
|
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 "csv"
|
19
|
+
|
20
|
+
module LicenseScout
|
21
|
+
class Exporter
|
22
|
+
class CSV
|
23
|
+
|
24
|
+
attr_reader :json
|
25
|
+
attr_reader :output_file
|
26
|
+
|
27
|
+
def initialize(json_file)
|
28
|
+
@json = FFI_Yajl::Parser.parse(File.read(json_file))
|
29
|
+
@output_file = json_file.gsub("json", "csv")
|
30
|
+
end
|
31
|
+
|
32
|
+
def export
|
33
|
+
headers = [
|
34
|
+
"Type",
|
35
|
+
"Name",
|
36
|
+
"Version",
|
37
|
+
"Has Exception",
|
38
|
+
"Exception Reason",
|
39
|
+
"License ID",
|
40
|
+
"License Source",
|
41
|
+
"License Content",
|
42
|
+
]
|
43
|
+
|
44
|
+
::CSV.open(output_file, "w+") do |csv|
|
45
|
+
csv << headers
|
46
|
+
|
47
|
+
json["dependencies"].each do |dependency|
|
48
|
+
type = dependency["type"]
|
49
|
+
name = dependency["name"]
|
50
|
+
version = dependency["version"]
|
51
|
+
has_exception = dependency["has_exception"]
|
52
|
+
exception_reason = dependency["exception_reason"]
|
53
|
+
licenses = dependency["licenses"]
|
54
|
+
|
55
|
+
licenses.each do |license|
|
56
|
+
id = license["id"]
|
57
|
+
source = license["source"]
|
58
|
+
content = license["content"]
|
59
|
+
|
60
|
+
csv << [
|
61
|
+
type,
|
62
|
+
name,
|
63
|
+
version,
|
64
|
+
(has_exception.nil? ? "Yes" : "No"),
|
65
|
+
(exception_reason.nil? ? "" : exception_reason),
|
66
|
+
id,
|
67
|
+
source,
|
68
|
+
content
|
69
|
+
]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/license_scout/spdx.rb
CHANGED
@@ -94,7 +94,6 @@ module LicenseScout
|
|
94
94
|
|
95
95
|
def special_cases
|
96
96
|
{
|
97
|
-
# Pulled from http://search.cpan.org/~dagolden/CPAN-Meta-2.150010/lib/CPAN/Meta/Spec.pm#license
|
98
97
|
"agpl_3" => "AGPL-3.0",
|
99
98
|
"apache_1_1" => "Apache-1.1",
|
100
99
|
"apache_2_0" => "Apache-2.0",
|
@@ -109,6 +108,8 @@ module LicenseScout
|
|
109
108
|
"mit" => "MIT",
|
110
109
|
"mozilla_1_0" => "MPL-1.0",
|
111
110
|
"mozilla_1_1" => "MPL-1.1",
|
111
|
+
"mplv1.0" => "MPL-1.0",
|
112
|
+
"mplv1.1" => "MPL-1.1",
|
112
113
|
"openssl" => "OpenSSL",
|
113
114
|
"qpl_1_0" => "QPL-1.0",
|
114
115
|
"perl" => "Artistic-1.0-Perl",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: license_scout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serdar Sutay
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-04-
|
12
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi-yajl
|
@@ -173,6 +173,8 @@ files:
|
|
173
173
|
- lib/license_scout/dependency_manager/npm.rb
|
174
174
|
- lib/license_scout/dependency_manager/rebar.rb
|
175
175
|
- lib/license_scout/exceptions.rb
|
176
|
+
- lib/license_scout/exporter.rb
|
177
|
+
- lib/license_scout/exporter/csv.rb
|
176
178
|
- lib/license_scout/license.rb
|
177
179
|
- lib/license_scout/log.rb
|
178
180
|
- lib/license_scout/reporter.rb
|