spandx 0.12.3 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Spandx
4
+ module Spdx
5
+ class Expression < Parslet::Parser
6
+ # https://spdx.org/spdx-specification-21-web-version
7
+ #
8
+ # idstring = 1*(ALPHA / DIGIT / "-" / "." )
9
+ # license-id = <short form license identifier in Appendix I.1>
10
+ # license-exception-id = <short form license exception identifier in Appendix I.2>
11
+ # license-ref = ["DocumentRef-"1*(idstring)":"]"LicenseRef-"1*(idstring)
12
+ # simple-expression = license-id / license-id"+" / license-ref
13
+ # compound-expression = 1*1(simple-expression /
14
+ # simple-expression "WITH" license-exception-id /
15
+ # compound-expression "AND" compound-expression /
16
+ # compound-expression "OR" compound-expression ) /
17
+ # "(" compound-expression ")" )
18
+ #
19
+ # license-expression = 1*1(simple-expression / compound-expression)
20
+ rule(:lparen) { str('(') }
21
+ rule(:rparen) { str(')') }
22
+ rule(:digit) { match('\d') }
23
+ rule(:space) { match('\s') }
24
+ rule(:space?) { space.maybe }
25
+ rule(:alpha) { match['a-zA-Z'] }
26
+ rule(:colon) { str(':') }
27
+ rule(:dot) { str('.') }
28
+ rule(:plus) { str('+') }
29
+ rule(:plus?) { plus.maybe }
30
+ rule(:hyphen) { str('-') }
31
+ rule(:hyphen?) { hyphen.maybe }
32
+ rule(:with_op) { str('with') | str('WITH') }
33
+ rule(:and_op) { str('AND') | str('and') }
34
+ rule(:or_op) { str('OR') | str('or') }
35
+
36
+ # idstring = 1*(ALPHA / DIGIT / "-" / "." )
37
+ rule(:id_character) { alpha | digit | hyphen | dot }
38
+ rule(:id_string) { id_character.repeat(1) }
39
+
40
+ # license-id = <short form license identifier in Appendix I.1>
41
+ rule(:license_id) do
42
+ id_string
43
+ end
44
+
45
+ # license-ref = ["DocumentRef-"1*(idstring)":"]"LicenseRef-"1*(idstring)
46
+ rule(:license_ref) do
47
+ (str('DocumentRef-') >> id_string >> colon).repeat(0, 1) >> str('LicenseRef-') >> id_string
48
+ end
49
+
50
+ # simple-expression = license-id / license-id"+" / license-ref
51
+ rule(:simple_expression) do
52
+ license_id >> plus? | license_ref
53
+ end
54
+
55
+ rule(:exception) do
56
+ match['eE'] >> str('xception')
57
+ end
58
+
59
+ rule(:version) do
60
+ digit >> dot >> digit
61
+ end
62
+
63
+ # license-exception-id = <short form license exception identifier in Appendix I.2>
64
+ rule(:license_exception_id) do
65
+ # alpha.repeat(1) >> hyphen >> exception >> (hyphen? >> version)
66
+ id_string
67
+ end
68
+
69
+ # simple-expression "WITH" license-exception-id
70
+ rule(:with_expression) do
71
+ simple_expression.as(:left) >> space >> with_op.as(:op) >> space >> license_exception_id.as(:right)
72
+ end
73
+
74
+ rule(:binary_operator) do
75
+ (or_op | and_op).as(:op)
76
+ end
77
+
78
+ rule(:binary_right) do
79
+ space >> binary_operator >> space >> (binary_expression | simple_expression).as(:right)
80
+ end
81
+
82
+ # compound-expression "AND" compound-expression
83
+ # compound-expression "OR" compound-expression
84
+ rule(:binary_expression) do
85
+ simple_expression.as(:left) >> binary_right
86
+ end
87
+
88
+ # (BSD-2-Clause OR MIT OR Apache-2.0)
89
+ #
90
+ #
91
+ # compound-expression = 1*1(
92
+ # simple-expression /
93
+ # simple-expression "WITH" license-exception-id /
94
+ # compound-expression "AND" compound-expression /
95
+ # compound-expression "OR" compound-expression
96
+ # ) / "(" compound-expression ")")
97
+ rule(:compound_expression) do
98
+ lparen >> compound_expression >> space? >> rparen |
99
+ (
100
+ binary_expression |
101
+ with_expression |
102
+ simple_expression.as(:left)
103
+ ).repeat(1, 1)
104
+ end
105
+
106
+ # license-expression = 1*1(simple-expression / compound-expression)
107
+ rule(:license_expression) do
108
+ (compound_expression | simple_expression).repeat(1, 1)
109
+ end
110
+
111
+ root(:license_expression)
112
+ end
113
+ end
114
+ end
@@ -61,14 +61,6 @@ module Spandx
61
61
  attributes[:referenceNumber] = value
62
62
  end
63
63
 
64
- def content
65
- @content ||= ::Spandx::Core::Content.new(raw_content)
66
- end
67
-
68
- def content=(value)
69
- @content = ::Spandx::Core::Content.new(value)
70
- end
71
-
72
64
  def <=>(other)
73
65
  id <=> other.id
74
66
  end
@@ -77,14 +69,12 @@ module Spandx
77
69
  id
78
70
  end
79
71
 
80
- def self.unknown(text)
81
- new(licenseId: 'Nonstandard', name: 'Unknown').tap { |x| x.content = text }
72
+ def inspect
73
+ "#<Spandx::Spdx::License id='#{id}'>"
82
74
  end
83
75
 
84
- private
85
-
86
- def raw_content
87
- @raw_content ||= (Spandx.git[:spdx].read("text/#{id}.txt") || '')
76
+ def self.unknown(text)
77
+ new(licenseId: 'Nonstandard', name: text)
88
78
  end
89
79
  end
90
80
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spandx
4
- VERSION = '0.12.3'
4
+ VERSION = '0.13.0'
5
5
  end
data/spandx.gemspec CHANGED
@@ -7,18 +7,18 @@ require 'spandx/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'spandx'
9
9
  spec.version = Spandx::VERSION
10
- spec.authors = ['mo khan']
11
- spec.email = ['mo@mokhan.ca']
10
+ spec.authors = ['Can Eldem', 'mo khan']
11
+ spec.email = ['eldemcan@gmail.com', 'mo@mokhan.ca']
12
12
 
13
13
  spec.summary = 'A ruby interface to the SPDX catalogue.'
14
- spec.description = 'A ruby interface to the SPDX catalogue. With a CLI that can scan project lockfiles to list out software licenses for each dependency'
15
- spec.homepage = 'https://github.com/mokhan/spandx'
14
+ spec.description = 'Spanx is a ruby API for interacting with the spdx.org software license catalogue. This gem includes a command line interface to scan a software project for the software licenses that are associated with each dependency in the project. Spandx also allows you to hook additional information for each dependency found. For instance, you can add plugin to Spandx to find and report vulnerabilities for the dependencies it found.'
15
+ spec.homepage = 'https://spandx.github.io/'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
17
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
18
18
 
19
19
  spec.metadata['homepage_uri'] = spec.homepage
20
- spec.metadata['source_code_uri'] = 'https://github.com/mokhan/spandx'
21
- spec.metadata['changelog_uri'] = 'https://github.com/mokhan/spandx/blob/master/CHANGELOG.md'
20
+ spec.metadata['source_code_uri'] = 'https://github.com/spandx/spandx'
21
+ spec.metadata['changelog_uri'] = 'https://github.com/spandx/spandx/blob/master/CHANGELOG.md'
22
22
 
23
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
24
  Dir.glob('exe/*') +
@@ -29,25 +29,28 @@ Gem::Specification.new do |spec|
29
29
  spec.bindir = 'exe'
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ['lib']
32
+ spec.extensions = ['ext/spandx/extconf.rb']
32
33
 
33
34
  spec.add_dependency 'addressable', '~> 2.7'
34
35
  spec.add_dependency 'bundler', '>= 1.16', '< 3.0.0'
35
36
  spec.add_dependency 'net-hippie', '~> 0.3'
36
37
  spec.add_dependency 'nokogiri', '~> 1.10'
38
+ spec.add_dependency 'parslet', '~> 2.0'
37
39
  spec.add_dependency 'thor'
40
+ spec.add_dependency 'tty-progressbar', '~> 0.17'
38
41
  spec.add_dependency 'zeitwerk', '~> 2.3'
39
42
 
43
+ spec.add_development_dependency 'benchmark-ips', '~> 2.8'
40
44
  spec.add_development_dependency 'bundler-audit', '~> 0.6'
41
45
  spec.add_development_dependency 'byebug', '~> 11.1'
42
- spec.add_development_dependency 'jaro_winkler', '~> 1.5'
43
46
  spec.add_development_dependency 'licensed', '~> 2.8'
44
- spec.add_development_dependency 'parallel_tests', '~> 2.32'
45
47
  spec.add_development_dependency 'rake', '~> 13.0'
48
+ spec.add_development_dependency 'rake-compiler', '~> 1.1'
46
49
  spec.add_development_dependency 'rspec', '~> 3.0'
47
50
  spec.add_development_dependency 'rspec-benchmark', '~> 0.5'
48
51
  spec.add_development_dependency 'rubocop', '~> 0.52'
49
52
  spec.add_development_dependency 'rubocop-rspec', '~> 1.22'
50
- spec.add_development_dependency 'text', '~> 1.3'
53
+ spec.add_development_dependency 'ruby-prof', '~> 1.3'
51
54
  spec.add_development_dependency 'vcr', '~> 5.0'
52
55
  spec.add_development_dependency 'webmock', '~> 3.7'
53
56
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spandx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
+ - Can Eldem
7
8
  - mo khan
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2020-04-19 00:00:00.000000000 Z
12
+ date: 2020-05-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: addressable
@@ -72,6 +73,20 @@ dependencies:
72
73
  - - "~>"
73
74
  - !ruby/object:Gem::Version
74
75
  version: '1.10'
76
+ - !ruby/object:Gem::Dependency
77
+ name: parslet
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.0'
75
90
  - !ruby/object:Gem::Dependency
76
91
  name: thor
77
92
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +101,20 @@ dependencies:
86
101
  - - ">="
87
102
  - !ruby/object:Gem::Version
88
103
  version: '0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: tty-progressbar
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.17'
111
+ type: :runtime
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.17'
89
118
  - !ruby/object:Gem::Dependency
90
119
  name: zeitwerk
91
120
  requirement: !ruby/object:Gem::Requirement
@@ -101,47 +130,47 @@ dependencies:
101
130
  - !ruby/object:Gem::Version
102
131
  version: '2.3'
103
132
  - !ruby/object:Gem::Dependency
104
- name: bundler-audit
133
+ name: benchmark-ips
105
134
  requirement: !ruby/object:Gem::Requirement
106
135
  requirements:
107
136
  - - "~>"
108
137
  - !ruby/object:Gem::Version
109
- version: '0.6'
138
+ version: '2.8'
110
139
  type: :development
111
140
  prerelease: false
112
141
  version_requirements: !ruby/object:Gem::Requirement
113
142
  requirements:
114
143
  - - "~>"
115
144
  - !ruby/object:Gem::Version
116
- version: '0.6'
145
+ version: '2.8'
117
146
  - !ruby/object:Gem::Dependency
118
- name: byebug
147
+ name: bundler-audit
119
148
  requirement: !ruby/object:Gem::Requirement
120
149
  requirements:
121
150
  - - "~>"
122
151
  - !ruby/object:Gem::Version
123
- version: '11.1'
152
+ version: '0.6'
124
153
  type: :development
125
154
  prerelease: false
126
155
  version_requirements: !ruby/object:Gem::Requirement
127
156
  requirements:
128
157
  - - "~>"
129
158
  - !ruby/object:Gem::Version
130
- version: '11.1'
159
+ version: '0.6'
131
160
  - !ruby/object:Gem::Dependency
132
- name: jaro_winkler
161
+ name: byebug
133
162
  requirement: !ruby/object:Gem::Requirement
134
163
  requirements:
135
164
  - - "~>"
136
165
  - !ruby/object:Gem::Version
137
- version: '1.5'
166
+ version: '11.1'
138
167
  type: :development
139
168
  prerelease: false
140
169
  version_requirements: !ruby/object:Gem::Requirement
141
170
  requirements:
142
171
  - - "~>"
143
172
  - !ruby/object:Gem::Version
144
- version: '1.5'
173
+ version: '11.1'
145
174
  - !ruby/object:Gem::Dependency
146
175
  name: licensed
147
176
  requirement: !ruby/object:Gem::Requirement
@@ -157,33 +186,33 @@ dependencies:
157
186
  - !ruby/object:Gem::Version
158
187
  version: '2.8'
159
188
  - !ruby/object:Gem::Dependency
160
- name: parallel_tests
189
+ name: rake
161
190
  requirement: !ruby/object:Gem::Requirement
162
191
  requirements:
163
192
  - - "~>"
164
193
  - !ruby/object:Gem::Version
165
- version: '2.32'
194
+ version: '13.0'
166
195
  type: :development
167
196
  prerelease: false
168
197
  version_requirements: !ruby/object:Gem::Requirement
169
198
  requirements:
170
199
  - - "~>"
171
200
  - !ruby/object:Gem::Version
172
- version: '2.32'
201
+ version: '13.0'
173
202
  - !ruby/object:Gem::Dependency
174
- name: rake
203
+ name: rake-compiler
175
204
  requirement: !ruby/object:Gem::Requirement
176
205
  requirements:
177
206
  - - "~>"
178
207
  - !ruby/object:Gem::Version
179
- version: '13.0'
208
+ version: '1.1'
180
209
  type: :development
181
210
  prerelease: false
182
211
  version_requirements: !ruby/object:Gem::Requirement
183
212
  requirements:
184
213
  - - "~>"
185
214
  - !ruby/object:Gem::Version
186
- version: '13.0'
215
+ version: '1.1'
187
216
  - !ruby/object:Gem::Dependency
188
217
  name: rspec
189
218
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +270,7 @@ dependencies:
241
270
  - !ruby/object:Gem::Version
242
271
  version: '1.22'
243
272
  - !ruby/object:Gem::Dependency
244
- name: text
273
+ name: ruby-prof
245
274
  requirement: !ruby/object:Gem::Requirement
246
275
  requirements:
247
276
  - - "~>"
@@ -282,19 +311,26 @@ dependencies:
282
311
  - - "~>"
283
312
  - !ruby/object:Gem::Version
284
313
  version: '3.7'
285
- description: A ruby interface to the SPDX catalogue. With a CLI that can scan project
286
- lockfiles to list out software licenses for each dependency
314
+ description: Spanx is a ruby API for interacting with the spdx.org software license
315
+ catalogue. This gem includes a command line interface to scan a software project
316
+ for the software licenses that are associated with each dependency in the project.
317
+ Spandx also allows you to hook additional information for each dependency found.
318
+ For instance, you can add plugin to Spandx to find and report vulnerabilities for
319
+ the dependencies it found.
287
320
  email:
321
+ - eldemcan@gmail.com
288
322
  - mo@mokhan.ca
289
323
  executables:
290
324
  - spandx
291
- extensions: []
325
+ extensions:
326
+ - ext/spandx/extconf.rb
292
327
  extra_rdoc_files: []
293
328
  files:
294
329
  - CHANGELOG.md
295
330
  - LICENSE.txt
296
331
  - README.md
297
332
  - exe/spandx
333
+ - ext/spandx/extconf.rb
298
334
  - lib/spandx.rb
299
335
  - lib/spandx/cli.rb
300
336
  - lib/spandx/cli/commands/build.rb
@@ -303,17 +339,22 @@ files:
303
339
  - lib/spandx/cli/main.rb
304
340
  - lib/spandx/core/cache.rb
305
341
  - lib/spandx/core/circuit.rb
342
+ - lib/spandx/core/concurrent.rb
306
343
  - lib/spandx/core/content.rb
344
+ - lib/spandx/core/data_file.rb
307
345
  - lib/spandx/core/dependency.rb
308
346
  - lib/spandx/core/gateway.rb
309
347
  - lib/spandx/core/git.rb
310
348
  - lib/spandx/core/guess.rb
311
349
  - lib/spandx/core/http.rb
350
+ - lib/spandx/core/index_file.rb
312
351
  - lib/spandx/core/license_plugin.rb
313
- - lib/spandx/core/null_gateway.rb
352
+ - lib/spandx/core/line_io.rb
314
353
  - lib/spandx/core/parser.rb
354
+ - lib/spandx/core/path_traversal.rb
315
355
  - lib/spandx/core/plugin.rb
316
356
  - lib/spandx/core/registerable.rb
357
+ - lib/spandx/core/relation.rb
317
358
  - lib/spandx/core/report.rb
318
359
  - lib/spandx/core/score.rb
319
360
  - lib/spandx/core/table.rb
@@ -342,17 +383,19 @@ files:
342
383
  - lib/spandx/ruby/gateway.rb
343
384
  - lib/spandx/ruby/parsers/gemfile_lock.rb
344
385
  - lib/spandx/spdx/catalogue.rb
386
+ - lib/spandx/spdx/composite_license.rb
387
+ - lib/spandx/spdx/expression.rb
345
388
  - lib/spandx/spdx/gateway.rb
346
389
  - lib/spandx/spdx/license.rb
347
390
  - lib/spandx/version.rb
348
391
  - spandx.gemspec
349
- homepage: https://github.com/mokhan/spandx
392
+ homepage: https://spandx.github.io/
350
393
  licenses:
351
394
  - MIT
352
395
  metadata:
353
- homepage_uri: https://github.com/mokhan/spandx
354
- source_code_uri: https://github.com/mokhan/spandx
355
- changelog_uri: https://github.com/mokhan/spandx/blob/master/CHANGELOG.md
396
+ homepage_uri: https://spandx.github.io/
397
+ source_code_uri: https://github.com/spandx/spandx
398
+ changelog_uri: https://github.com/spandx/spandx/blob/master/CHANGELOG.md
356
399
  post_install_message:
357
400
  rdoc_options: []
358
401
  require_paths:
@@ -361,7 +404,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
361
404
  requirements:
362
405
  - - ">="
363
406
  - !ruby/object:Gem::Version
364
- version: 2.4.0
407
+ version: 2.5.0
365
408
  required_rubygems_version: !ruby/object:Gem::Requirement
366
409
  requirements:
367
410
  - - ">="