hcl-checker 1.0.6 → 1.4.0

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
- SHA1:
3
- metadata.gz: d1efd195e8ca8b8db483856773b83144bc9137c2
4
- data.tar.gz: e2bf9f4f3c1ea37361e5df981316b7849bf74c5e
2
+ SHA256:
3
+ metadata.gz: 195128a0325ac3b7fa3add01a739dbe3ce0aeb5b3314edfc74d195caa3a0aa61
4
+ data.tar.gz: ab84f84386083bdbb9aaea917716ea7e8462eaed2b89a2ab4f887fb4c3b2ee93
5
5
  SHA512:
6
- metadata.gz: 5172205785804e8b064e61667fec47c889a1e9dc86a5309b6b4030c71b6c7226b2c02ea06fa3376eba8b5439e4c83f4615f29a338e2c9a171e216922ae7002fd
7
- data.tar.gz: e456fbf641474294ba47bfb3c07af523801c717902d6415f31fb5720833e4c19106e6433f0c4a2718ab111080f2de1c6c249638be2347c6644b58401cf7175c7
6
+ metadata.gz: b53587ad90fa9ed3cf6c2fbfd5cad15f6b526e62e5c63298fbd963a1629d6283a0bac0ab7276674acba8a1d67e38bc2118fe8f9a0a11a5d362afef4957cc745a
7
+ data.tar.gz: 4d908d23f548138a2e4e876709cda19321650203d13219f8ac8fe3748cd1427e628f9cb834f80bf684252a7d06d9a97d72663f3ac6c19699a0149593e3450a0d
data/Gemfile CHANGED
@@ -1,5 +1,15 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ # This is needed due https://nvd.nist.gov/vuln/detail/CVE-2018-14404
4
+ # A NULL pointer dereference vulnerability exists in the xpath.c:xmlXPathCompOpEval()
5
+ # function of libxml2 through 2.9.8 when parsing an invalid XPath expression in the
6
+ # XPATH_OP_AND or XPATH_OP_OR case. Applications processing untrusted XSL format inputs
7
+ # with the use of the libxml2 library may be vulnerable to a denial of service attack due
8
+ # to a crash of the application.
9
+ # Nokogiri >= 1.8.5 solves this problem
10
+ gem "nokogiri", ">= 1.10.8"
11
+
12
+
3
13
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
14
 
5
15
  # Specify your gem's dependencies in hcl-checker.gemspec
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hcl-checker (1.0.6)
4
+ hcl-checker (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- diff-lcs (1.3)
10
- filesize (0.1.1)
9
+ diff-lcs (1.4.4)
10
+ filesize (0.2.0)
11
11
  jsobfu (0.4.2)
12
12
  rkelly-remix
13
- json (2.0.4)
14
- metasm (1.0.3)
15
- mini_portile2 (2.3.0)
16
- nokogiri (1.8.2)
17
- mini_portile2 (~> 2.3.0)
18
- racc (1.4.14)
19
- rake (10.4.2)
13
+ json (2.3.1)
14
+ metasm (1.0.4)
15
+ mini_portile2 (2.4.0)
16
+ nokogiri (1.10.10)
17
+ mini_portile2 (~> 2.4.0)
18
+ racc (1.5.0)
19
+ rake (12.3.3)
20
20
  rb-readline (0.5.5)
21
21
  rex (2.0.12)
22
22
  filesize (~> 0)
@@ -25,33 +25,34 @@ GEM
25
25
  metasm (~> 1)
26
26
  nokogiri (~> 1)
27
27
  rb-readline (~> 0)
28
- rexical (1.0.5)
28
+ rexical (1.0.7)
29
29
  rkelly-remix (0.0.7)
30
- rspec (3.7.0)
31
- rspec-core (~> 3.7.0)
32
- rspec-expectations (~> 3.7.0)
33
- rspec-mocks (~> 3.7.0)
34
- rspec-core (3.7.1)
35
- rspec-support (~> 3.7.0)
36
- rspec-expectations (3.7.0)
30
+ rspec (3.9.0)
31
+ rspec-core (~> 3.9.0)
32
+ rspec-expectations (~> 3.9.0)
33
+ rspec-mocks (~> 3.9.0)
34
+ rspec-core (3.9.2)
35
+ rspec-support (~> 3.9.3)
36
+ rspec-expectations (3.9.2)
37
37
  diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.7.0)
39
- rspec-mocks (3.7.0)
38
+ rspec-support (~> 3.9.0)
39
+ rspec-mocks (3.9.1)
40
40
  diff-lcs (>= 1.2.0, < 2.0)
41
- rspec-support (~> 3.7.0)
42
- rspec-support (3.7.0)
41
+ rspec-support (~> 3.9.0)
42
+ rspec-support (3.9.3)
43
43
 
44
44
  PLATFORMS
45
45
  ruby
46
46
 
47
47
  DEPENDENCIES
48
- bundler (~> 1.16)
48
+ bundler (~> 2.1.4)
49
49
  hcl-checker!
50
- racc (= 1.4.14)
51
- rake (~> 10.0)
50
+ nokogiri (>= 1.10.8)
51
+ racc (= 1.5.0)
52
+ rake (~> 12.3.3)
52
53
  rex (= 2.0.12)
53
- rexical (= 1.0.5)
54
+ rexical (>= 1.0.7)
54
55
  rspec (~> 3.0)
55
56
 
56
57
  BUNDLED WITH
57
- 1.16.1
58
+ 2.1.4
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Hcl::Checker
2
2
 
3
- **Hashicorp Configuration Language** syntax checker and parser.
3
+ **Hashicorp Configuration Language** syntax checker and parser.
4
4
 
5
5
  Parser originally created by [Sikula](https://github.com/sikula) and available
6
6
  at [Ruby HCL Repository](https://github.com/sikula/ruby-hcl). Only works with
7
- [HCL Version 1](https://github.com/hashicorp/hcl).
7
+ [HCL Version 1](https://github.com/hashicorp/hcl).
8
8
 
9
9
  ## Installation
10
10
 
@@ -47,21 +47,21 @@ You can validate the `hcl_string` contents with `valid?` method. This will
47
47
  return `true` if is a valid HCL or `false` if not.
48
48
 
49
49
  ```
50
- 2.3.2 :014 > HCL::Checker.valid? hcl_string
50
+ 2.3.2 :014 > HCL1::Checker.valid? hcl_string
51
51
  => true
52
52
  ```
53
53
 
54
54
  You can parse the `hcl_string` into a `Hash` with `parse` method.
55
55
 
56
56
  ```
57
- 2.3.2 :015 > HCL::Checker.parse(hcl_string)
57
+ 2.3.2 :015 > HCL1::Checker.parse(hcl_string)
58
58
  => {"provider"=>{"aws"=>{"region"=>"${var.aws_region}", "access_key"=>"${var.aws_access_key}", "secret_key"=>"${var.aws_secret_key}"}}, "resource"=>{"aws_vpc"=>{"default"=>{"cidr_block"=>"10.0.0.0/16", "enable_dns_hostnames"=>true, "tags"=>{"Name"=>"Event Store VPC"}}}}}
59
59
  ```
60
60
 
61
61
  If after a `parse` you got `false` you can check `last_error` with:
62
62
 
63
63
  ```
64
- 2.4.2 :063 > HCL::Checker.last_error
64
+ 2.4.2 :063 > HCL1::Checker.last_error
65
65
  => "Parse error at \"eec8b16c-ee89-4ea0-bdcc-d094300a42e8\" , (invalid token: ,)"
66
66
  ```
67
67
 
@@ -84,7 +84,7 @@ $ bundle exec rake build_grammar
84
84
  Building Lexer....done
85
85
  Building Parser....done
86
86
  ```
87
-
87
+
88
88
  ## Contributing
89
89
 
90
90
  Bug reports and pull requests are welcome on GitHub at
@@ -96,5 +96,3 @@ to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
96
96
 
97
97
  The gem is available as open source under the terms of the [MIT
98
98
  License](https://opensource.org/licenses/MIT).
99
-
100
-
@@ -20,7 +20,7 @@ macro
20
20
  RIGHTBRACE \}
21
21
  LEFTBRACKET \[
22
22
  RIGHTBRACKET \]
23
- HEREDOCUMENT \<<-
23
+ HEREDOCUMENT \<<\-?
24
24
 
25
25
  rule
26
26
  # [:state] pattern [actions]
@@ -26,8 +26,12 @@ rule
26
26
 
27
27
 
28
28
  objectlist:
29
- objectitem
29
+ objectitem COMMA
30
30
  { result = [val[0]] }
31
+ | objectitem
32
+ { result = [val[0]] }
33
+ | objectlist objectitem COMMA
34
+ { result = val[0] << val[1] }
31
35
  | objectlist objectitem
32
36
  { result = val[0] << val[1] }
33
37
  ;
@@ -96,6 +100,10 @@ rule
96
100
  { result = val[0] }
97
101
  | STRING
98
102
  { result = val[0] }
103
+ | list
104
+ { result = val[0] }
105
+ | object
106
+ { result = val[0] }
99
107
  ;
100
108
 
101
109
  number:
@@ -122,7 +130,7 @@ require_relative './lexer'
122
130
  #// from object.go: there is a flattened list structure
123
131
  #//
124
132
  def flatten_objectlist(list)
125
- list.each_with_object({}) do |a, h|
133
+ (list || {}).each_with_object({}) do |a, h|
126
134
  h[a.first] =
127
135
  case a.last
128
136
  when Hash
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = 'hcl-checker'
7
7
  spec.version = HCL::Checker::VERSION
8
8
  spec.authors = ['Marcelo Castellani']
9
- spec.email = ['marcelo.castellani@totvs.com.br']
9
+ spec.email = ['marcelo@linux.com']
10
10
 
11
11
  spec.summary = 'Hashicorp Configuration Language parser for Ruby'
12
12
  spec.description = 'Hashicorp Configuration Language parser and checker for Ruby'
@@ -18,11 +18,35 @@ Gem::Specification.new do |spec|
18
18
  end
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.16'
22
- spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_development_dependency 'bundler', '~> 2.1.4'
22
+ spec.add_development_dependency 'rake', '~> 12.3.3'
23
23
  spec.add_development_dependency 'rspec', '~> 3.0'
24
- spec.add_development_dependency 'racc', '1.4.14'
24
+ spec.add_development_dependency 'racc', '1.5.0'
25
25
  spec.add_development_dependency 'rex', '2.0.12'
26
- spec.add_development_dependency 'rexical', '1.0.5'
26
+ spec.add_development_dependency 'rexical', '>= 1.0.7'
27
27
 
28
+ spec.post_install_message = %q{
29
+ Hello, I am updating this Gem to support version 2.0 of the HCL.
30
+
31
+ In the meantime, it is important that you know that there will be a
32
+ compatibility break with the current version, for Gem to support both
33
+ versions.
34
+
35
+ Therefore, instead of using just HCL::Checker you must tell which
36
+ version you are using, like this:
37
+
38
+ HCL1::Checker
39
+
40
+ Or
41
+
42
+ HCL2::Checker
43
+
44
+ At the moment both HCL::Checker and HCL1::Checker will work, but with
45
+ the release of support for version 2 the HCL::Checker syntax will no
46
+ longer work.
47
+
48
+ So, update your code.
49
+
50
+ Thank you :)
51
+ }
28
52
  end
@@ -1,5 +1,5 @@
1
1
  module HCL
2
2
  module Checker
3
- VERSION = '1.0.6'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
@@ -1,123 +1,124 @@
1
1
  #--
2
2
  # DO NOT MODIFY!!!!
3
- # This file is automatically generated by rex 1.0.5
3
+ # This file is automatically generated by rex 1.0.7
4
4
  # from lexical definition file "./assets/lexer.rex".
5
5
  #++
6
6
 
7
7
 
8
8
  class HCLLexer
9
- require 'strscan'
9
+ require 'strscan'
10
10
 
11
- class ScanError < StandardError ; end
11
+ class ScanError < StandardError ; end
12
12
 
13
- attr_reader :lineno
14
- attr_reader :filename
15
- attr_accessor :state
13
+ attr_reader :lineno
14
+ attr_reader :filename
15
+ attr_accessor :state
16
16
 
17
- def scan_setup(str)
18
- @ss = StringScanner.new(str)
19
- @lineno = 1
20
- @state = nil
21
- end
17
+ def scan_setup(str)
18
+ @ss = StringScanner.new(str)
19
+ @lineno = 1
20
+ @state = nil
21
+ end
22
22
 
23
- def action
24
- yield
25
- end
23
+ def action
24
+ yield
25
+ end
26
26
 
27
- def scan_str(str)
28
- scan_setup(str)
29
- do_parse
30
- end
31
- alias :scan :scan_str
27
+ def scan_str(str)
28
+ scan_setup(str)
29
+ do_parse
30
+ end
31
+ alias :scan :scan_str
32
32
 
33
- def load_file( filename )
34
- @filename = filename
35
- open(filename, "r") do |f|
36
- scan_setup(f.read)
37
- end
38
- end
33
+ def load_file( filename )
34
+ @filename = filename
35
+ File.open(filename, "r") do |f|
36
+ scan_setup(f.read)
37
+ end
38
+ end
39
39
 
40
- def scan_file( filename )
41
- load_file(filename)
42
- do_parse
43
- end
40
+ def scan_file( filename )
41
+ load_file(filename)
42
+ do_parse
43
+ end
44
44
 
45
45
 
46
- def next_token
47
- return if @ss.eos?
48
-
49
- # skips empty actions
50
- until token = _next_token or @ss.eos?; end
51
- token
52
- end
46
+ def next_token
47
+ return if @ss.eos?
53
48
 
54
- def _next_token
55
- text = @ss.peek(1)
56
- @lineno += 1 if text == "\n"
57
- token = case @state
58
- when nil
59
- case
60
- when (text = @ss.scan(/\s+/))
61
- ;
49
+ # skips empty actions
50
+ until token = _next_token or @ss.eos?; end
51
+ token
52
+ end
62
53
 
63
- when (text = @ss.scan(/\#.*|\/\/.*$/))
64
- ;
54
+ def _next_token
55
+ text = @ss.peek(1)
56
+ @lineno += 1 if text == "\n"
57
+ token = case @state
58
+ when nil
59
+ case
60
+ when (text = @ss.scan(/\s+/))
61
+ ;
65
62
 
66
- when (text = @ss.scan(/\n|\r/))
67
- ;
63
+ when (text = @ss.scan(/\#.*|\/\/.*$/))
64
+ ;
68
65
 
69
- when (text = @ss.scan(/\/\*/))
70
- action { consume_comment(text) }
66
+ when (text = @ss.scan(/\n|\r/))
67
+ ;
71
68
 
72
- when (text = @ss.scan(/true|false/))
73
- action { [:BOOL, to_boolean(text)]}
69
+ when (text = @ss.scan(/\/\*/))
70
+ action { consume_comment(text) }
74
71
 
75
- when (text = @ss.scan(/\-?\d+\.\d+/))
76
- action { [:FLOAT, text.to_f] }
72
+ when (text = @ss.scan(/true|false/))
73
+ action { [:BOOL, to_boolean(text)]}
77
74
 
78
- when (text = @ss.scan(/-?\d+/))
79
- action { [:NUMBER, text.to_i] }
75
+ when (text = @ss.scan(/\-?\d+\.\d+/))
76
+ action { [:FLOAT, text.to_f] }
80
77
 
81
- when (text = @ss.scan(/\"/))
82
- action { [:STRING, consume_string(text)] }
78
+ when (text = @ss.scan(/-?\d+/))
79
+ action { [:NUMBER, text.to_i] }
83
80
 
84
- when (text = @ss.scan(/\<<-/))
85
- action { [:STRING, consume_heredoc] }
81
+ when (text = @ss.scan(/\"/))
82
+ action { [:STRING, consume_string(text)] }
86
83
 
87
- when (text = @ss.scan(/\{/))
88
- action { [:LEFTBRACE, text]}
84
+ when (text = @ss.scan(/\<<\-?/))
85
+ action { [:STRING, consume_heredoc] }
89
86
 
90
- when (text = @ss.scan(/\}/))
91
- action { [:RIGHTBRACE, text]}
87
+ when (text = @ss.scan(/\{/))
88
+ action { [:LEFTBRACE, text]}
92
89
 
93
- when (text = @ss.scan(/\[/))
94
- action { [:LEFTBRACKET, text]}
90
+ when (text = @ss.scan(/\}/))
91
+ action { [:RIGHTBRACE, text]}
95
92
 
96
- when (text = @ss.scan(/\]/))
97
- action { [:RIGHTBRACKET, text]}
93
+ when (text = @ss.scan(/\[/))
94
+ action { [:LEFTBRACKET, text]}
98
95
 
99
- when (text = @ss.scan(/\,/))
100
- action { [:COMMA, text]}
96
+ when (text = @ss.scan(/\]/))
97
+ action { [:RIGHTBRACKET, text]}
101
98
 
102
- when (text = @ss.scan(/[a-zA-Z_][a-zA-Z0-9_\-\.]*/))
103
- action { [:IDENTIFIER, text]}
99
+ when (text = @ss.scan(/\,/))
100
+ action { [:COMMA, text]}
104
101
 
105
- when (text = @ss.scan(/\=/))
106
- action { [:EQUAL, text]}
102
+ when (text = @ss.scan(/[a-zA-Z_][a-zA-Z0-9_\-\.]*/))
103
+ action { [:IDENTIFIER, text]}
107
104
 
108
- when (text = @ss.scan(/\-/))
109
- action { [:MINUS, text]}
105
+ when (text = @ss.scan(/\=/))
106
+ action { [:EQUAL, text]}
110
107
 
111
- else
112
- text = @ss.string[@ss.pos .. -1]
113
- raise ScanError, "can not match: '" + text + "'"
114
- end # if
115
-
116
- else
117
- raise ScanError, "undefined state: '" + state.to_s + "'"
118
- end # case state
119
- token
120
- end # def _next_token
108
+ when (text = @ss.scan(/\-/))
109
+ action { [:MINUS, text]}
110
+
111
+
112
+ else
113
+ text = @ss.string[@ss.pos .. -1]
114
+ raise ScanError, "can not match: '" + text + "'"
115
+ end # if
116
+
117
+ else
118
+ raise ScanError, "undefined state: '" + state.to_s + "'"
119
+ end # case state
120
+ token
121
+ end # def _next_token
121
122
 
122
123
  def lex(input)
123
124
  scan_setup(input)