license_finder 6.4.0 → 6.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +51 -2
- data/Dockerfile +11 -9
- data/README.md +27 -4
- data/Rakefile +0 -9
- data/VERSION +1 -1
- data/ci/pipelines/release.yml.erb +14 -4
- data/lib/license_finder/cli/inherited_decisions.rb +18 -0
- data/lib/license_finder/configuration.rb +1 -1
- data/lib/license_finder/decisions.rb +45 -9
- data/lib/license_finder/license.rb +37 -0
- data/lib/license_finder/license/definitions.rb +23 -1
- data/lib/license_finder/license/templates/0BSD.txt +10 -0
- data/lib/license_finder/logger.rb +2 -0
- data/lib/license_finder/package.rb +1 -0
- data/lib/license_finder/package_manager.rb +7 -2
- data/lib/license_finder/package_managers/bundler.rb +1 -1
- data/lib/license_finder/package_managers/dotnet.rb +2 -1
- data/lib/license_finder/package_managers/erlangmk.rb +40 -0
- data/lib/license_finder/package_managers/go_modules.rb +35 -12
- data/lib/license_finder/package_managers/mix.rb +1 -1
- data/lib/license_finder/package_managers/nuget.rb +48 -3
- data/lib/license_finder/package_managers/pipenv.rb +1 -1
- data/lib/license_finder/package_managers/rebar.rb +29 -8
- data/lib/license_finder/package_utils/license_files.rb +2 -2
- data/lib/license_finder/packages/erlangmk_package.rb +107 -0
- data/lib/license_finder/packages/pip_package.rb +9 -2
- data/lib/license_finder/scanner.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b24945564259115c89ce1e2891676e85757074f15e38485ca498f5344b543ebd
|
4
|
+
data.tar.gz: 2ecc05295033dde8a53cb45d76b024e9acd06ba650cb8e83f991be74c0f2ea3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74e0144f9834798f971f024d167ce42afd653e29a2f279ef1b67ace4949ca1bd7ce8375264eb6d14a3bad67d2f4a5d7df5ee5a851cbb5b16df79c4c26555d471
|
7
|
+
data.tar.gz: 9c04d6fb15c1f84d41391dbed3a391f20cafe3511213632d7733c943dbb10d63709ced8ef520308b49421ae21fe2d519c5e38e1efb50fe6d70fb74a041218bf7
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,49 @@
|
|
1
|
+
# [6.7.0] / 2020-07-23
|
2
|
+
|
3
|
+
# [6.6.2] / 2020-07-09
|
4
|
+
|
5
|
+
### Added
|
6
|
+
* support for rebar3 - [b20e7444](https://github.com/pivotal/LicenseFinder/commit/b20e7444c147d8dbfa46eb4e8e549e03be751e02) - Jeff Jun
|
7
|
+
* Support for Go modules projects outside of the current working directory - [56b3bec6](https://github.com/pivotal/LicenseFinder/commit/56b3bec632b3884ce4cad538742b4a13c55fd7c5)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
* Change Go modules to only report imported packages (as with other Go package managers) - [34361fda](https://github.com/pivotal/LicenseFinder/commit/34361fdab2dc3f197f7aec6408175018dee3b453) and [dffae4ab](https://github.com/pivotal/LicenseFinder/commit/dffae4ab95e34115b6a54bf681fc0966a8611f01)
|
11
|
+
* Detect Go modules based on `go.mod` (instead of `go.sum`) - [667f6be7](https://github.com/pivotal/LicenseFinder/commit/667f6be716504a53ccc2824daae08af085566546)
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
* handle empty case for mix dependencies [#173637843] - [fc34b281](https://github.com/pivotal/LicenseFinder/commit/fc34b2813925a709addde675849e199b05fc4a23) - Jeff Jun
|
15
|
+
|
16
|
+
### Removed
|
17
|
+
* support for rebar2 [#173637980] - [b20e7444](https://github.com/pivotal/LicenseFinder/commit/b20e7444c147d8dbfa46eb4e8e549e03be751e02) - Jeff Jun
|
18
|
+
* Removed the unnecessary prepare command for Go modules - [284cc5c8](https://github.com/pivotal/LicenseFinder/commit/284cc5c821270a6e56275e32bac836a3e451f46b)
|
19
|
+
|
20
|
+
# [6.6.1] / 2020-06-30
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
* Handle multiple solution files for nuget [#173021333] - [040d9559](https://github.com/pivotal/LicenseFinder/commit/040d9559a4bda07490255cc34c1a7891081bc511)
|
24
|
+
* matches license names from pypi api call with known licenses to avoid returning misformatted licenses [#173421573] - [6b96d746](https://github.com/pivotal/LicenseFinder/commit/6b96d74600034abcacee6ed2b322aa3abfaa0992) - Jeff Jun
|
25
|
+
* Update Nuget Package Manager prepare command - [6ac07066](https://github.com/pivotal/LicenseFinder/commit/6ac070668955bc034da1647658440ce5bb0d9bd2) - Jason Smith
|
26
|
+
|
27
|
+
# [6.6.0] / 2020-06-22
|
28
|
+
|
29
|
+
# [6.5.0] / 2020-06-01
|
30
|
+
|
31
|
+
### Added
|
32
|
+
* Support legacy nuget projects [#172950097] - [0cccbcf9](https://github.com/pivotal/LicenseFinder/commit/0cccbcf9aa92f4297ef0174242bdb19da1babc65)
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
* Upgrade to golang 1.14.3. Update dotnet-sdk to 3.1 - [0969e98f](https://github.com/pivotal/LicenseFinder/commit/0969e98fde4a82f8931601baa4dd96dc01300a14)
|
36
|
+
|
1
37
|
# [6.4.0] / 2020-05-22
|
2
38
|
|
39
|
+
Big shout out to @forelabs for introducing many new features and improvements for this release. Thanks again!!
|
40
|
+
|
3
41
|
### Added
|
42
|
+
* Introducing new inherited_decisions command - [3453feb](https://github.com/pivotal/LicenseFinder/commit/3453feb659a6c3c6e5aa444e3755ddd5d32f3664) - Sven Dunemann
|
43
|
+
* Decision Applier: Merge manual and system packages - [c690532](https://github.com/pivotal/LicenseFinder/commit/c690532ec8addab16bef4edd390f05ceb353435f) - Sven Dunemann
|
44
|
+
* Introduce package_url to packages - [18972f7](https://github.com/pivotal/LicenseFinder/commit/18972f7b3a04340e1b7bb560780130b68696b8a2) - Sven Dunemann
|
45
|
+
* Add --write-headers option for csv exports - [18e01f8](https://github.com/pivotal/LicenseFinder/commit/18e01f8728a9dc525d7567292cc1e2f390ec854d) - Sven Dunemann
|
46
|
+
* Yarn: Add authors & install_path - [08a0f67](https://github.com/pivotal/LicenseFinder/commit/08a0f67837a218231217767561f2282c1b3a890a) - Sven Dunemann
|
4
47
|
* install path for nuget dependencies [#172251374] - [ad73c946](https://github.com/pivotal/LicenseFinder/commit/ad73c946113846f8f548adfc73542aebb3763175) - Jeff Jun
|
5
48
|
* new Rubocop cops - [c4cc6b8b](https://github.com/pivotal/LicenseFinder/commit/c4cc6b8b13273db17b65cecaf24c9053e4989ea1) - Jeff Jun
|
6
49
|
|
@@ -8,8 +51,9 @@
|
|
8
51
|
* Separate lines in license text with LF when exported to JSON - [baddb976](https://github.com/pivotal/LicenseFinder/commit/baddb976e7a8683c5cc320eddc8c2712dfb16c15) - Robert Huitl
|
9
52
|
|
10
53
|
### Changed
|
11
|
-
*
|
12
|
-
|
54
|
+
* Go15VendorExperiment: Detect go only if vendor includes go files - [0f8e609](https://github.com/pivotal/LicenseFinder/commit/0f8e609f0921937c6187deccd80e4bc4b7d67ee4) - Sven Dunemann
|
55
|
+
* Bump PHP version to 7.4 - [cbe45c5](https://github.com/pivotal/LicenseFinder/commit/cbe45c5cdb3ec200ea215086a3b3eb879e83222a) - Yivan
|
56
|
+
* Significantly improve the license text matching file to be more dynamic - [acf5705](https://github.com/pivotal/LicenseFinder/commit/acf570573b4a2414d9c43212dea5d4ecb157319e)
|
13
57
|
* Update Ruby version to 2.7.1 [#172295831] - [475e2948](https://github.com/pivotal/LicenseFinder/commit/475e2948ec1ad859aee59e77aa9ce2a51e1a5029)
|
14
58
|
|
15
59
|
# [6.3.0] / 2020-05-06
|
@@ -857,3 +901,8 @@ Bugfixes:
|
|
857
901
|
[6.2.0]: https://github.com/pivotal/LicenseFinder/compare/v6.1.2...v6.2.0
|
858
902
|
[6.3.0]: https://github.com/pivotal/LicenseFinder/compare/v6.2.0...v6.3.0
|
859
903
|
[6.4.0]: https://github.com/pivotal/LicenseFinder/compare/v6.3.0...v6.4.0
|
904
|
+
[6.5.0]: https://github.com/pivotal/LicenseFinder/compare/v6.4.0...v6.5.0
|
905
|
+
[6.6.0]: https://github.com/pivotal/LicenseFinder/compare/v6.5.0...v6.6.0
|
906
|
+
[6.6.1]: https://github.com/pivotal/LicenseFinder/compare/v6.6.0...v6.6.1
|
907
|
+
[6.6.2]: https://github.com/pivotal/LicenseFinder/compare/v6.6.1...v6.6.2
|
908
|
+
[6.7.0]: https://github.com/pivotal/LicenseFinder/compare/v6.6.2...v6.7.0
|
data/Dockerfile
CHANGED
@@ -3,7 +3,7 @@ FROM ubuntu:xenial
|
|
3
3
|
# Versioning
|
4
4
|
ENV PIP_INSTALL_VERSION 19.0.2
|
5
5
|
ENV PIP3_INSTALL_VERSION 8.1.1
|
6
|
-
ENV GO_LANG_VERSION 1.
|
6
|
+
ENV GO_LANG_VERSION 1.14.3
|
7
7
|
ENV MAVEN_VERSION 3.6.0
|
8
8
|
ENV SBT_VERSION 1.3.3
|
9
9
|
ENV GRADLE_VERSION 5.6.4
|
@@ -48,11 +48,13 @@ ENV JAVA_HOME=/opt/jdk-12.0.2
|
|
48
48
|
ENV PATH=$PATH:$JAVA_HOME/bin
|
49
49
|
RUN java -version
|
50
50
|
|
51
|
-
# install
|
52
|
-
RUN
|
51
|
+
# install rebar3
|
52
|
+
RUN curl -o rebar3 https://s3.amazonaws.com/rebar3/rebar3 && \
|
53
|
+
sudo chmod +x rebar3 && \
|
54
|
+
sudo mv rebar3 /usr/local/bin/rebar3
|
53
55
|
|
54
|
-
# install and update python-pip
|
55
|
-
RUN apt-get install -y python-pip python3-pip && \
|
56
|
+
# install and update python and python-pip
|
57
|
+
RUN apt-get install -y python python-pip python3-pip && \
|
56
58
|
pip2 install --no-cache-dir --upgrade pip==$PIP_INSTALL_VERSION && \
|
57
59
|
pip3 install --no-cache-dir --upgrade pip==$PIP3_INSTALL_VERSION
|
58
60
|
|
@@ -141,8 +143,8 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E03280
|
|
141
143
|
echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list &&\
|
142
144
|
apt-get update &&\
|
143
145
|
apt-get install -y mono-complete &&\
|
144
|
-
curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe &&\
|
145
|
-
|
146
|
+
curl -o "/usr/local/bin/nuget.exe" "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" &&\
|
147
|
+
curl -o "/usr/local/bin/nugetv3.5.0.exe" "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe"
|
146
148
|
|
147
149
|
# install dotnet core
|
148
150
|
WORKDIR /tmp
|
@@ -150,14 +152,14 @@ RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsof
|
|
150
152
|
sudo dpkg -i packages-microsoft-prod.deb &&\
|
151
153
|
rm packages-microsoft-prod.deb &&\
|
152
154
|
sudo apt-get update &&\
|
153
|
-
sudo apt-get install -y dotnet-runtime-2.1 dotnet-sdk-2.1 dotnet-sdk-2.2 dotnet-sdk-3.0
|
155
|
+
sudo apt-get install -y dotnet-runtime-2.1 dotnet-sdk-2.1 dotnet-sdk-2.2 dotnet-sdk-3.0 dotnet-sdk-3.1
|
154
156
|
|
155
157
|
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4F4EA0AAE5267A6C &&\
|
156
158
|
echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu xenial main" | sudo tee /etc/apt/sources.list.d/php.list &&\
|
157
159
|
apt-get update &&\
|
158
160
|
apt-get install -y php7.4-cli &&\
|
159
161
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" &&\
|
160
|
-
php -r "if (hash_file('sha384', 'composer-setup.php') === '
|
162
|
+
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" &&\
|
161
163
|
php composer-setup.php &&\
|
162
164
|
php -r "unlink('composer-setup.php');" &&\
|
163
165
|
mv composer.phar /usr/bin/composer
|
data/README.md
CHANGED
@@ -43,7 +43,7 @@ and give you an actionable exception report.
|
|
43
43
|
|
44
44
|
### Experimental project types
|
45
45
|
|
46
|
-
* Erlang (via `rebar`)
|
46
|
+
* Erlang (via `rebar` and `Erlang.mk`)
|
47
47
|
* Objective-C, Swift (via Carthage or CocoaPods \[0.39 and below. See [CocoaPods Specs Repo Sharding](http://blog.cocoapods.org/Sharding/)\])
|
48
48
|
* Objective-C (+ CocoaPods 0.39 and below. See [CocoaPods Specs Repo Sharding](http://blog.cocoapods.org/Sharding/))
|
49
49
|
* Elixir (via `mix`)
|
@@ -176,6 +176,7 @@ languages, as long as that language has a package definition in the project dire
|
|
176
176
|
* `Podfile` (for `pod`)
|
177
177
|
* `Cartfile` (for `carthage`)
|
178
178
|
* `rebar.config` (for `rebar`)
|
179
|
+
* `Erlang.mk` or `erlang.mk` file (for `Erlang.mk`)
|
179
180
|
* `mix.exs` (for `mix`)
|
180
181
|
* `packages/` directory (for `nuget`)
|
181
182
|
* `*.csproj` (for `dotnet`)
|
@@ -183,7 +184,7 @@ languages, as long as that language has a package definition in the project dire
|
|
183
184
|
* `glide.lock` file (for `glide`)
|
184
185
|
* `vendor/vendor.json` file (for `govendor`)
|
185
186
|
* `Gopkg.lock` file (for `dep`)
|
186
|
-
* `go.
|
187
|
+
* `go.mod` file (for `go mod`)
|
187
188
|
* `vendor.conf` file (for `trash`)
|
188
189
|
* `yarn.lock` file (for `yarn`)
|
189
190
|
* `conanfile.txt` file (for `conan`)
|
@@ -327,7 +328,7 @@ you should manually research what the actual license is. When you
|
|
327
328
|
have established the real license, you can record it with:
|
328
329
|
|
329
330
|
```sh
|
330
|
-
$ license_finder
|
331
|
+
$ license_finder licenses add my_unknown_dependency MIT --homepage="www.unknown-code.org"
|
331
332
|
```
|
332
333
|
|
333
334
|
This command would assign the MIT license to the dependency
|
@@ -379,6 +380,26 @@ items, even if someone attempts to manually approve or permit it. However,
|
|
379
380
|
if a dependency has even one license that is not restricted, it can still be
|
380
381
|
manually approved or permitted.
|
381
382
|
|
383
|
+
## Decision inheritance
|
384
|
+
|
385
|
+
Add or remove decision files you want to inherit from - see `license_finder inherited_decisions help` for more information.
|
386
|
+
|
387
|
+
This allows you to have a centralized decision file for approved/restricted licenses. If you have multiple projects it's way easier to have one single place where you approved or restricted licenses defined.
|
388
|
+
|
389
|
+
Add one or more decision files to the inherited decisions
|
390
|
+
```bash
|
391
|
+
license_finder inherited_decisions add DECISION_FILE
|
392
|
+
```
|
393
|
+
|
394
|
+
Remove one or more decision files from the inherited decisions
|
395
|
+
```bash
|
396
|
+
license_finder inherited_decisions remove DECISION_FILE
|
397
|
+
```
|
398
|
+
|
399
|
+
List all the inherited decision files
|
400
|
+
```bash
|
401
|
+
license_finder inherited_decisions list
|
402
|
+
```
|
382
403
|
|
383
404
|
## Configuration
|
384
405
|
|
@@ -392,7 +413,7 @@ If you have a gradle project, you can invoke gradle with a custom script by
|
|
392
413
|
passing (for example) `--gradle_command gradlew` to `license_finder` or
|
393
414
|
`license_finder report`.
|
394
415
|
|
395
|
-
Similarly you can invoke a custom rebar script with `--rebar_command
|
416
|
+
Similarly you can invoke a custom rebar script with `--rebar_command rebar`.
|
396
417
|
If you store rebar dependencies in a custom directory (by setting `deps_dir` in
|
397
418
|
`rebar.config`), set `--rebar_deps_dir`.
|
398
419
|
|
@@ -467,6 +488,8 @@ licenseConfigurations := Set("compile", "provided")
|
|
467
488
|
|
468
489
|
## Upgrading
|
469
490
|
|
491
|
+
To upgrade to `license_finder` version >= 6.0, you have to replace the terminology `whitelist` with `permit` and `blacklist` with `restrict` in your `dependency_decisions.yml`. See [Changelog](https://github.com/pivotal/LicenseFinder/blob/master/CHANGELOG.md#600--2020-01-22) for more details.
|
492
|
+
|
470
493
|
To upgrade from `license_finder` version 1.2 to 2.0, see
|
471
494
|
[`license_finder_upgrade`](https://github.com/mainej/license_finder_upgrade).
|
472
495
|
To upgrade to 2.0 from a version lower than 1.2, first upgrade to 1.2, and run
|
data/Rakefile
CHANGED
@@ -6,15 +6,6 @@ Bundler::GemHelper.install_tasks
|
|
6
6
|
require './lib/license_finder/platform'
|
7
7
|
require 'rspec/core/rake_task'
|
8
8
|
|
9
|
-
namespace :spec do
|
10
|
-
desc 'Run test tagged \'focus\''
|
11
|
-
RSpec::Core::RakeTask.new(:focus) do |t|
|
12
|
-
t.fail_on_error = true
|
13
|
-
t.pattern = './spec/**/*_spec.rb'
|
14
|
-
t.rspec_opts = %w[--color --tag focus]
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
9
|
desc 'Run all specs in spec/'
|
19
10
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
20
11
|
t.fail_on_error = true
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
6.
|
1
|
+
6.7.0
|
@@ -24,7 +24,7 @@ resources:
|
|
24
24
|
source:
|
25
25
|
driver: gcs
|
26
26
|
bucket: lf-semver-version
|
27
|
-
key:
|
27
|
+
key: version
|
28
28
|
json_key: ((GCPQueuedReportsBucketCredentials))
|
29
29
|
|
30
30
|
- name: dockerhub-edge
|
@@ -123,21 +123,31 @@ jobs:
|
|
123
123
|
|
124
124
|
- name: bump-major
|
125
125
|
plan:
|
126
|
-
-
|
126
|
+
- get: semver-version
|
127
127
|
tags: ["private-worker"]
|
128
128
|
params: {bump: major}
|
129
|
+
- put: semver-version
|
130
|
+
tags: ["private-worker"]
|
131
|
+
params: {file: semver-version/version}
|
132
|
+
|
129
133
|
|
130
134
|
- name: bump-minor
|
131
135
|
plan:
|
132
|
-
-
|
136
|
+
- get: semver-version
|
133
137
|
tags: ["private-worker"]
|
134
138
|
params: {bump: minor}
|
139
|
+
- put: semver-version
|
140
|
+
tags: ["private-worker"]
|
141
|
+
params: {file: semver-version/version}
|
135
142
|
|
136
143
|
- name: bump-patch
|
137
144
|
plan:
|
138
|
-
-
|
145
|
+
- get: semver-version
|
139
146
|
tags: ["private-worker"]
|
140
147
|
params: {bump: patch}
|
148
|
+
- put: semver-version
|
149
|
+
tags: ["private-worker"]
|
150
|
+
params: {file: semver-version/version}
|
141
151
|
|
142
152
|
- name: release
|
143
153
|
disable_manual_trigger: true
|
@@ -20,6 +20,15 @@ module LicenseFinder
|
|
20
20
|
say "Added #{decision_files.join(', ')} to the inherited decisions"
|
21
21
|
end
|
22
22
|
|
23
|
+
auditable
|
24
|
+
desc 'add_with_auth URL AUTH_TYPE TOKEN_OR_ENV', 'Add a remote decision file that needs authentication'
|
25
|
+
def add_with_auth(*params)
|
26
|
+
url, auth_type, token_or_env = params
|
27
|
+
auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
|
28
|
+
modifying { decisions.add_decision [:inherit_from, auth_info] }
|
29
|
+
say "Added #{url} to the inherited decisions"
|
30
|
+
end
|
31
|
+
|
23
32
|
auditable
|
24
33
|
desc 'remove DECISION_FILE...', 'Remove one or more decision files from the inherited decisions'
|
25
34
|
def remove(*decision_files)
|
@@ -27,6 +36,15 @@ module LicenseFinder
|
|
27
36
|
modifying { decision_files.each { |filepath| decisions.remove_inheritance(filepath) } }
|
28
37
|
say "Removed #{decision_files.join(', ')} from the inherited decisions"
|
29
38
|
end
|
39
|
+
|
40
|
+
auditable
|
41
|
+
desc 'remove_with_auth URL AUTH_TYPE TOKEN_OR_ENV', 'Add a remote decision file that needs authentication'
|
42
|
+
def remove_with_auth(*params)
|
43
|
+
url, auth_type, token_or_env = params
|
44
|
+
auth_info = { 'url' => url, 'authorization' => "#{auth_type} #{token_or_env}" }
|
45
|
+
modifying { decisions.remove_inheritance(auth_info) }
|
46
|
+
say "Removed #{url} from the inherited decisions"
|
47
|
+
end
|
30
48
|
end
|
31
49
|
end
|
32
50
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'open-uri'
|
4
|
+
require 'license_finder/license'
|
4
5
|
|
5
6
|
module LicenseFinder
|
6
7
|
class Decisions
|
@@ -39,6 +40,9 @@ module LicenseFinder
|
|
39
40
|
end
|
40
41
|
|
41
42
|
def permitted?(lic)
|
43
|
+
return lic.sub_licenses.any? { |sub_lic| @permitted.include?(sub_lic) } if lic.is_a?(OrLicense)
|
44
|
+
return lic.sub_licenses.all? { |sub_lic| @permitted.include?(sub_lic) } if lic.is_a?(AndLicense)
|
45
|
+
|
42
46
|
@permitted.include?(lic)
|
43
47
|
end
|
44
48
|
|
@@ -183,19 +187,37 @@ module LicenseFinder
|
|
183
187
|
self
|
184
188
|
end
|
185
189
|
|
186
|
-
def inherit_from(
|
190
|
+
def inherit_from(filepath_info)
|
187
191
|
decisions =
|
188
|
-
if
|
189
|
-
|
192
|
+
if filepath_info.is_a?(Hash)
|
193
|
+
resolve_inheritance(filepath_info)
|
194
|
+
elsif filepath_info =~ %r{^https?://}
|
195
|
+
open_uri(filepath_info).read
|
190
196
|
else
|
191
|
-
Pathname(
|
197
|
+
Pathname(filepath_info).read
|
192
198
|
end
|
193
199
|
|
194
|
-
add_decision [:inherit_from,
|
195
|
-
@inherited_decisions <<
|
200
|
+
add_decision [:inherit_from, filepath_info]
|
201
|
+
@inherited_decisions << filepath_info
|
196
202
|
restore_inheritance(decisions)
|
197
203
|
end
|
198
204
|
|
205
|
+
def resolve_inheritance(filepath_info)
|
206
|
+
if (gem_name = filepath_info['gem'])
|
207
|
+
Pathname(gem_config_path(gem_name, filepath_info['path'])).read
|
208
|
+
else
|
209
|
+
open_uri(filepath_info['url'], filepath_info['authorization']).read
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def gem_config_path(gem_name, relative_config_path)
|
214
|
+
spec = Gem::Specification.find_by_name(gem_name)
|
215
|
+
File.join(spec.gem_dir, relative_config_path)
|
216
|
+
rescue Gem::LoadError => e
|
217
|
+
raise Gem::LoadError,
|
218
|
+
"Unable to find gem #{gem_name}; is the gem installed? #{e}"
|
219
|
+
end
|
220
|
+
|
199
221
|
def remove_inheritance(filepath)
|
200
222
|
@decisions -= [[:inherit_from, filepath]]
|
201
223
|
@inherited_decisions.delete(filepath)
|
@@ -213,17 +235,31 @@ module LicenseFinder
|
|
213
235
|
self
|
214
236
|
end
|
215
237
|
|
216
|
-
def open_uri(uri)
|
238
|
+
def open_uri(uri, auth = nil)
|
239
|
+
header = {}
|
240
|
+
auth_header = resolve_authorization(auth)
|
241
|
+
header['Authorization'] = auth_header if auth_header
|
242
|
+
|
217
243
|
# ruby < 2.5.0 URI.open is private
|
218
244
|
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0')
|
219
245
|
# rubocop:disable Security/Open
|
220
|
-
open(uri)
|
246
|
+
open(uri, header)
|
221
247
|
# rubocop:enable Security/Open
|
222
248
|
else
|
223
|
-
URI.open(uri)
|
249
|
+
URI.open(uri, header)
|
224
250
|
end
|
225
251
|
end
|
226
252
|
|
253
|
+
def resolve_authorization(auth)
|
254
|
+
return unless auth
|
255
|
+
|
256
|
+
token_env = auth.match(/\$(\S.*)/)
|
257
|
+
return auth unless token_env
|
258
|
+
|
259
|
+
token = ENV[token_env[1]]
|
260
|
+
auth.sub(token_env[0], token)
|
261
|
+
end
|
262
|
+
|
227
263
|
#########
|
228
264
|
# PERSIST
|
229
265
|
#########
|
@@ -19,6 +19,9 @@ module LicenseFinder
|
|
19
19
|
|
20
20
|
def find_by_name(name)
|
21
21
|
name ||= 'unknown'
|
22
|
+
return OrLicense.new(name) if name.include?(OrLicense.operator)
|
23
|
+
return AndLicense.new(name) if name.include?(AndLicense.operator)
|
24
|
+
|
22
25
|
all.detect { |l| l.matches_name? l.stripped_name(name) } || Definitions.build_unrecognized(name)
|
23
26
|
end
|
24
27
|
|
@@ -61,6 +64,10 @@ module LicenseFinder
|
|
61
64
|
name.hash
|
62
65
|
end
|
63
66
|
|
67
|
+
def unrecognized_matcher?
|
68
|
+
matcher.is_a?(NoneMatcher)
|
69
|
+
end
|
70
|
+
|
64
71
|
private
|
65
72
|
|
66
73
|
attr_reader :short_name, :pretty_name, :other_names
|
@@ -70,4 +77,34 @@ module LicenseFinder
|
|
70
77
|
([short_name, pretty_name] + other_names).uniq
|
71
78
|
end
|
72
79
|
end
|
80
|
+
class AndLicense < License
|
81
|
+
def self.operator
|
82
|
+
' AND '
|
83
|
+
end
|
84
|
+
|
85
|
+
def initialize(name, operator = AndLicense.operator)
|
86
|
+
@short_name = name
|
87
|
+
@pretty_name = name
|
88
|
+
@url = nil
|
89
|
+
@matcher = NoneMatcher.new
|
90
|
+
# removes heading and trailing parentesis and splits
|
91
|
+
name = name[1..-2] if name.start_with?('(')
|
92
|
+
names = name.split(operator)
|
93
|
+
@sub_licenses = names.map do |sub_name|
|
94
|
+
License.find_by_name(sub_name)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
attr_reader :sub_licenses
|
99
|
+
end
|
100
|
+
|
101
|
+
class OrLicense < AndLicense
|
102
|
+
def self.operator
|
103
|
+
' OR '
|
104
|
+
end
|
105
|
+
|
106
|
+
def initialize(name)
|
107
|
+
super(name, OrLicense.operator)
|
108
|
+
end
|
109
|
+
end
|
73
110
|
end
|
@@ -25,7 +25,8 @@ module LicenseFinder
|
|
25
25
|
python,
|
26
26
|
ruby,
|
27
27
|
simplifiedbsd,
|
28
|
-
wtfpl
|
28
|
+
wtfpl,
|
29
|
+
zerobsd
|
29
30
|
]
|
30
31
|
end
|
31
32
|
|
@@ -302,6 +303,27 @@ module LicenseFinder
|
|
302
303
|
url: 'http://www.wtfpl.net/'
|
303
304
|
)
|
304
305
|
end
|
306
|
+
|
307
|
+
def zerobsd
|
308
|
+
matcher = AnyMatcher.new(
|
309
|
+
Matcher.from_template(Template.named('0BSD'))
|
310
|
+
)
|
311
|
+
|
312
|
+
License.new(
|
313
|
+
short_name: '0BSD',
|
314
|
+
pretty_name: 'BSD Zero Clause License',
|
315
|
+
other_names: [
|
316
|
+
'0-Clause BSD',
|
317
|
+
'Zero-Clause BSD',
|
318
|
+
'BSD-0-Clause',
|
319
|
+
'BSD-Zero-Clause',
|
320
|
+
'BSD 0-Clause',
|
321
|
+
'BSD Zero-Clause'
|
322
|
+
],
|
323
|
+
url: 'https://opensource.org/licenses/0BSD',
|
324
|
+
matcher: matcher
|
325
|
+
)
|
326
|
+
end
|
305
327
|
end
|
306
328
|
end
|
307
329
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
2
|
+
purpose with or without fee is hereby granted.
|
3
|
+
|
4
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
5
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
6
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
7
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
8
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
9
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
10
|
+
PERFORMANCE OF THIS SOFTWARE.
|
@@ -189,6 +189,7 @@ require 'license_finder/packages/gradle_package'
|
|
189
189
|
require 'license_finder/packages/cocoa_pods_package'
|
190
190
|
require 'license_finder/packages/carthage_package'
|
191
191
|
require 'license_finder/packages/rebar_package'
|
192
|
+
require 'license_finder/packages/erlangmk_package'
|
192
193
|
require 'license_finder/packages/mix_package'
|
193
194
|
require 'license_finder/packages/merged_package'
|
194
195
|
require 'license_finder/packages/nuget_package'
|
@@ -119,8 +119,12 @@ module LicenseFinder
|
|
119
119
|
attr_reader :logger, :project_path
|
120
120
|
|
121
121
|
def log_errors(stderr)
|
122
|
-
|
123
|
-
|
122
|
+
log_errors_with_cmd(prepare_command, stderr)
|
123
|
+
end
|
124
|
+
|
125
|
+
def log_errors_with_cmd(prep_cmd, stderr)
|
126
|
+
logger.info prep_cmd, 'did not succeed.', color: :red
|
127
|
+
logger.info prep_cmd, stderr, color: :red
|
124
128
|
log_to_file stderr
|
125
129
|
end
|
126
130
|
|
@@ -159,6 +163,7 @@ require 'license_finder/package_managers/cocoa_pods'
|
|
159
163
|
require 'license_finder/package_managers/carthage'
|
160
164
|
require 'license_finder/package_managers/gradle'
|
161
165
|
require 'license_finder/package_managers/rebar'
|
166
|
+
require 'license_finder/package_managers/erlangmk'
|
162
167
|
require 'license_finder/package_managers/nuget'
|
163
168
|
require 'license_finder/package_managers/dotnet'
|
164
169
|
require 'license_finder/package_managers/dep'
|
@@ -27,7 +27,7 @@ module LicenseFinder
|
|
27
27
|
def prepare_command
|
28
28
|
ignored_groups_argument = !ignored_groups.empty? ? "--without #{ignored_groups.to_a.join(' ')}" : ''
|
29
29
|
|
30
|
-
gem_path = SecureRandom.uuid
|
30
|
+
gem_path = "lf-bundler-gems-#{SecureRandom.uuid}"
|
31
31
|
logger.info self.class, "Running bundle install for #{Dir.pwd} with path #{gem_path}", color: :blue
|
32
32
|
|
33
33
|
"bundle install #{ignored_groups_argument} --path #{gem_path}".strip
|
@@ -63,7 +63,8 @@ module LicenseFinder
|
|
63
63
|
.uniq { |d| [d.name, d.version] }
|
64
64
|
|
65
65
|
package_metadatas.map do |d|
|
66
|
-
|
66
|
+
path = Dir.glob("#{Dir.home}/.nuget/packages/#{d.name.downcase}/#{d.version}").first
|
67
|
+
NugetPackage.new(d.name, d.version, spec_licenses: d.read_license_urls, install_path: path)
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LicenseFinder
|
4
|
+
class Erlangmk < PackageManager
|
5
|
+
def package_management_command
|
6
|
+
'make'
|
7
|
+
end
|
8
|
+
|
9
|
+
def package_management_command_with_path
|
10
|
+
"#{package_management_command} --directory=#{project_path} --no-print-directory"
|
11
|
+
end
|
12
|
+
|
13
|
+
def prepare_command
|
14
|
+
"#{package_management_command_with_path} fetch-deps"
|
15
|
+
end
|
16
|
+
|
17
|
+
def possible_package_paths
|
18
|
+
[
|
19
|
+
project_path.join('Erlang.mk'),
|
20
|
+
project_path.join('erlang.mk')
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def current_packages
|
25
|
+
deps.map do |dep|
|
26
|
+
ErlangmkPackage.new(dep)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def deps
|
33
|
+
command = "#{package_management_command_with_path} QUERY='name fetch_method repo version absolute_path' query-deps"
|
34
|
+
stdout, stderr, status = Cmd.run(command)
|
35
|
+
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
|
36
|
+
|
37
|
+
stdout.each_line.map(&:strip).reject { |line| line.start_with?('make') }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -4,7 +4,7 @@ require 'license_finder/packages/go_package'
|
|
4
4
|
|
5
5
|
module LicenseFinder
|
6
6
|
class GoModules < PackageManager
|
7
|
-
PACKAGES_FILE = 'go.
|
7
|
+
PACKAGES_FILE = 'go.mod'
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def takes_priority_over
|
@@ -12,12 +12,8 @@ module LicenseFinder
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def prepare_command
|
16
|
-
'GO111MODULE=on go mod tidy && GO111MODULE=on go mod vendor'
|
17
|
-
end
|
18
|
-
|
19
15
|
def active?
|
20
|
-
|
16
|
+
mod_files?
|
21
17
|
end
|
22
18
|
|
23
19
|
def current_packages
|
@@ -33,17 +29,44 @@ module LicenseFinder
|
|
33
29
|
private
|
34
30
|
|
35
31
|
def packages_info
|
36
|
-
|
37
|
-
|
32
|
+
Dir.chdir(project_path) do
|
33
|
+
# Explanations:
|
34
|
+
# * Only list dependencies (packages not listed in the project directory)
|
35
|
+
# (.DepOnly)
|
36
|
+
# * Ignore standard library packages
|
37
|
+
# (not .Standard)
|
38
|
+
# * Replacement modules are respected
|
39
|
+
# (or .Module.Replace .Module)
|
40
|
+
# * Module cache directory or (vendored) package directory
|
41
|
+
# (or $mod.Dir .Dir)
|
42
|
+
format_str = \
|
43
|
+
'{{ if and (.DepOnly) (not .Standard) }}'\
|
44
|
+
'{{ $mod := (or .Module.Replace .Module) }}'\
|
45
|
+
'{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}'\
|
46
|
+
'{{ end }}'
|
38
47
|
|
39
|
-
|
48
|
+
# The module list flag (`-m`) is intentionally not used here. If the module
|
49
|
+
# dependency tree were followed, transitive dependencies that are never imported
|
50
|
+
# may be included.
|
51
|
+
#
|
52
|
+
# Instead, the owning module is listed for each imported package. This better
|
53
|
+
# matches the implementation of other Go package managers.
|
54
|
+
#
|
55
|
+
# TODO: Figure out a way to make the vendor directory work (i.e. remove the
|
56
|
+
# -mod=readonly flag). Each of the imported packages gets listed separatly,
|
57
|
+
# confusing the issue as to which package is the root of the module.
|
58
|
+
info_output, _stderr, _status = Cmd.run("GO111MODULE=on go list -mod=readonly -deps -f '#{format_str}' ./...")
|
59
|
+
|
60
|
+
# Since many packages may belong to a single module, #uniq is used to deduplicate
|
61
|
+
info_output.split("\n").uniq
|
62
|
+
end
|
40
63
|
end
|
41
64
|
|
42
|
-
def
|
43
|
-
|
65
|
+
def mod_files?
|
66
|
+
mod_file_paths.any?
|
44
67
|
end
|
45
68
|
|
46
|
-
def
|
69
|
+
def mod_file_paths
|
47
70
|
Dir[project_path.join(PACKAGES_FILE)]
|
48
71
|
end
|
49
72
|
|
@@ -96,7 +96,7 @@ module LicenseFinder
|
|
96
96
|
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
|
97
97
|
|
98
98
|
packages_lines(stdout)
|
99
|
-
.reject { |package_lines| package_lines.length == 1 } # in_umbrella: true dependencies
|
99
|
+
.reject { |package_lines| package_lines.length == 1 || package_lines.empty? } # in_umbrella: true dependencies
|
100
100
|
.map { |package_lines| [package_lines[0].split(' ')[1], resolve_version(package_lines[1])] }
|
101
101
|
end
|
102
102
|
|
@@ -73,14 +73,59 @@ module LicenseFinder
|
|
73
73
|
assemblies.flat_map(&:dependencies)
|
74
74
|
end
|
75
75
|
|
76
|
+
def nuget_binary
|
77
|
+
legacy_vcproj = Dir['**/*.vcproj'].any?
|
78
|
+
|
79
|
+
if legacy_vcproj
|
80
|
+
'/usr/local/bin/nugetv3.5.0.exe'
|
81
|
+
else
|
82
|
+
'/usr/local/bin/nuget.exe'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
76
86
|
def package_management_command
|
77
87
|
return 'nuget' if LicenseFinder::Platform.windows?
|
78
88
|
|
79
|
-
|
89
|
+
"mono #{nuget_binary}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def prepare
|
93
|
+
Dir.chdir(project_path) do
|
94
|
+
cmd = prepare_command
|
95
|
+
stdout, stderr, status = Cmd.run(cmd)
|
96
|
+
return if status.success?
|
97
|
+
|
98
|
+
log_errors stderr
|
99
|
+
|
100
|
+
if stderr.include?('-PackagesDirectory')
|
101
|
+
logger.info cmd, 'trying fallback prepare command', color: :magenta
|
102
|
+
|
103
|
+
cmd = "#{cmd} -PackagesDirectory /#{Dir.home}/.nuget/packages"
|
104
|
+
stdout, stderr, status = Cmd.run(cmd)
|
105
|
+
return if status.success?
|
106
|
+
|
107
|
+
log_errors_with_cmd(cmd, stderr)
|
108
|
+
end
|
109
|
+
|
110
|
+
error_message = "Prepare command '#{cmd}' failed\n#{stderr}"
|
111
|
+
error_message += "\n#{stdout}\n" if !stdout.nil? && !stdout.empty?
|
112
|
+
raise error_message unless @prepare_no_fail
|
113
|
+
end
|
80
114
|
end
|
81
115
|
|
82
116
|
def prepare_command
|
83
|
-
|
117
|
+
cmd = package_management_command
|
118
|
+
sln_files = Dir['*.sln']
|
119
|
+
cmds = []
|
120
|
+
if sln_files.count > 1
|
121
|
+
sln_files.each do |sln|
|
122
|
+
cmds << "#{cmd} restore #{sln}"
|
123
|
+
end
|
124
|
+
else
|
125
|
+
cmds << "#{cmd} restore"
|
126
|
+
end
|
127
|
+
|
128
|
+
cmds.join(' && ')
|
84
129
|
end
|
85
130
|
|
86
131
|
def installed?(logger = Core.default_logger)
|
@@ -96,7 +141,7 @@ module LicenseFinder
|
|
96
141
|
def nuget_check
|
97
142
|
return 'where nuget' if LicenseFinder::Platform.windows?
|
98
143
|
|
99
|
-
|
144
|
+
"which mono && ls #{nuget_binary}"
|
100
145
|
end
|
101
146
|
|
102
147
|
def self.nuspec_license_urls(specfile_content)
|
@@ -15,7 +15,7 @@ module LicenseFinder
|
|
15
15
|
begin
|
16
16
|
packages = {}
|
17
17
|
each_dependency(groups: allowed_groups) do |name, data, group|
|
18
|
-
version = canonicalize(data['version'])
|
18
|
+
version = canonicalize(data['version'] || 'unknown')
|
19
19
|
package = packages.fetch(key_for(name, version)) do |key|
|
20
20
|
packages[key] = build_package_for(name, version)
|
21
21
|
end
|
@@ -5,23 +5,25 @@ module LicenseFinder
|
|
5
5
|
def initialize(options = {})
|
6
6
|
super
|
7
7
|
@command = options[:rebar_command] || package_management_command
|
8
|
-
@deps_path = Pathname(options[:rebar_deps_dir] || '
|
8
|
+
@deps_path = Pathname(options[:rebar_deps_dir] || File.join(project_path, '_build/default/lib'))
|
9
9
|
end
|
10
10
|
|
11
11
|
def current_packages
|
12
|
-
|
12
|
+
rebar_deps.map do |name, version|
|
13
|
+
licenses, homepage = dep_info(name)
|
13
14
|
RebarPackage.new(
|
14
15
|
name,
|
15
|
-
|
16
|
+
version,
|
16
17
|
install_path: @deps_path.join(name),
|
17
18
|
homepage: homepage,
|
19
|
+
spec_licenses: licenses.nil? ? [] : [licenses],
|
18
20
|
logger: logger
|
19
21
|
)
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
23
25
|
def package_management_command
|
24
|
-
'
|
26
|
+
'rebar3'
|
25
27
|
end
|
26
28
|
|
27
29
|
def possible_package_paths
|
@@ -30,15 +32,34 @@ module LicenseFinder
|
|
30
32
|
|
31
33
|
private
|
32
34
|
|
33
|
-
def
|
34
|
-
command = "#{@command}
|
35
|
+
def rebar_deps
|
36
|
+
command = "#{@command} tree"
|
35
37
|
stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(command) }
|
36
38
|
raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?
|
37
39
|
|
38
40
|
stdout
|
39
41
|
.each_line
|
40
|
-
.reject { |line| line.start_with?('=') }
|
41
|
-
.map
|
42
|
+
.reject { |line| line.start_with?('=') || line.include?('project app') }
|
43
|
+
.map do |line|
|
44
|
+
matches = line.match(/(?<name>\w+)─(?<version>[\S.]+)\s*/)
|
45
|
+
[matches[:name], matches[:version]] if matches
|
46
|
+
end.compact
|
47
|
+
end
|
48
|
+
|
49
|
+
def dep_info(name)
|
50
|
+
command = "#{@command} pkgs #{name}"
|
51
|
+
stdout, _, status = Cmd.run(command)
|
52
|
+
return [nil, nil] unless status.success?
|
53
|
+
|
54
|
+
licenses = nil
|
55
|
+
homepage = nil
|
56
|
+
|
57
|
+
stdout.scan(/Licenses: (?<licenses>.+)|(?<homepage>(https|http).*)/) do |pkg_licenses, pkg_homepage|
|
58
|
+
licenses ||= pkg_licenses
|
59
|
+
homepage ||= pkg_homepage
|
60
|
+
end
|
61
|
+
|
62
|
+
[licenses, homepage]
|
42
63
|
end
|
43
64
|
end
|
44
65
|
end
|
@@ -4,7 +4,7 @@ require 'license_finder/package_utils/possible_license_file'
|
|
4
4
|
|
5
5
|
module LicenseFinder
|
6
6
|
class LicenseFiles
|
7
|
-
CANDIDATE_FILE_NAMES = %w[
|
7
|
+
CANDIDATE_FILE_NAMES = %w[License Licence COPYING README].freeze
|
8
8
|
CANDIDATE_PATH_WILDCARD = "*{#{CANDIDATE_FILE_NAMES.join(',')}}*"
|
9
9
|
|
10
10
|
def self.find(install_path, options = {})
|
@@ -35,7 +35,7 @@ module LicenseFinder
|
|
35
35
|
def candidate_files_and_dirs
|
36
36
|
return [] if install_path.nil?
|
37
37
|
|
38
|
-
Pathname.glob(install_path.join('**', CANDIDATE_PATH_WILDCARD))
|
38
|
+
Pathname.glob(install_path.join('**', CANDIDATE_PATH_WILDCARD), File::FNM_CASEFOLD)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
class InvalidErlangmkPackageError < ArgumentError
|
6
|
+
end
|
7
|
+
|
8
|
+
module LicenseFinder
|
9
|
+
class ErlangmkPackage < Package
|
10
|
+
attr_reader :dep_parent,
|
11
|
+
:dep_name,
|
12
|
+
:dep_fetch_method,
|
13
|
+
:dep_repo_unformatted,
|
14
|
+
:dep_version_unformatted,
|
15
|
+
:dep_absolute_path
|
16
|
+
|
17
|
+
def initialize(dep_string_from_query_deps)
|
18
|
+
@dep_parent,
|
19
|
+
@dep_name,
|
20
|
+
@dep_fetch_method,
|
21
|
+
@dep_repo_unformatted,
|
22
|
+
@dep_version_unformatted,
|
23
|
+
@dep_absolute_path = dep_string_from_query_deps.split
|
24
|
+
|
25
|
+
raise_invalid(dep_string_from_query_deps) unless all_parts_valid?
|
26
|
+
|
27
|
+
super(
|
28
|
+
dep_name,
|
29
|
+
dep_version,
|
30
|
+
homepage: dep_repo,
|
31
|
+
install_path: dep_absolute_path
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def package_manager
|
36
|
+
'Erlangmk'
|
37
|
+
end
|
38
|
+
|
39
|
+
def dep_version
|
40
|
+
@dep_version ||= begin
|
41
|
+
version_prefix_re = Regexp.new('^v')
|
42
|
+
dep_version_unformatted.sub(version_prefix_re, '')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def dep_repo
|
47
|
+
@dep_repo ||= dep_repo_unformatted
|
48
|
+
.chomp('.git')
|
49
|
+
.sub('git@github.com:', 'https://github.com/')
|
50
|
+
end
|
51
|
+
|
52
|
+
def raise_invalid(dep_string)
|
53
|
+
invalid_dep_message = "'#{dep_string}' does not look like a valid Erlank.mk dependency"
|
54
|
+
valid_dep_example = "A valid dependency example: 'lager: goldrush git https://github.com/DeadZen/goldrush.git 0.1.9 /absolute/path/to/dep'"
|
55
|
+
raise(InvalidErlangmkPackageError, "#{invalid_dep_message}. #{valid_dep_example}")
|
56
|
+
end
|
57
|
+
|
58
|
+
def all_parts_valid?
|
59
|
+
dep_part_valid?(dep_parent) &&
|
60
|
+
dep_part_valid?(dep_name) &&
|
61
|
+
set?(dep_fetch_method) &&
|
62
|
+
dep_repo_valid? &&
|
63
|
+
dep_version_valid? &&
|
64
|
+
set?(dep_absolute_path)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def dep_part_valid?(dep_part)
|
70
|
+
set?(dep_part) &&
|
71
|
+
word?(dep_part)
|
72
|
+
end
|
73
|
+
|
74
|
+
def set?(dep_part)
|
75
|
+
!dep_part.nil? &&
|
76
|
+
!dep_part.empty?
|
77
|
+
end
|
78
|
+
|
79
|
+
def word?(dep_part)
|
80
|
+
dep = dep_part.chomp(':')
|
81
|
+
dep =~ word_re
|
82
|
+
end
|
83
|
+
|
84
|
+
def word_re
|
85
|
+
@word_re ||= Regexp.new('^\w+$')
|
86
|
+
end
|
87
|
+
|
88
|
+
def dep_repo_valid?
|
89
|
+
set?(dep_repo_unformatted) &&
|
90
|
+
URI.parse(dep_repo)
|
91
|
+
end
|
92
|
+
|
93
|
+
def dep_version_valid?
|
94
|
+
return false unless set?(dep_version_unformatted)
|
95
|
+
|
96
|
+
if dep_version =~ version_re
|
97
|
+
Gem::Version.correct?(dep_version)
|
98
|
+
else
|
99
|
+
dep_version =~ word_re
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def version_re
|
104
|
+
@version_re ||= Regexp.new('\d+\.\d+\.\d+')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -8,9 +8,16 @@ module LicenseFinder
|
|
8
8
|
INVALID_LICENSES = ['', 'UNKNOWN'].to_set
|
9
9
|
|
10
10
|
def self.license_names_from_spec(spec)
|
11
|
-
|
11
|
+
license_names = spec['license'].to_s.strip.split(' or ')
|
12
|
+
has_unrecognized_license = false
|
12
13
|
|
13
|
-
|
14
|
+
license_names.each do |license_name|
|
15
|
+
license = License.find_by_name(license_name.strip)
|
16
|
+
|
17
|
+
has_unrecognized_license ||= license.unrecognized_matcher?
|
18
|
+
end
|
19
|
+
|
20
|
+
return license_names if !license_names.empty? && !has_unrecognized_license
|
14
21
|
|
15
22
|
spec
|
16
23
|
.fetch('classifiers', [])
|
@@ -4,7 +4,7 @@ module LicenseFinder
|
|
4
4
|
class Scanner
|
5
5
|
PACKAGE_MANAGERS = [
|
6
6
|
GoModules, GoDep, GoWorkspace, Go15VendorExperiment, Glide, Gvt, Govendor, Trash, Dep, Bundler, NPM, Pip,
|
7
|
-
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer, Pipenv
|
7
|
+
Yarn, Bower, Maven, Gradle, CocoaPods, Rebar, Erlangmk, Nuget, Carthage, Mix, Conan, Sbt, Cargo, Dotnet, Composer, Pipenv
|
8
8
|
].freeze
|
9
9
|
|
10
10
|
class << self
|
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: 6.
|
4
|
+
version: 6.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Collins
|
@@ -27,7 +27,7 @@ authors:
|
|
27
27
|
autorequire:
|
28
28
|
bindir: bin
|
29
29
|
cert_chain: []
|
30
|
-
date: 2020-
|
30
|
+
date: 2020-07-23 00:00:00.000000000 Z
|
31
31
|
dependencies:
|
32
32
|
- !ruby/object:Gem::Dependency
|
33
33
|
name: bundler
|
@@ -379,6 +379,7 @@ files:
|
|
379
379
|
- lib/license_finder/license/matcher.rb
|
380
380
|
- lib/license_finder/license/none_matcher.rb
|
381
381
|
- lib/license_finder/license/template.rb
|
382
|
+
- lib/license_finder/license/templates/0BSD.txt
|
382
383
|
- lib/license_finder/license/templates/Apache1_1.txt
|
383
384
|
- lib/license_finder/license/templates/Apache2.txt
|
384
385
|
- lib/license_finder/license/templates/BSD.txt
|
@@ -413,6 +414,7 @@ files:
|
|
413
414
|
- lib/license_finder/package_managers/conan.rb
|
414
415
|
- lib/license_finder/package_managers/dep.rb
|
415
416
|
- lib/license_finder/package_managers/dotnet.rb
|
417
|
+
- lib/license_finder/package_managers/erlangmk.rb
|
416
418
|
- lib/license_finder/package_managers/glide.rb
|
417
419
|
- lib/license_finder/package_managers/go_15vendorexperiment.rb
|
418
420
|
- lib/license_finder/package_managers/go_dep.rb
|
@@ -448,6 +450,7 @@ files:
|
|
448
450
|
- lib/license_finder/packages/cocoa_pods_package.rb
|
449
451
|
- lib/license_finder/packages/composer_package.rb
|
450
452
|
- lib/license_finder/packages/conan_package.rb
|
453
|
+
- lib/license_finder/packages/erlangmk_package.rb
|
451
454
|
- lib/license_finder/packages/go_package.rb
|
452
455
|
- lib/license_finder/packages/gradle_package.rb
|
453
456
|
- lib/license_finder/packages/manual_package.rb
|
@@ -501,7 +504,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
501
504
|
- !ruby/object:Gem::Version
|
502
505
|
version: '0'
|
503
506
|
requirements: []
|
504
|
-
rubygems_version: 3.1.
|
507
|
+
rubygems_version: 3.1.4
|
505
508
|
signing_key:
|
506
509
|
specification_version: 4
|
507
510
|
summary: Audit the OSS licenses of your application's dependencies.
|