Git Product home page Git Product logo

licensefinder's Introduction

License Finder

Build Status Code Climate

With bundler it's easy for your project to depend on many gems. This decomposition is nice, but managing licenses becomes difficult. This tool gathers info about the licenses of the gems in your project.

Installation

Add license_finder to your project's Gemfile and bundle:

gem 'license_finder'

Usage

License finder will generate reports of action items - i.e., dependencies that do not fall within your license "whitelist".

$ license_finder

(Note) If you wish to run license_finder without the progress spinner use the --quiet option.

On a brand new Rails project, you could expect license_finder to output something like the following (assuming you whitelisted the MIT license -- see Configuration):

Dependencies that need approval:

highline, 1.6.14, ruby
json, 1.7.5, ruby
mime-types, 1.19, ruby
rails, 3.2.8, other
rdoc, 3.12, other
rubyzip, 0.9.9, ruby
xml-simple, 1.1.1, other

The executable task will also write out a dependencies.db, dependencies.csv, and dependencies.html file in the doc/ directory (by default -- see Configuration).

The latter two files are human readable reports that you could send to your non-technical business partners, lawyers, etc.

license_finder will also return a non-zero exit status if there are unapproved dependencies. You could use this in a CI build, for example, to alert you whenever someone adds an unapproved dependency to the project.

Run license_finder help to see other available commands.

Manually setting licenses

When license_finder reports that a dependency's license is 'other', you should manually research what the actual license is. When you have established the real license, you can record it with:

$ license_finder license MIT my_unknown_dependency

This command would assign the MIT license to the dependency my_unknown_dependency.

Manually approving dependencies

Whenever you have a dependency that falls outside of your whitelist, license_finder will tell you. If your business decides that this is an acceptable risk, you can manually approve the dependency by using the license_finder approve command.

For example, lets assume you've only whitelisted the "MIT" license in your config/license_finder.yml. You then add the awesome_gpl_gem to your Gemfile, which we'll assume is licensed with the GPL license. You then run license_finder and see the gem listed in the output:

awesome_gpl_gem, 1.0.0, GPL

Your business tells you that in this case, it's acceptable to use this gem. You now run:

$ license_finder approve awesome_gpl_gem

If you rerun license_finder, you should no longer see awesome_gpl_gem in the output.

Managing license whitelist

Licenses can be added to a whitelist that tells LicenseFinder to automatically approve dependencies using the specified licenses. These licenses can be managed with the whitelist command.

To list licenses currently on the whitelist:

$ license_finder whitelist list

To add a license to the whitelist:

$ license_finder whitelist add MIT

To remove a license from the whitelist:

$ license_finder whitelist remove MIT

Managing ignored Bundler groups

Bundler groups can be added to an ignore list which will prevent LicenseFinder from evaluating their licenses. These groups can be managed with the ignored_bundler_groups command.

To list currently ignored Bundler groups:

$ license_finder ignored_bundler_groups list

To add a group to the ignored Bundler groups:

$ license_finder ignored_bundler_groups add development

To remove a group from the ignored Bundler groups:

$ license_finder ignored_bundler_groups remove development

Managing non-Bundler dependencies

license_finder can track dependencies that Bundler doesn't know about (JS libraries that don't appear in your Gemfile, etc.)

$ license_finder dependencies add MIT my_js_dep 0.1.2

To automatically approve a non-bundler dependency when you add it, use:

$ license_finder dependencies add MIT my_js_dep 0.1.2 --approve

The version is optional. Run license_finder dependencies help for additional documentation about managing non-Bundler dependencies.

license_finder cannot automatically detect when a non-Bundler dependency has been removed from your project, so you can use:

$ license_finder dependencies remove my_js_dep

Managing project name

The HTML report generated by license_finder will have the name of your project at the top. By default, this is set to the name of your working directory. However, this can be changed using the command line:

$ license_finder project_name set 'My Project Name'

The changes will be reflected in the report the next time you run license_finder.

Configuration

The first time you run license_finder it will create a default configuration file ./config/license_finder.yml:

---
whitelist:
#- MIT
#- Apache 2.0
ignore_groups:
#- test
#- development
dependencies_file_dir: './doc/'
project_name: My Project Name

By modifying this file, you can configure license_finder's behavior. Whitelisted licenses will be automatically approved and ignore_groups will limit which dependencies are included in your license report. You can store the license database and text files in another directory by changing dependencies_file_dir.

HTML Report

The HTML report generated by license_finder has two sections, an overview at the top, and then a series of dependency summaries afterwards.

HTML Report

The individual dependency summary follows a pattern like this:

HTML Report

Upgrade for pre 0.8.0 users

If you wish to cleanup your root directory you can run:

$ license_finder move

This will move your dependencies.* files to the /doc directory and update the config.

Compatibility

license_finder is compatible with ruby 1.9, and ruby 2.0. There is also experimental support for jruby.

A note to gem authors / maintainers

For the good of humanity, please add a license to your gemspec!

Gem::Specification.new do |s|
  s.name = "my_great_gem"
  s.license = "MIT"
end

And add a LICENSE file to your gem that contains your license text.

Support

Contributing

  • Fork the project
  • Create a feature branch
  • Make your feature addition or bug fix (with tests)
  • Rebase on top of master
  • Send a pull request

License

LicenseFinder is released under the MIT License. http://www.opensource.org/licenses/mit-license

licensefinder's People

Contributors

brentwheeldon avatar mainej avatar pivotalcommon avatar moonmaster9000 avatar kmayer avatar elliterate avatar bwalding avatar bquorning avatar dmgoud avatar nertzy avatar jordimassaguerpla avatar tildewill avatar nycvotes-dev avatar pivotal-joonus avatar

Watchers

Shanmuga avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.