license_finder 6.6.0 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00a090f4a84431d9c17451f6d1ee035e45a9cb79964e3b54eeb6f76f8b852cff
4
- data.tar.gz: c9b1590ea442e18751cc06de3b6a2219345e179bf29339312663d0391cccb323
3
+ metadata.gz: ee81cbd6066d49c1b93db3632b2d67f23e4fb902acb36c0de7c325d5de34646f
4
+ data.tar.gz: a419dca63dc18e5cc1729ae19121df28017454ecaade8988ed50461c796d5a17
5
5
  SHA512:
6
- metadata.gz: fbb1eddec4981aac19f48cfd0c525d5f56ac5ec1a5cd4c234a3a4c2b9609efd6fb747f9c9b345397ec0b2328623b8a5f2da9aedab0a7cc8c7cafc4ade34c4511
7
- data.tar.gz: 75104bce30468c753473bef4895b9a6df493bc144eea8599f25c7c0ba9b8e97997407fe822bef1ee109d00227ff9946493e0c791326bf8a8759aa28e56959ed7
6
+ metadata.gz: f4d1ddc619a4216629b35e902a17c59f04ea65de6cce867c9cbfcddfb95281d23879bb595b202d867e388dd5f6f6d5ac68f7fa813a111c27b122aaa353ca6d1a
7
+ data.tar.gz: 5ec2d9e6f798b53870cf6e7196be92d0a596d58d459de70b585f68f8d8e618d8a98a6b91ded3991ed42f4f9a1793496fc9d7db34966900570201eac77ddc1e6e
@@ -1,3 +1,10 @@
1
+ # [6.6.1] / 2020-06-30
2
+
3
+ ### Changed
4
+ * Handle multiple solution files for nuget [#173021333] - [040d9559](https://github.com/pivotal/LicenseFinder/commit/040d9559a4bda07490255cc34c1a7891081bc511)
5
+ * 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
6
+ * Update Nuget Package Manager prepare command - [6ac07066](https://github.com/pivotal/LicenseFinder/commit/6ac070668955bc034da1647658440ce5bb0d9bd2) - Jason Smith
7
+
1
8
  # [6.6.0] / 2020-06-22
2
9
 
3
10
  # [6.5.0] / 2020-06-01
@@ -877,3 +884,4 @@ Bugfixes:
877
884
  [6.4.0]: https://github.com/pivotal/LicenseFinder/compare/v6.3.0...v6.4.0
878
885
  [6.5.0]: https://github.com/pivotal/LicenseFinder/compare/v6.4.0...v6.5.0
879
886
  [6.6.0]: https://github.com/pivotal/LicenseFinder/compare/v6.5.0...v6.6.0
887
+ [6.6.1]: https://github.com/pivotal/LicenseFinder/compare/v6.6.0...v6.6.1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 6.6.0
1
+ 6.6.1
@@ -123,21 +123,31 @@ jobs:
123
123
 
124
124
  - name: bump-major
125
125
  plan:
126
- - put: semver-version
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
- - put: semver-version
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
- - put: semver-version
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,16 +187,18 @@ module LicenseFinder
183
187
  self
184
188
  end
185
189
 
186
- def inherit_from(filepath)
190
+ def inherit_from(filepath_info)
187
191
  decisions =
188
- if filepath =~ %r{^https?://}
189
- open_uri(filepath).read
192
+ if filepath_info.is_a?(Hash)
193
+ open_uri(filepath_info['url'], filepath_info['authorization']).read
194
+ elsif filepath_info =~ %r{^https?://}
195
+ open_uri(filepath_info).read
190
196
  else
191
- Pathname(filepath).read
197
+ Pathname(filepath_info).read
192
198
  end
193
199
 
194
- add_decision [:inherit_from, filepath]
195
- @inherited_decisions << filepath
200
+ add_decision [:inherit_from, filepath_info]
201
+ @inherited_decisions << filepath_info
196
202
  restore_inheritance(decisions)
197
203
  end
198
204
 
@@ -213,17 +219,31 @@ module LicenseFinder
213
219
  self
214
220
  end
215
221
 
216
- def open_uri(uri)
222
+ def open_uri(uri, auth = nil)
223
+ header = {}
224
+ auth_header = resolve_authorization(auth)
225
+ header['Authorization'] = auth_header if auth_header
226
+
217
227
  # ruby < 2.5.0 URI.open is private
218
228
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.5.0')
219
229
  # rubocop:disable Security/Open
220
- open(uri)
230
+ open(uri, header)
221
231
  # rubocop:enable Security/Open
222
232
  else
223
- URI.open(uri)
233
+ URI.open(uri, header)
224
234
  end
225
235
  end
226
236
 
237
+ def resolve_authorization(auth)
238
+ return unless auth
239
+
240
+ token_env = auth.match(/\$(\S.*)/)
241
+ return auth unless token_env
242
+
243
+ token = ENV[token_env[1]]
244
+ auth.sub(token_env[0], token)
245
+ end
246
+
227
247
  #########
228
248
  # PERSIST
229
249
  #########
@@ -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,33 @@ 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
+ names = name[1..-2].split(operator)
92
+ @sub_licenses = names.map do |sub_name|
93
+ License.find_by_name(sub_name)
94
+ end
95
+ end
96
+
97
+ attr_reader :sub_licenses
98
+ end
99
+
100
+ class OrLicense < AndLicense
101
+ def self.operator
102
+ ' OR '
103
+ end
104
+
105
+ def initialize(name)
106
+ super(name, OrLicense.operator)
107
+ end
108
+ end
73
109
  end
@@ -90,29 +90,42 @@ module LicenseFinder
90
90
  end
91
91
 
92
92
  def prepare
93
- cmd = prepare_command
94
- stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(cmd) }
95
- return if status.success?
93
+ Dir.chdir(project_path) do
94
+ cmd = prepare_command
95
+ stdout, stderr, status = Cmd.run(cmd)
96
+ return if status.success?
96
97
 
97
- log_errors stderr
98
+ log_errors stderr
98
99
 
99
- if stderr.include?('-PackagesDirectory')
100
- logger.info cmd, 'trying fallback prepare command', color: :magenta
100
+ if stderr.include?('-PackagesDirectory')
101
+ logger.info cmd, 'trying fallback prepare command', color: :magenta
101
102
 
102
- cmd = "#{cmd} -PackagesDirectory ."
103
- stdout, stderr, status = Dir.chdir(project_path) { Cmd.run(cmd) }
104
- return if status.success?
103
+ cmd = "#{cmd} -PackagesDirectory /#{Dir.home}/.nuget/packages"
104
+ stdout, stderr, status = Cmd.run(cmd)
105
+ return if status.success?
105
106
 
106
- log_errors_with_cmd(cmd, stderr)
107
- end
107
+ log_errors_with_cmd(cmd, stderr)
108
+ end
108
109
 
109
- error_message = "Prepare command '#{cmd}' failed\n#{stderr}"
110
- error_message += "\n#{stdout}\n" if !stdout.nil? && !stdout.empty?
111
- raise error_message unless @prepare_no_fail
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
112
114
  end
113
115
 
114
116
  def prepare_command
115
- "#{package_management_command} restore"
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(' && ')
116
129
  end
117
130
 
118
131
  def installed?(logger = Core.default_logger)
@@ -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
- license = spec['license'].to_s.strip
11
+ license_names = spec['license'].to_s.strip.split(' or ')
12
+ has_unrecognized_license = false
12
13
 
13
- return [license] unless INVALID_LICENSES.include?(license)
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', [])
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.0
4
+ version: 6.6.1
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-22 00:00:00.000000000 Z
30
+ date: 2020-06-30 00:00:00.000000000 Z
31
31
  dependencies:
32
32
  - !ruby/object:Gem::Dependency
33
33
  name: bundler