license_finder 0.7.0 → 0.7.1
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.
- data/features/ignore_bundle_groups.feature +11 -0
- data/features/license_finder.feature +15 -0
- data/features/step_definitions/steps.rb +75 -16
- data/features/whitelist.feature +24 -0
- data/lib/license_finder.rb +1 -1
- data/lib/license_finder/bundle.rb +7 -1
- data/lib/license_finder/bundled_gem.rb +1 -9
- data/lib/license_finder/configuration.rb +15 -0
- data/lib/license_finder/dependency.rb +1 -6
- data/lib/license_finder/license.rb +5 -1
- data/lib/license_finder/license/apache2.rb +1 -1
- data/lib/license_finder/license/bsd.rb +1 -1
- data/lib/license_finder/license/new_bsd.rb +1 -1
- data/lib/license_finder/license/simplified_bsd.rb +1 -1
- data/lib/license_finder/license_url.rb +2 -2
- data/lib/license_finder/persistence/yaml/configuration.rb +1 -1
- data/license_finder.gemspec +3 -3
- data/spec/lib/license_finder/bundled_gem_spec.rb +1 -24
- data/spec/lib/license_finder/configuration_spec.rb +38 -0
- data/spec/lib/license_finder/dependency_spec.rb +20 -12
- data/spec/lib/license_finder/license_spec.rb +31 -0
- data/spec/support/shared_examples/persistence/configuration.rb +0 -6
- data/spec/support/shared_examples/persistence/dependency.rb +0 -1
- metadata +41 -11
- data/spec/lib/license_finder/persistence/yaml/configuration_spec.rb +0 -5
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: Ignore Bundle Groups
|
2
|
+
As a developer
|
3
|
+
I want to ignore certain bundler groups
|
4
|
+
So that any gems I use in development, or for testing, are automatically approved for use
|
5
|
+
|
6
|
+
Scenario:
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my application depends on a gem "gpl_gem" licensed with "GPL" in the "test" bundler groups
|
9
|
+
And I whitelist the "test" bundler group
|
10
|
+
When I run "license_finder"
|
11
|
+
Then I should not see "gpl_gem" in its output
|
@@ -44,3 +44,18 @@ Feature: License Finder command line executable
|
|
44
44
|
And I run "license_finder"
|
45
45
|
Then I should see "All gems are approved for use" in its output
|
46
46
|
And it should exit with status code 0
|
47
|
+
|
48
|
+
Scenario: Merging a legacy dependencies.yml file
|
49
|
+
Given I have an app with license finder
|
50
|
+
And my app depends on a gem "random_licensed_gem" licensed with "random_license"
|
51
|
+
And I have a legacy dependencies.yml file with "random_licensed_gem" approved with its "random_license" license
|
52
|
+
And I whitelist the following licenses: "MIT, other"
|
53
|
+
When I run "license_finder"
|
54
|
+
Then I should see exactly one entry for "random_licensed_gem" in "dependencies.yml"
|
55
|
+
|
56
|
+
Scenario: Remove readme file paths from legacy dependencies.yml
|
57
|
+
Given I have an app with license finder
|
58
|
+
And my app depends on a gem "random_licensed_gem" licensed with "random_license"
|
59
|
+
And I have a legacy dependencies.yml file with readme_files entry for gem "random_licensed_gem"
|
60
|
+
When I run "license_finder"
|
61
|
+
Then I should not see an entry "readme_files" for gem "random_licensed_gem" in my dependencies.yml
|
@@ -1,5 +1,8 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'pathname'
|
3
|
+
require 'bundler'
|
2
4
|
require 'capybara'
|
5
|
+
require 'pry'
|
3
6
|
|
4
7
|
Given /^I have a rails app(?:lication)? with license finder$/ do
|
5
8
|
@user = ::DSL::User.new
|
@@ -11,7 +14,6 @@ Given /^I have an app(?:lication)? with license finder$/ do
|
|
11
14
|
@user.create_nonrails_app
|
12
15
|
end
|
13
16
|
|
14
|
-
|
15
17
|
Given /^I have an app(?:lication)? with rake and license finder$/ do
|
16
18
|
@user = ::DSL::User.new
|
17
19
|
@user.create_nonrails_app
|
@@ -25,10 +27,6 @@ Given /^my app(?:lication)? does not have a "([^"]+)" directory$/ do |name|
|
|
25
27
|
File.should_not be_exists(path)
|
26
28
|
end
|
27
29
|
|
28
|
-
Then /^I should see a "([^"]+)" directory$/ do |name|
|
29
|
-
File.should be_exists(@user.app_path(name))
|
30
|
-
end
|
31
|
-
|
32
30
|
Given /^my (?:rails )?app(?:lication)? depends on a gem "(.*?)" licensed with "(.*?)"$/ do |gem_name, license|
|
33
31
|
@user.add_dependency_to_app gem_name, :license => license
|
34
32
|
end
|
@@ -45,6 +43,36 @@ Given /^I whitelist the following licenses: "([^"]*)"$/ do |licenses|
|
|
45
43
|
@user.configure_license_finder_whitelist licenses.split(", ")
|
46
44
|
end
|
47
45
|
|
46
|
+
Given /^I have a legacy dependencies\.yml file with "(.*?)" approved with its "(.*?)" license$/ do |gem_name, license_name|
|
47
|
+
File.open(@user.dependencies_file_path, 'w+') do |f|
|
48
|
+
<<-YAML
|
49
|
+
- name: #{gem_name}
|
50
|
+
version: 1.5.0
|
51
|
+
license: #{license_name}
|
52
|
+
approved: true
|
53
|
+
notes: ''
|
54
|
+
license_files:
|
55
|
+
- path: /some/path/to/files/that/are/rad
|
56
|
+
YAML
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
And /^I have a legacy dependencies\.yml file with readme_files entry for gem "(.*?)"$/ do |gem_name|
|
61
|
+
File.open(@user.dependencies_file_path, 'w+') do |f|
|
62
|
+
<<-YAML
|
63
|
+
- name: #{gem_name}
|
64
|
+
version: 1.5.0
|
65
|
+
license: some_license
|
66
|
+
approved: true
|
67
|
+
notes: ''
|
68
|
+
license_files:
|
69
|
+
- path: /some/path/to/files/that/are/rad
|
70
|
+
readme_files:
|
71
|
+
- path: /some/path/to/files/that/are/rad/readme
|
72
|
+
YAML
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
48
76
|
When /^I run "(.*?)"$/ do |command|
|
49
77
|
@output = @user.execute_command command
|
50
78
|
end
|
@@ -69,6 +97,29 @@ When /^my app(?:lication)? depends on a gem "([^"]*)" with:$/ do |gem_name, gem_
|
|
69
97
|
)
|
70
98
|
end
|
71
99
|
|
100
|
+
When /^the text "([^"]*)" should link to "([^"]*)"$/ do |text, link|
|
101
|
+
html = Capybara.string File.read(@user.dependencies_html_path)
|
102
|
+
html.all(:xpath, "//a[@href='#{link}']").first.text.should == text
|
103
|
+
end
|
104
|
+
|
105
|
+
When /^I have a truncated dependencies.yml file$/ do
|
106
|
+
File.open(@user.dependencies_file_path, 'w+') do |f|
|
107
|
+
f.puts ""
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
When /^"([^"]*)" is an alternative name for the "MIT" license$/ do |alternative_name|
|
112
|
+
# this step is simply for readability
|
113
|
+
end
|
114
|
+
|
115
|
+
When /^I whitelist the "([^"]*)" bundler group$/ do |group|
|
116
|
+
@user.configure_license_finder_bundler_whitelist(group)
|
117
|
+
end
|
118
|
+
|
119
|
+
Then /^I should see a "([^"]+)" directory$/ do |name|
|
120
|
+
File.should be_exists(@user.app_path(name))
|
121
|
+
end
|
122
|
+
|
72
123
|
Then /^I should see "(.*?)" in its output$/ do |gem_name|
|
73
124
|
@output.should include gem_name
|
74
125
|
end
|
@@ -85,6 +136,11 @@ Then /^I should see the file "([^"]*)" containing:$/ do |filename, text|
|
|
85
136
|
File.read(@user.app_path(filename)).should include(text.gsub(/^\s+/, ""))
|
86
137
|
end
|
87
138
|
|
139
|
+
Then /^I should see exactly one entry for "(.*?)" in "(.*?)"$/ do |gem_name, filename|
|
140
|
+
file_contents = File.read(@user.app_path(filename))
|
141
|
+
file_contents.scan(/#{gem_name}/).size.should == 1
|
142
|
+
end
|
143
|
+
|
88
144
|
Then /^I should see the following settings for "([^"]*)":$/ do |name, yaml|
|
89
145
|
expected_settings = YAML.load(yaml)
|
90
146
|
all_settings = YAML.load(File.read(@user.dependencies_file_path))
|
@@ -92,6 +148,12 @@ Then /^I should see the following settings for "([^"]*)":$/ do |name, yaml|
|
|
92
148
|
actual_settings.should include expected_settings
|
93
149
|
end
|
94
150
|
|
151
|
+
Then /^I should not see an entry "(.*?)" for gem "(.*?)" in my dependencies\.yml$/ do |entry_key, gem_name|
|
152
|
+
settings = YAML.load(File.read(@user.dependencies_file_path))
|
153
|
+
gem_settings = settings.detect { |gem| gem['name'] == gem_name }
|
154
|
+
gem_settings.should_not have_key entry_key
|
155
|
+
end
|
156
|
+
|
95
157
|
Then /^it should exit with status code (\d)$/ do |status|
|
96
158
|
$?.exitstatus.should == status.to_i
|
97
159
|
end
|
@@ -209,6 +271,14 @@ module DSL
|
|
209
271
|
end
|
210
272
|
end
|
211
273
|
|
274
|
+
def configure_license_finder_bundler_whitelist(whitelisted_groups=[])
|
275
|
+
whitelisted_groups = Array whitelisted_groups
|
276
|
+
FileUtils.mkdir_p(config_path)
|
277
|
+
File.open(File.join(config_path, "license_finder.yml"), "w") do |f|
|
278
|
+
f.write({'ignore_groups' => whitelisted_groups}.to_yaml)
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
212
282
|
def execute_command(command)
|
213
283
|
Bundler.with_clean_env do
|
214
284
|
@output = `cd #{app_path} && bundle exec #{command}`
|
@@ -290,14 +360,3 @@ module DSL
|
|
290
360
|
end
|
291
361
|
end
|
292
362
|
end
|
293
|
-
|
294
|
-
|
295
|
-
When /^the text "([^"]*)" should link to "([^"]*)"$/ do |text, link|
|
296
|
-
html = Capybara.string File.read(@user.dependencies_html_path)
|
297
|
-
html.find(:xpath, "//a[@href='#{link}']").text.should == text
|
298
|
-
end
|
299
|
-
When /^I have a truncated dependencies.yml file$/ do
|
300
|
-
File.open(@user.dependencies_file_path, 'w+') do |f|
|
301
|
-
f.puts ""
|
302
|
-
end
|
303
|
-
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Whitelist licenses
|
2
|
+
As a developer
|
3
|
+
I want to whitelist certain OSS licenses that my business has pre-approved
|
4
|
+
So that any dependencies with those licenses do not show up as action items
|
5
|
+
|
6
|
+
Scenario: Auditing an application with whitelisted licenses
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
9
|
+
When I run "license_finder"
|
10
|
+
Then I should see "mit_licensed_gem" in its output
|
11
|
+
When I whitelist the following licenses: "MIT, other"
|
12
|
+
And I run "license_finder"
|
13
|
+
Then I should see "All gems are approved for use" in its output
|
14
|
+
And it should exit with status code 0
|
15
|
+
|
16
|
+
Scenario: Whitelist with MIT License alternative name "Expat" should whitelist "MIT" licenses
|
17
|
+
Given I have an app with license finder
|
18
|
+
And "Expat" is an alternative name for the "MIT" license
|
19
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
20
|
+
When I run "license_finder"
|
21
|
+
Then I should see "mit_licensed_gem" in its output
|
22
|
+
When I whitelist the "Expat" license
|
23
|
+
And I run "license_finder"
|
24
|
+
Then I should not see "mit_licensed_gem" in its output
|
data/lib/license_finder.rb
CHANGED
@@ -7,7 +7,7 @@ module LicenseFinder
|
|
7
7
|
|
8
8
|
DEPENDENCY_ATTRIBUTES = [
|
9
9
|
"name", "source", "version", "license", "license_url", "approved", "notes",
|
10
|
-
"license_files", "
|
10
|
+
"license_files", "bundler_groups", "summary",
|
11
11
|
"description", "homepage", "children", "parents"
|
12
12
|
]
|
13
13
|
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class Bundle
|
3
|
+
attr_writer :ignore_groups
|
4
|
+
|
3
5
|
def initialize(bundler_definition=nil)
|
4
6
|
@definition = bundler_definition || Bundler::Definition.build(gemfile_path, lockfile_path, nil)
|
5
7
|
end
|
@@ -21,6 +23,10 @@ module LicenseFinder
|
|
21
23
|
private
|
22
24
|
attr_reader :definition
|
23
25
|
|
26
|
+
def ignore_groups
|
27
|
+
@ignore_groups ||= LicenseFinder.config.ignore_groups
|
28
|
+
end
|
29
|
+
|
24
30
|
def setup_parent_child_relationships
|
25
31
|
dependency_index = {}
|
26
32
|
|
@@ -41,7 +47,7 @@ module LicenseFinder
|
|
41
47
|
end
|
42
48
|
|
43
49
|
def included_groups
|
44
|
-
definition.groups -
|
50
|
+
definition.groups - ignore_groups
|
45
51
|
end
|
46
52
|
|
47
53
|
def gemfile_path
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class BundledGem
|
3
3
|
LICENSE_FILE_NAMES = %w(LICENSE License Licence COPYING README Readme ReadMe)
|
4
|
-
README_FILE_NAMES = %w(README Readme ReadMe)
|
5
4
|
|
6
5
|
attr_reader :parents
|
7
6
|
|
@@ -35,8 +34,7 @@ module LicenseFinder
|
|
35
34
|
'name' => @spec.name,
|
36
35
|
'version' => @spec.version.to_s,
|
37
36
|
'license' => determine_license,
|
38
|
-
'license_files' => license_files.map(&:
|
39
|
-
'readme_files' => readme_files.map(&:full_file_path),
|
37
|
+
'license_files' => license_files.map(&:file_path),
|
40
38
|
'source' => 'bundle',
|
41
39
|
'bundler_groups' => (@bundler_dependency.groups if @bundler_dependency),
|
42
40
|
'summary' => @spec.summary,
|
@@ -61,12 +59,6 @@ module LicenseFinder
|
|
61
59
|
get_files_for_paths(paths_for_license_files)
|
62
60
|
end
|
63
61
|
|
64
|
-
def readme_files
|
65
|
-
find_matching_files(README_FILE_NAMES).map do |path|
|
66
|
-
get_file_for_path(path)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
62
|
def install_path
|
71
63
|
@spec.full_gem_path
|
72
64
|
end
|
@@ -1,4 +1,19 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class Configuration < LicenseFinder::Persistence::Configuration
|
3
|
+
def ignore_groups
|
4
|
+
super.map &:to_sym
|
5
|
+
end
|
6
|
+
|
7
|
+
def whitelisted?(license_name)
|
8
|
+
license = License.find_by_name(license_name) || license_name
|
9
|
+
whitelisted_licenses.include? license
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def whitelisted_licenses
|
14
|
+
whitelist.map do |license_name|
|
15
|
+
LicenseFinder::License.find_by_name(license_name) || license_name
|
16
|
+
end.compact
|
17
|
+
end
|
3
18
|
end
|
4
19
|
end
|
@@ -1,18 +1,13 @@
|
|
1
1
|
module LicenseFinder
|
2
2
|
class Dependency < LicenseFinder::Persistence::Dependency
|
3
3
|
def approved
|
4
|
-
|
5
|
-
self.approved = config.whitelist.include?(license)
|
4
|
+
self.approved = !!(config.whitelisted?(license) || super)
|
6
5
|
end
|
7
6
|
|
8
7
|
def license_files
|
9
8
|
super || (self.license_files = [])
|
10
9
|
end
|
11
10
|
|
12
|
-
def readme_files
|
13
|
-
super || (self.readme_files = [])
|
14
|
-
end
|
15
|
-
|
16
11
|
def bundler_groups
|
17
12
|
super || (self.bundler_groups = [])
|
18
13
|
end
|
@@ -3,6 +3,10 @@ module LicenseFinder::License
|
|
3
3
|
def all
|
4
4
|
@all ||= []
|
5
5
|
end
|
6
|
+
|
7
|
+
def find_by_name(license_name)
|
8
|
+
all.detect { |l| l.names.map(&:downcase).include? license_name.to_s.downcase }
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
class Text
|
@@ -30,7 +34,7 @@ module LicenseFinder::License
|
|
30
34
|
end
|
31
35
|
|
32
36
|
def names
|
33
|
-
[demodulized_name] + self.alternative_names
|
37
|
+
([demodulized_name, pretty_name] + self.alternative_names).uniq
|
34
38
|
end
|
35
39
|
|
36
40
|
def alternative_names
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class LicenseFinder::License::Apache2 < LicenseFinder::License::Base
|
2
|
-
self.alternative_names = ["Apache 2.0", "Apache2"]
|
2
|
+
self.alternative_names = ["Apache 2.0", "Apache2", "Apache-2.0"]
|
3
3
|
self.license_url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
|
4
4
|
|
5
5
|
def self.pretty_name
|
@@ -1,4 +1,4 @@
|
|
1
1
|
class LicenseFinder::License::BSD < LicenseFinder::License::Base
|
2
|
-
self.alternative_names = ["BSD4", "bsd-old", "4-clause BSD"]
|
2
|
+
self.alternative_names = ["BSD4", "bsd-old", "4-clause BSD", "BSD-4-Clause"]
|
3
3
|
self.license_url = "http://en.wikipedia.org/wiki/BSD_licenses#4-clause_license_.28original_.22BSD_License.22.29"
|
4
4
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class LicenseFinder::License::NewBSD < LicenseFinder::License::Base
|
2
2
|
self.license_url = "http://opensource.org/licenses/BSD-3-Clause"
|
3
|
-
self.alternative_names = ["Modified BSD", "BSD3", "BSD-3", "3-clause BSD"]
|
3
|
+
self.alternative_names = ["Modified BSD", "BSD3", "BSD-3", "3-clause BSD", "BSD-3-Clause"]
|
4
4
|
|
5
5
|
def self.pretty_name
|
6
6
|
'New BSD'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class LicenseFinder::License::SimplifiedBSD < LicenseFinder::License::Base
|
2
2
|
self.license_url = "http://opensource.org/licenses/bsd-license"
|
3
|
-
self.alternative_names = ["Simplified BSD", "FreeBSD", "2-clause BSD"]
|
3
|
+
self.alternative_names = ["Simplified BSD", "FreeBSD", "2-clause BSD", "BSD-2-Clause"]
|
4
4
|
|
5
5
|
def self.pretty_name
|
6
6
|
'Simplified BSD'
|
@@ -2,9 +2,9 @@ module LicenseFinder::LicenseUrl
|
|
2
2
|
extend self
|
3
3
|
|
4
4
|
def find_by_name(name)
|
5
|
-
|
5
|
+
name = name.to_s
|
6
6
|
|
7
|
-
license = LicenseFinder::License.
|
7
|
+
license = LicenseFinder::License.find_by_name(name)
|
8
8
|
license.license_url if license
|
9
9
|
end
|
10
10
|
end
|
data/license_finder.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "license_finder"
|
3
|
-
s.version = "0.7.
|
3
|
+
s.version = "0.7.1"
|
4
4
|
s.authors = ["Jacob Maine", "Matthew Kane Parker", "Ian Lesperance", "David Edwards", "Paul Meskers"]
|
5
|
-
s.email = ["
|
5
|
+
s.email = ["licensefinder@pivotalabs.com"]
|
6
6
|
s.homepage = "https://github.com/pivotal/LicenseFinder"
|
7
7
|
s.summary = "Audit the OSS licenses of your application's dependencies."
|
8
8
|
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
|
19
19
|
s.add_dependency "bundler"
|
20
20
|
s.add_development_dependency "rails", ">=3"
|
21
|
-
%w(rspec rake cucumber rails pry capybara).each do |gem|
|
21
|
+
%w(rspec rake cucumber rails pry nokogiri xpath capybara).each do |gem|
|
22
22
|
s.add_development_dependency gem
|
23
23
|
end
|
24
24
|
|
@@ -87,30 +87,6 @@ describe LicenseFinder::BundledGem do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
describe "#readme_files" do
|
91
|
-
it "is empty if there aren't any readme files" do
|
92
|
-
subject.readme_files.should == []
|
93
|
-
end
|
94
|
-
|
95
|
-
it "includes files with names like README, Readme or COPYING" do
|
96
|
-
gemspec.stub(:full_gem_path).and_return(fixture_path('readme'))
|
97
|
-
|
98
|
-
subject.readme_files.map(&:file_name).should =~ [
|
99
|
-
"Project ReadMe",
|
100
|
-
"README",
|
101
|
-
"Readme.markdown"
|
102
|
-
]
|
103
|
-
end
|
104
|
-
|
105
|
-
it "includes files deep in the hierarchy" do
|
106
|
-
gemspec.stub(:full_gem_path).and_return(fixture_path('nested_readme'))
|
107
|
-
|
108
|
-
subject.readme_files.map { |f| [f.file_name, f.file_path] }.should =~ [
|
109
|
-
%w[README vendor/README]
|
110
|
-
]
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
90
|
describe '#to_dependency' do
|
115
91
|
subject { LicenseFinder::BundledGem.new(gemspec).to_dependency }
|
116
92
|
|
@@ -129,6 +105,7 @@ describe LicenseFinder::BundledGem do
|
|
129
105
|
end
|
130
106
|
|
131
107
|
its(:license) { should == 'Detected License' }
|
108
|
+
its(:license_files) { should == ["LICENSE"] }
|
132
109
|
end
|
133
110
|
|
134
111
|
describe 'with an unknown license' do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LicenseFinder::Configuration do
|
4
|
+
it_behaves_like "a persistable configuration"
|
5
|
+
|
6
|
+
let(:config) { LicenseFinder::Configuration.new }
|
7
|
+
|
8
|
+
describe "whitelisted?" do
|
9
|
+
context "canonical name whitelisted" do
|
10
|
+
before { config.whitelist = [LicenseFinder::License::Apache2.names[rand(LicenseFinder::License::Apache2.names.count)]]}
|
11
|
+
|
12
|
+
let(:possible_license_names) { LicenseFinder::License::Apache2.names }
|
13
|
+
|
14
|
+
it "should return true if if the license is the canonical name, pretty name, or alternative name of the license" do
|
15
|
+
possible_license_names.each do |name|
|
16
|
+
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't."
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be case-insensitive" do
|
21
|
+
possible_license_names.map(&:downcase).each do |name|
|
22
|
+
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#ignore_groups" do
|
29
|
+
it "should default to an empty array" do
|
30
|
+
config.ignore_groups.should == []
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should always return symbolized versions of the ignore groups" do
|
34
|
+
config.ignore_groups = %w[test development]
|
35
|
+
config.ignore_groups.should == [:test, :development]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -11,23 +11,32 @@ module LicenseFinder
|
|
11
11
|
'notes' => 'some notes',
|
12
12
|
'homepage' => 'homepage',
|
13
13
|
'license_files' => ['/Users/pivotal/foo/lic1', '/Users/pivotal/bar/lic2'],
|
14
|
-
'readme_files' => ['/Users/pivotal/foo/Readme1', '/Users/pivotal/bar/Readme2'],
|
15
14
|
'source' => "bundle",
|
16
15
|
'bundler_groups' => ["test"]
|
17
16
|
}
|
18
17
|
end
|
19
18
|
|
19
|
+
let(:config) { LicenseFinder::Configuration.new }
|
20
|
+
|
20
21
|
before do
|
21
|
-
LicenseFinder.stub(:config).and_return
|
22
|
-
|
23
|
-
:dependencies_yaml => 'dependencies.yml'
|
24
|
-
}))
|
22
|
+
LicenseFinder.stub(:config).and_return config
|
23
|
+
config.whitelist = ["MIT", "other"]
|
25
24
|
end
|
26
25
|
|
27
26
|
describe "#approved" do
|
28
27
|
it "should return true when the license is whitelisted" do
|
29
28
|
dependency = Dependency.new('license' => 'MIT')
|
30
|
-
dependency.
|
29
|
+
dependency.should be_approved
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should return true when the license is an alternative name of a whitelisted license" do
|
33
|
+
dependency = Dependency.new('license' => 'Expat')
|
34
|
+
dependency.should be_approved
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return true when the license has no matching license class, but is whitelisted anyways" do
|
38
|
+
dependency = Dependency.new('license' => 'other')
|
39
|
+
dependency.should be_approved
|
31
40
|
end
|
32
41
|
|
33
42
|
it "should return false when the license is not whitelisted" do
|
@@ -35,6 +44,8 @@ module LicenseFinder
|
|
35
44
|
dependency.approved.should == false
|
36
45
|
end
|
37
46
|
|
47
|
+
|
48
|
+
|
38
49
|
it "should be overridable" do
|
39
50
|
dependency = Dependency.new
|
40
51
|
dependency.approved = true
|
@@ -55,8 +66,7 @@ module LicenseFinder
|
|
55
66
|
'name' => 'foo',
|
56
67
|
'license' => 'MIT',
|
57
68
|
'version' => '0.0.1',
|
58
|
-
'license_files' => "old license files"
|
59
|
-
'readme_files' => "old readme files"
|
69
|
+
'license_files' => "old license files"
|
60
70
|
)
|
61
71
|
end
|
62
72
|
|
@@ -66,7 +76,6 @@ module LicenseFinder
|
|
66
76
|
'license' => 'MIT',
|
67
77
|
'version' => '0.0.2',
|
68
78
|
'license_files' => "new license files",
|
69
|
-
'readme_files' => "new readme files",
|
70
79
|
'summary' => 'foo summary',
|
71
80
|
'description' => 'awesome foo description!',
|
72
81
|
'bundler_groups' => [1, 2, 3],
|
@@ -82,12 +91,11 @@ module LicenseFinder
|
|
82
91
|
}.to raise_error
|
83
92
|
end
|
84
93
|
|
85
|
-
it 'should return the new version, license files,
|
94
|
+
it 'should return the new version, license files, source, and homepage' do
|
86
95
|
merged = subject.merge(new_dep)
|
87
96
|
|
88
97
|
merged.version.should == '0.0.2'
|
89
98
|
merged.license_files.should == new_dep.license_files
|
90
|
-
merged.readme_files.should == new_dep.readme_files
|
91
99
|
merged.source.should == new_dep.source
|
92
100
|
merged.homepage.should == new_dep.homepage
|
93
101
|
end
|
@@ -167,7 +175,7 @@ module LicenseFinder
|
|
167
175
|
end
|
168
176
|
|
169
177
|
describe "defaults" do
|
170
|
-
%w(license_files
|
178
|
+
%w(license_files bundler_groups children parents).each do |attribute|
|
171
179
|
describe "##{attribute}" do
|
172
180
|
it "should default to an empty array" do
|
173
181
|
Dependency.new.send(attribute).should == []
|
@@ -1,5 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
+
class FooLicense < LicenseFinder::License::Base
|
4
|
+
self.alternative_names = ["the foo license"]
|
5
|
+
self.license_url = "http://foo.license.com"
|
6
|
+
|
7
|
+
def self.pretty_name
|
8
|
+
"Ye Ole Foo License"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module LicenseFinder
|
13
|
+
describe License do
|
14
|
+
describe ".find_by_name" do
|
15
|
+
it "should match on demodulized names" do
|
16
|
+
License.find_by_name("FooLicense").should == FooLicense
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should match on pretty names" do
|
20
|
+
License.find_by_name("Ye Ole Foo License").should == FooLicense
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should match on alternative names" do
|
24
|
+
License.find_by_name("the foo license").should == FooLicense
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return nil if no match" do
|
28
|
+
License.find_by_name(:unknown).should be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
3
34
|
describe LicenseFinder::License::Base do
|
4
35
|
describe ".names" do
|
5
36
|
subject do
|
@@ -10,7 +10,6 @@ shared_examples_for "a persistable dependency" do
|
|
10
10
|
'notes' => 'some notes',
|
11
11
|
'homepage' => 'homepage',
|
12
12
|
'license_files' => ['/Users/pivotal/foo/lic1', '/Users/pivotal/bar/lic2'],
|
13
|
-
'readme_files' => ['/Users/pivotal/foo/Readme1', '/Users/pivotal/bar/Readme2'],
|
14
13
|
'source' => "bundle",
|
15
14
|
'bundler_groups' => ["test"]
|
16
15
|
}
|
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: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date:
|
16
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: bundler
|
@@ -127,6 +127,38 @@ dependencies:
|
|
127
127
|
- - ! '>='
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
|
+
- !ruby/object:Gem::Dependency
|
131
|
+
name: nokogiri
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: xpath
|
148
|
+
requirement: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ! '>='
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
type: :development
|
155
|
+
prerelease: false
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
130
162
|
- !ruby/object:Gem::Dependency
|
131
163
|
name: capybara
|
132
164
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +182,7 @@ description: ! " Do you know the licenses of all your application's dependencie
|
|
150
182
|
with, you can whitelist them, leaving you with an action report of only those dependencies
|
151
183
|
that have \n licenses that fall outside of the whitelist.\n"
|
152
184
|
email:
|
153
|
-
-
|
185
|
+
- licensefinder@pivotalabs.com
|
154
186
|
executables:
|
155
187
|
- license_finder
|
156
188
|
extensions: []
|
@@ -165,12 +197,14 @@ files:
|
|
165
197
|
- bin/license_finder
|
166
198
|
- features/approve_dependencies.feature
|
167
199
|
- features/html_report.feature
|
200
|
+
- features/ignore_bundle_groups.feature
|
168
201
|
- features/license_finder.feature
|
169
202
|
- features/license_finder_rake_task.feature
|
170
203
|
- features/rails_rake.feature
|
171
204
|
- features/set_license.feature
|
172
205
|
- features/step_definitions/steps.rb
|
173
206
|
- features/text_report.feature
|
207
|
+
- features/whitelist.feature
|
174
208
|
- files/license_finder.yml
|
175
209
|
- lib/data/licenses/Apache2.txt
|
176
210
|
- lib/data/licenses/BSD.txt
|
@@ -245,6 +279,7 @@ files:
|
|
245
279
|
- spec/lib/license_finder/bundle_syncer_spec.rb
|
246
280
|
- spec/lib/license_finder/bundled_gem_spec.rb
|
247
281
|
- spec/lib/license_finder/cli_spec.rb
|
282
|
+
- spec/lib/license_finder/configuration_spec.rb
|
248
283
|
- spec/lib/license_finder/dependency_spec.rb
|
249
284
|
- spec/lib/license_finder/html_report_spec.rb
|
250
285
|
- spec/lib/license_finder/license/apache_spec.rb
|
@@ -258,7 +293,6 @@ files:
|
|
258
293
|
- spec/lib/license_finder/license/simplified_bsd_spec.rb
|
259
294
|
- spec/lib/license_finder/license_spec.rb
|
260
295
|
- spec/lib/license_finder/license_url_spec.rb
|
261
|
-
- spec/lib/license_finder/persistence/yaml/configuration_spec.rb
|
262
296
|
- spec/lib/license_finder/persistence/yaml/dependency_spec.rb
|
263
297
|
- spec/lib/license_finder/possible_license_file_spec.rb
|
264
298
|
- spec/lib/license_finder/reporter_spec.rb
|
@@ -282,18 +316,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
282
316
|
- - ! '>='
|
283
317
|
- !ruby/object:Gem::Version
|
284
318
|
version: '0'
|
285
|
-
segments:
|
286
|
-
- 0
|
287
|
-
hash: -3357817247708009893
|
288
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
320
|
none: false
|
290
321
|
requirements:
|
291
322
|
- - ! '>='
|
292
323
|
- !ruby/object:Gem::Version
|
293
324
|
version: '0'
|
294
|
-
segments:
|
295
|
-
- 0
|
296
|
-
hash: -3357817247708009893
|
297
325
|
requirements: []
|
298
326
|
rubyforge_project:
|
299
327
|
rubygems_version: 1.8.24
|
@@ -303,12 +331,14 @@ summary: Audit the OSS licenses of your application's dependencies.
|
|
303
331
|
test_files:
|
304
332
|
- features/approve_dependencies.feature
|
305
333
|
- features/html_report.feature
|
334
|
+
- features/ignore_bundle_groups.feature
|
306
335
|
- features/license_finder.feature
|
307
336
|
- features/license_finder_rake_task.feature
|
308
337
|
- features/rails_rake.feature
|
309
338
|
- features/set_license.feature
|
310
339
|
- features/step_definitions/steps.rb
|
311
340
|
- features/text_report.feature
|
341
|
+
- features/whitelist.feature
|
312
342
|
- spec/fixtures/APACHE-2-LICENSE
|
313
343
|
- spec/fixtures/GPLv2
|
314
344
|
- spec/fixtures/ISC-LICENSE
|
@@ -338,6 +368,7 @@ test_files:
|
|
338
368
|
- spec/lib/license_finder/bundle_syncer_spec.rb
|
339
369
|
- spec/lib/license_finder/bundled_gem_spec.rb
|
340
370
|
- spec/lib/license_finder/cli_spec.rb
|
371
|
+
- spec/lib/license_finder/configuration_spec.rb
|
341
372
|
- spec/lib/license_finder/dependency_spec.rb
|
342
373
|
- spec/lib/license_finder/html_report_spec.rb
|
343
374
|
- spec/lib/license_finder/license/apache_spec.rb
|
@@ -351,7 +382,6 @@ test_files:
|
|
351
382
|
- spec/lib/license_finder/license/simplified_bsd_spec.rb
|
352
383
|
- spec/lib/license_finder/license_spec.rb
|
353
384
|
- spec/lib/license_finder/license_url_spec.rb
|
354
|
-
- spec/lib/license_finder/persistence/yaml/configuration_spec.rb
|
355
385
|
- spec/lib/license_finder/persistence/yaml/dependency_spec.rb
|
356
386
|
- spec/lib/license_finder/possible_license_file_spec.rb
|
357
387
|
- spec/lib/license_finder/reporter_spec.rb
|