papers 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/README.md +92 -107
- data/lib/papers/configuration.rb +11 -3
- data/lib/papers/dependency_specification.rb +5 -0
- data/lib/papers/dependency_specification/bower_component.rb +38 -0
- data/lib/papers/dependency_specification/gem.rb +1 -6
- data/lib/papers/license_validator.rb +8 -10
- data/lib/papers/manifest_generator.rb +16 -3
- data/lib/papers/version.rb +2 -2
- data/papers.gemspec +1 -0
- data/spec/papers_spec.rb +117 -71
- metadata +26 -16
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OWQ4YzEzZGQ0YjQ1NDE3NTAzZGE2Yzc5OWY0NzI4ZmJiODc3NTQ1Ng==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d38f6dd8a9213870b3198c533cb7a54731d8d15b
|
4
|
+
data.tar.gz: 460c188a68833bd4d67522e36163037a1c65e073
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
OTJiNTc5NzIxMjJlOTFkMzIxNjE1YWQwM2YzNjRhMDQyZWJhYWQxODIzMTE2
|
11
|
-
ZDU0NjVkM2Y5YTViYmM0MzgwNWJiNWVhYjFmNGJhYjBkNWU3ZTU=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Mjc1NTI2MTdkNTE1N2YwZGNjNjU3MDgyM2M1Zjg2ZTJhMzc0Nzc1ZGE5ODk2
|
14
|
-
YzM4ODI1YzJkZTM4OTAxOGMxMDg4ZTgyOGJkNDRlZjE1YmNiNDVmNWExNjk1
|
15
|
-
ODIxNmJmNDJmNDU3NzE0Y2NjNzY4MDdmNzM1YWI2YTY2YmVmZDU=
|
6
|
+
metadata.gz: a90556c81b2d76635c8ee185c9da05952c75d49762f3731eeb4af79297e929e8491b499d2900978915ad18282df9be4000841f836e46f795c93c68adaa7ddbe9
|
7
|
+
data.tar.gz: 55573fadd64de745cedfe761eb48c6eea4ab2a0a23012a3b57f95e1f37b57735c7a82de5329350b2145459d906932730c4da57c11ed02316dd1cb5abd72c653b
|
data/README.md
CHANGED
@@ -2,163 +2,148 @@
|
|
2
2
|
|
3
3
|
> "Papers, please."
|
4
4
|
|
5
|
-
Check that your Ruby
|
5
|
+
Check that your Ruby project's dependencies are licensed with only the licenses you specify. **Papers** will validate that your gems and JavaScript files conform to a whitelist of software licenses. Don't get caught flat-footed by the GPL.
|
6
6
|
|
7
|
-
|
8
|
-
* [Usage](#usage)
|
9
|
-
* [Example Validations](#example-validations)
|
10
|
-
* [Configuration](#configuration)
|
11
|
-
* [Structure of Dependency Manifest](#dependency-manifest-structure)
|
12
|
-
* [License](#license)
|
13
|
-
* [Contributing](#contributing)
|
7
|
+
## Contents
|
14
8
|
|
9
|
+
* [Installation](#installation)
|
10
|
+
* [Usage](#usage)
|
11
|
+
* [License](#license)
|
12
|
+
* [Contributing](#contributing)
|
15
13
|
|
16
|
-
|
14
|
+
## Installation
|
17
15
|
|
18
|
-
|
16
|
+
In your application's Gemfile:
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
```
|
18
|
+
```ruby
|
23
19
|
gem 'papers'
|
24
20
|
```
|
25
|
-
### 1. Generate Dependency Manifest from your bundled gems and JS
|
26
21
|
|
27
|
-
|
28
|
-
|
22
|
+
Then, after a `bundle install`, run Papers' installer:
|
23
|
+
|
24
|
+
```sh
|
25
|
+
$ bundle exec papers --generate
|
29
26
|
Created config/papers_manifest.yml!
|
30
27
|
```
|
31
|
-
### 2. Create a Validation Spec (or [use ours](#testing-with-rspec))
|
32
28
|
|
33
|
-
|
29
|
+
This creates a YAML file detailing your bundled gems and JavaScript files:
|
34
30
|
|
35
|
-
```
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
```yaml
|
32
|
+
# config/papers_manifest.yml
|
33
|
+
---
|
34
|
+
gems:
|
35
|
+
sqlite3-1.3.7:
|
36
|
+
license: MIT
|
37
|
+
license_url: https://github.com/luislavena/sqlite3-ruby/blob/master/LICENSE
|
38
|
+
project_url: https://github.com/luislavena/sqlite3-ruby
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
javascripts:
|
41
|
+
app/assets/javascripts/application.js:
|
42
|
+
license: Unknown
|
43
|
+
license_url:
|
44
|
+
project_url:
|
45
|
+
```
|
42
46
|
|
43
|
-
|
44
|
-
got: ["sass-3.2.12 is licensed under GPL, which is not whitelisted"]
|
47
|
+
## Usage
|
45
48
|
|
46
|
-
|
47
|
-
# ./spec/integration/papers_license_validation_spec.rb:14:in `block (2 levels) in <top (required)>'
|
49
|
+
Configure Papers in your test suite:
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
got: false
|
53
|
-
# ./spec/integration/papers_license_validation_spec.rb:9:in `block (2 levels) in <top (required)>'
|
51
|
+
```ruby
|
52
|
+
# spec/spec_helper.rb or test/test_helper.rb
|
53
|
+
require 'papers'
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
Papers.configure do |config|
|
56
|
+
# A whitelist of accepted licenses. Defaults to:
|
57
|
+
#
|
58
|
+
# [
|
59
|
+
# 'MIT',
|
60
|
+
# 'BSD',
|
61
|
+
# 'Apache 2.0',
|
62
|
+
# 'Apache-2.0',
|
63
|
+
# 'LGPLv2.1',
|
64
|
+
# 'LGPLv3',
|
65
|
+
# 'Ruby',
|
66
|
+
# 'Manually Reviewed',
|
67
|
+
# 'Unlicensed'
|
68
|
+
# ]
|
69
|
+
config.license_whitelist << 'New Relic'
|
70
|
+
|
71
|
+
# The location of your dependency manifest. Defaults to config/papers_manifest.yml
|
72
|
+
config.manifest_file = File.join('config', 'papers_manifest.yml')
|
73
|
+
|
74
|
+
# Configures Papers to validate licenses for bundled gems. Defaults to true.
|
75
|
+
config.validate_gems = true
|
76
|
+
|
77
|
+
# Configures Papers to validate licenses for included JavaScript files. Defaults to true.
|
78
|
+
config.validate_javascript = true
|
79
|
+
|
80
|
+
# A list of paths where you have included JavaScript files. Defaults to:
|
81
|
+
#
|
82
|
+
# %w[app/assets/javascripts lib/assets/javascripts vendor/assets/javascripts]
|
83
|
+
config.javascript_paths << File.join('public', 'javascripts')
|
84
|
+
|
85
|
+
# Configures Papers to validate licenses for bower components. Defaults to false.
|
86
|
+
config.validate_bower_components = false
|
87
|
+
|
88
|
+
# Configures where Papers should look for bower components. Each component
|
89
|
+
# must have a .bower.json file in its directory for Papers to see it.
|
90
|
+
config.bower_components_path = 'vendor/assets/components'
|
91
|
+
end
|
58
92
|
```
|
59
93
|
|
60
|
-
|
61
|
-
|
62
|
-
## testing with RSpec
|
63
|
-
|
64
|
-
```
|
65
|
-
# => spec/integration/papers_license_validation_spec.rb
|
94
|
+
Then, create a test that will validate your dependencies' licenses:
|
66
95
|
|
96
|
+
```ruby
|
97
|
+
# Using RSpec
|
67
98
|
require 'spec_helper'
|
68
|
-
require 'papers'
|
69
99
|
|
70
100
|
describe 'Papers License Validation' do
|
71
|
-
|
72
|
-
let(:validator) { Papers::LicenseValidator.new }
|
101
|
+
subject(:validator) { Papers::LicenseValidator.new }
|
73
102
|
|
74
103
|
it 'knows and is satisfied by all dependency licenses' do
|
75
|
-
expect(validator
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'finds no errors during license validation' do
|
79
|
-
validator.valid?
|
80
|
-
expect(validator.errors).to eq([])
|
104
|
+
expect(validator).to be_valid, "License validator failed:\n#{validator.errors.join("\n")}"
|
81
105
|
end
|
82
106
|
end
|
83
|
-
```
|
84
|
-
|
85
|
-
## testing with MiniTest
|
86
|
-
|
87
|
-
```
|
88
|
-
# => test/integration/papers_license_validation_test.rb
|
89
107
|
|
108
|
+
# Using Minitest (Test::Unit)
|
90
109
|
require 'test_helper'
|
91
|
-
require 'papers'
|
92
110
|
|
93
111
|
class PapersLicenseValidationTest < ActiveSupport::TestCase
|
94
112
|
def test_know_and_be_satisfied_by_all_licenses
|
95
113
|
validator = Papers::LicenseValidator.new
|
96
114
|
|
97
115
|
assert validator.valid?, "License validator failed:\n#{validator.errors.join("\n")}"
|
98
|
-
|
99
|
-
assert_equal validator.errors, []
|
100
116
|
end
|
101
117
|
end
|
102
118
|
```
|
103
119
|
|
104
|
-
|
120
|
+
Finally, run your test suite!
|
105
121
|
|
106
|
-
|
122
|
+
```sh
|
123
|
+
$ bundle exec rspec spec/integration/papers_license_validation_spec.rb
|
124
|
+
.
|
107
125
|
|
108
|
-
|
109
|
-
@license_whitelist = [
|
110
|
-
'MIT',
|
111
|
-
'BSD',
|
112
|
-
'Apache 2.0',
|
113
|
-
'Apache-2.0',
|
114
|
-
'LGPLv2.1',
|
115
|
-
'LGPLv3',
|
116
|
-
'Ruby',
|
117
|
-
'Manually Reviewed',
|
118
|
-
'Unlicensed'
|
119
|
-
]
|
120
|
-
```
|
121
|
-
|
122
|
-
## Available configuration options
|
123
|
-
|
124
|
-
To configure the Papers gem, pass options to ```Papers.configure``` before initialization of LicenseValidator. Currently supported config options:
|
126
|
+
Failures:
|
125
127
|
|
126
|
-
|
127
|
-
|
128
|
-
c.license_whitelist << 'New Relic'
|
129
|
-
c.manifest_file = File.join('some','other','dependency_manifest.yml')
|
130
|
-
c.validate_gems = true
|
131
|
-
c.validate_javascript = true
|
132
|
-
c.javascript_paths << File.join('some','other','javascripts')
|
133
|
-
end
|
128
|
+
1) Papers License Validation knows and is satisfied by all dependency licenses
|
129
|
+
Failure/Error: expect(validator).to be_valid
|
134
130
|
|
135
|
-
|
136
|
-
|
137
|
-
```
|
131
|
+
expected: true value
|
132
|
+
got: false
|
138
133
|
|
139
|
-
|
134
|
+
License validator failed: sass-3.2.12 is licensed under GPL, which is not whitelisted
|
140
135
|
|
141
|
-
|
142
|
-
#
|
143
|
-
---
|
144
|
-
gems:
|
145
|
-
sqlite3-1.3.7:
|
146
|
-
license: MIT
|
147
|
-
license_url: https://github.com/luislavena/sqlite3-ruby
|
148
|
-
project_url: https://github.com/luislavena/sqlite3-ruby/blob/master/LICENSE
|
149
|
-
...
|
136
|
+
(compared using ==)
|
137
|
+
# ./spec/integration/papers_license_validation_spec.rb:9:in `block (2 levels) in <top (required)>'
|
150
138
|
|
151
|
-
|
152
|
-
|
153
|
-
license: New Relic
|
154
|
-
license_url: http://newrelic.com
|
155
|
-
project_url: http://newrelic.com
|
139
|
+
Finished in 0.01043 seconds
|
140
|
+
1 examples, 1 failures
|
156
141
|
```
|
157
142
|
|
158
|
-
|
143
|
+
## License
|
159
144
|
|
160
145
|
The Papers Gem is licensed under the __MIT License__. See [MIT-LICENSE](https://github.com/newrelic/papers/blob/master/MIT-LICENSE) for full text.
|
161
146
|
|
162
|
-
|
147
|
+
## Contributing
|
163
148
|
|
164
149
|
You are welcome to send pull requests to us - however, by doing so you agree that you are granting New Relic a non-exclusive, non-revokable, no-cost license to use the code, algorithms, patents, and ideas in that code in our products if we so choose. You also agree the code is provided as-is and you provide no warranties as to its fitness or correctness for any purpose.
|
data/lib/papers/configuration.rb
CHANGED
@@ -5,10 +5,11 @@ module Papers
|
|
5
5
|
attr_accessor :manifest_file
|
6
6
|
|
7
7
|
attr_accessor :validate_gems
|
8
|
-
|
9
8
|
attr_accessor :validate_javascript
|
9
|
+
attr_accessor :validate_bower_components
|
10
10
|
|
11
11
|
attr_accessor :javascript_paths
|
12
|
+
attr_accessor :bower_components_path
|
12
13
|
|
13
14
|
def initialize
|
14
15
|
@license_whitelist = [
|
@@ -25,14 +26,17 @@ module Papers
|
|
25
26
|
|
26
27
|
@manifest_file = File.join(Dir.pwd, 'config', 'papers_manifest.yml')
|
27
28
|
|
28
|
-
@validate_gems
|
29
|
-
@validate_javascript
|
29
|
+
@validate_gems = true
|
30
|
+
@validate_javascript = true
|
31
|
+
@validate_bower_components = false
|
30
32
|
|
31
33
|
@javascript_paths = [
|
32
34
|
File.join(Dir.pwd, 'app', 'assets', 'javascripts'),
|
33
35
|
File.join(Dir.pwd, 'lib', 'assets', 'javascripts'),
|
34
36
|
File.join(Dir.pwd, 'vendor', 'assets', 'javascripts')
|
35
37
|
]
|
38
|
+
|
39
|
+
@bower_components_path = File.join(Dir.pwd, 'vendor', 'assets', 'components')
|
36
40
|
end
|
37
41
|
|
38
42
|
def validate_gems?
|
@@ -42,5 +46,9 @@ module Papers
|
|
42
46
|
def validate_javascript?
|
43
47
|
!!@validate_javascript
|
44
48
|
end
|
49
|
+
|
50
|
+
def validate_bower_components?
|
51
|
+
!!@validate_bower_components
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
@@ -9,6 +9,11 @@ module Papers
|
|
9
9
|
@project_url = options[:project_url]
|
10
10
|
end
|
11
11
|
|
12
|
+
def name_without_version
|
13
|
+
return @name unless @name.include?('-')
|
14
|
+
@name.split('-')[0..-2].join('-')
|
15
|
+
end
|
16
|
+
|
12
17
|
def acceptable_license?
|
13
18
|
Papers.config.license_whitelist.include?(license)
|
14
19
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Papers
|
4
|
+
class BowerComponent < DependencySpecification
|
5
|
+
def pretty_hash
|
6
|
+
{
|
7
|
+
name: name_without_version,
|
8
|
+
license: license,
|
9
|
+
license_url: @license_url,
|
10
|
+
project_url: @project_url
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.introspected
|
15
|
+
full_introspected_entries.map { |e| e['name'] }
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.full_introspected_entries
|
19
|
+
bower_json_entries.map do |entry|
|
20
|
+
{
|
21
|
+
'name' => "#{entry['name']}-#{entry['_release']}",
|
22
|
+
'homepage' => entry['homepage']
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.bower_json_entries
|
28
|
+
json_files = Dir["#{Papers.config.bower_components_path}/*/.bower.json"]
|
29
|
+
json_files.map do |path|
|
30
|
+
JSON.parse File.read(path)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.manifest_key
|
35
|
+
"bower_components"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -9,15 +9,10 @@ module Papers
|
|
9
9
|
}
|
10
10
|
end
|
11
11
|
|
12
|
-
def name_without_version
|
13
|
-
return @name unless @name.include?('-')
|
14
|
-
@name.split('-')[0..-2].join('-')
|
15
|
-
end
|
16
|
-
|
17
12
|
def self.introspected
|
18
13
|
Bundler.load.specs.map do |spec|
|
19
14
|
# bundler versions aren't controlled by the Gemfile
|
20
|
-
if spec.name ==
|
15
|
+
if spec.name == 'bundler'
|
21
16
|
spec.name
|
22
17
|
else
|
23
18
|
"#{spec.name}-#{spec.version}"
|
@@ -3,6 +3,7 @@ require 'yaml'
|
|
3
3
|
require 'papers/dependency_specification'
|
4
4
|
require 'papers/dependency_specification/gem'
|
5
5
|
require 'papers/dependency_specification/javascript'
|
6
|
+
require 'papers/dependency_specification/bower_component'
|
6
7
|
|
7
8
|
module Papers
|
8
9
|
class LicenseValidator
|
@@ -15,8 +16,9 @@ module Papers
|
|
15
16
|
def valid?
|
16
17
|
@errors = []
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
validate_spec_type(Gem) if Papers.config.validate_gems?
|
20
|
+
validate_spec_type(Javascript) if Papers.config.validate_javascript?
|
21
|
+
validate_spec_type(BowerComponent) if Papers.config.validate_bower_components?
|
20
22
|
|
21
23
|
@errors.empty?
|
22
24
|
end
|
@@ -33,6 +35,10 @@ module Papers
|
|
33
35
|
Javascript.all_from_manifest(manifest).map(&:pretty_hash)
|
34
36
|
end
|
35
37
|
|
38
|
+
def pretty_bower_component_list
|
39
|
+
BowerComponent.all_from_manifest(manifest).map(&:pretty_hash)
|
40
|
+
end
|
41
|
+
|
36
42
|
private
|
37
43
|
|
38
44
|
def validate_spec_type(spec_type)
|
@@ -50,13 +56,5 @@ module Papers
|
|
50
56
|
end
|
51
57
|
end
|
52
58
|
end
|
53
|
-
|
54
|
-
def validate_gems
|
55
|
-
validate_spec_type Gem
|
56
|
-
end
|
57
|
-
|
58
|
-
def validate_js
|
59
|
-
validate_spec_type Javascript
|
60
|
-
end
|
61
59
|
end
|
62
60
|
end
|
@@ -38,8 +38,9 @@ module Papers
|
|
38
38
|
|
39
39
|
def build_manifest
|
40
40
|
manifest = {
|
41
|
-
"gems"
|
42
|
-
"javascripts"
|
41
|
+
"gems" => get_installed_gems,
|
42
|
+
"javascripts" => get_installed_javascripts,
|
43
|
+
"bower_components" => get_installed_bower_components
|
43
44
|
}
|
44
45
|
return manifest
|
45
46
|
end
|
@@ -78,6 +79,18 @@ module Papers
|
|
78
79
|
js.empty? ? nil : js
|
79
80
|
end
|
80
81
|
|
82
|
+
def get_installed_bower_components
|
83
|
+
components = {}
|
84
|
+
BowerComponent.full_introspected_entries.each do |entry|
|
85
|
+
components[entry['name']] = {
|
86
|
+
'license' => 'Unknown',
|
87
|
+
'license_url' => nil,
|
88
|
+
'project_url' => ensure_valid_url(entry['homepage'])
|
89
|
+
}
|
90
|
+
end
|
91
|
+
components.empty? ? nil : components
|
92
|
+
end
|
93
|
+
|
81
94
|
def manifest_exists?
|
82
95
|
!!File.exist?(@manifest_path)
|
83
96
|
end
|
@@ -106,4 +119,4 @@ module Papers
|
|
106
119
|
|
107
120
|
end
|
108
121
|
|
109
|
-
end
|
122
|
+
end
|
data/lib/papers/version.rb
CHANGED
data/papers.gemspec
CHANGED
data/spec/papers_spec.rb
CHANGED
@@ -8,8 +8,8 @@ describe 'Papers' do
|
|
8
8
|
|
9
9
|
it 'validates a manifest with empty values and set of dependencies' do
|
10
10
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
11
|
-
|
12
|
-
|
11
|
+
'javascripts' => {},
|
12
|
+
'gems' => {}
|
13
13
|
})
|
14
14
|
Papers::Gem.stub(:introspected).and_return([])
|
15
15
|
|
@@ -18,106 +18,104 @@ describe 'Papers' do
|
|
18
18
|
|
19
19
|
it 'detects mismatched gems' do
|
20
20
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
'license' =>
|
21
|
+
'javascripts' => {},
|
22
|
+
'gems' => {
|
23
|
+
'foo-1.2' => {
|
24
|
+
'license' => 'MIT',
|
25
25
|
'license_url' => nil,
|
26
26
|
'project_url' => nil
|
27
27
|
},
|
28
|
-
|
29
|
-
'license' =>
|
28
|
+
'baz-1.3' => {
|
29
|
+
'license' => 'BSD',
|
30
30
|
'license_url' => nil,
|
31
31
|
'project_url' => nil
|
32
32
|
}
|
33
33
|
}
|
34
34
|
})
|
35
|
-
Papers::Gem.stub(:introspected).and_return([
|
35
|
+
Papers::Gem.stub(:introspected).and_return(['bar-1.2', 'baz-1.3'])
|
36
36
|
|
37
37
|
expect(validator.valid?).to be_false
|
38
38
|
|
39
39
|
expect(validator.errors).to eq([
|
40
|
-
|
41
|
-
|
40
|
+
'bar-1.2 is included in the application, but not in the manifest',
|
41
|
+
'foo-1.2 is included in the manifest, but not in the application'
|
42
42
|
])
|
43
43
|
|
44
44
|
validator.valid?
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'detects mismatched gem versions' do
|
48
|
-
Papers::Configuration.any_instance.stub(:validate_javascript?).and_return(
|
49
|
-
|
50
|
-
expect(validator).to receive(:validate_js).at_least(:once)
|
48
|
+
Papers::Configuration.any_instance.stub(:validate_javascript?).and_return(false)
|
51
49
|
|
52
50
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
'license' =>
|
51
|
+
'javascripts' => {},
|
52
|
+
'gems' => {
|
53
|
+
'foo-1.2' => {
|
54
|
+
'license' => 'MIT',
|
57
55
|
'license_url' => nil,
|
58
56
|
'project_url' => nil
|
59
57
|
},
|
60
|
-
|
61
|
-
'license' =>
|
58
|
+
'baz-1.3' => {
|
59
|
+
'license' => 'BSD',
|
62
60
|
'license_url' => nil,
|
63
61
|
'project_url' => nil
|
64
62
|
}
|
65
63
|
}
|
66
64
|
})
|
67
|
-
Papers::Gem.stub(:introspected).and_return([
|
65
|
+
Papers::Gem.stub(:introspected).and_return(['foo-1.2', 'baz-1.2'])
|
68
66
|
|
69
67
|
expect(validator.valid?).to be_false
|
70
68
|
|
71
69
|
expect(validator.errors).to eq([
|
72
|
-
|
73
|
-
|
70
|
+
'baz-1.2 is included in the application, but not in the manifest',
|
71
|
+
'baz-1.3 is included in the manifest, but not in the application'
|
74
72
|
])
|
75
73
|
validator.valid?
|
76
74
|
end
|
77
75
|
|
78
76
|
it 'is OK with matching gem sets' do
|
79
77
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
'license' =>
|
78
|
+
'javascripts' => {},
|
79
|
+
'gems' => {
|
80
|
+
'foo-1.2' => {
|
81
|
+
'license' => 'MIT',
|
84
82
|
'license_url' => nil,
|
85
83
|
'project_url' => nil
|
86
84
|
},
|
87
|
-
|
88
|
-
'license' =>
|
85
|
+
'baz-1.3' => {
|
86
|
+
'license' => 'BSD',
|
89
87
|
'license_url' => nil,
|
90
88
|
'project_url' => nil
|
91
89
|
}
|
92
90
|
},
|
93
91
|
})
|
94
|
-
Papers::Gem.stub(:introspected).and_return([
|
92
|
+
Papers::Gem.stub(:introspected).and_return(['foo-1.2', 'baz-1.3'])
|
95
93
|
|
96
94
|
expect(validator.valid?).to be_true
|
97
95
|
end
|
98
96
|
|
99
97
|
it 'is OK with matching gem sets but complain about a license issue' do
|
100
98
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
'license' =>
|
99
|
+
'javascripts' => {},
|
100
|
+
'gems' => {
|
101
|
+
'foo-1.2' => {
|
102
|
+
'license' => 'MIT',
|
105
103
|
'license_url' => nil,
|
106
104
|
'project_url' => nil
|
107
105
|
},
|
108
|
-
|
109
|
-
'license' =>
|
106
|
+
'baz-1.3' => {
|
107
|
+
'license' => 'GPL',
|
110
108
|
'license_url' => nil,
|
111
109
|
'project_url' => nil
|
112
110
|
}
|
113
111
|
},
|
114
112
|
})
|
115
|
-
Papers::Gem.stub(:introspected).and_return([
|
113
|
+
Papers::Gem.stub(:introspected).and_return(['foo-1.2', 'baz-1.3'])
|
116
114
|
|
117
115
|
expect(validator.valid?).to be_false
|
118
116
|
|
119
117
|
expect(validator.errors).to eq([
|
120
|
-
|
118
|
+
'baz-1.3 is licensed under GPL, which is not whitelisted'
|
121
119
|
])
|
122
120
|
|
123
121
|
validator.valid?
|
@@ -125,82 +123,130 @@ describe 'Papers' do
|
|
125
123
|
|
126
124
|
it 'displays gem licenses in a pretty format without versions' do
|
127
125
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
'license' =>
|
126
|
+
'javascripts' => {},
|
127
|
+
'gems' => {
|
128
|
+
'foo-1.2' => {
|
129
|
+
'license' => 'MIT',
|
132
130
|
'license_url' => nil,
|
133
131
|
'project_url' => nil
|
134
132
|
},
|
135
|
-
|
136
|
-
'license' =>
|
133
|
+
'baz-1.3' => {
|
134
|
+
'license' => 'BSD',
|
137
135
|
'license_url' => nil,
|
138
136
|
'project_url' => nil
|
139
137
|
},
|
140
|
-
|
141
|
-
'license' =>
|
138
|
+
'with-hyphens-1.4' => {
|
139
|
+
'license' => 'MIT',
|
142
140
|
'license_url' => nil,
|
143
141
|
'project_url' => nil
|
144
142
|
}
|
145
143
|
},
|
146
144
|
})
|
145
|
+
|
147
146
|
expect(validator.pretty_gem_list).to eq([
|
148
147
|
{
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
148
|
+
name: 'baz',
|
149
|
+
license: 'BSD',
|
150
|
+
license_url: nil,
|
151
|
+
project_url: nil
|
153
152
|
},
|
154
153
|
{
|
155
|
-
:
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
154
|
+
name: 'foo',
|
155
|
+
license: 'MIT',
|
156
|
+
license_url: nil,
|
157
|
+
project_url: nil
|
159
158
|
},
|
160
159
|
{
|
161
|
-
:
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
165
|
-
|
166
|
-
|
160
|
+
name: 'with-hyphens',
|
161
|
+
license: 'MIT',
|
162
|
+
license_url: nil,
|
163
|
+
project_url: nil
|
164
|
+
}
|
165
|
+
])
|
167
166
|
end
|
168
167
|
|
169
168
|
it 'displays JS libraries in a pretty format without versions' do
|
170
169
|
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
171
|
-
|
172
|
-
|
173
|
-
'license' =>
|
170
|
+
'javascripts' => {
|
171
|
+
'/path/to/foo.js' => {
|
172
|
+
'license' => 'MIT',
|
174
173
|
'license_url' => nil,
|
175
174
|
'project_url' => nil
|
176
175
|
},
|
177
|
-
|
178
|
-
'license' =>
|
176
|
+
'/path/to/newrelic.js' => {
|
177
|
+
'license' => 'New Relic',
|
179
178
|
'license_url' => nil,
|
180
179
|
'project_url' => nil
|
181
180
|
}
|
182
181
|
},
|
183
|
-
|
182
|
+
'gems' => {}
|
184
183
|
})
|
184
|
+
|
185
185
|
expect(validator.pretty_js_list).to eq([
|
186
186
|
{
|
187
|
-
:name =>
|
188
|
-
:license =>
|
187
|
+
:name =>'/path/to/foo.js',
|
188
|
+
:license =>'MIT',
|
189
189
|
:license_url => nil,
|
190
190
|
:project_url => nil
|
191
191
|
},
|
192
192
|
{
|
193
|
-
:name =>
|
194
|
-
:license =>
|
193
|
+
:name =>'/path/to/newrelic.js',
|
194
|
+
:license =>'New Relic',
|
195
195
|
:license_url => nil,
|
196
196
|
:project_url => nil
|
197
197
|
}
|
198
198
|
])
|
199
199
|
end
|
200
200
|
|
201
|
+
it 'displays bower component licenses in a pretty format without versions' do
|
202
|
+
Papers::Configuration.any_instance.stub(:validate_bower_components?).and_return(true)
|
203
|
+
|
204
|
+
Papers::LicenseValidator.any_instance.stub(:manifest).and_return({
|
205
|
+
'javascripts' => {},
|
206
|
+
'gems' => {},
|
207
|
+
'bower_components' => {
|
208
|
+
'foo-1.2' => {
|
209
|
+
'license' => 'MIT',
|
210
|
+
'license_url' => nil,
|
211
|
+
'project_url' => nil
|
212
|
+
},
|
213
|
+
'baz-1.3' => {
|
214
|
+
'license' => 'BSD',
|
215
|
+
'license_url' => nil,
|
216
|
+
'project_url' => nil
|
217
|
+
},
|
218
|
+
'with-hyphens-1.4' => {
|
219
|
+
'license' => 'MIT',
|
220
|
+
'license_url' => nil,
|
221
|
+
'project_url' => nil
|
222
|
+
}
|
223
|
+
},
|
224
|
+
})
|
225
|
+
|
226
|
+
expect(validator.pretty_bower_component_list).to eq([
|
227
|
+
{
|
228
|
+
name: 'baz',
|
229
|
+
license: 'BSD',
|
230
|
+
license_url: nil,
|
231
|
+
project_url: nil
|
232
|
+
},
|
233
|
+
{
|
234
|
+
name: 'foo',
|
235
|
+
license: 'MIT',
|
236
|
+
license_url: nil,
|
237
|
+
project_url: nil
|
238
|
+
},
|
239
|
+
{
|
240
|
+
name: 'with-hyphens',
|
241
|
+
license: 'MIT',
|
242
|
+
license_url: nil,
|
243
|
+
project_url: nil
|
244
|
+
}
|
245
|
+
])
|
246
|
+
end
|
247
|
+
|
201
248
|
it 'displays the gem name when the gemspec does not specify a version' do
|
202
249
|
gemspec = Papers::Gem.new(name: 'foo')
|
203
250
|
expect('foo').to eq(gemspec.name_without_version)
|
204
251
|
end
|
205
|
-
|
206
252
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: papers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ralph Bodenner
|
@@ -12,37 +12,47 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2014-01-23 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: rake
|
19
|
+
requirement: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
17
31
|
- !ruby/object:Gem::Dependency
|
18
32
|
name: rspec
|
19
33
|
requirement: !ruby/object:Gem::Requirement
|
20
34
|
requirements:
|
21
|
-
- - ~>
|
35
|
+
- - "~>"
|
22
36
|
- !ruby/object:Gem::Version
|
23
37
|
version: '2.14'
|
24
38
|
type: :development
|
25
39
|
prerelease: false
|
26
40
|
version_requirements: !ruby/object:Gem::Requirement
|
27
41
|
requirements:
|
28
|
-
- - ~>
|
42
|
+
- - "~>"
|
29
43
|
- !ruby/object:Gem::Version
|
30
44
|
version: '2.14'
|
31
|
-
description:
|
32
|
-
(both gems
|
33
|
-
|
34
|
-
and javascript libraries) conform to a software license whitelist. Don''t get
|
35
|
-
|
45
|
+
description: |
|
46
|
+
Validate that the licenses used by your Ruby project's dependencies (both gems
|
47
|
+
and javascript libraries) conform to a software license whitelist. Don't get
|
36
48
|
caught flat-footed by the GPL.
|
37
|
-
|
38
|
-
'
|
39
49
|
email: support@newrelic.com
|
40
50
|
executables:
|
41
51
|
- papers
|
42
52
|
extensions: []
|
43
53
|
extra_rdoc_files: []
|
44
54
|
files:
|
45
|
-
- .gitignore
|
55
|
+
- ".gitignore"
|
46
56
|
- Gemfile
|
47
57
|
- MIT-LICENSE
|
48
58
|
- README.md
|
@@ -52,6 +62,7 @@ files:
|
|
52
62
|
- lib/papers/cli.rb
|
53
63
|
- lib/papers/configuration.rb
|
54
64
|
- lib/papers/dependency_specification.rb
|
65
|
+
- lib/papers/dependency_specification/bower_component.rb
|
55
66
|
- lib/papers/dependency_specification/gem.rb
|
56
67
|
- lib/papers/dependency_specification/javascript.rb
|
57
68
|
- lib/papers/license_validator.rb
|
@@ -69,20 +80,19 @@ require_paths:
|
|
69
80
|
- lib
|
70
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
82
|
requirements:
|
72
|
-
- -
|
83
|
+
- - ">="
|
73
84
|
- !ruby/object:Gem::Version
|
74
85
|
version: '0'
|
75
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
87
|
requirements:
|
77
|
-
- -
|
88
|
+
- - ">="
|
78
89
|
- !ruby/object:Gem::Version
|
79
90
|
version: '0'
|
80
91
|
requirements: []
|
81
92
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
93
|
+
rubygems_version: 2.2.0
|
83
94
|
signing_key:
|
84
95
|
specification_version: 4
|
85
96
|
summary: Validate the licenses of software dependencies you use
|
86
97
|
test_files:
|
87
98
|
- spec/papers_spec.rb
|
88
|
-
has_rdoc:
|