license_finder 6.6.1 → 6.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee81cbd6066d49c1b93db3632b2d67f23e4fb902acb36c0de7c325d5de34646f
4
- data.tar.gz: a419dca63dc18e5cc1729ae19121df28017454ecaade8988ed50461c796d5a17
3
+ metadata.gz: 6280c04b3b05215777ec6e3db87cdff9766dfb6d53a699142710817c09b41335
4
+ data.tar.gz: 3643643ad824644d608e4e6015a34c0de2892c217efe603d7fa66ec937bdeff9
5
5
  SHA512:
6
- metadata.gz: f4d1ddc619a4216629b35e902a17c59f04ea65de6cce867c9cbfcddfb95281d23879bb595b202d867e388dd5f6f6d5ac68f7fa813a111c27b122aaa353ca6d1a
7
- data.tar.gz: 5ec2d9e6f798b53870cf6e7196be92d0a596d58d459de70b585f68f8d8e618d8a98a6b91ded3991ed42f4f9a1793496fc9d7db34966900570201eac77ddc1e6e
6
+ metadata.gz: fc5928a7331d5012b13a87d0fb218fe8141c561e63ba8230e453a65bd206339d9cb593724e810ecd46f7dce231ab16d466df44a119bae1a4d64f00c0518dddaa
7
+ data.tar.gz: 28fbde267804e39d141ad54cd71df26693b2857870be8a5d37a84a04202f25db6398e4e8f216f302e17ecf52daf5810f3db7682712c7a9a1249fb93544ff06a3
@@ -1,3 +1,28 @@
1
+ # [6.8.2] / 2020-09-08
2
+
3
+ # [6.8.1] / 2020-08-13
4
+
5
+ # [6.8.0] / 2020-08-06
6
+
7
+ # [6.7.0] / 2020-07-23
8
+
9
+ # [6.6.2] / 2020-07-09
10
+
11
+ ### Added
12
+ * support for rebar3 - [b20e7444](https://github.com/pivotal/LicenseFinder/commit/b20e7444c147d8dbfa46eb4e8e549e03be751e02) - Jeff Jun
13
+ * Support for Go modules projects outside of the current working directory - [56b3bec6](https://github.com/pivotal/LicenseFinder/commit/56b3bec632b3884ce4cad538742b4a13c55fd7c5)
14
+
15
+ ### Changed
16
+ * 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)
17
+ * Detect Go modules based on `go.mod` (instead of `go.sum`) - [667f6be7](https://github.com/pivotal/LicenseFinder/commit/667f6be716504a53ccc2824daae08af085566546)
18
+
19
+ ### Fixed
20
+ * handle empty case for mix dependencies [#173637843] - [fc34b281](https://github.com/pivotal/LicenseFinder/commit/fc34b2813925a709addde675849e199b05fc4a23) - Jeff Jun
21
+
22
+ ### Removed
23
+ * support for rebar2 [#173637980] - [b20e7444](https://github.com/pivotal/LicenseFinder/commit/b20e7444c147d8dbfa46eb4e8e549e03be751e02) - Jeff Jun
24
+ * Removed the unnecessary prepare command for Go modules - [284cc5c8](https://github.com/pivotal/LicenseFinder/commit/284cc5c821270a6e56275e32bac836a3e451f46b)
25
+
1
26
  # [6.6.1] / 2020-06-30
2
27
 
3
28
  ### Changed
@@ -885,3 +910,8 @@ Bugfixes:
885
910
  [6.5.0]: https://github.com/pivotal/LicenseFinder/compare/v6.4.0...v6.5.0
886
911
  [6.6.0]: https://github.com/pivotal/LicenseFinder/compare/v6.5.0...v6.6.0
887
912
  [6.6.1]: https://github.com/pivotal/LicenseFinder/compare/v6.6.0...v6.6.1
913
+ [6.6.2]: https://github.com/pivotal/LicenseFinder/compare/v6.6.1...v6.6.2
914
+ [6.7.0]: https://github.com/pivotal/LicenseFinder/compare/v6.6.2...v6.7.0
915
+ [6.8.0]: https://github.com/pivotal/LicenseFinder/compare/v6.7.0...v6.8.0
916
+ [6.8.1]: https://github.com/pivotal/LicenseFinder/compare/v6.8.0...v6.8.1
917
+ [6.8.2]: https://github.com/pivotal/LicenseFinder/compare/v6.8.1...v6.8.2
data/Dockerfile CHANGED
@@ -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 python and rebar
52
- RUN apt-get install -y python rebar
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
 
@@ -157,7 +159,7 @@ RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 4F4EA0AAE5
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') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" &&\
162
+ php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { 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.sum` file (for `go mod`)
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 dependencies add my_unknown_dependency MIT --homepage="www.unknown-code.org"
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
@@ -412,7 +413,7 @@ If you have a gradle project, you can invoke gradle with a custom script by
412
413
  passing (for example) `--gradle_command gradlew` to `license_finder` or
413
414
  `license_finder report`.
414
415
 
415
- Similarly you can invoke a custom rebar script with `--rebar_command rebar2`.
416
+ Similarly you can invoke a custom rebar script with `--rebar_command rebar`.
416
417
  If you store rebar dependencies in a custom directory (by setting `deps_dir` in
417
418
  `rebar.config`), set `--rebar_deps_dir`.
418
419
 
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.6.1
1
+ 6.8.2
@@ -35,7 +35,7 @@ module LicenseFinder
35
35
  end
36
36
 
37
37
  def rebar_deps_dir
38
- path = get(:rebar_deps_dir) || 'deps'
38
+ path = get(:rebar_deps_dir) || '_build/default/lib'
39
39
  project_path.join(path).expand_path
40
40
  end
41
41
 
@@ -190,7 +190,7 @@ module LicenseFinder
190
190
  def inherit_from(filepath_info)
191
191
  decisions =
192
192
  if filepath_info.is_a?(Hash)
193
- open_uri(filepath_info['url'], filepath_info['authorization']).read
193
+ resolve_inheritance(filepath_info)
194
194
  elsif filepath_info =~ %r{^https?://}
195
195
  open_uri(filepath_info).read
196
196
  else
@@ -202,6 +202,22 @@ module LicenseFinder
202
202
  restore_inheritance(decisions)
203
203
  end
204
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
+
205
221
  def remove_inheritance(filepath)
206
222
  @decisions -= [[:inherit_from, filepath]]
207
223
  @inherited_decisions.delete(filepath)
@@ -88,7 +88,8 @@ module LicenseFinder
88
88
  @url = nil
89
89
  @matcher = NoneMatcher.new
90
90
  # removes heading and trailing parentesis and splits
91
- names = name[1..-2].split(operator)
91
+ name = name[1..-2] if name.start_with?('(')
92
+ names = name.split(operator)
92
93
  @sub_licenses = names.map do |sub_name|
93
94
  License.find_by_name(sub_name)
94
95
  end
@@ -19,6 +19,7 @@ module LicenseFinder
19
19
  lgpl,
20
20
  lgpl2_1,
21
21
  mit,
22
+ mpl1_1,
22
23
  mpl2,
23
24
  newbsd,
24
25
  ofl,
@@ -182,8 +183,32 @@ module LicenseFinder
182
183
  )
183
184
  end
184
185
 
186
+ def mpl1_1
187
+ header_regexp = /Mozilla Public Licen[sc]e.*Version 1\.1/im
188
+
189
+ header_regexp_matcher = Matcher.from_regex(header_regexp)
190
+ mpl1_1_tmpl = Template.named('MPL1_1')
191
+
192
+ matcher = AnyMatcher.new(
193
+ HeaderMatcher.new(header_regexp_matcher, 2),
194
+ Matcher.from_template(mpl1_1_tmpl)
195
+ )
196
+
197
+ License.new(
198
+ short_name: 'MPL1_1',
199
+ pretty_name: 'Mozilla Public License 1.1',
200
+ other_names: [
201
+ 'MPL-1.1',
202
+ 'Mozilla Public License, Version 1.1',
203
+ 'Mozilla Public License version 1.1'
204
+ ],
205
+ url: 'https://www.mozilla.org/media/MPL/1.1/index.0c5913925d40.txt',
206
+ matcher: matcher
207
+ )
208
+ end
209
+
185
210
  def mpl2
186
- header_regexp = /Mozilla Public Licen[sc]e, version 2.0/
211
+ header_regexp = /Mozilla Public Licen[sc]e, version 2\.0/
187
212
 
188
213
  matcher = AnyMatcher.new(
189
214
  Matcher.from_template(Template.named('MPL2')),
@@ -2,9 +2,14 @@
2
2
 
3
3
  module LicenseFinder
4
4
  class License
5
- HeaderMatcher = Struct.new(:base_matcher) do
5
+ HeaderMatcher = Struct.new(:base_matcher, :first_n_lines) do
6
6
  def matches_text?(text)
7
- header = text.split("\n").first || ''
7
+ n = if first_n_lines.nil?
8
+ 1
9
+ else
10
+ first_n_lines
11
+ end
12
+ header = text.lines.first(n).join || ''
8
13
  base_matcher.matches_text?(header)
9
14
  end
10
15
  end
@@ -0,0 +1,469 @@
1
+ MOZILLA PUBLIC LICENSE
2
+ Version 1.1
3
+
4
+ ---------------
5
+
6
+ 1. Definitions.
7
+
8
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
9
+ Covered Code available to a third party.
10
+
11
+ 1.1. "Contributor" means each entity that creates or contributes to
12
+ the creation of Modifications.
13
+
14
+ 1.2. "Contributor Version" means the combination of the Original
15
+ Code, prior Modifications used by a Contributor, and the Modifications
16
+ made by that particular Contributor.
17
+
18
+ 1.3. "Covered Code" means the Original Code or Modifications or the
19
+ combination of the Original Code and Modifications, in each case
20
+ including portions thereof.
21
+
22
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
23
+ accepted in the software development community for the electronic
24
+ transfer of data.
25
+
26
+ 1.5. "Executable" means Covered Code in any form other than Source
27
+ Code.
28
+
29
+ 1.6. "Initial Developer" means the individual or entity identified
30
+ as the Initial Developer in the Source Code notice required by Exhibit
31
+ A.
32
+
33
+ 1.7. "Larger Work" means a work which combines Covered Code or
34
+ portions thereof with code not governed by the terms of this License.
35
+
36
+ 1.8. "License" means this document.
37
+
38
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
39
+ extent possible, whether at the time of the initial grant or
40
+ subsequently acquired, any and all of the rights conveyed herein.
41
+
42
+ 1.9. "Modifications" means any addition to or deletion from the
43
+ substance or structure of either the Original Code or any previous
44
+ Modifications. When Covered Code is released as a series of files, a
45
+ Modification is:
46
+ A. Any addition to or deletion from the contents of a file
47
+ containing Original Code or previous Modifications.
48
+
49
+ B. Any new file that contains any part of the Original Code or
50
+ previous Modifications.
51
+
52
+ 1.10. "Original Code" means Source Code of computer software code
53
+ which is described in the Source Code notice required by Exhibit A as
54
+ Original Code, and which, at the time of its release under this
55
+ License is not already Covered Code governed by this License.
56
+
57
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
58
+ hereafter acquired, including without limitation, method, process,
59
+ and apparatus claims, in any patent Licensable by grantor.
60
+
61
+ 1.11. "Source Code" means the preferred form of the Covered Code for
62
+ making modifications to it, including all modules it contains, plus
63
+ any associated interface definition files, scripts used to control
64
+ compilation and installation of an Executable, or source code
65
+ differential comparisons against either the Original Code or another
66
+ well known, available Covered Code of the Contributor's choice. The
67
+ Source Code can be in a compressed or archival form, provided the
68
+ appropriate decompression or de-archiving software is widely available
69
+ for no charge.
70
+
71
+ 1.12. "You" (or "Your") means an individual or a legal entity
72
+ exercising rights under, and complying with all of the terms of, this
73
+ License or a future version of this License issued under Section 6.1.
74
+ For legal entities, "You" includes any entity which controls, is
75
+ controlled by, or is under common control with You. For purposes of
76
+ this definition, "control" means (a) the power, direct or indirect,
77
+ to cause the direction or management of such entity, whether by
78
+ contract or otherwise, or (b) ownership of more than fifty percent
79
+ (50%) of the outstanding shares or beneficial ownership of such
80
+ entity.
81
+
82
+ 2. Source Code License.
83
+
84
+ 2.1. The Initial Developer Grant.
85
+ The Initial Developer hereby grants You a world-wide, royalty-free,
86
+ non-exclusive license, subject to third party intellectual property
87
+ claims:
88
+ (a) under intellectual property rights (other than patent or
89
+ trademark) Licensable by Initial Developer to use, reproduce,
90
+ modify, display, perform, sublicense and distribute the Original
91
+ Code (or portions thereof) with or without Modifications, and/or
92
+ as part of a Larger Work; and
93
+
94
+ (b) under Patents Claims infringed by the making, using or
95
+ selling of Original Code, to make, have made, use, practice,
96
+ sell, and offer for sale, and/or otherwise dispose of the
97
+ Original Code (or portions thereof).
98
+
99
+ (c) the licenses granted in this Section 2.1(a) and (b) are
100
+ effective on the date Initial Developer first distributes
101
+ Original Code under the terms of this License.
102
+
103
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
104
+ granted: 1) for code that You delete from the Original Code; 2)
105
+ separate from the Original Code; or 3) for infringements caused
106
+ by: i) the modification of the Original Code or ii) the
107
+ combination of the Original Code with other software or devices.
108
+
109
+ 2.2. Contributor Grant.
110
+ Subject to third party intellectual property claims, each Contributor
111
+ hereby grants You a world-wide, royalty-free, non-exclusive license
112
+
113
+ (a) under intellectual property rights (other than patent or
114
+ trademark) Licensable by Contributor, to use, reproduce, modify,
115
+ display, perform, sublicense and distribute the Modifications
116
+ created by such Contributor (or portions thereof) either on an
117
+ unmodified basis, with other Modifications, as Covered Code
118
+ and/or as part of a Larger Work; and
119
+
120
+ (b) under Patent Claims infringed by the making, using, or
121
+ selling of Modifications made by that Contributor either alone
122
+ and/or in combination with its Contributor Version (or portions
123
+ of such combination), to make, use, sell, offer for sale, have
124
+ made, and/or otherwise dispose of: 1) Modifications made by that
125
+ Contributor (or portions thereof); and 2) the combination of
126
+ Modifications made by that Contributor with its Contributor
127
+ Version (or portions of such combination).
128
+
129
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
130
+ effective on the date Contributor first makes Commercial Use of
131
+ the Covered Code.
132
+
133
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
134
+ granted: 1) for any code that Contributor has deleted from the
135
+ Contributor Version; 2) separate from the Contributor Version;
136
+ 3) for infringements caused by: i) third party modifications of
137
+ Contributor Version or ii) the combination of Modifications made
138
+ by that Contributor with other software (except as part of the
139
+ Contributor Version) or other devices; or 4) under Patent Claims
140
+ infringed by Covered Code in the absence of Modifications made by
141
+ that Contributor.
142
+
143
+ 3. Distribution Obligations.
144
+
145
+ 3.1. Application of License.
146
+ The Modifications which You create or to which You contribute are
147
+ governed by the terms of this License, including without limitation
148
+ Section 2.2. The Source Code version of Covered Code may be
149
+ distributed only under the terms of this License or a future version
150
+ of this License released under Section 6.1, and You must include a
151
+ copy of this License with every copy of the Source Code You
152
+ distribute. You may not offer or impose any terms on any Source Code
153
+ version that alters or restricts the applicable version of this
154
+ License or the recipients' rights hereunder. However, You may include
155
+ an additional document offering the additional rights described in
156
+ Section 3.5.
157
+
158
+ 3.2. Availability of Source Code.
159
+ Any Modification which You create or to which You contribute must be
160
+ made available in Source Code form under the terms of this License
161
+ either on the same media as an Executable version or via an accepted
162
+ Electronic Distribution Mechanism to anyone to whom you made an
163
+ Executable version available; and if made available via Electronic
164
+ Distribution Mechanism, must remain available for at least twelve (12)
165
+ months after the date it initially became available, or at least six
166
+ (6) months after a subsequent version of that particular Modification
167
+ has been made available to such recipients. You are responsible for
168
+ ensuring that the Source Code version remains available even if the
169
+ Electronic Distribution Mechanism is maintained by a third party.
170
+
171
+ 3.3. Description of Modifications.
172
+ You must cause all Covered Code to which You contribute to contain a
173
+ file documenting the changes You made to create that Covered Code and
174
+ the date of any change. You must include a prominent statement that
175
+ the Modification is derived, directly or indirectly, from Original
176
+ Code provided by the Initial Developer and including the name of the
177
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
178
+ Executable version or related documentation in which You describe the
179
+ origin or ownership of the Covered Code.
180
+
181
+ 3.4. Intellectual Property Matters
182
+ (a) Third Party Claims.
183
+ If Contributor has knowledge that a license under a third party's
184
+ intellectual property rights is required to exercise the rights
185
+ granted by such Contributor under Sections 2.1 or 2.2,
186
+ Contributor must include a text file with the Source Code
187
+ distribution titled "LEGAL" which describes the claim and the
188
+ party making the claim in sufficient detail that a recipient will
189
+ know whom to contact. If Contributor obtains such knowledge after
190
+ the Modification is made available as described in Section 3.2,
191
+ Contributor shall promptly modify the LEGAL file in all copies
192
+ Contributor makes available thereafter and shall take other steps
193
+ (such as notifying appropriate mailing lists or newsgroups)
194
+ reasonably calculated to inform those who received the Covered
195
+ Code that new knowledge has been obtained.
196
+
197
+ (b) Contributor APIs.
198
+ If Contributor's Modifications include an application programming
199
+ interface and Contributor has knowledge of patent licenses which
200
+ are reasonably necessary to implement that API, Contributor must
201
+ also include this information in the LEGAL file.
202
+
203
+ (c) Representations.
204
+ Contributor represents that, except as disclosed pursuant to
205
+ Section 3.4(a) above, Contributor believes that Contributor's
206
+ Modifications are Contributor's original creation(s) and/or
207
+ Contributor has sufficient rights to grant the rights conveyed by
208
+ this License.
209
+
210
+ 3.5. Required Notices.
211
+ You must duplicate the notice in Exhibit A in each file of the Source
212
+ Code. If it is not possible to put such notice in a particular Source
213
+ Code file due to its structure, then You must include such notice in a
214
+ location (such as a relevant directory) where a user would be likely
215
+ to look for such a notice. If You created one or more Modification(s)
216
+ You may add your name as a Contributor to the notice described in
217
+ Exhibit A. You must also duplicate this License in any documentation
218
+ for the Source Code where You describe recipients' rights or ownership
219
+ rights relating to Covered Code. You may choose to offer, and to
220
+ charge a fee for, warranty, support, indemnity or liability
221
+ obligations to one or more recipients of Covered Code. However, You
222
+ may do so only on Your own behalf, and not on behalf of the Initial
223
+ Developer or any Contributor. You must make it absolutely clear than
224
+ any such warranty, support, indemnity or liability obligation is
225
+ offered by You alone, and You hereby agree to indemnify the Initial
226
+ Developer and every Contributor for any liability incurred by the
227
+ Initial Developer or such Contributor as a result of warranty,
228
+ support, indemnity or liability terms You offer.
229
+
230
+ 3.6. Distribution of Executable Versions.
231
+ You may distribute Covered Code in Executable form only if the
232
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
233
+ and if You include a notice stating that the Source Code version of
234
+ the Covered Code is available under the terms of this License,
235
+ including a description of how and where You have fulfilled the
236
+ obligations of Section 3.2. The notice must be conspicuously included
237
+ in any notice in an Executable version, related documentation or
238
+ collateral in which You describe recipients' rights relating to the
239
+ Covered Code. You may distribute the Executable version of Covered
240
+ Code or ownership rights under a license of Your choice, which may
241
+ contain terms different from this License, provided that You are in
242
+ compliance with the terms of this License and that the license for the
243
+ Executable version does not attempt to limit or alter the recipient's
244
+ rights in the Source Code version from the rights set forth in this
245
+ License. If You distribute the Executable version under a different
246
+ license You must make it absolutely clear that any terms which differ
247
+ from this License are offered by You alone, not by the Initial
248
+ Developer or any Contributor. You hereby agree to indemnify the
249
+ Initial Developer and every Contributor for any liability incurred by
250
+ the Initial Developer or such Contributor as a result of any such
251
+ terms You offer.
252
+
253
+ 3.7. Larger Works.
254
+ You may create a Larger Work by combining Covered Code with other code
255
+ not governed by the terms of this License and distribute the Larger
256
+ Work as a single product. In such a case, You must make sure the
257
+ requirements of this License are fulfilled for the Covered Code.
258
+
259
+ 4. Inability to Comply Due to Statute or Regulation.
260
+
261
+ If it is impossible for You to comply with any of the terms of this
262
+ License with respect to some or all of the Covered Code due to
263
+ statute, judicial order, or regulation then You must: (a) comply with
264
+ the terms of this License to the maximum extent possible; and (b)
265
+ describe the limitations and the code they affect. Such description
266
+ must be included in the LEGAL file described in Section 3.4 and must
267
+ be included with all distributions of the Source Code. Except to the
268
+ extent prohibited by statute or regulation, such description must be
269
+ sufficiently detailed for a recipient of ordinary skill to be able to
270
+ understand it.
271
+
272
+ 5. Application of this License.
273
+
274
+ This License applies to code to which the Initial Developer has
275
+ attached the notice in Exhibit A and to related Covered Code.
276
+
277
+ 6. Versions of the License.
278
+
279
+ 6.1. New Versions.
280
+ Netscape Communications Corporation ("Netscape") may publish revised
281
+ and/or new versions of the License from time to time. Each version
282
+ will be given a distinguishing version number.
283
+
284
+ 6.2. Effect of New Versions.
285
+ Once Covered Code has been published under a particular version of the
286
+ License, You may always continue to use it under the terms of that
287
+ version. You may also choose to use such Covered Code under the terms
288
+ of any subsequent version of the License published by Netscape. No one
289
+ other than Netscape has the right to modify the terms applicable to
290
+ Covered Code created under this License.
291
+
292
+ 6.3. Derivative Works.
293
+ If You create or use a modified version of this License (which you may
294
+ only do in order to apply it to code which is not already Covered Code
295
+ governed by this License), You must (a) rename Your license so that
296
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
297
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
298
+ license (except to note that your license differs from this License)
299
+ and (b) otherwise make it clear that Your version of the license
300
+ contains terms which differ from the Mozilla Public License and
301
+ Netscape Public License. (Filling in the name of the Initial
302
+ Developer, Original Code or Contributor in the notice described in
303
+ Exhibit A shall not of themselves be deemed to be modifications of
304
+ this License.)
305
+
306
+ 7. DISCLAIMER OF WARRANTY.
307
+
308
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
309
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
310
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
311
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
312
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
313
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
314
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
315
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
316
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
317
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
318
+
319
+ 8. TERMINATION.
320
+
321
+ 8.1. This License and the rights granted hereunder will terminate
322
+ automatically if You fail to comply with terms herein and fail to cure
323
+ such breach within 30 days of becoming aware of the breach. All
324
+ sublicenses to the Covered Code which are properly granted shall
325
+ survive any termination of this License. Provisions which, by their
326
+ nature, must remain in effect beyond the termination of this License
327
+ shall survive.
328
+
329
+ 8.2. If You initiate litigation by asserting a patent infringement
330
+ claim (excluding declatory judgment actions) against Initial Developer
331
+ or a Contributor (the Initial Developer or Contributor against whom
332
+ You file such action is referred to as "Participant") alleging that:
333
+
334
+ (a) such Participant's Contributor Version directly or indirectly
335
+ infringes any patent, then any and all rights granted by such
336
+ Participant to You under Sections 2.1 and/or 2.2 of this License
337
+ shall, upon 60 days notice from Participant terminate prospectively,
338
+ unless if within 60 days after receipt of notice You either: (i)
339
+ agree in writing to pay Participant a mutually agreeable reasonable
340
+ royalty for Your past and future use of Modifications made by such
341
+ Participant, or (ii) withdraw Your litigation claim with respect to
342
+ the Contributor Version against such Participant. If within 60 days
343
+ of notice, a reasonable royalty and payment arrangement are not
344
+ mutually agreed upon in writing by the parties or the litigation claim
345
+ is not withdrawn, the rights granted by Participant to You under
346
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
347
+ the 60 day notice period specified above.
348
+
349
+ (b) any software, hardware, or device, other than such Participant's
350
+ Contributor Version, directly or indirectly infringes any patent, then
351
+ any rights granted to You by such Participant under Sections 2.1(b)
352
+ and 2.2(b) are revoked effective as of the date You first made, used,
353
+ sold, distributed, or had made, Modifications made by that
354
+ Participant.
355
+
356
+ 8.3. If You assert a patent infringement claim against Participant
357
+ alleging that such Participant's Contributor Version directly or
358
+ indirectly infringes any patent where such claim is resolved (such as
359
+ by license or settlement) prior to the initiation of patent
360
+ infringement litigation, then the reasonable value of the licenses
361
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
362
+ into account in determining the amount or value of any payment or
363
+ license.
364
+
365
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
366
+ all end user license agreements (excluding distributors and resellers)
367
+ which have been validly granted by You or any distributor hereunder
368
+ prior to termination shall survive termination.
369
+
370
+ 9. LIMITATION OF LIABILITY.
371
+
372
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
373
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
374
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
375
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
376
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
377
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
378
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
379
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
380
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
381
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
382
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
383
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
384
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
385
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
386
+
387
+ 10. U.S. GOVERNMENT END USERS.
388
+
389
+ The Covered Code is a "commercial item," as that term is defined in
390
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
391
+ software" and "commercial computer software documentation," as such
392
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
393
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
394
+ all U.S. Government End Users acquire Covered Code with only those
395
+ rights set forth herein.
396
+
397
+ 11. MISCELLANEOUS.
398
+
399
+ This License represents the complete agreement concerning subject
400
+ matter hereof. If any provision of this License is held to be
401
+ unenforceable, such provision shall be reformed only to the extent
402
+ necessary to make it enforceable. This License shall be governed by
403
+ California law provisions (except to the extent applicable law, if
404
+ any, provides otherwise), excluding its conflict-of-law provisions.
405
+ With respect to disputes in which at least one party is a citizen of,
406
+ or an entity chartered or registered to do business in the United
407
+ States of America, any litigation relating to this License shall be
408
+ subject to the jurisdiction of the Federal Courts of the Northern
409
+ District of California, with venue lying in Santa Clara County,
410
+ California, with the losing party responsible for costs, including
411
+ without limitation, court costs and reasonable attorneys' fees and
412
+ expenses. The application of the United Nations Convention on
413
+ Contracts for the International Sale of Goods is expressly excluded.
414
+ Any law or regulation which provides that the language of a contract
415
+ shall be construed against the drafter shall not apply to this
416
+ License.
417
+
418
+ 12. RESPONSIBILITY FOR CLAIMS.
419
+
420
+ As between Initial Developer and the Contributors, each party is
421
+ responsible for claims and damages arising, directly or indirectly,
422
+ out of its utilization of rights under this License and You agree to
423
+ work with Initial Developer and Contributors to distribute such
424
+ responsibility on an equitable basis. Nothing herein is intended or
425
+ shall be deemed to constitute any admission of liability.
426
+
427
+ 13. MULTIPLE-LICENSED CODE.
428
+
429
+ Initial Developer may designate portions of the Covered Code as
430
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
431
+ Developer permits you to utilize portions of the Covered Code under
432
+ Your choice of the MPL or the alternative licenses, if any, specified
433
+ by the Initial Developer in the file described in Exhibit A.
434
+
435
+ EXHIBIT A -Mozilla Public License.
436
+
437
+ ``The contents of this file are subject to the Mozilla Public License
438
+ Version 1.1 (the "License"); you may not use this file except in
439
+ compliance with the License. You may obtain a copy of the License at
440
+ https://www.mozilla.org/MPL/
441
+
442
+ Software distributed under the License is distributed on an "AS IS"
443
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
444
+ License for the specific language governing rights and limitations
445
+ under the License.
446
+
447
+ The Original Code is ______________________________________.
448
+
449
+ The Initial Developer of the Original Code is ________________________.
450
+ Portions created by ______________________ are Copyright (C) ______
451
+ _______________________. All Rights Reserved.
452
+
453
+ Contributor(s): ______________________________________.
454
+
455
+ Alternatively, the contents of this file may be used under the terms
456
+ of the _____ license (the "[___] License"), in which case the
457
+ provisions of [______] License are applicable instead of those
458
+ above. If you wish to allow use of your version of this file only
459
+ under the terms of the [____] License and not to allow others to use
460
+ your version of this file under the MPL, indicate your decision by
461
+ deleting the provisions above and replace them with the notice and
462
+ other provisions required by the [___] License. If you do not delete
463
+ the provisions above, a recipient may use your version of this file
464
+ under either the MPL or the [___] License."
465
+
466
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
467
+ the notices in the Source Code files of the Original Code. You should
468
+ use the text of this Exhibit A rather than the text found in the
469
+ Original Code Source Code for Your Modifications.]
@@ -10,8 +10,8 @@ module LicenseFinder
10
10
  SPECIAL_DOUBLE_QUOTES = /[“”„«»]/.freeze
11
11
  ALPHABET_ORDERED_LIST = /\\\([a-z]\\\)\\\s/.freeze
12
12
  ALPHABET_ORDERED_LIST_OPTIONAL = '(\([a-z]\)\s)?'
13
- LIST_BULLETS = /(\d{1,2}\\\.|\\\*)\\\s/.freeze
14
- LIST_BULLETS_OPTIONAL = '(\d{1,2}.|\*)?\s*'
13
+ LIST_BULLETS = /(\d{1,2}\\\.|\\\*|\\\-)\\\s/.freeze
14
+ LIST_BULLETS_OPTIONAL = '(\d{1,2}.|\*|\-)?\s*'
15
15
  NEWLINE_CHARACTER = /\n+/.freeze
16
16
  QUOTE_COMMENT_CHARACTER = /^\s*\>+/.freeze
17
17
  ESCAPED_QUOTES = /\\\"/.freeze
@@ -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'
@@ -163,6 +163,7 @@ require 'license_finder/package_managers/cocoa_pods'
163
163
  require 'license_finder/package_managers/carthage'
164
164
  require 'license_finder/package_managers/gradle'
165
165
  require 'license_finder/package_managers/rebar'
166
+ require 'license_finder/package_managers/erlangmk'
166
167
  require 'license_finder/package_managers/nuget'
167
168
  require 'license_finder/package_managers/dotnet'
168
169
  require 'license_finder/package_managers/dep'
@@ -0,0 +1,50 @@
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
+ # The IS_DEP=1 is added because not all erlang.mk-based projects are
14
+ # updated to a version that is compatible with LicenseFinder
15
+ def prepare_command
16
+ "#{package_management_command_with_path} IS_DEP=1 fetch-deps"
17
+ end
18
+
19
+ def possible_package_paths
20
+ [
21
+ project_path.join('Erlang.mk'),
22
+ project_path.join('erlang.mk')
23
+ ]
24
+ end
25
+
26
+ def current_packages
27
+ deps.map do |dep|
28
+ ErlangmkPackage.new(dep)
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def deps
35
+ command = "#{package_management_command_with_path} QUERY='name fetch_method repo version absolute_path' query-deps"
36
+ stdout, stderr, status = Cmd.run(command)
37
+ if status.success?
38
+ dep_re = Regexp.new('^\s*DEP')
39
+ line_re = Regexp.new('^[_a-z0-9]+:')
40
+ stdout.each_line.map(&:strip).select { |line| !(line.start_with?('make') || line =~ dep_re) && line =~ line_re }
41
+ elsif stderr.include? "No rule to make target 'query-deps'"
42
+ # The stderr check happens because not all erlang.mk-based projects are
43
+ # updated to a version that is compatible with LicenseFinder
44
+ []
45
+ else
46
+ raise "Command '#{command}' failed to execute: #{stderr}"
47
+ end
48
+ end
49
+ end
50
+ 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.sum'
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
- sum_files?
16
+ mod_files?
21
17
  end
22
18
 
23
19
  def current_packages
@@ -33,19 +29,44 @@ module LicenseFinder
33
29
  private
34
30
 
35
31
  def packages_info
36
- info_output, stderr, _status = Cmd.run("GO111MODULE=on go list -m -f '{{.Path}},{{.Version}},{{.Dir}}' all")
37
- if stderr =~ Regexp.compile("can't compute 'all' using the vendor directory")
38
- info_output, _stderr, _status = Cmd.run("GO111MODULE=on go list -m -mod=mod -f '{{.Path}},{{.Version}},{{.Dir}}' all")
39
- end
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 }}'
40
47
 
41
- info_output.split("\n")
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
42
63
  end
43
64
 
44
- def sum_files?
45
- sum_file_paths.any?
65
+ def mod_files?
66
+ mod_file_paths.any?
46
67
  end
47
68
 
48
- def sum_file_paths
69
+ def mod_file_paths
49
70
  Dir[project_path.join(PACKAGES_FILE)]
50
71
  end
51
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
 
@@ -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] || 'deps')
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
- rebar_ouput.map do |name, version_type, version_value, homepage|
12
+ rebar_deps.map do |name, version|
13
+ licenses, homepage = dep_info(name)
13
14
  RebarPackage.new(
14
15
  name,
15
- "#{version_type}: #{version_value}",
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
- 'rebar'
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 rebar_ouput
34
- command = "#{@command} list-deps"
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 { |line| line.split(' ') }
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
@@ -0,0 +1,114 @@
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
+ dep_version_unformatted.sub(version_prefix_re, '')
42
+ end
43
+ end
44
+
45
+ def dep_repo
46
+ @dep_repo ||= dep_repo_unformatted
47
+ .chomp('.git')
48
+ .sub('git@github.com:', 'https://github.com/')
49
+ end
50
+
51
+ def raise_invalid(dep_string)
52
+ invalid_dep_message = "'#{dep_string}' does not look like a valid Erlank.mk dependency"
53
+ valid_dep_example = "A valid dependency example: 'lager: goldrush git https://github.com/DeadZen/goldrush.git 0.1.9 /absolute/path/to/dep'"
54
+ raise(InvalidErlangmkPackageError, "#{invalid_dep_message}. #{valid_dep_example}")
55
+ end
56
+
57
+ def all_parts_valid?
58
+ dep_part_valid?(dep_parent) &&
59
+ dep_part_valid?(dep_name) &&
60
+ set?(dep_fetch_method) &&
61
+ dep_repo_valid? &&
62
+ dep_version_valid? &&
63
+ set?(dep_absolute_path)
64
+ end
65
+
66
+ private
67
+
68
+ def dep_part_valid?(dep_part)
69
+ set?(dep_part) &&
70
+ word?(dep_part)
71
+ end
72
+
73
+ def set?(dep_part)
74
+ !dep_part.nil? &&
75
+ !dep_part.empty?
76
+ end
77
+
78
+ def word?(dep_part)
79
+ dep = dep_part.chomp(':')
80
+ dep =~ word_re
81
+ end
82
+
83
+ def dep_repo_valid?
84
+ set?(dep_repo_unformatted) &&
85
+ URI.parse(dep_repo)
86
+ end
87
+
88
+ def dep_version_valid?
89
+ return false unless set?(dep_version_unformatted)
90
+
91
+ if dep_version =~ version_re
92
+ Gem::Version.correct?(dep_version)
93
+ else
94
+ dep_version =~ word_dot_re
95
+ end
96
+ end
97
+
98
+ def version_re
99
+ @version_re ||= Regexp.new('\d+\.\d+\.\d+')
100
+ end
101
+
102
+ def version_prefix_re
103
+ @version_prefix_re ||= Regexp.new('^v')
104
+ end
105
+
106
+ def word_re
107
+ @word_re ||= Regexp.new('^\w+$')
108
+ end
109
+
110
+ def word_dot_re
111
+ @word_dot_re ||= Regexp.new('^[.\w]+$')
112
+ end
113
+ end
114
+ end
@@ -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.6.1
4
+ version: 6.8.2
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-06-30 00:00:00.000000000 Z
30
+ date: 2020-09-08 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler
@@ -392,6 +392,7 @@ files:
392
392
  - lib/license_finder/license/templates/LGPL.txt
393
393
  - lib/license_finder/license/templates/LGPL2_1.txt
394
394
  - lib/license_finder/license/templates/MIT.txt
395
+ - lib/license_finder/license/templates/MPL1_1.txt
395
396
  - lib/license_finder/license/templates/MPL2.txt
396
397
  - lib/license_finder/license/templates/NewBSD.txt
397
398
  - lib/license_finder/license/templates/OFL.txt
@@ -414,6 +415,7 @@ files:
414
415
  - lib/license_finder/package_managers/conan.rb
415
416
  - lib/license_finder/package_managers/dep.rb
416
417
  - lib/license_finder/package_managers/dotnet.rb
418
+ - lib/license_finder/package_managers/erlangmk.rb
417
419
  - lib/license_finder/package_managers/glide.rb
418
420
  - lib/license_finder/package_managers/go_15vendorexperiment.rb
419
421
  - lib/license_finder/package_managers/go_dep.rb
@@ -449,6 +451,7 @@ files:
449
451
  - lib/license_finder/packages/cocoa_pods_package.rb
450
452
  - lib/license_finder/packages/composer_package.rb
451
453
  - lib/license_finder/packages/conan_package.rb
454
+ - lib/license_finder/packages/erlangmk_package.rb
452
455
  - lib/license_finder/packages/go_package.rb
453
456
  - lib/license_finder/packages/gradle_package.rb
454
457
  - lib/license_finder/packages/manual_package.rb