spandx 0.17.0 → 0.18.0
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 +4 -4
- data/CHANGELOG.md +8 -2
- data/README.md +2 -2
- data/lib/spandx/terraform/parsers/hcl.rb +103 -0
- data/lib/spandx/terraform/parsers/lock_file.rb +38 -0
- data/lib/spandx/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d25ff66ba00edb25cf87b9d9af71ed9433bf084a819a80f86676714754359b34
|
4
|
+
data.tar.gz: 59e6783d2cba9287e0a65836aeae6705434fc0c9ccdfb093763d83b23d673207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c75d55cc57a24d00912a98d0a339b22f21e04fb0c84459ce9b769b900cce83f5877557cbe70e2cdff522d1869ba4d89688b9e9d67913719247cc53897216cb01
|
7
|
+
data.tar.gz: 770105bb92091a740afc3d886194712eb54908718af73e2769acfd512afe553d3f00de0e1ada81930b3d5c09a0a6053dfcc3cd8c9f48ecdb76673e1534ad9fff
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Version 0.
|
1
|
+
Version 0.18.0
|
2
2
|
|
3
3
|
# Changelog
|
4
4
|
|
@@ -8,6 +8,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
8
8
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
9
9
|
|
10
10
|
## [Unreleased]
|
11
|
+
|
12
|
+
## [0.18.0] - 2021-05-10
|
13
|
+
### Added
|
14
|
+
- Add support for parsing `.terraform.lock.hcl` files.
|
15
|
+
|
11
16
|
## [0.17.0] - 2020-12-28
|
12
17
|
### Added
|
13
18
|
- Allow indexing gems from index.rubygems.org.
|
@@ -223,7 +228,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
223
228
|
### Added
|
224
229
|
- Provide ruby API to the latest SPDX catalogue.
|
225
230
|
|
226
|
-
[Unreleased]: https://github.com/spandx/spandx/compare/v0.
|
231
|
+
[Unreleased]: https://github.com/spandx/spandx/compare/v0.18.0...HEAD
|
232
|
+
[0.18.0]: https://github.com/spandx/spandx/compare/v0.17.0...v0.18.0
|
227
233
|
[0.17.0]: https://github.com/spandx/spandx/compare/v0.16.1...v0.17.0
|
228
234
|
[0.16.1]: https://github.com/spandx/spandx/compare/v0.16.0...v0.16.1
|
229
235
|
[0.16.0]: https://github.com/spandx/spandx/compare/v0.15.1...v0.16.0
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# Spandx 
|
6
6
|
|
7
|
-
A
|
7
|
+
A Ruby API for interacting with the https://spdx.org software license catalogue.
|
8
8
|
This gem includes a command line interface to scan a software project for the
|
9
9
|
software licenses that are associated with each dependency in the project.
|
10
10
|
`spandx` leverages an offline cache of software licenses for known dependencies.
|
@@ -104,7 +104,7 @@ end
|
|
104
104
|
|
105
105
|
## Development
|
106
106
|
|
107
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/
|
107
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
108
108
|
|
109
109
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
110
110
|
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spandx
|
4
|
+
module Terraform
|
5
|
+
module Parsers
|
6
|
+
class Hcl < Parslet::Parser
|
7
|
+
rule(:alpha) { match['a-zA-Z'] }
|
8
|
+
rule(:assign) { str('=') }
|
9
|
+
rule(:comma) { str(',') }
|
10
|
+
rule(:comment) { (str('#') | str('//')) >> ((str("\n") >> str("\r").maybe).absent? >> any).repeat >> eol }
|
11
|
+
rule(:crlf) { match('[\r\n]') }
|
12
|
+
rule(:digit) { match('\d') }
|
13
|
+
rule(:dot) { str('.') }
|
14
|
+
rule(:eol) { whitespace? >> crlf.repeat }
|
15
|
+
rule(:greater_than_or_equal_to) { str('>=') }
|
16
|
+
rule(:hyphen) { str('-') }
|
17
|
+
rule(:lbracket) { str('[') }
|
18
|
+
rule(:lcurly) { str('{') }
|
19
|
+
rule(:major) { number }
|
20
|
+
rule(:major_minor) { (number >> dot >> number) }
|
21
|
+
rule(:major_minor_patch) { number >> dot >> number >> dot >> number }
|
22
|
+
rule(:multiline_comment) { str('/*') >> (str('*/').absent? >> any).repeat >> str('*/') }
|
23
|
+
rule(:number) { digit.repeat }
|
24
|
+
rule(:pre_release) { hyphen >> (alpha | digit).repeat }
|
25
|
+
rule(:pre_release?) { pre_release.maybe }
|
26
|
+
rule(:quote) { str('"') }
|
27
|
+
rule(:rbracket) { str(']') }
|
28
|
+
rule(:rcurly) { str('}') }
|
29
|
+
rule(:space) { match('\s') }
|
30
|
+
rule(:tilda_wacka) { str('~>') }
|
31
|
+
rule(:version) { number >> dot >> number >> dot >> number >> pre_release? }
|
32
|
+
rule(:whitespace) { (multiline_comment | comment | space).repeat }
|
33
|
+
rule(:whitespace?) { whitespace.maybe }
|
34
|
+
|
35
|
+
rule(:pessimistic_version_constraint) do
|
36
|
+
tilda_wacka >> whitespace >> (
|
37
|
+
major_minor_patch |
|
38
|
+
major_minor |
|
39
|
+
major
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
rule(:greater_than_or_equal_to_version) do
|
44
|
+
greater_than_or_equal_to >> whitespace >> (
|
45
|
+
major_minor_patch |
|
46
|
+
major_minor |
|
47
|
+
major
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
rule(:version_constraint) do
|
52
|
+
pessimistic_version_constraint | greater_than_or_equal_to_version
|
53
|
+
end
|
54
|
+
|
55
|
+
rule :version_assignment do
|
56
|
+
str('version') >> whitespace >> assign >> whitespace >> quote >> version.as(:version) >> quote
|
57
|
+
end
|
58
|
+
|
59
|
+
rule :constraint_assignment do
|
60
|
+
str('constraints') >> whitespace >> assign >> whitespace >> quote >> version_constraint.as(:constraints) >> quote
|
61
|
+
end
|
62
|
+
|
63
|
+
rule :string do
|
64
|
+
quote >> match('[0-9A-Za-z.~> :=/]').repeat.as(:value) >> quote
|
65
|
+
end
|
66
|
+
|
67
|
+
rule :array_item do
|
68
|
+
whitespace >> string >> comma >> eol
|
69
|
+
end
|
70
|
+
|
71
|
+
rule :array do
|
72
|
+
lbracket >> eol >> array_item.repeat >> rbracket
|
73
|
+
end
|
74
|
+
|
75
|
+
rule :argument do
|
76
|
+
alpha.repeat.as(:name) >> whitespace >> assign >> whitespace >> (array.as(:values) | string)
|
77
|
+
end
|
78
|
+
|
79
|
+
rule :arguments do
|
80
|
+
(argument >> eol).repeat
|
81
|
+
end
|
82
|
+
|
83
|
+
rule :identifier do
|
84
|
+
whitespace >> quote >> ((alpha | match('[./]')).repeat).as(:name) >> quote >> whitespace
|
85
|
+
end
|
86
|
+
|
87
|
+
rule :block_body do
|
88
|
+
arguments.as(:arguments)
|
89
|
+
end
|
90
|
+
|
91
|
+
rule :block do
|
92
|
+
whitespace? >> (alpha.repeat).as(:type) >> identifier >> whitespace >> lcurly >> eol >> block_body >> rcurly >> eol
|
93
|
+
end
|
94
|
+
|
95
|
+
rule :blocks do
|
96
|
+
block.repeat.as(:blocks)
|
97
|
+
end
|
98
|
+
|
99
|
+
root(:blocks)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Spandx
|
4
|
+
module Terraform
|
5
|
+
module Parsers
|
6
|
+
class LockFile < ::Spandx::Core::Parser
|
7
|
+
def initialize
|
8
|
+
@parser = Spandx::Terraform::Parsers::Hcl.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def match?(pathname)
|
12
|
+
basename = pathname.basename
|
13
|
+
basename.fnmatch?('.terraform.lock.hcl')
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(path)
|
17
|
+
tree = @parser.parse(path.read)
|
18
|
+
tree[:blocks].map do |block|
|
19
|
+
version_arg = version_arg_from(block)
|
20
|
+
::Spandx::Core::Dependency.new(
|
21
|
+
name: block[:name].to_s,
|
22
|
+
version: version_arg[:value]&.to_s,
|
23
|
+
path: path
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def version_arg_from(block)
|
31
|
+
block[:arguments].find do |x|
|
32
|
+
x[:name] == 'version'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/spandx/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spandx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Can Eldem
|
8
8
|
- mo khan
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: addressable
|
@@ -434,6 +434,8 @@ files:
|
|
434
434
|
- lib/spandx/spdx/expression.rb
|
435
435
|
- lib/spandx/spdx/gateway.rb
|
436
436
|
- lib/spandx/spdx/license.rb
|
437
|
+
- lib/spandx/terraform/parsers/hcl.rb
|
438
|
+
- lib/spandx/terraform/parsers/lock_file.rb
|
437
439
|
- lib/spandx/version.rb
|
438
440
|
- spandx.gemspec
|
439
441
|
homepage: https://spandx.github.io/
|
@@ -443,7 +445,7 @@ metadata:
|
|
443
445
|
homepage_uri: https://spandx.github.io/
|
444
446
|
source_code_uri: https://github.com/spandx/spandx
|
445
447
|
changelog_uri: https://github.com/spandx/spandx/blob/main/CHANGELOG.md
|
446
|
-
post_install_message:
|
448
|
+
post_install_message:
|
447
449
|
rdoc_options: []
|
448
450
|
require_paths:
|
449
451
|
- lib
|
@@ -459,7 +461,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
459
461
|
version: '0'
|
460
462
|
requirements: []
|
461
463
|
rubygems_version: 3.2.3
|
462
|
-
signing_key:
|
464
|
+
signing_key:
|
463
465
|
specification_version: 4
|
464
466
|
summary: A ruby interface to the SPDX catalogue.
|
465
467
|
test_files: []
|