junoser 0.5.2 → 0.5.4

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
2
  SHA256:
3
- metadata.gz: aab5884056a5ff176a5daffacb2a000a70dc9108026fcd38aef0d0f761cf17d0
4
- data.tar.gz: cf10c3ccc516c51cc829b16273daf0cab69829e3ec65d48f3c3df8bef372ad2b
3
+ metadata.gz: 3e3d7eddfe23eff9321fcd418687ab21af2d7f6a9188d1c3a7971c9f69393449
4
+ data.tar.gz: d8496ad009be8d91d5c08d69f45ad44203683bca6b986896ecedb36b2946b709
5
5
  SHA512:
6
- metadata.gz: 9fd221d5bc56a46b6db96a46f32cdd88da4aef3fab73e9ede294a1c2c53ba3a2b1c9bcd88df84453faec84ab36f6990d7a4017cc13c484034b191e53d75d4b4b
7
- data.tar.gz: cee62b7fda182dcf3b67e3b3b14207cd105074b89edf699a9ae455009ee843d8d8d6802e5e383dc6e07439dbf30a01e24051ac87102b07fcbadecc3978ee89b4
6
+ metadata.gz: 699d47a030b28169dc1d9daceb881e34aee2aed4f9a119f34e81f37bfae9b4f633c14f78ebe05974b9e0f4809280add29bb695d4c73f65c53637fed3a722b509
7
+ data.tar.gz: 81df8499d1d55b562b1a571dd5328b3fcd8e1fb82de8babf2cd377a951f2b6770eeed58a7cb0bd52c5180a27d378e2c9c18f128435c16cc84194a5f09abdddfc
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby-version: ['3.1', '3.0', '2.7']
12
+ ruby-version: ['3.2', '3.1', '3.0']
13
13
  os: [ubuntu-latest]
14
14
  experimental: [false]
15
15
  include:
data/CHANGELOG.md CHANGED
@@ -1,20 +1,45 @@
1
+ ## [0.5.4] - 2023-07-15
2
+
3
+ ### Added
4
+
5
+ * Newly supported syntax
6
+ * "chassis dump-on-panic"
7
+
8
+ ### Fixed
9
+
10
+ * "policy-options policy-statement xxx from policy" didn't accept `[ ... ]` or `( ... )` expressions
11
+ * "system no-redirects-ipv6" was unexpectedly marked as invalid
12
+ * "snmp trap-group xxx categories chassis-cluster" was unexpectedly marked as invalid
13
+ * error when parsing "class-of-service schedulers foo drop-profile-map ..."
14
+
15
+
16
+ ## [0.5.3] - 2023-07-10
17
+
18
+ ### Added
19
+
20
+ * Newly supported syntax
21
+ * "chassis cluster" (by porting the hierarchy from vSRX 18.3R1.9)
22
+ * "security log stream xxx transport"
23
+
24
+
1
25
  ## [0.5.2] - 2022-12-10
2
26
 
3
27
  ### Fixed
4
28
 
5
- * "system services ssh root-login deny-password"
29
+ * "system services ssh root-login deny-password" was unexpectedly marked as invalid
6
30
 
7
31
 
8
32
  ## [0.5.1] - 2022-11-02
9
33
 
10
34
  ### Added
11
35
 
12
- * Support "protocols iccp peer xxx liveness-detection single-hop"
36
+ * Newly supported syntax
37
+ * "protocols iccp peer xxx liveness-detection single-hop"
38
+ * "poe" based on EX 18.1R3-S6.1
13
39
 
14
40
  ### Fixed
15
41
 
16
- * Support one-line form of "poe interface xxx" and "poe fpc xxx"
17
- * "interfaces xxx ether-options speed"
42
+ * "interfaces xxx ether-options speed" was unexpectedly marked as invalid
18
43
 
19
44
 
20
45
  ## [0.5.0] - 2022-11-02
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.5.2)
4
+ junoser (0.5.4)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile2 (2.8.0)
11
- nokogiri (1.13.10)
12
- mini_portile2 (~> 2.8.0)
10
+ mini_portile2 (2.8.2)
11
+ nokogiri (1.15.3)
12
+ mini_portile2 (~> 2.8.2)
13
13
  racc (~> 1.4)
14
14
  parslet (2.0.0)
15
- power_assert (2.0.2)
16
- racc (1.6.1)
15
+ power_assert (2.0.3)
16
+ racc (1.7.1)
17
17
  rake (13.0.6)
18
- test-unit (3.5.5)
18
+ test-unit (3.6.1)
19
19
  power_assert
20
20
 
21
21
  PLATFORMS
@@ -29,4 +29,4 @@ DEPENDENCIES
29
29
  test-unit
30
30
 
31
31
  BUNDLED WITH
32
- 2.3.24
32
+ 2.4.1
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2022 Shintaro Kojima
3
+ Copyright (c) 2015-2023 Shintaro Kojima
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -103,4 +103,4 @@ Or send a pull request to fix.
103
103
 
104
104
  ## Copyright and License
105
105
 
106
- Copyright (c) 2015-2022 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
106
+ Copyright (c) 2015-2023 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
@@ -17,23 +17,22 @@ module Junoser
17
17
  def rule
18
18
  str = @rule.read
19
19
  str = process_lines(str)
20
- str = str.split(/\n/).map {|l|
21
- process_line(l) unless l =~ /^ *#/ # Skip additional comment lines
20
+ str = str.split(/\n/).map { |l|
21
+ process_line(l) unless l =~ /^ *#/ # Skip additional comment lines
22
22
  }.compact.join("\n")
23
23
  finalize(str)
24
24
  end
25
25
 
26
-
27
26
  private
28
27
 
29
28
  def process_line(str)
30
- remove_undefined_variables(str)
31
- process_common_syntax(str)
32
- process_argument_syntax(str)
33
- process_structural_syntax(str)
34
- process_word(str)
35
- process_reserved_word(str)
36
- process_comment(str)
29
+ str = remove_undefined_variables(str)
30
+ str = process_common_syntax(str)
31
+ str = process_argument_syntax(str)
32
+ str = process_structural_syntax(str)
33
+ str = process_word(str)
34
+ str = process_reserved_word(str)
35
+ str = process_comment(str)
37
36
 
38
37
  str
39
38
  end
@@ -49,31 +48,31 @@ module Junoser
49
48
 
50
49
  def process_common_syntax(str)
51
50
  # rule(:foo) do -> foo(...args) {
52
- str.gsub!(/^rule\(:(\S+)\) do/) {"#$1(...args) { return_next_line"}
51
+ str.gsub!(/^rule\(:(\S+)\) do/) { "#$1(...args) { return_next_line" }
53
52
  # end -> }
54
- str.gsub!(/^(\s*)end$/) {"#$1}"}
53
+ str.gsub!(/^(\s*)end$/) { "#$1}" }
55
54
 
56
55
  # arg.as(:arg) ( -> {"arg":
57
56
  str.gsub! /arg\.as\(:arg\) \(/, '{"arg":'
58
57
  # arg.as(:arg) -> {"arg": null}
59
58
  str.gsub! /arg.as\(:arg\)/, '{"arg": null}'
60
59
  # ("foo" | "bar").as(:arg) ( -> {"(bar|baz)":
61
- str.gsub!(/\(([^)]+)\)\.as\(:arg\) \(/) {"{\"(#{$1.gsub('"', '').split(' | ').join('|')})\":"}
60
+ str.gsub!(/\(([^)]+)\)\.as\(:arg\) \(/) { "{\"(#{$1.gsub('"', '').split(' | ').join('|')})\":" }
62
61
  # enum(("foo" | "bar")).as(:arg) ( -> {"(bar|baz)": # TODO: support "enum" in the middle of line
63
- str.gsub!(/enum\(\(([^)]+)\)\)\.as\(:arg\) \(/) {"{\"(#{$1.gsub('"', '').split(' | ').join('|')})\":"}
62
+ str.gsub!(/enum\(\(([^)]+)\)\)\.as\(:arg\) \(/) { "{\"(#{$1.gsub('"', '').split(' | ').join('|')})\":" }
64
63
 
65
64
  str.gsub! '.as(:arg)', ''
66
65
 
67
66
  # c( -> {
68
- str.gsub!(/^(\s*)c\(/) {"#$1{"}
67
+ str.gsub!(/^(\s*)c\(/) { "#$1{" }
69
68
 
70
69
  # foo /* doc */, -> foo() /* doc */,
71
- str.gsub!(%r|^(\s*)(?!arg)(\w+)( /\* (.*) \*/,?)$|) {"#$1this.#$2()#$3"}
70
+ str.gsub!(%r|^(\s*)(?!arg)(\w+)( /\* (.*) \*/,?)$|) { "#$1this.#$2()#$3" }
72
71
  # foo, -> foo(),
73
- str.gsub!(%r|^(\s*)(?!arg)(\w+)(,?)$|) {"#$1this.#$2()#$3"}
72
+ str.gsub!(%r|^(\s*)(?!arg)(\w+)(,?)$|) { "#$1this.#$2()#$3" }
74
73
 
75
74
  # ) -> }
76
- str.gsub!(/^(\s+)\)/) {"#$1}"}
75
+ str.gsub!(/^(\s+)\)/) { "#$1}" }
77
76
 
78
77
  str
79
78
  end
@@ -81,56 +80,56 @@ module Junoser
81
80
  def process_argument_syntax(str)
82
81
  # "foo" (("bar" | "baz")) ( -> "foo(bar|baz)": {
83
82
  # "foo" enum(("bar" | "baz")) ( -> "foo(bar|baz)": { # TODO: support "enum" in the middle of line
84
- str.gsub!(/^(\s*)"(\S+)" (?:enum)?\(\((.*)\)\) \(/) {"#$1\"#$2(#{$3.gsub('"', '').split(' | ').join('|')})\": {"}
83
+ str.gsub!(/^(\s*)"(\S+)" (?:enum)?\(\((.*)\)\) \(/) { "#$1\"#$2(#{$3.gsub('"', '').split(' | ').join('|')})\": {" }
85
84
  # "foo" arg ( -> "foo(arg)": {
86
- str.gsub!(/^(\s*)"(\S+)" arg \(/) {"#$1\"#$2(arg)\": {"}
85
+ str.gsub!(/^(\s*)"(\S+)" arg \(/) { "#$1\"#$2(arg)\": {" }
87
86
 
88
87
  # "foo" (... | arg) /* doc */ -> "foo": "arg"
89
- str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$3\": arg#$4"}
88
+ str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$3\": arg#$4" }
90
89
 
91
90
  # "foo" (... | arg) ( /* doc */ -> "foo(arg)": {
92
- str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) \( /\* (.*) \*/$|) {"#$1\"#$2(arg) | #$3\": {"}
91
+ str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) \( /\* (.*) \*/$|) { "#$1\"#$2(arg) | #$3\": {" }
93
92
  # "foo" (... | arg) ( -> "foo(arg)": {
94
- str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) \($|) {"#$1\"#$2(arg)\": {"}
93
+ str.gsub!(%r|^(\s*)"(\S+)" \(.* \| arg ?.*\) \($|) { "#$1\"#$2(arg)\": {" }
95
94
 
96
95
  # "foo" (arg | ...) /* doc */ -> "foo": "arg"
97
- str.gsub!(%r|^(\s*)"(\S+)" \(arg ?.*\) /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$3\": arg#$4"}
96
+ str.gsub!(%r|^(\s*)"(\S+)" \(arg ?.*\) /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$3\": arg#$4" }
98
97
 
99
98
  # "foo" (arg | ...) ( /* doc */ -> "foo(arg)": {
100
- str.gsub!(%r|^(\s*)"(\S+)" \(arg ?.*\) \( /\* (.*) \*/(,?)$|) {"#$1\"#$2(arg) | #$3\": {#$4"}
99
+ str.gsub!(%r|^(\s*)"(\S+)" \(arg ?.*\) \( /\* (.*) \*/(,?)$|) { "#$1\"#$2(arg) | #$3\": {#$4" }
101
100
 
102
101
  # "foo" ("bar" | "baz") ( /* doc */ -> "foo(bar|baz)": {
103
- str.gsub!(%r|^(\s*)"(\S+)" \("([^)]+)"\) \( /\* (.*) \*/$|) {"#$1\"#$2(#{$3.split('" | "').join('|')}) | #$4\": {"}
102
+ str.gsub!(%r|^(\s*)"(\S+)" \("([^)]+)"\) \( /\* (.*) \*/$|) { "#$1\"#$2(#{$3.split('" | "').join('|')}) | #$4\": {" }
104
103
  # "foo" ("bar" | "baz") ( -> "foo(bar|baz)": {
105
- str.gsub!(%r|^(\s*)"(\S+)" \("([^)]+)"\) \($|) {"#$1\"#$2(#{$3.split('" | "').join('|')})\": {"}
104
+ str.gsub!(%r|^(\s*)"(\S+)" \("([^)]+)"\) \($|) { "#$1\"#$2(#{$3.split('" | "').join('|')})\": {" }
106
105
 
107
106
  # "foo" ("bar" | "baz") /* doc */, -> "foo": ["bar", "baz"],
108
- str.gsub!(%r|^(\s*)"(\S+)" \(([^)]+)\) /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$4\": [#{$3.split(' | ').join(', ')}]#$5"}
107
+ str.gsub!(%r|^(\s*)"(\S+)" \(([^)]+)\) /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$4\": [#{$3.split(' | ').join(', ')}]#$5" }
109
108
  # "foo" ("bar" | "baz"), -> "foo": ["bar", "baz"],
110
- str.gsub!(%r|^(\s*)"(\S+)" \(([^)]+)\)(,?)$|) {"#$1\"#$2\": [#{$3.split(' | ').join(', ')}]#$4"}
109
+ str.gsub!(%r|^(\s*)"(\S+)" \(([^)]+)\)(,?)$|) { "#$1\"#$2\": [#{$3.split(' | ').join(', ')}]#$4" }
111
110
 
112
111
  # "foo" enum(("bar" | "baz")) -> "foo": new Enumeration(["bar", "baz"])
113
- str.gsub!(/^(\s*)("\S+") enum\(\((.*)\)\)/) {"#$1#$2: new Enumeration(#{$3.gsub('"', '').split(' | ')})"}
112
+ str.gsub!(/^(\s*)("\S+") enum\(\((.*)\)\)/) { "#$1#$2: new Enumeration(#{$3.gsub('"', '').split(' | ')})" }
114
113
 
115
114
  # "foo" arg /* doc */, -> "foo | doc": "arg",
116
- str.gsub!(%r|^(\s*)"([^"]+)" arg /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$3\": \"arg\"#$4"}
115
+ str.gsub!(%r|^(\s*)"([^"]+)" arg /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$3\": \"arg\"#$4" }
117
116
  # "foo" arg, -> "foo": "arg",
118
- str.gsub!(%r|(\s*)"([^"]+)" arg(,?)$|) {"#$1\"#$2\": \"arg\"#$3"}
117
+ str.gsub!(%r|(\s*)"([^"]+)" arg(,?)$|) { "#$1\"#$2\": \"arg\"#$3" }
119
118
 
120
119
  # "foo" ipaddr, -> "foo": this.ipaddr(),
121
- str.gsub!(%r|(\s*)"([^"]+)" ipaddr(,?)$|) {"#$1\"#$2\": this.ipaddr()#$3"}
120
+ str.gsub!(%r|(\s*)"([^"]+)" ipaddr(,?)$|) { "#$1\"#$2\": this.ipaddr()#$3" }
122
121
 
123
122
  str
124
123
  end
125
124
 
126
125
  def process_structural_syntax(str)
127
126
  # "foo" ( /* doc */ -> "foo | doc": (...args) => {
128
- str.gsub!(%r|^(\s*)"(\S+)" \( /\* (.*) \*/|) {"#$1\"#$2 | #$3\": {"}
127
+ str.gsub!(%r|^(\s*)"(\S+)" \( /\* (.*) \*/|) { "#$1\"#$2 | #$3\": {" }
129
128
  # "foo" ( -> "foo": (...args) => {
130
- str.gsub!(%r|^(\s*)"(\S+)" \($|) {"#$1\"#$2\": {"}
129
+ str.gsub!(%r|^(\s*)"(\S+)" \($|) { "#$1\"#$2\": {" }
131
130
 
132
131
  # "foo" arg ( /* doc */ -> "foo | doc": (...args) => {
133
- str.gsub!(%r|^(\s*)"(\S+)" arg \( /\* (.*) \*/|) {"#$1\"#$2 | #$3\": {"}
132
+ str.gsub!(%r|^(\s*)"(\S+)" arg \( /\* (.*) \*/|) { "#$1\"#$2 | #$3\": {" }
134
133
 
135
134
  str
136
135
  end
@@ -142,9 +141,9 @@ module Junoser
142
141
  str.gsub!(/ ((?!arg\w)(arg)|(enum)?\(arg\))/, ' "arg"')
143
142
 
144
143
  # "foo" /* doc */, -> "foo | doc": null,
145
- str.gsub!(%r|^(\s*)"([^"]+)" /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$3\": null#$4"}
144
+ str.gsub!(%r|^(\s*)"([^"]+)" /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$3\": null#$4" }
146
145
  # "foo", -> "foo": null,
147
- str.gsub!(%r|^(\s*)"([^"]+)"(,?)$|) {"#$1\"#$2\": null#$3"}
146
+ str.gsub!(%r|^(\s*)"([^"]+)"(,?)$|) { "#$1\"#$2\": null#$3" }
148
147
 
149
148
  # ("foo" | "bar") -> ["foo", "bar"]
150
149
  str.gsub!(/^(\s*) \(+("[^"]+(?:" \| "[^"]+)*")\)+(,?)$/) do
@@ -153,10 +152,10 @@ module Junoser
153
152
  end
154
153
 
155
154
  # enum(("bar" | "baz")) -> "foo": new Enumeration(["bar", "baz"])
156
- str.gsub!(/^(\s*)enum\(\((.*)\)\)/) {"#$1new Enumeration(#{$2.gsub('"', '').split(' | ')})"}
155
+ str.gsub!(/^(\s*)enum\(\((.*)\)\)/) { "#$1new Enumeration(#{$2.gsub('"', '').split(' | ')})" }
157
156
 
158
157
  # (arg | "foo") -> ["arg", "foo"]
159
- str.gsub!(/^(\s*) \(arg( \| "[^"]+")+\)/) {"#$1[\"arg\"#{$2.split(' | ').join(', ')}]"}
158
+ str.gsub!(/^(\s*) \(arg( \| "[^"]+")+\)/) { "#$1[\"arg\"#{$2.split(' | ').join(', ')}]" }
160
159
 
161
160
  str
162
161
  end
@@ -184,8 +183,11 @@ module Junoser
184
183
  str.gsub!(/"(dest|src|static)-nat-rule-match/) { '"match' }
185
184
 
186
185
  # faster interface speed support
187
- str.gsub! '"40g", "oc3"', '"40g", "100g", "200g", "400g", "800g", "oc3"'
188
- str.gsub! '"100G"', '"100G", "200G", "400G", "800G"'
186
+ str.gsub! '"400g", "oc3"', '"400g", "800g", "oc3"'
187
+ str.gsub! '"400G"', '"400G", "800G"'
188
+
189
+ # support "set interfaces xxx ether-options speed"
190
+ str.gsub! '"ethernet-1', '"1'
189
191
 
190
192
  fix_route_filter(str)
191
193
 
@@ -193,9 +195,9 @@ module Junoser
193
195
  end
194
196
 
195
197
  def fix_route_filter(str)
196
- str.gsub!(/("exact \| [^"]*"): "arg"/) {"#$1: null"}
197
- str.gsub!(/("longer \| [^"]*"): "arg"/) {"#$1: null"}
198
- str.gsub!(/("orlonger \| [^"]*"): "arg"/) {"#$1: null"}
198
+ str.gsub!(/("exact \| [^"]*"): "arg"/) { "#$1: null" }
199
+ str.gsub!(/("longer \| [^"]*"): "arg"/) { "#$1: null" }
200
+ str.gsub!(/("orlonger \| [^"]*"): "arg"/) { "#$1: null" }
199
201
  end
200
202
 
201
203
  def process_comment(str)
@@ -203,17 +205,27 @@ module Junoser
203
205
  str.gsub! '%', '' % %''
204
206
 
205
207
  # "foo": ... /* doc */, -> "foo | doc": ...,
206
- str.gsub!(%r|^(\s*)"([^"]+)": (.*) /\* (.*) \*/(,?)$|) {"#$1\"#$2 | #$4\": #$3#$5"}
208
+ str.gsub!(%r|^(\s*)"([^"]+)": (.*) /\* (.*) \*/(,?)$|) { "#$1\"#$2 | #$4\": #$3#$5" }
207
209
 
208
210
  str
209
211
  end
210
212
 
211
213
  def process_lines(str)
212
- # "set protocols mpls path"
214
+ # set protocols mpls path
213
215
  str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
214
216
  "#{$1}#{$2}s(#{$2}ipaddr,"
215
217
  end
216
218
 
219
+ # set protocols iccp peer xxx liveness-detection single-hop
220
+ str.gsub!(/(^rule\(:peer_group\) do.*?\n(\s*)"detection-time" \(.*?c\(\s*"threshold" arg .*?\)\s*\))/m) do
221
+ "#{$1},\n#{format('"single-hop"', $2)}"
222
+ end
223
+
224
+ # set forwarding-options dhcp-relay server-group
225
+ str.gsub!(/^(rule\(:(?:v6_)?server_group_type\) do)\n(.*?)\nend/m) do
226
+ "#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
227
+ end
228
+
217
229
  str
218
230
  end
219
231
 
@@ -227,7 +239,7 @@ module Junoser
227
239
  # ->
228
240
  #
229
241
  # return ...
230
- lines.gsub!(/return_next_line\n(\s*)/m) {"\n#$1return "}
242
+ lines.gsub!(/return_next_line\n(\s*)/m) { "\n#$1return " }
231
243
 
232
244
  # {
233
245
  # {
@@ -236,7 +248,7 @@ module Junoser
236
248
  #
237
249
  # {
238
250
  # "null_1": {
239
- lines.gsub!(/([{,]\n\s*){/m) {"#$1\"null_#{sequence}\": {"}
251
+ lines.gsub!(/([{,]\n\s*){/m) { "#$1\"null_#{sequence}\": {" }
240
252
 
241
253
  # {
242
254
  # foo()
@@ -245,10 +257,10 @@ module Junoser
245
257
  #
246
258
  # {
247
259
  # "null_1": foo()
248
- lines.gsub!(/([{,]\n\s*)([^ "(]+)/m) {"#$1\"null_#{sequence}\": #$2"}
260
+ lines.gsub!(/([{,]\n\s*)([^ "(]+)/m) { "#$1\"null_#{sequence}\": #$2" }
249
261
 
250
262
  # "arg" -> "arg_1"
251
- lines.gsub('"arg":') {%["arg_#{sequence}":]}
263
+ lines.gsub('"arg":') { %["arg_#{sequence}":] }
252
264
  end
253
265
 
254
266
  # } -> )
@@ -302,12 +314,12 @@ module Junoser
302
314
 
303
315
  def objectize_arg_of_s(lines)
304
316
  # s( -> s({
305
- lines.gsub!(/^( *(?:return|\S+:)? +)s\($/m) {"#$1this.s({"}
317
+ lines.gsub!(/^( *(?:return|\S+:)? +)s\($/m) { "#$1this.s({" }
306
318
  # sc( -> sc({
307
- lines.gsub!(/^( *(?:return|\S+:)? +)sc\($/m) {"#$1this.sc({"}
319
+ lines.gsub!(/^( *(?:return|\S+:)? +)sc\($/m) { "#$1this.sc({" }
308
320
 
309
321
  # ) -> })
310
- lines.gsub!(/^( *)\)(,?)$/m) {"#$1})#$2"}
322
+ lines.gsub!(/^( *)\)(,?)$/m) { "#$1})#$2" }
311
323
 
312
324
  lines
313
325
  end
@@ -180,7 +180,7 @@ module Junoser
180
180
  end
181
181
 
182
182
  rule(:policy_algebra) do
183
- arg.as(:arg)
183
+ any.as(:arg)
184
184
  end
185
185
 
186
186
  rule(:regular_expression) do
@@ -3611,6 +3611,15 @@ module Junoser
3611
3611
  a(str("rotation"), arg),
3612
3612
  str("allow-duplicates")
3613
3613
  )
3614
+ ),
3615
+ b(str("transport"),
3616
+ c(
3617
+ a(str("tcp-connections"), arg),
3618
+ b(str("protocol"),
3619
+ (str("udp") | str("tcp") | str("tls"))
3620
+ ),
3621
+ a(str("tls-profile"), arg)
3622
+ )
3614
3623
  )
3615
3624
  )
3616
3625
  ),
@@ -9566,7 +9575,7 @@ module Junoser
9566
9575
  b(str("categories"),
9567
9576
  c(
9568
9577
  str("authentication"),
9569
- str("chassis"),
9578
+ str("chassis-ha-reswatch"),
9570
9579
  str("link"),
9571
9580
  str("remote-operations"),
9572
9581
  str("routing"),
@@ -9578,7 +9587,7 @@ module Junoser
9578
9587
  str("services"),
9579
9588
  str("chassis-cluster"),
9580
9589
  str("chassis-high-availability"),
9581
- str("chassis-ha-reswatch"),
9590
+ str("chassis"),
9582
9591
  str("timing-events"),
9583
9592
  str("dot3oam-events"),
9584
9593
  b(str("sonet-alarms"),
@@ -22376,7 +22385,87 @@ module Junoser
22376
22385
  ),
22377
22386
  str("vlan-isolation")
22378
22387
  )
22388
+ ),
22389
+ str("dump-on-panic"),
22390
+ # Ported from vSRX 18.3R1.9
22391
+ b(str("cluster"),
22392
+ c(
22393
+ b(str("traceoptions"),
22394
+ c(
22395
+ str("no-remote-trace"),
22396
+ b(str("file"),
22397
+ sc(
22398
+ arg,
22399
+ a(str("size"), arg),
22400
+ a(str("files"), arg),
22401
+ str("world-readable"),
22402
+ str("no-world-readable"),
22403
+ b(str("match"),
22404
+ regular_expression
22405
+ )
22406
+ )
22407
+ ).as(:oneline),
22408
+ a(str("flag"), enum(str("cli") | str("configuration") | str("eventlib") | str("fsm") | str("heartbeat") | str("interface") | str("routing-socket") | str("uspipc") | str("init") | str("socket") | str("snmp") | str("ip-monitoring") | str("hw-monitoring") | str("fabric-monitoring") | str("schedule-monitoring") | str("heartbeat-tlv") | str("all"))).as(:oneline),
22409
+ b(str("level"),
22410
+ (str("emergency") | str("alert") | str("critical") | str("error") | str("warning") | str("notice") | str("info") | str("debug") | str("all"))
22411
+ )
22412
+ )
22413
+ ),
22414
+ str("control-link-recovery"),
22415
+ a(str("reth-count"), arg),
22416
+ str("control-ports").as(:oneline),
22417
+ a(str("heartbeat-interval"), arg),
22418
+ a(str("heartbeat-threshold"), arg),
22419
+ str("network-management"),
22420
+ a(str("node"), enum(str("0") | str("1"))),
22421
+ b(a(str("redundancy-group"), arg),
22422
+ c(
22423
+ a(str("node"), enum(str("0") | str("1")),
22424
+ sc(
22425
+ a(str("priority"), arg)
22426
+ )
22427
+ ).as(:oneline),
22428
+ b(str("preempt"),
22429
+ c(
22430
+ a(str("delay"), arg),
22431
+ a(str("limit"), arg),
22432
+ a(str("period"), arg)
22433
+ )
22434
+ ),
22435
+ a(str("gratuitous-arp-count"), arg),
22436
+ a(str("hold-down-interval"), arg),
22437
+ b(a(str("interface-monitor"), arg),
22438
+ sc(
22439
+ a(str("weight"), arg)
22440
+ )
22441
+ ).as(:oneline),
22442
+ b(str("ip-monitoring"),
22443
+ c(
22444
+ a(str("global-weight"), arg),
22445
+ a(str("global-threshold"), arg),
22446
+ a(str("retry-interval"), arg),
22447
+ a(str("retry-count"), arg),
22448
+ b(str("family"),
22449
+ c(
22450
+ b(str("inet"),
22451
+ c(
22452
+ ip_monitoring_address_type
22453
+ )
22454
+ )
22455
+ )
22456
+ )
22457
+ )
22458
+ )
22459
+ )
22460
+ ),
22461
+ b(str("configuration-synchronize"),
22462
+ c(
22463
+ str("no-secondary-bootup-auto")
22464
+ )
22465
+ )
22466
+ )
22379
22467
  )
22468
+ # End of vSRX 18.3R1.9
22380
22469
  )
22381
22470
  end
22382
22471
 
@@ -44919,15 +45008,15 @@ module Junoser
44919
45008
  a(str("priority"), arg),
44920
45009
  a(str("excess-priority"), arg),
44921
45010
  b(str("drop-profile-map"),
44922
- s(
44923
- b(str("loss-priority"),
44924
- (str("low") | str("high") | str("medium-low") | str("medium-high") | str("any"))
45011
+ s(
45012
+ s(str("loss-priority"),
45013
+ (str("low") | str("high") | str("medium-low") | str("medium-high") | str("any"))
44925
45014
  ),
44926
- b(str("protocol"),
44927
- (str("tcp") | str("non-tcp") | str("any"))
45015
+ s(str("protocol"),
45016
+ (str("tcp") | str("non-tcp") | str("any"))
44928
45017
  ),
44929
- c(
44930
- a(str("drop-profile"), arg)
45018
+ s(str("drop-profile"),
45019
+ arg
44931
45020
  )
44932
45021
  )
44933
45022
  ).as(:oneline),
@@ -83361,8 +83450,8 @@ module Junoser
83361
83450
  str("no-neighbor-learn"),
83362
83451
  str("no-multicast-echo"),
83363
83452
  str("extended-echo"),
83364
- str("no-redirects"),
83365
83453
  str("no-redirects-ipv6"),
83454
+ str("no-redirects"),
83366
83455
  str("nd-override-preferred-src"),
83367
83456
  str("no-ping-record-route"),
83368
83457
  str("no-ping-time-stamp"),
@@ -127220,6 +127309,20 @@ module Junoser
127220
127309
  str("no-world-readable")
127221
127310
  ).as(:oneline)
127222
127311
  end
127312
+
127313
+ rule(:ip_monitoring_address_type) do
127314
+ b(arg.as(:arg),
127315
+ c(
127316
+ a(str("weight"), arg),
127317
+ b(str("interface"),
127318
+ s(
127319
+ arg,
127320
+ a(str("secondary-ip-address"), arg)
127321
+ )
127322
+ )
127323
+ )
127324
+ )
127325
+ end
127223
127326
  # End of vSRX 18.3R1.9
127224
127327
  end
127225
127328
  end
data/lib/junoser/ruler.rb CHANGED
@@ -96,6 +96,19 @@ module Junoser
96
96
  'prefix_list_items'], $1)
97
97
  end
98
98
 
99
+ str.gsub!(/^(\s*)"drop-profile-map" \(\s*s\(\s*"loss-priority" \(\s*(.*\s*\),)\s*"protocol" \(\s*(.*\s*\),)\s*c\(\s*"drop-profile" (.*)/) do
100
+ format([
101
+ '"drop-profile-map" (',
102
+ ' s(',
103
+ ' s("loss-priority",',
104
+ " #{$2}",
105
+ ' s("protocol",',
106
+ " #{$3}",
107
+ ' s("drop-profile",',
108
+ " #{$4}"
109
+ ], $1)
110
+ end
111
+
99
112
  #
100
113
  # "arg" matches anything so move to the end
101
114
  #
@@ -138,6 +151,8 @@ module Junoser
138
151
  str.gsub!(/"snmp"(.*\s*.*)"snmptrap"/) { %["snmptrap"#{$1}"snmp"] }
139
152
  str.gsub!(/"ospf"(.*\s*.*)"ospf3"/) { %["ospf3"#{$1}"ospf"] }
140
153
  str.gsub!(/"deny"(.*\s*.*)"deny-password"/) { %["deny-password"#{$1}"deny"] }
154
+ str.gsub!(/"no-redirects"(.*\s*.*)"no-redirects-ipv6"/) { %["no-redirects-ipv6"#{$1}"no-redirects"] }
155
+ str.gsub!(/"chassis"([^()]*)"chassis-ha-reswatch"/m) { %["chassis-ha-reswatch"#{$1}"chassis"] }
141
156
  str.gsub! '"tls1" | "tls11" | "tls12"', '"tls11" | "tls12" | "tls1"'
142
157
  str.gsub!(/("group1" \| "group2" \| "group5") \| ([^)]+)/) { "#{$2} | #{$1}" }
143
158
 
@@ -252,6 +267,9 @@ module Junoser
252
267
  # Fix .xsd: support "set interfaces xxx ether-options speed"
253
268
  str.gsub! '"ethernet-1', '"1'
254
269
 
270
+ # Fix .xsd: support "set policy-options policy-statement xxx from policy [expression]"
271
+ str.gsub!(/^rule\(:policy_algebra\) do(\s*)arg\.as\(:arg\)\send/) { "rule(:policy_algebra) do#{$1}any.as(:arg)\nend" }
272
+
255
273
  str
256
274
  end
257
275
 
@@ -1,3 +1,3 @@
1
1
  module Junoser
2
- VERSION = "0.5.2"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junoser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-09 00:00:00.000000000 Z
11
+ date: 2023-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubygems_version: 3.3.7
153
+ rubygems_version: 3.4.1
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: PEG parser for JUNOS configuration.