You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a major refactor of License Scout that modifies it's operating
model to drive more configuration from external configuration managed
by YAML files rather than by configuration stored within the gem itself.
This allows teams to add exceptions, fallbacks, and other configuration
based on their needs without requiring us to release a new version of
the license_scout gem.
Signed-off-by: Tom Duffield <[email protected]>
LicenseScout discovers and collects the licenses of a project and its
4
-
dependencies, including transitive dependencies.
3
+
License Scout is a utility that discovers and aggregates the licenses for your software project's transitive dependencies.
5
4
6
-
Currently supported project types are:
5
+
Currently supported Dependency Types and Dependency Managers are:
7
6
8
-
* Chef - Berkshelf
9
-
* Erlang - rebar
10
-
* Golang - godeps
11
-
* Javascript - npm
12
-
* Perl - CPAN
13
-
* Ruby - bundler
7
+
Dependency Type | Supported Dependency Managers
8
+
--- | ---
9
+
chef_cookbook | berkshelf
10
+
erlang | rebar
11
+
elixir | mix
12
+
golang | dep, godep, glide
13
+
habitat | habitat
14
+
nodejs | npm
15
+
perl | cpan
16
+
ruby | bundler
17
+
18
+
## Dependencies
19
+
20
+
* If you wish to scan for `berkshelf` dependencies, you'll need to manually install the Berkshelf gem in the same Ruby as License Scout
21
+
* If you wish to scan for `mix` or `rebar` dependencies, you'll need to install Erlang OTP 18.3 or greater.
14
22
15
23
## Usage
16
24
25
+
License Scout's default behavior is to scan the current directory and return a breakdown of all the licenses it can find.
26
+
17
27
```bash
18
-
$ bin/license_scout /dir/to/scout/successfully/
28
+
my_project $ license_scout
29
+
30
+
+------+------------+------------+---------+
31
+
| Type | Dependency | License(s) | Results |
32
+
+------+------------+------------+---------+
33
+
...
34
+
```
35
+
36
+
LicenseScout will exit `0` if it was able to find licenses for all your dependencies. Otherwise, it will exit `1`.
37
+
38
+
Under the covers, License Scout leverages [Licensee](http://ben.balter.com/licensee/) (the same Ruby Gem [GitHub](https://developer.github.com/v3/licenses/) uses to detect [OSS licenses](https://spdx.org/licenses/)). In addition to using Licensee to scan your source code for licenses, License Scout will go a step further and attempt to determine if the metadata provided by the Dependency Manager specifies which license each dependency uses. At the end of the process, License Scout will provide you a Dependency Manifest following information:
39
+
40
+
1. The name of the license(s) (the SPDX ID if the a recognized open source license).
41
+
2. The name of the file where the License Scout found the license.
42
+
3. The contents of the license file (if available).
43
+
44
+
In addition to the printout provided to STDOUT, License Scout will also save a JSON manifest of all your dependencies to disk.
45
+
46
+
```json
47
+
{
48
+
"license_manifest_version": 2,
49
+
"generated_on": "<DATE>",
50
+
"name": "<YOUR_PROJECT>",
51
+
"dependencies": [...]
52
+
}
53
+
```
54
+
55
+
For more information about the structure of JSON manifest, please check out the full [JSON Schema](lib/license_scout/data/dependency_manifest_v2_schema.json).
56
+
57
+
### Result Types
58
+
59
+
License Scout will provide a summary of the licenses it finds to STDOUT. These results are intended to provide direction as to which actions may or may not be necessary to generate a Dependency Manifest that meets all of your compliance requirements. To do this it categorizes its findings into the following results.
60
+
61
+
Result | Description
62
+
--- | ---
63
+
Flagged | License Scout was able to determine the license for this software dependency, and it is one of the licenses you have explicitly flagged. You should either remove the dependency or [add an Exception](#dependency-exceptions).
64
+
Missing | License Scout could not find any license files or license metadata associated with this dependency. You should contact the maintainer and/or specify a [Fallback License](#fallback-licenses).
65
+
Unpermitted | License Scout was able to determine the license for this software dependency, but it is not one of the licenses you have explicitly allowed. You should either remove the dependency or [add an Exception](#dependency-exceptions).
66
+
OK | There were no issues.
67
+
Undetermined | License Scout found a license file but was unable to determine (with sufficient confidence) what license that file represents. License Scout was also unable to determine the license using Dependency Manager metadata. You should contact the maintainer and/or specify a [Fallback License](#fallback-licenses).
68
+
69
+
## Advanced Usage
70
+
71
+
### Configuration File(s)
72
+
73
+
You can control License Scout's behavior by providing one or more YAML configuration files, available either locally or via HTTP, to the `--config-files` option of the CLI.
License Scout evalutes these files in the order they are provided, allowing you to hydrate configuration by composing multiple files together. For example, you can have a single organization-wide configuration file that specifies what licenses are allowed and project-specific configuration file that specifies exceptions and which directories to scan.
80
+
81
+
#### How multiple configuration files are handled
82
+
83
+
License Scout uses [mixlib-config](https://github.com/chef/mixlib-config) to handle it's configuration. When loading multiple configuration files, mixlib-config (and thus License Scout) will not perform deep merges of Arrays. That means that License Scout will not merge (for example) `allowed_licenses` (or `flagged_licenses`) from two different configuration files; it will only take the `allowed_licenses` value from the configuration that is loaded last. This logic does not apply to the `fallbacks` or `exceptions`, because those are defined as [`config_contexts`](lib/license_scout/config.rb). It **does** apply to the individuals types specified within the `fallbacks` or `exceptions` however.
84
+
85
+
### Allowed and Flagged Licenses
19
86
20
-
$ bin/license_scout /dir/to/scout/unsuccessfully/
21
-
Dependency 'gopkg.in_yaml.v2' version '53feefa2559fb8dfa8d81baad31be332c97d6c77' under 'go_godep' is missing license information.
22
-
>> Found 41 dependencies for go_godep. 40 OK, 1 with problems
87
+
License Scout provides you with the ability to provide a list of licenses that are explicitly allowed, or a list of licenses that should be flagged for further scrutiny.
88
+
89
+
- When you specify a list of `allowed_licenses`, License Scout will exit `1` if it detects a dependency with a license other than one on the list.
90
+
- When you specify a list of `flagged_licenses`, License Scout will exit `1` if it finds a dependency with that license.
91
+
92
+
To add a license to the list of allowed or flagged licenses, you need only provide the array of licenses as a string in your configuration file. A configuration may have a list of allowed licenses _or_ flagged licenses, it cannot have both. _License Scout does not support regular expressions or glob-patterms for `allowed_licenses` or `flagged_licenses`._
93
+
94
+
```yaml
95
+
allowed_licenses:
96
+
- Apache-2.0
97
+
98
+
# OR
99
+
100
+
flagged_licenses:
101
+
- Apache-2.0
23
102
```
24
103
25
-
Detailed instructions for fixing licensing failures found by license_scout are now provided in the script's output. See [bin/license_scout](bin/license_scout) for more details.
104
+
License Scout will compare these string values to the licenses it finds within the dependencies. License Scout does its best to resolve everything down to valid [SPDX IDs](https://spdx.org/licenses/), so you should specify licenses using their SDPX ID.
105
+
106
+
> _Warning: Because we cannot control how maintainers specify licenses in their metadata, there may be a situation where License Scout cannot correctly detect the intended SPDX ID. In this case, you may need to temporarily provide a temporary Fallback License in your configuration. If you encounter this situation, we encourage you to [open an Issue](https://github.com/chef/license_scout) with us._
107
+
108
+
### Dependency Exceptions
109
+
110
+
If you specify a list of allowed or flagged licenses, there may be a dependency that does not adhere to the specified license(s) for which you wish to make an exception. License Scout allows you to specify Exceptions to these lsits as part of your Configuration File.
111
+
112
+
```yaml
113
+
---
114
+
allowed_licenses:
115
+
- Apache-2.0
116
+
117
+
exceptions:
118
+
ruby:
119
+
- name: bundler
120
+
reason: Used only during .gem creation
121
+
- name: json (1.8.3)
122
+
```
123
+
124
+
Exceptions are organized by `type` (e.g. `ruby` - see Table above). There are two elements to each exception: a `name` and a `reason`.
125
+
126
+
Property | Description
127
+
--- | ---
128
+
`name`| Can be specified by `dep-name` or `dep-name (dep-version)` where `dep-name` is the name of the dependency as it exists in the Dependency Manifest and `dep-version` can be a traditional version, git reference, or type-specific version specification such as `$pkg_version-$pkg_release` for Habitat.
129
+
`reason`| An optional string that will be included in the Dependency Manifest for documentation purposes.
130
+
131
+
Simple glob-style pattern matching _is_ supported for Exceptions, so you can have an Exception for a large collection of dependencies without enumerating them all.
132
+
133
+
```yaml
134
+
---
135
+
exceptions:
136
+
chef_cookbook:
137
+
- name: apache2 (5.*)
138
+
reason: Allowed by TICKET-001
139
+
habitat:
140
+
- name: core/bundler (1.15.1-*)
141
+
reason: Only used for .gem creation
142
+
ruby:
143
+
- name: aws-sdk-*
144
+
reason: Exception granted by Bobo T. Clown on 2018/02/31
145
+
```
146
+
147
+
### Fallback Licenses
148
+
149
+
In situations where License Scout is unable to determine the license for a particular dependency, either because Licensee was not able to identify any of the license files or the Dependency Manager did not provide any metadata that incidated how the dependency was licensed, you'll need to provide a Fallback License in your configuration. Like Exceptions, Fallback Licenses are grouped by `type`.
name | The name of the dependency as it appears in the JSON manifest.
162
+
license_id | The ID of the license as it appears in the JSON manifest.
163
+
license_content | A URL to a file where the raw text of the license can be downloaded.
164
+
165
+
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.
166
+
167
+
## Configuration
168
+
169
+
Value | Description | Default
170
+
--- | --- | ---
171
+
directories | The fully-qualified local paths to the directories you wish to scan | _The current working directory._ |
172
+
name | The name you want to give to the scan result. | _The basename of the first directory to be scanned._ |
173
+
output_directory | The path to the directory where the output JSON file should be saved. | _The current working directory._ |
174
+
log_level | What log information should be included in STDOUT | `info` |
175
+
allowed_licenses | Only allow dependencies to have these licenses. | `[]` |
176
+
flagged_licenses | An array of licenses that should be flagged for removal or exception. | `[]` |
177
+
exceptions | An array of Exceptions. | `[]` |
178
+
environment | A hash of additional Environment Variables to pass to [mixlib-shellout](https://github.com/chef/mixlib-shellout) | `{}` |
179
+
escript_bin | The path to the `escript` binary you wish to use when shelling out to Erlang. | `escript` |
180
+
ruby_bin | The path to the `ruby` binary you wish to use when shelling out to Ruby. | `ruby` |
181
+
cpanm_root | The path to where the cpanminus install cache is located. | `~/.cpanm` |
26
182
27
183
## Contributing
28
184
29
-
This project is maintained by the contribution guidelines identified for
30
-
[chef](https://github.com/chef/chef) project. You can find the guidelines here:
185
+
This project is maintained by the contribution guidelines identified for [chef](https://github.com/chef/chef) project. You can find the guidelines here:
0 commit comments