license_finder 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/Rakefile +21 -0
- data/bin/license_finder +54 -0
- data/db/migrate/201303290935_create_dependencies.rb +14 -0
- data/db/migrate/201303291155_create_licenses.rb +13 -0
- data/db/migrate/201303291402_create_approvals.rb +13 -0
- data/db/migrate/201303291456_create_ancestries.rb +9 -0
- data/db/migrate/201303291519_create_bundler_groups.rb +13 -0
- data/db/migrate/201303291720_move_manual_from_approvals_to_licenses.rb +11 -0
- data/db/migrate/201303291753_allow_null_license_names.rb +7 -0
- data/db/migrate/201304011027_allow_null_dependency_version.rb +7 -0
- data/db/migrate/201304020947_change_table_name_licenses_to_license_aliases.rb +5 -0
- data/features/approve_dependencies.feature +14 -0
- data/features/html_report.feature +38 -0
- data/features/ignore_bundle_groups.feature +11 -0
- data/features/license_finder.feature +47 -0
- data/features/license_finder_rake_task.feature +37 -0
- data/features/rails_rake.feature +9 -0
- data/features/set_license.feature +12 -0
- data/features/step_definitions/license_finder_steps.rb +25 -0
- data/features/step_definitions/steps.rb +376 -0
- data/features/text_report.feature +27 -0
- data/features/whitelist.feature +24 -0
- data/files/license_finder.yml +8 -0
- data/lib/data/licenses/Apache2.txt +172 -0
- data/lib/data/licenses/BSD.txt +24 -0
- data/lib/data/licenses/GPLv2.txt +339 -0
- data/lib/data/licenses/ISC.txt +2 -0
- data/lib/data/licenses/LGPL.txt +165 -0
- data/lib/data/licenses/MIT.txt +9 -0
- data/lib/data/licenses/NewBSD.txt +21 -0
- data/lib/data/licenses/Ruby.txt +52 -0
- data/lib/data/licenses/SimplifiedBSD.txt +23 -0
- data/lib/license_finder.rb +47 -0
- data/lib/license_finder/bundle.rb +48 -0
- data/lib/license_finder/bundle_syncer.rb +11 -0
- data/lib/license_finder/bundled_gem.rb +48 -0
- data/lib/license_finder/cli.rb +49 -0
- data/lib/license_finder/configuration.rb +71 -0
- data/lib/license_finder/dependency_report.rb +30 -0
- data/lib/license_finder/gem_saver.rb +69 -0
- data/lib/license_finder/html_report.rb +14 -0
- data/lib/license_finder/license.rb +90 -0
- data/lib/license_finder/license/apache2.rb +8 -0
- data/lib/license_finder/license/bsd.rb +4 -0
- data/lib/license_finder/license/gplv2.rb +4 -0
- data/lib/license_finder/license/isc.rb +3 -0
- data/lib/license_finder/license/lgpl.rb +3 -0
- data/lib/license_finder/license/mit.rb +23 -0
- data/lib/license_finder/license/new_bsd.rb +8 -0
- data/lib/license_finder/license/ruby.rb +11 -0
- data/lib/license_finder/license/simplified_bsd.rb +8 -0
- data/lib/license_finder/license_files.rb +36 -0
- data/lib/license_finder/license_url.rb +12 -0
- data/lib/license_finder/platform.rb +32 -0
- data/lib/license_finder/possible_license_file.rb +32 -0
- data/lib/license_finder/railtie.rb +7 -0
- data/lib/license_finder/reporter.rb +20 -0
- data/lib/license_finder/tables.rb +7 -0
- data/lib/license_finder/tables/approval.rb +4 -0
- data/lib/license_finder/tables/bundler_group.rb +4 -0
- data/lib/license_finder/tables/dependency.rb +31 -0
- data/lib/license_finder/tables/license_alias.rb +22 -0
- data/lib/license_finder/text_report.rb +9 -0
- data/lib/license_finder/yml_to_sql.rb +127 -0
- data/lib/tasks/license_finder.rake +7 -0
- data/lib/templates/html_report.erb +111 -0
- data/lib/templates/text_report.erb +3 -0
- data/license_finder.gemspec +36 -0
- data/readme.md +115 -0
- data/spec/fixtures/APACHE-2-LICENSE +202 -0
- data/spec/fixtures/GPLv2 +339 -0
- data/spec/fixtures/ISC-LICENSE +10 -0
- data/spec/fixtures/MIT-LICENSE +22 -0
- data/spec/fixtures/MIT-LICENSE-with-varied-disclaimer +22 -0
- data/spec/fixtures/README-with-MIT-LICENSE +222 -0
- data/spec/fixtures/license_directory/COPYING +0 -0
- data/spec/fixtures/license_directory/LICENSE/BSD-2-Clause.txt +25 -0
- data/spec/fixtures/license_directory/LICENSE/GPL-2.0.txt +339 -0
- data/spec/fixtures/license_directory/LICENSE/LICENSE +191 -0
- data/spec/fixtures/license_directory/LICENSE/MIT.txt +21 -0
- data/spec/fixtures/license_directory/LICENSE/RUBY.txt +60 -0
- data/spec/fixtures/license_names/COPYING.txt +0 -0
- data/spec/fixtures/license_names/LICENSE +0 -0
- data/spec/fixtures/license_names/Licence.rdoc +0 -0
- data/spec/fixtures/license_names/Mit-License +0 -0
- data/spec/fixtures/license_names/README.rdoc +0 -0
- data/spec/fixtures/mit_licensed_gem/LICENSE +22 -0
- data/spec/fixtures/nested_gem/vendor/LICENSE +0 -0
- data/spec/fixtures/nested_readme/vendor/README +0 -0
- data/spec/fixtures/other_licensed_gem/LICENSE +3 -0
- data/spec/fixtures/readme/Project ReadMe b/data/spec/fixtures/readme/Project → ReadMe +0 -0
- data/spec/fixtures/readme/README +0 -0
- data/spec/fixtures/readme/Readme.markdown +0 -0
- data/spec/fixtures/utf8_gem/README +210 -0
- data/spec/lib/license_finder/bundle_spec.rb +61 -0
- data/spec/lib/license_finder/bundle_syncer_spec.rb +16 -0
- data/spec/lib/license_finder/bundled_gem_spec.rb +62 -0
- data/spec/lib/license_finder/cli_spec.rb +38 -0
- data/spec/lib/license_finder/configuration_spec.rb +70 -0
- data/spec/lib/license_finder/gem_saver_spec.rb +155 -0
- data/spec/lib/license_finder/html_report_spec.rb +84 -0
- data/spec/lib/license_finder/license/apache_spec.rb +7 -0
- data/spec/lib/license_finder/license/bsd_spec.rb +41 -0
- data/spec/lib/license_finder/license/gplv2_spec.rb +7 -0
- data/spec/lib/license_finder/license/isc_spec.rb +7 -0
- data/spec/lib/license_finder/license/lgpl_spec.rb +7 -0
- data/spec/lib/license_finder/license/mit_spec.rb +33 -0
- data/spec/lib/license_finder/license/new_bsd_spec.rb +35 -0
- data/spec/lib/license_finder/license/ruby_spec.rb +19 -0
- data/spec/lib/license_finder/license/simplified_bsd_spec.rb +7 -0
- data/spec/lib/license_finder/license_files_spec.rb +50 -0
- data/spec/lib/license_finder/license_spec.rb +45 -0
- data/spec/lib/license_finder/license_url_spec.rb +20 -0
- data/spec/lib/license_finder/possible_license_file_spec.rb +37 -0
- data/spec/lib/license_finder/reporter_spec.rb +4 -0
- data/spec/lib/license_finder/tables/dependency_spec.rb +102 -0
- data/spec/lib/license_finder/tables/license_alias_spec.rb +54 -0
- data/spec/lib/license_finder/text_report_spec.rb +31 -0
- data/spec/lib/license_finder/yml_to_sql_spec.rb +99 -0
- data/spec/lib/license_finder_spec.rb +82 -0
- data/spec/spec_helper.rb +31 -0
- data/spec/support/license_examples.rb +30 -0
- metadata +435 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2012 Pivotal Labs
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
22
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
|
8
|
+
desc "Run all specs in spec/"
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.fail_on_error = true
|
11
|
+
t.pattern = "./spec/**/*_spec.rb"
|
12
|
+
t.rspec_opts = %w[--color]
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
desc "Run all cukes in features/"
|
17
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
18
|
+
t.cucumber_opts = "features --format pretty"
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => [:spec, :features]
|
data/bin/license_finder
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'license_finder'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
module SpinnerStrategy
|
7
|
+
module Spin
|
8
|
+
def self.run
|
9
|
+
thread = Thread.new() {
|
10
|
+
wheel = '\|/-'
|
11
|
+
i = 0
|
12
|
+
while not LicenseFinder::CLI.class_variable_get("@@run_complete") do
|
13
|
+
print "\r ---------- #{wheel[i]} ----------"
|
14
|
+
i = (i + 1) % 4
|
15
|
+
end
|
16
|
+
}
|
17
|
+
yield
|
18
|
+
thread.join
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module Noop
|
23
|
+
def self.run
|
24
|
+
yield
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
options = {}
|
30
|
+
spinner = SpinnerStrategy::Spin
|
31
|
+
|
32
|
+
OptionParser.new do |opts|
|
33
|
+
opts.banner = "Usage: license_finder [options] [dependency]"
|
34
|
+
|
35
|
+
opts.on("-a", "--approve", "Approve a gem by name.") do |gem_name|
|
36
|
+
options[:approve] = true
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-l", "--license [LICENSE]", "Update a gem's license.") do |license|
|
40
|
+
options[:license] = license
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("-q", "--quiet") do
|
44
|
+
spinner = SpinnerStrategy::Noop
|
45
|
+
end
|
46
|
+
end.parse!
|
47
|
+
|
48
|
+
unless options.empty?
|
49
|
+
options[:dependency] = ARGV.last
|
50
|
+
end
|
51
|
+
|
52
|
+
spinner.run {
|
53
|
+
LicenseFinder::CLI.execute! options
|
54
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# sequel -m db/migrate -E sqlite://doc/dependencies.db
|
2
|
+
|
3
|
+
Sequel.migration do
|
4
|
+
change do
|
5
|
+
create_table(:dependencies) do
|
6
|
+
primary_key :id
|
7
|
+
String :name, null: false
|
8
|
+
String :version, null: false
|
9
|
+
String :summary
|
10
|
+
String :description
|
11
|
+
String :homepage
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Feature: Approving non-whitelisted Dependencies
|
2
|
+
So that I can track the dependencies of my application which my business has approved
|
3
|
+
As an application developer using license finder
|
4
|
+
I want to be able to manually approve dependencies that have licenses which fall outside of my whitelist
|
5
|
+
|
6
|
+
Scenario: Approving a non-whitelisted dependency via the `license_finder` command
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app depends on a gem "gpl_gem" licensed with "GPL"
|
9
|
+
When I run "license_finder"
|
10
|
+
Then I should see "gpl_gem" in its output
|
11
|
+
When I run "license_finder -a gpl_gem"
|
12
|
+
When I run "license_finder"
|
13
|
+
Then I should not see "gpl_gem" in its output
|
14
|
+
Then I should see the "gpl_gem" in the html flagged as "approved"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Feature: HTML Report
|
2
|
+
So that I can easily view a report outlining my application dependencies and licenses
|
3
|
+
As a non-technical application product owner
|
4
|
+
I want license finder to generate an easy-to-understand HTML report
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I have an app with license finder
|
8
|
+
|
9
|
+
Scenario: Dependency details listed in HTML report
|
10
|
+
Given my application depends on a gem "mit_licensed_gem" with:
|
11
|
+
| license | summary | description | version | homepage | bundler_groups |
|
12
|
+
| MIT | mit is cool | seriously | 0.0.1 | http://mit_licensed_gem.github.com | test |
|
13
|
+
When I run "license_finder"
|
14
|
+
And I should see the "mit_licensed_gem" in the html with the following details:
|
15
|
+
| license | summary | description | name | bundler_groups |
|
16
|
+
| MIT | mit is cool | seriously | mit_licensed_gem v0.0.1 | test |
|
17
|
+
And the text "MIT" should link to "http://opensource.org/licenses/mit-license"
|
18
|
+
And the text "mit_licensed_gem" should link to "http://mit_licensed_gem.github.com"
|
19
|
+
|
20
|
+
Scenario: Approval status of dependencies indicated in HTML report
|
21
|
+
Given my app depends on a gem "gpl_licensed_gem" licensed with "GPL"
|
22
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
23
|
+
And I whitelist the "MIT" license
|
24
|
+
When I run "license_finder"
|
25
|
+
Then I should see the "gpl_licensed_gem" in the html flagged as "unapproved"
|
26
|
+
And I should see the "mit_licensed_gem" in the html flagged as "approved"
|
27
|
+
|
28
|
+
Scenario: Dependency summary
|
29
|
+
Given my app depends on a gem "gpl_licensed_gem" licensed with "GPL"
|
30
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
31
|
+
And I whitelist the following licenses: "MIT, other"
|
32
|
+
When I run "license_finder"
|
33
|
+
# rake, bundler, license_finder, my_app, gpl_licensed_gem, mit_licensed_gem
|
34
|
+
Then I should see "8 total" in the html
|
35
|
+
# gpl_licensed_gem
|
36
|
+
And I should see "1 unapproved" in the html
|
37
|
+
# gpl_licensed_gem
|
38
|
+
And I should see "1 GPL" in the html
|
@@ -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
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Feature: License Finder command line executable
|
2
|
+
So that I can report and manage my application's dependencies and licenses to my business
|
3
|
+
As an application developer
|
4
|
+
I want a command-line interface
|
5
|
+
|
6
|
+
Scenario: Running without a configuration file
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app does not have a "config" directory
|
9
|
+
When I run "license_finder -q"
|
10
|
+
Then I should see a "config" directory
|
11
|
+
And I should see the file "config/license_finder.yml" with the following content:
|
12
|
+
"""
|
13
|
+
---
|
14
|
+
whitelist:
|
15
|
+
#- MIT
|
16
|
+
#- Apache 2.0
|
17
|
+
ignore_groups:
|
18
|
+
#- test
|
19
|
+
#- development
|
20
|
+
dependencies_file_dir: './doc/'
|
21
|
+
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Auditing an application with non-whitelisted licenses
|
25
|
+
Given I have an app with license finder
|
26
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
27
|
+
When I run "license_finder -q"
|
28
|
+
Then it should exit with status code 1
|
29
|
+
And I should see "mit_licensed_gem" in its output
|
30
|
+
|
31
|
+
Scenario: Auditing an application with whitelisted licenses
|
32
|
+
Given I have an app with license finder
|
33
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
34
|
+
When I run "license_finder -q"
|
35
|
+
Then I should see "mit_licensed_gem" in its output
|
36
|
+
When I whitelist the following licenses: "MIT, other"
|
37
|
+
And I run "license_finder -q"
|
38
|
+
Then I should see "All gems are approved for use" in its output
|
39
|
+
And it should exit with status code 0
|
40
|
+
|
41
|
+
Scenario: Keep manually set license dependencies
|
42
|
+
Given I have a project that depends on mime-types
|
43
|
+
And I manually set the license type to Ruby
|
44
|
+
And I run license_finder again
|
45
|
+
Then the mime-types license is set to Ruby
|
46
|
+
When I run license_finder again
|
47
|
+
Then the mime-types license is set to Ruby
|
@@ -0,0 +1,37 @@
|
|
1
|
+
Feature: License Finder rake task
|
2
|
+
So that I can break my build suite if someone adds a dependency to the application with a non-whitelisted license
|
3
|
+
As an application developer
|
4
|
+
I want a rake task that exit's with a non-zero exit status if there are any action items
|
5
|
+
|
6
|
+
Scenario: Running without a configuration file
|
7
|
+
Given I have an app with rake and license finder
|
8
|
+
And my app does not have a "config" directory
|
9
|
+
When I run "rake license_finder"
|
10
|
+
Then I should see a "config" directory
|
11
|
+
And I should see the file "config/license_finder.yml" with the following content:
|
12
|
+
"""
|
13
|
+
---
|
14
|
+
whitelist:
|
15
|
+
#- MIT
|
16
|
+
#- Apache 2.0
|
17
|
+
ignore_groups:
|
18
|
+
#- test
|
19
|
+
#- development
|
20
|
+
dependencies_file_dir: './doc/'
|
21
|
+
|
22
|
+
"""
|
23
|
+
|
24
|
+
Scenario: Auditing an application with non-whitelisted licenses
|
25
|
+
Given I have an app with rake and license finder
|
26
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
27
|
+
When I run "rake license_finder"
|
28
|
+
Then it should exit with status code 1
|
29
|
+
And I should see "mit_licensed_gem" in its output
|
30
|
+
|
31
|
+
Scenario: Auditing an application with whitelisted licenses
|
32
|
+
Given I have an app with rake and license finder
|
33
|
+
And my app depends on a gem "mit_licensed_gem" licensed with "MIT"
|
34
|
+
And I whitelist the following licenses: "MIT, other"
|
35
|
+
When I run "rake license_finder"
|
36
|
+
Then it should exit with status code 0
|
37
|
+
And I should see "All gems are approved for use" in its output
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Feature: The rake task is automatically made available in Rails project
|
2
|
+
So that I do not have to modify the Rails rakefile
|
3
|
+
As an application developer
|
4
|
+
I want the license_finder rake task automatically loaded for me in a rails project
|
5
|
+
|
6
|
+
Scenario: The application is a Rails app
|
7
|
+
Given I have a rails app with license finder
|
8
|
+
When I run "rake license_finder"
|
9
|
+
Then I should see "Dependencies that need approval:" in its output
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Feature: Set a dependency's license through a command line interface
|
2
|
+
So that my dependencies all have the correct licenses
|
3
|
+
As an application developer
|
4
|
+
I want a command line interface to set licenses for specific dependencies
|
5
|
+
|
6
|
+
Scenario: Setting a license for a dependency
|
7
|
+
Given I have an app with license finder
|
8
|
+
And my app depends on a gem "other_license_gem" licensed with "other"
|
9
|
+
When I run "license_finder"
|
10
|
+
When I run "license_finder -l MIT other_license_gem"
|
11
|
+
And I run license_finder again
|
12
|
+
Then I should see other_license_gem set to MIT license
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'license_finder'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
4
|
+
require 'bundler'
|
5
|
+
require 'capybara'
|
6
|
+
|
7
|
+
Given /^I have a project that depends on mime\-types$/ do
|
8
|
+
@user = ::DSL::User.new
|
9
|
+
@user.create_rails_app
|
10
|
+
@user.add_gem_dependency('mime-types')
|
11
|
+
@user.bundle_app
|
12
|
+
@user.execute_command "license_finder"
|
13
|
+
end
|
14
|
+
|
15
|
+
Given /^I manually set the license type to Ruby$/ do
|
16
|
+
@output = @user.execute_command "license_finder -l Ruby mime-types"
|
17
|
+
end
|
18
|
+
|
19
|
+
When /^I run license_finder again$/ do
|
20
|
+
@output = @user.execute_command "license_finder -q"
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^the mime\-types license is set to Ruby$/ do
|
24
|
+
@output.should =~ /mime-types.*Ruby/
|
25
|
+
end
|