hcl-checker 1.5.0 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +32 -0
- data/Gemfile +3 -4
- data/Gemfile.lock +21 -22
- data/Rakefile +7 -7
- data/assets/lexer.rex +15 -13
- data/assets/parse.y +29 -13
- data/bin/console +3 -3
- data/hcl-checker.gemspec +10 -10
- data/lib/hcl/{lexer.rb → checker/lexer.rb} +13 -12
- data/lib/hcl/{parser.rb → checker/parser.rb} +72 -46
- data/lib/hcl/checker/version.rb +1 -1
- data/lib/hcl/checker.rb +14 -7
- metadata +35 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 667f88b2558cf8ce0a69698c4eda47c4b157a1a97ae7e4e71589be6dca5007c4
|
4
|
+
data.tar.gz: a9e1d9c61e8575b4e4393c1a1758b007642db713a3f6ebd3243603cea13d62e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6312e830effebabe892a98b3b9a15d1e7ceea84edc035e95989b84cce6269ad5242ff697838ba5499bbfedfecb511cbe0c02034d38267336dbe7b2a1c1a1384
|
7
|
+
data.tar.gz: 456b8cafe4e9923f9951ec4f0b8f4fcb1f6bad3209e1fb8d4f4f1ed9c155dafbe74a8e045aa7e4becbfa516d97a4c25a07ffbc3c6a2a0481caf56b502d097a77
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
3
|
+
Exclude:
|
4
|
+
- lib/hcl/lexer.rb
|
5
|
+
- lib/hcl/parser.rb
|
6
|
+
|
7
|
+
Layout/LineLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/BlockLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/ClassLength:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Metrics/CyclomaticComplexity:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
Metrics/MethodLength:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Metrics/PerceivedComplexity:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/Documentation:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/FrozenStringLiteralComment:
|
32
|
+
EnforcedStyle: never
|
data/Gemfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# This is needed due https://nvd.nist.gov/vuln/detail/CVE-2018-14404
|
4
4
|
# A NULL pointer dereference vulnerability exists in the xpath.c:xmlXPathCompOpEval()
|
@@ -7,10 +7,9 @@ source "https://rubygems.org"
|
|
7
7
|
# with the use of the libxml2 library may be vulnerable to a denial of service attack due
|
8
8
|
# to a crash of the application.
|
9
9
|
# Nokogiri >= 1.8.5 solves this problem
|
10
|
-
gem
|
10
|
+
gem 'nokogiri', '>= 1.11.4'
|
11
11
|
|
12
|
-
|
13
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
12
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
14
13
|
|
15
14
|
# Specify your gem's dependencies in hcl-checker.gemspec
|
16
15
|
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hcl-checker (1.
|
4
|
+
hcl-checker (1.6.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
9
|
+
diff-lcs (1.5.0)
|
10
10
|
filesize (0.2.0)
|
11
11
|
jsobfu (0.4.2)
|
12
12
|
rkelly-remix
|
13
|
-
json (2.
|
14
|
-
metasm (1.0.
|
15
|
-
|
16
|
-
|
17
|
-
mini_portile2 (~> 2.4.0)
|
13
|
+
json (2.6.1)
|
14
|
+
metasm (1.0.5)
|
15
|
+
nokogiri (1.13.6-arm64-darwin)
|
16
|
+
racc (~> 1.4)
|
18
17
|
racc (1.5.0)
|
19
18
|
rake (12.3.3)
|
20
19
|
rb-readline (0.5.5)
|
@@ -27,27 +26,27 @@ GEM
|
|
27
26
|
rb-readline (~> 0)
|
28
27
|
rexical (1.0.7)
|
29
28
|
rkelly-remix (0.0.7)
|
30
|
-
rspec (3.
|
31
|
-
rspec-core (~> 3.
|
32
|
-
rspec-expectations (~> 3.
|
33
|
-
rspec-mocks (~> 3.
|
34
|
-
rspec-core (3.
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-expectations (3.
|
29
|
+
rspec (3.11.0)
|
30
|
+
rspec-core (~> 3.11.0)
|
31
|
+
rspec-expectations (~> 3.11.0)
|
32
|
+
rspec-mocks (~> 3.11.0)
|
33
|
+
rspec-core (3.11.0)
|
34
|
+
rspec-support (~> 3.11.0)
|
35
|
+
rspec-expectations (3.11.0)
|
37
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-mocks (3.
|
37
|
+
rspec-support (~> 3.11.0)
|
38
|
+
rspec-mocks (3.11.1)
|
40
39
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
-
rspec-support (~> 3.
|
42
|
-
rspec-support (3.
|
40
|
+
rspec-support (~> 3.11.0)
|
41
|
+
rspec-support (3.11.0)
|
43
42
|
|
44
43
|
PLATFORMS
|
45
|
-
|
44
|
+
arm64-darwin-21
|
46
45
|
|
47
46
|
DEPENDENCIES
|
48
|
-
bundler (~> 2.
|
47
|
+
bundler (~> 2.3.13)
|
49
48
|
hcl-checker!
|
50
|
-
nokogiri (>= 1.
|
49
|
+
nokogiri (>= 1.11.4)
|
51
50
|
racc (= 1.5.0)
|
52
51
|
rake (~> 12.3.3)
|
53
52
|
rex (= 2.0.12)
|
@@ -55,4 +54,4 @@ DEPENDENCIES
|
|
55
54
|
rspec (~> 3.0)
|
56
55
|
|
57
56
|
BUNDLED WITH
|
58
|
-
2.
|
57
|
+
2.3.13
|
data/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new do |c|
|
5
|
-
options = [
|
6
|
-
options += [
|
5
|
+
options = ['--color']
|
6
|
+
options += ['--format', 'documentation']
|
7
7
|
c.rspec_opts = options
|
8
8
|
end
|
9
9
|
|
10
|
-
desc
|
10
|
+
desc 'Generate Grammar files for HCL'
|
11
11
|
task :build_grammar do
|
12
12
|
print 'Building Lexer'
|
13
|
-
`rex
|
13
|
+
`rex ./assets/lexer.rex -o ./lib/hcl/checker/lexer.rb`
|
14
14
|
print "....done\n"
|
15
15
|
print 'Building Parser'
|
16
|
-
`racc ./assets/parse.y -o ./lib/hcl/parser.rb`
|
16
|
+
`racc ./assets/parse.y -o ./lib/hcl/checker/parser.rb`
|
17
17
|
print "....done\n\n"
|
18
18
|
end
|
data/assets/lexer.rex
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
class HCLLexer
|
1
|
+
class HCL::Checker::Lexer
|
3
2
|
option
|
4
3
|
independent
|
5
4
|
|
@@ -51,25 +50,26 @@ rule
|
|
51
50
|
{MINUS} { [:MINUS, text]}
|
52
51
|
|
53
52
|
inner
|
54
|
-
|
55
53
|
def lex(input)
|
56
54
|
scan_setup(input)
|
57
55
|
tokens = []
|
58
56
|
while token = next_token
|
59
57
|
tokens << token
|
60
58
|
end
|
59
|
+
|
61
60
|
tokens
|
62
61
|
end
|
63
62
|
|
64
63
|
|
65
64
|
def to_boolean(input)
|
66
|
-
input
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
case input
|
66
|
+
when /true/
|
67
|
+
true
|
68
|
+
when /false/
|
69
|
+
false
|
70
|
+
else
|
71
|
+
raise "Invalid value for `to_boolean`, expected true/false got #{input}"
|
72
|
+
end
|
73
73
|
end
|
74
74
|
|
75
75
|
|
@@ -93,19 +93,21 @@ inner
|
|
93
93
|
result = ''
|
94
94
|
nested = 0
|
95
95
|
|
96
|
-
|
96
|
+
loop do
|
97
97
|
case(text = @ss.scan_until(%r{\"|\$\{|\}|\\}))
|
98
98
|
when %r{\$\{\z}
|
99
99
|
nested += 1
|
100
100
|
when %r{\}\z}
|
101
|
-
nested -= 1 if nested
|
101
|
+
nested -= 1 if nested.positive?
|
102
102
|
when %r{\\\z}
|
103
103
|
result += text.chop + @ss.getch
|
104
104
|
next
|
105
105
|
end
|
106
106
|
|
107
107
|
result += text.to_s
|
108
|
-
|
108
|
+
|
109
|
+
break if nested.zero? && text =~ %r{\"\z}
|
110
|
+
end
|
109
111
|
|
110
112
|
result.chop
|
111
113
|
end
|
data/assets/parse.y
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class HCL::Checker::Parser
|
2
2
|
token BOOL
|
3
3
|
FLOAT
|
4
4
|
NUMBER
|
@@ -41,7 +41,7 @@ rule
|
|
41
41
|
LEFTBRACE objectlist RIGHTBRACE
|
42
42
|
{ result = flatten_objectlist(val[1]) }
|
43
43
|
| LEFTBRACE RIGHTBRACE
|
44
|
-
{ return }
|
44
|
+
{ return {} }
|
45
45
|
;
|
46
46
|
|
47
47
|
objectkey:
|
@@ -88,7 +88,7 @@ rule
|
|
88
88
|
LEFTBRACKET listitems RIGHTBRACKET
|
89
89
|
{ result = val[1] }
|
90
90
|
| LEFTBRACKET RIGHTBRACKET
|
91
|
-
{ return }
|
91
|
+
{ return [] }
|
92
92
|
;
|
93
93
|
|
94
94
|
listitems:
|
@@ -109,6 +109,8 @@ rule
|
|
109
109
|
{ result = val[0] }
|
110
110
|
| object
|
111
111
|
{ result = val[0] }
|
112
|
+
| IDENTIFIER
|
113
|
+
{ result = val[0] }
|
112
114
|
;
|
113
115
|
|
114
116
|
number:
|
@@ -122,7 +124,7 @@ rule
|
|
122
124
|
end
|
123
125
|
|
124
126
|
---- header
|
125
|
-
require_relative '
|
127
|
+
require_relative 'lexer'
|
126
128
|
|
127
129
|
---- inner
|
128
130
|
#//
|
@@ -130,19 +132,31 @@ require_relative './lexer'
|
|
130
132
|
#// keys are encountered.
|
131
133
|
#//
|
132
134
|
#// from decoder.go: if we're at the root or we're directly within
|
133
|
-
#// a list, decode
|
135
|
+
#// a list, decode to hashes, otherwise lists
|
134
136
|
#//
|
135
137
|
#// from object.go: there is a flattened list structure
|
136
138
|
#//
|
139
|
+
#// if @duplicate_mode is set:
|
140
|
+
#// - :array then duplicates will be appended to an array
|
141
|
+
#// - :merge then duplicates will be deep merged into a hash
|
142
|
+
#//
|
137
143
|
def flatten_objectlist(list)
|
138
144
|
(list || {}).each_with_object({}) do |a, h|
|
139
|
-
h
|
140
|
-
case
|
141
|
-
when
|
145
|
+
if h.keys.include?(a.first)
|
146
|
+
case @duplicate_mode
|
147
|
+
when :array
|
148
|
+
if h[a.first].is_a?(Array)
|
149
|
+
h[a.first].push(a.last)
|
150
|
+
else
|
151
|
+
h[a.first] = [ h[a.first], a.last ]
|
152
|
+
end
|
153
|
+
when :merge
|
142
154
|
deep_merge(h[a.first] || {}, a.last)
|
143
|
-
else
|
144
|
-
h[a.first] = a.last
|
155
|
+
else raise ArgumentError
|
145
156
|
end
|
157
|
+
else
|
158
|
+
h[a.first] = a.last
|
159
|
+
end
|
146
160
|
end
|
147
161
|
end
|
148
162
|
|
@@ -154,10 +168,12 @@ require_relative './lexer'
|
|
154
168
|
end
|
155
169
|
|
156
170
|
|
157
|
-
def parse(input)
|
158
|
-
@
|
171
|
+
def parse(input, duplicate_mode = :array)
|
172
|
+
@duplicate_mode = duplicate_mode
|
173
|
+
@lexer = HCL::Checker::Lexer.new.lex(input)
|
159
174
|
do_parse
|
160
|
-
|
175
|
+
|
176
|
+
@result
|
161
177
|
end
|
162
178
|
|
163
179
|
|
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'hcl/checker'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "hcl/checker"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
data/hcl-checker.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path('
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require 'hcl/checker/version'
|
4
4
|
|
@@ -19,19 +19,19 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
spec.required_ruby_version = '>= 2.5.0'
|
21
21
|
|
22
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
23
|
-
spec.add_development_dependency 'rake', '~> 12.3.3'
|
24
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 2.3.13'
|
25
23
|
spec.add_development_dependency 'racc', '1.5.0'
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.3.3'
|
26
25
|
spec.add_development_dependency 'rex', '2.0.12'
|
27
26
|
spec.add_development_dependency 'rexical', '>= 1.0.7'
|
27
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
|
+
|
29
|
+
spec.post_install_message = '
|
30
|
+
Hello, me again. This version fixes:
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
the module name be kept only as HCL, instead of HCL1 and HCL2, I went back and
|
32
|
-
kept it. Sorry for those who eventually switched from HCL to HCL1. And thanks to
|
33
|
-
everyone who got in touch justifying why my change would be bad for all users.
|
32
|
+
- Update dependencies due security issues
|
33
|
+
- Support interpolation only expression list
|
34
34
|
|
35
35
|
Thank you :)
|
36
|
-
|
36
|
+
'
|
37
37
|
end
|
@@ -4,8 +4,7 @@
|
|
4
4
|
# from lexical definition file "./assets/lexer.rex".
|
5
5
|
#++
|
6
6
|
|
7
|
-
|
8
|
-
class HCLLexer
|
7
|
+
class HCL::Checker::Lexer
|
9
8
|
require 'strscan'
|
10
9
|
|
11
10
|
class ScanError < StandardError ; end
|
@@ -135,13 +134,14 @@ class HCLLexer
|
|
135
134
|
tokens
|
136
135
|
end
|
137
136
|
def to_boolean(input)
|
138
|
-
input
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
137
|
+
case input
|
138
|
+
when /true/
|
139
|
+
true
|
140
|
+
when /false/
|
141
|
+
false
|
142
|
+
else
|
143
|
+
raise "Invalid value for `to_boolean`, expected true/false got #{input}"
|
144
|
+
end
|
145
145
|
end
|
146
146
|
def consume_comment(input)
|
147
147
|
nested = 1
|
@@ -159,18 +159,19 @@ class HCLLexer
|
|
159
159
|
def consume_string(input)
|
160
160
|
result = ''
|
161
161
|
nested = 0
|
162
|
-
|
162
|
+
loop do
|
163
163
|
case(text = @ss.scan_until(%r{\"|\$\{|\}|\\}))
|
164
164
|
when %r{\$\{\z}
|
165
165
|
nested += 1
|
166
166
|
when %r{\}\z}
|
167
|
-
nested -= 1 if nested
|
167
|
+
nested -= 1 if nested.positive?
|
168
168
|
when %r{\\\z}
|
169
169
|
result += text.chop + @ss.getch
|
170
170
|
next
|
171
171
|
end
|
172
172
|
result += text.to_s
|
173
|
-
|
173
|
+
break if nested.zero? && text =~ %r{\"\z}
|
174
|
+
end
|
174
175
|
result.chop
|
175
176
|
end
|
176
177
|
def consume_heredoc
|
@@ -6,29 +6,43 @@
|
|
6
6
|
|
7
7
|
require 'racc/parser.rb'
|
8
8
|
|
9
|
-
require_relative '
|
9
|
+
require_relative 'lexer'
|
10
10
|
|
11
|
-
|
11
|
+
module HCL
|
12
|
+
module Checker
|
13
|
+
class Parser < Racc::Parser
|
12
14
|
|
13
|
-
module_eval(<<'...end parse.y/module_eval...', 'parse.y',
|
15
|
+
module_eval(<<'...end parse.y/module_eval...', 'parse.y', 130)
|
14
16
|
#//
|
15
17
|
#// HCL is unclear on what one should do when duplicate
|
16
18
|
#// keys are encountered.
|
17
19
|
#//
|
18
20
|
#// from decoder.go: if we're at the root or we're directly within
|
19
|
-
#// a list, decode
|
21
|
+
#// a list, decode to hashes, otherwise lists
|
20
22
|
#//
|
21
23
|
#// from object.go: there is a flattened list structure
|
22
24
|
#//
|
25
|
+
#// if @duplicate_mode is set:
|
26
|
+
#// - :array then duplicates will be appended to an array
|
27
|
+
#// - :merge then duplicates will be deep merged into a hash
|
28
|
+
#//
|
23
29
|
def flatten_objectlist(list)
|
24
30
|
(list || {}).each_with_object({}) do |a, h|
|
25
|
-
h
|
26
|
-
case
|
27
|
-
when
|
31
|
+
if h.keys.include?(a.first)
|
32
|
+
case @duplicate_mode
|
33
|
+
when :array
|
34
|
+
if h[a.first].is_a?(Array)
|
35
|
+
h[a.first].push(a.last)
|
36
|
+
else
|
37
|
+
h[a.first] = [ h[a.first], a.last ]
|
38
|
+
end
|
39
|
+
when :merge
|
28
40
|
deep_merge(h[a.first] || {}, a.last)
|
29
|
-
else
|
30
|
-
h[a.first] = a.last
|
41
|
+
else raise ArgumentError
|
31
42
|
end
|
43
|
+
else
|
44
|
+
h[a.first] = a.last
|
45
|
+
end
|
32
46
|
end
|
33
47
|
end
|
34
48
|
|
@@ -40,10 +54,12 @@ module_eval(<<'...end parse.y/module_eval...', 'parse.y', 128)
|
|
40
54
|
end
|
41
55
|
|
42
56
|
|
43
|
-
def parse(input)
|
44
|
-
@
|
57
|
+
def parse(input, duplicate_mode = :array)
|
58
|
+
@duplicate_mode = duplicate_mode
|
59
|
+
@lexer = HCL::Checker::Lexer.new.lex(input)
|
45
60
|
do_parse
|
46
|
-
|
61
|
+
|
62
|
+
@result
|
47
63
|
end
|
48
64
|
|
49
65
|
|
@@ -69,46 +85,46 @@ module_eval(<<'...end parse.y/module_eval...', 'parse.y', 128)
|
|
69
85
|
##### State transition tables begin ###
|
70
86
|
|
71
87
|
racc_action_table = [
|
72
|
-
22, 29, 28, 10,
|
73
|
-
6, 27, 29, 28,
|
74
|
-
14,
|
75
|
-
37,
|
76
|
-
|
88
|
+
22, 29, 28, 10, 19, 26, 44, 23, 5, 14,
|
89
|
+
6, 27, 29, 28, 13, 43, 40, 17, 37, 18,
|
90
|
+
14, 14, 27, 34, 29, 28, 32, 5, 40, 6,
|
91
|
+
37, 5, 14, 6, 27, 5, 41, 6, -11, -10,
|
92
|
+
31, 42, 12, 45, 20 ]
|
77
93
|
|
78
94
|
racc_action_check = [
|
79
|
-
13, 13, 13, 1,
|
80
|
-
0, 13, 27, 27,
|
81
|
-
27,
|
82
|
-
|
83
|
-
|
95
|
+
13, 13, 13, 1, 10, 13, 33, 13, 0, 13,
|
96
|
+
0, 13, 27, 27, 7, 33, 27, 9, 27, 9,
|
97
|
+
27, 9, 27, 27, 44, 44, 26, 3, 44, 3,
|
98
|
+
44, 30, 44, 30, 44, 14, 30, 14, 6, 5,
|
99
|
+
14, 32, 4, 42, 11 ]
|
84
100
|
|
85
101
|
racc_action_pointer = [
|
86
|
-
1, 3, nil, 20,
|
87
|
-
|
88
|
-
nil, nil, nil, nil, nil, nil,
|
89
|
-
|
90
|
-
nil,
|
102
|
+
1, 3, nil, 20, 37, 31, 30, 6, nil, 10,
|
103
|
+
4, 39, nil, -2, 28, nil, nil, nil, nil, nil,
|
104
|
+
nil, nil, nil, nil, nil, nil, 11, 9, nil, nil,
|
105
|
+
24, nil, 34, 1, nil, nil, nil, nil, nil, nil,
|
106
|
+
nil, nil, 27, nil, 21, nil, nil ]
|
91
107
|
|
92
108
|
racc_action_default = [
|
93
|
-
-2, -
|
94
|
-
-
|
95
|
-
-6, -12, -13, -14, -15, -16, -18, -
|
96
|
-
-
|
97
|
-
-8, -
|
109
|
+
-2, -36, -1, -3, -5, -22, -23, -36, -19, -36,
|
110
|
+
-36, -7, -4, -36, -36, -20, -21, -22, -23, 47,
|
111
|
+
-6, -12, -13, -14, -15, -16, -18, -36, -34, -35,
|
112
|
+
-36, -9, -36, -36, -25, -26, -29, -30, -31, -32,
|
113
|
+
-33, -8, -36, -24, -28, -17, -27 ]
|
98
114
|
|
99
115
|
racc_goto_table = [
|
100
|
-
11, 35, 3, 15,
|
101
|
-
|
116
|
+
11, 35, 3, 15, 16, 33, 21, 24, 2, 1,
|
117
|
+
25, nil, nil, nil, nil, nil, 30, nil, 46, nil,
|
102
118
|
nil, nil, nil, nil, nil, nil, nil, 11 ]
|
103
119
|
|
104
120
|
racc_goto_check = [
|
105
|
-
4, 12, 3, 5,
|
106
|
-
|
121
|
+
4, 12, 3, 5, 9, 11, 7, 5, 2, 1,
|
122
|
+
8, nil, nil, nil, nil, nil, 3, nil, 12, nil,
|
107
123
|
nil, nil, nil, nil, nil, nil, nil, 4 ]
|
108
124
|
|
109
125
|
racc_goto_pointer = [
|
110
|
-
nil,
|
111
|
-
nil, -
|
126
|
+
nil, 9, 8, 2, -3, -6, nil, -7, -3, -5,
|
127
|
+
nil, -22, -26 ]
|
112
128
|
|
113
129
|
racc_goto_default = [
|
114
130
|
nil, nil, nil, nil, 4, 39, 7, 36, 38, 8,
|
@@ -148,12 +164,13 @@ racc_reduce_table = [
|
|
148
164
|
1, 32, :_reduce_30,
|
149
165
|
1, 32, :_reduce_31,
|
150
166
|
1, 32, :_reduce_32,
|
151
|
-
1,
|
152
|
-
1, 27, :_reduce_34
|
167
|
+
1, 32, :_reduce_33,
|
168
|
+
1, 27, :_reduce_34,
|
169
|
+
1, 27, :_reduce_35 ]
|
153
170
|
|
154
|
-
racc_reduce_n =
|
171
|
+
racc_reduce_n = 36
|
155
172
|
|
156
|
-
racc_shift_n =
|
173
|
+
racc_shift_n = 47
|
157
174
|
|
158
175
|
racc_token_table = {
|
159
176
|
false => 0,
|
@@ -291,7 +308,7 @@ module_eval(<<'.,.,', 'parse.y', 41)
|
|
291
308
|
|
292
309
|
module_eval(<<'.,.,', 'parse.y', 43)
|
293
310
|
def _reduce_9(val, _values, result)
|
294
|
-
return
|
311
|
+
return {}
|
295
312
|
result
|
296
313
|
end
|
297
314
|
.,.,
|
@@ -403,7 +420,7 @@ module_eval(<<'.,.,', 'parse.y', 88)
|
|
403
420
|
|
404
421
|
module_eval(<<'.,.,', 'parse.y', 90)
|
405
422
|
def _reduce_25(val, _values, result)
|
406
|
-
return
|
423
|
+
return []
|
407
424
|
result
|
408
425
|
end
|
409
426
|
.,.,
|
@@ -457,7 +474,7 @@ module_eval(<<'.,.,', 'parse.y', 110)
|
|
457
474
|
end
|
458
475
|
.,.,
|
459
476
|
|
460
|
-
module_eval(<<'.,.,', 'parse.y',
|
477
|
+
module_eval(<<'.,.,', 'parse.y', 112)
|
461
478
|
def _reduce_33(val, _values, result)
|
462
479
|
result = val[0]
|
463
480
|
result
|
@@ -471,8 +488,17 @@ module_eval(<<'.,.,', 'parse.y', 117)
|
|
471
488
|
end
|
472
489
|
.,.,
|
473
490
|
|
491
|
+
module_eval(<<'.,.,', 'parse.y', 119)
|
492
|
+
def _reduce_35(val, _values, result)
|
493
|
+
result = val[0]
|
494
|
+
result
|
495
|
+
end
|
496
|
+
.,.,
|
497
|
+
|
474
498
|
def _reduce_none(val, _values, result)
|
475
499
|
val[0]
|
476
500
|
end
|
477
501
|
|
478
|
-
end # class
|
502
|
+
end # class Parser
|
503
|
+
end # module Checker
|
504
|
+
end # module HCL
|
data/lib/hcl/checker/version.rb
CHANGED
data/lib/hcl/checker.rb
CHANGED
@@ -1,26 +1,33 @@
|
|
1
|
-
|
2
|
-
require_relative 'lexer'
|
3
|
-
require_relative 'parser'
|
1
|
+
require_relative 'checker/version'
|
2
|
+
require_relative 'checker/lexer'
|
3
|
+
require_relative 'checker/parser'
|
4
4
|
|
5
5
|
module HCL
|
6
6
|
module Checker
|
7
|
+
VALID_DUPLICATE_MODES = %i(array merge).freeze
|
8
|
+
|
7
9
|
class << self
|
8
10
|
attr_accessor :last_error
|
9
11
|
|
10
12
|
def valid?(value)
|
11
|
-
ret =
|
13
|
+
ret = HCL::Checker::Parser.new.parse(value)
|
12
14
|
return true if ret.is_a? Hash
|
15
|
+
|
13
16
|
false
|
14
17
|
rescue Racc::ParseError => e
|
15
18
|
@last_error = e.message
|
19
|
+
|
16
20
|
false
|
17
21
|
end
|
18
22
|
|
19
|
-
def parse(value)
|
20
|
-
|
23
|
+
def parse(value, duplicate_mode = :array)
|
24
|
+
raise ArgumentError, "Invalid duplicate mode #{duplicate_mode}, must be one of #{VALID_DUPLICATE_MODES}" unless VALID_DUPLICATE_MODES.include?(duplicate_mode)
|
25
|
+
|
26
|
+
HCL::Checker::Parser.new.parse(value, duplicate_mode)
|
21
27
|
rescue Racc::ParseError => e
|
22
28
|
@last_error = e.message
|
23
|
-
|
29
|
+
|
30
|
+
e.message
|
24
31
|
end
|
25
32
|
end
|
26
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcl-checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Castellani
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.3.13
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.3.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: racc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.5.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rex
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.0.12
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.0.12
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rexical
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.0.7
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.0.7
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '3.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '3.0'
|
97
97
|
description: Hashicorp Configuration Language parser and checker for Ruby
|
98
98
|
email:
|
99
99
|
- marcelo@linux.com
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".gitignore"
|
105
105
|
- ".rspec"
|
106
|
+
- ".rubocop.yml"
|
106
107
|
- ".travis.yml"
|
107
108
|
- CODE_OF_CONDUCT.md
|
108
109
|
- Gemfile
|
@@ -116,19 +117,19 @@ files:
|
|
116
117
|
- bin/setup
|
117
118
|
- hcl-checker.gemspec
|
118
119
|
- lib/hcl/checker.rb
|
120
|
+
- lib/hcl/checker/lexer.rb
|
121
|
+
- lib/hcl/checker/parser.rb
|
119
122
|
- lib/hcl/checker/version.rb
|
120
|
-
- lib/hcl/lexer.rb
|
121
|
-
- lib/hcl/parser.rb
|
122
123
|
homepage: https://github.com/mfcastellani/hcl-checker
|
123
124
|
licenses:
|
124
125
|
- MIT
|
125
126
|
metadata: {}
|
126
127
|
post_install_message: |2
|
127
128
|
|
128
|
-
Hello, me again.
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
Hello, me again. This version fixes:
|
130
|
+
|
131
|
+
- Update dependencies due security issues
|
132
|
+
- Support interpolation only expression list
|
132
133
|
|
133
134
|
Thank you :)
|
134
135
|
rdoc_options: []
|
@@ -145,8 +146,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
146
|
- !ruby/object:Gem::Version
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
|
-
rubygems_version: 3.
|
149
|
-
signing_key:
|
149
|
+
rubygems_version: 3.2.3
|
150
|
+
signing_key:
|
150
151
|
specification_version: 4
|
151
152
|
summary: Hashicorp Configuration Language parser for Ruby
|
152
153
|
test_files: []
|