junoser 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aaec08e09e4a42a8f3f9fb44e00fcb2d5eca3e074f5588d77d86c72d9ed37f52
4
- data.tar.gz: 477440a7283850df8a638fe78bb71837e11e7feff8eff600d665bd56aace5260
3
+ metadata.gz: b370402809bb2214265f0dd6e692c591337882121f7f5c1f8f3653553cd29f83
4
+ data.tar.gz: 72dd3c61381706e34cba7618e6402f6be59380137c3b7198747d898e17d550c0
5
5
  SHA512:
6
- metadata.gz: 5fff90b0676b526f00c5946116fc4af18fa9a55f431efab460d012551956db180a1b20971923e5069fb059a4e7136ad3f995deef76abea15db4302fbdb91949e
7
- data.tar.gz: 2046e70037d4fffff6705d6cdbc02d7542107c92d98905f2858f5398b00769da22fc1f33353747c9918ccd225b9fa72be0a689f10c345ec0a7e5e136711debb7
6
+ metadata.gz: 606fec606c9882cddbef3f1cc687d00f19cf0f535acdb84da448dfea730e5c7d69f16d4837014c5b7c4b1a68fea00c957f72c867ffcdccae3773b7fbf2c76b5d
7
+ data.tar.gz: d88215e1ef62177ed15e5c0e76a149ac53a96880fb19c9bfd32c275e750b2aa298bb39a6a01b6a3ee3b650592da1d843b7bb443ac9bbfa75ef620b1e2c061752
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [0.4.1] - 2021-06-06
2
+
3
+ ### Added
4
+
5
+ * Newly supported syntax
6
+ * "apply-groups-except"
7
+
8
+ ### Fixed
9
+
10
+ * "scpf-link", "https", "inet6", "icmp6", "icmpv6", "ospf3", and "snmptrap" keywords might be marked as invalid in some hierarchies
11
+ * "policy-options community xxx members"
12
+ * "policy-options route-distinguisher xxx members"
13
+ * "routing-options confederation members"
14
+
15
+
1
16
  ## [0.4.0] - 2021-05-02
2
17
 
3
18
  ### Added
data/Gemfile.lock CHANGED
@@ -1,19 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.4.0)
4
+ junoser (0.4.1)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- nokogiri (1.11.3)
10
+ mini_portile2 (2.5.3)
11
+ nokogiri (1.11.7)
12
+ mini_portile2 (~> 2.5.0)
11
13
  racc (~> 1.4)
12
14
  parslet (2.0.0)
13
15
  power_assert (2.0.0)
14
16
  racc (1.5.2)
15
17
  rake (13.0.3)
16
- test-unit (3.4.1)
18
+ test-unit (3.4.4)
17
19
  power_assert
18
20
 
19
21
  PLATFORMS
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/testtask'
7
7
  xsd_path = File.join(__dir__, 'tmp/junos-system-19.3.xsd')
8
8
  rule_path = File.join(__dir__, 'tmp/rule.rb')
9
9
  ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
10
- js_parser_path = File.join(__dir__, 'tmp/schema.js')
10
+ js_parser_path = File.join(__dir__, 'tmp/junos.js')
11
11
 
12
12
  def open_files(input, output, &block)
13
13
  i = open(input)
@@ -5168,7 +5168,6 @@ rule(:configuration) do
5168
5168
  )
5169
5169
  ),
5170
5170
  # End of vSRX 18.3R1.9
5171
-
5172
5171
  "interfaces" ( /* Interface configuration */
5173
5172
  c(
5174
5173
  "pic-set" arg ( /* NP bundling configuration */
@@ -49,7 +49,7 @@ module Junoser
49
49
  private
50
50
 
51
51
  def trim_apply_groups(line)
52
- line.gsub! /\s+(apply-groups\s+.*)/, ''
52
+ line.gsub! /\s+(apply-groups(-except)?\s+.*)/, ''
53
53
  return $1
54
54
  end
55
55
  end
@@ -63,8 +63,6 @@ module Junoser
63
63
 
64
64
  str.gsub! '.as(:arg)', ''
65
65
 
66
- # any -> "any"
67
-
68
66
  # c( -> {
69
67
  str.gsub!(/^(\s*)c\(/) {"#$1{"}
70
68
 
@@ -226,9 +224,14 @@ module Junoser
226
224
  lines.gsub('"arg":') {%["arg_#{sequence}":]}
227
225
  end
228
226
 
227
+ # } -> )
229
228
  def balance_parenthesis(lines)
230
229
  # Fixes
231
230
  lines.gsub! 'Timeslots (1..24;', 'Timeslots (1..24);'
231
+ lines.gsub! '(such that the VLAN range is x <= range <= y.', '(such that the VLAN range is x <= range <= y).'
232
+ lines.gsub! '(intended primarily for use with a peer or group"', '(intended primarily for use with a peer or group)"'
233
+ lines.gsub! '(e.g. QSFP28 and QSFP+,', '(e.g. QSFP28 and QSFP+),'
234
+ lines.gsub! '(see the description of policy evaluation at the top of this module."', '(see the description of policy evaluation at the top of this module)."'
232
235
 
233
236
  count = 0
234
237
  target = nil
@@ -273,37 +276,28 @@ module Junoser
273
276
  def objectize_arg_of_s(lines)
274
277
  # s( -> s({
275
278
  lines.gsub!(/^( *(?:return|\S+:)? +)s\($/m) {"#$1this.s({"}
279
+ # sc( -> sc({
280
+ lines.gsub!(/^( *(?:return|\S+:)? +)sc\($/m) {"#$1this.sc({"}
276
281
 
277
282
  # ) -> })
278
- lines.gsub!(/^( *)\)$/m) {"#$1})"}
283
+ lines.gsub!(/^( *)\)(,?)$/m) {"#$1})#$2"}
279
284
 
280
285
  lines
281
286
  end
282
287
 
283
288
  def rule_header
284
289
  <<~EOS
290
+ /* eslint-disable semi */
291
+
285
292
  class Enumeration {
286
293
  constructor(list) {
287
294
  this.list = list;
288
- this.children = [];
289
- }
290
-
291
- map(callback) {
292
- // NOTE: This is a bit hacky but assuming that it's called like "this.children.map((node) => node.name)"
293
- return this.list;
294
- }
295
-
296
- find(callback) {
297
- // NOTE: This is a bit hacky but assuming that it's called like "this.children.find((node) => node.name === string)"
298
- return;
299
- }
300
-
301
- forEach(callback) {
302
- return this.list.forEach(callback);
303
295
  }
296
+ }
304
297
 
305
- keywords() {
306
- return this.list;
298
+ class Repeatable {
299
+ constructor(list) {
300
+ this.list = list;
307
301
  }
308
302
  }
309
303
 
@@ -327,6 +321,10 @@ module Junoser
327
321
  return new Sequence(list);
328
322
  }
329
323
 
324
+ sc(obj) {
325
+ return new Repeatable(obj);
326
+ }
327
+
330
328
  EOS
331
329
  end
332
330
 
@@ -335,7 +333,8 @@ module Junoser
335
333
 
336
334
  }
337
335
 
338
- module.exports = {JunosSchema: JunosSchema, Enumeration: Enumeration, Sequence: Sequence};
336
+ // eslint-disable-next-line no-undef
337
+ module.exports = {JunosSchema, Enumeration, Repeatable, Sequence};
339
338
  EOS
340
339
  end
341
340
  end
@@ -23,7 +23,7 @@ module Junoser
23
23
 
24
24
  begin
25
25
  # .xsd doesn't include "apply-groups"
26
- if line =~ /(.*)\s+apply-groups\s+(\S+|\[.*\])$/
26
+ if line =~ /(.*)\s+apply-groups(-except)?\s+(\S+|\[.*\])$/
27
27
  return $1 == 'set' ? true : parse($1)
28
28
  end
29
29
 
@@ -783,8 +783,8 @@ module Junoser
783
783
  c(
784
784
  b(str("family"),
785
785
  c(
786
- str("inet"),
787
786
  str("inet6"),
787
+ str("inet"),
788
788
  str("ccc")
789
789
  )
790
790
  ),
@@ -5255,7 +5255,6 @@ module Junoser
5255
5255
  )
5256
5256
  ),
5257
5257
  # End of vSRX 18.3R1.9
5258
-
5259
5258
  b(str("interfaces"),
5260
5259
  c(
5261
5260
  b(a(str("pic-set"), arg),
@@ -8046,8 +8045,8 @@ module Junoser
8046
8045
  ).as(:oneline),
8047
8046
  b(str("web-authentication"),
8048
8047
  c(
8049
- str("http"),
8050
8048
  str("https"),
8049
+ str("http"),
8051
8050
  str("redirect-to-https")
8052
8051
  )
8053
8052
  ),
@@ -8289,8 +8288,8 @@ module Junoser
8289
8288
  ),
8290
8289
  b(str("web-authentication"),
8291
8290
  c(
8292
- str("http"),
8293
8291
  str("https"),
8292
+ str("http"),
8294
8293
  str("redirect-to-https")
8295
8294
  )
8296
8295
  ),
@@ -19335,8 +19334,8 @@ module Junoser
19335
19334
  str("auto-image-upgrade"),
19336
19335
  b(str("route-localization"),
19337
19336
  c(
19338
- str("inet"),
19339
- str("inet6")
19337
+ str("inet6"),
19338
+ str("inet")
19340
19339
  )
19341
19340
  ),
19342
19341
  b(str("state"),
@@ -22305,8 +22304,8 @@ module Junoser
22305
22304
  a(str("program-number"), arg)
22306
22305
  )
22307
22306
  ),
22308
- str("icmp"),
22309
22307
  str("icmpv6"),
22308
+ str("icmp"),
22310
22309
  b(str("ip"),
22311
22310
  c(
22312
22311
  a(str("protocol-number"), arg)
@@ -22844,8 +22843,8 @@ module Junoser
22844
22843
  a(str("program-number"), arg)
22845
22844
  )
22846
22845
  ),
22847
- str("icmp"),
22848
22846
  str("icmpv6"),
22847
+ str("icmp"),
22849
22848
  b(str("ip"),
22850
22849
  c(
22851
22850
  a(str("protocol-number"), arg)
@@ -30446,8 +30445,8 @@ module Junoser
30446
30445
  ).as(:oneline),
30447
30446
  b(str("web-authentication"),
30448
30447
  c(
30449
- str("http"),
30450
30448
  str("https"),
30449
+ str("http"),
30451
30450
  str("redirect-to-https")
30452
30451
  )
30453
30452
  ),
@@ -30689,8 +30688,8 @@ module Junoser
30689
30688
  ),
30690
30689
  b(str("web-authentication"),
30691
30690
  c(
30692
- str("http"),
30693
30691
  str("https"),
30692
+ str("http"),
30694
30693
  str("redirect-to-https")
30695
30694
  )
30696
30695
  ),
@@ -39931,8 +39930,8 @@ module Junoser
39931
39930
  rule(:jdhcp_dual_stack_protocol_mstr_type) do
39932
39931
  c(
39933
39932
  c(
39934
- str("inet"),
39935
- str("inet6")
39933
+ str("inet6"),
39934
+ str("inet")
39936
39935
  )
39937
39936
  ).as(:oneline)
39938
39937
  end
@@ -42063,8 +42062,8 @@ module Junoser
42063
42062
  sc(
42064
42063
  interface_name,
42065
42064
  c(
42066
- str("inet"),
42067
- str("inet6")
42065
+ str("inet6"),
42066
+ str("inet")
42068
42067
  )
42069
42068
  )
42070
42069
  ).as(:oneline),
@@ -45848,8 +45847,8 @@ module Junoser
45848
45847
  ).as(:oneline),
45849
45848
  b(str("web-authentication"),
45850
45849
  c(
45851
- str("http"),
45852
45850
  str("https"),
45851
+ str("http"),
45853
45852
  str("redirect-to-https")
45854
45853
  )
45855
45854
  ),
@@ -46091,8 +46090,8 @@ module Junoser
46091
46090
  ),
46092
46091
  b(str("web-authentication"),
46093
46092
  c(
46094
- str("http"),
46095
46093
  str("https"),
46094
+ str("http"),
46096
46095
  str("redirect-to-https")
46097
46096
  )
46098
46097
  ),
@@ -49300,8 +49299,8 @@ module Junoser
49300
49299
  ).as(:oneline),
49301
49300
  b(str("web-authentication"),
49302
49301
  c(
49303
- str("http"),
49304
49302
  str("https"),
49303
+ str("http"),
49305
49304
  str("redirect-to-https")
49306
49305
  )
49307
49306
  ),
@@ -49543,8 +49542,8 @@ module Junoser
49543
49542
  ),
49544
49543
  b(str("web-authentication"),
49545
49544
  c(
49546
- str("http"),
49547
49545
  str("https"),
49546
+ str("http"),
49548
49547
  str("redirect-to-https")
49549
49548
  )
49550
49549
  ),
@@ -52740,8 +52739,8 @@ module Junoser
52740
52739
  c(
52741
52740
  b(str("family"),
52742
52741
  c(
52743
- str("inet"),
52744
- str("inet6")
52742
+ str("inet6"),
52743
+ str("inet")
52745
52744
  )
52746
52745
  )
52747
52746
  )
@@ -52749,8 +52748,8 @@ module Junoser
52749
52748
  str("l2circuit-control-passthrough"),
52750
52749
  b(str("explicit-null-cos"),
52751
52750
  c(
52752
- str("inet"),
52753
- str("inet6")
52751
+ str("inet6"),
52752
+ str("inet")
52754
52753
  )
52755
52754
  ),
52756
52755
  b(str("helpers"),
@@ -54908,7 +54907,7 @@ module Junoser
54908
54907
  (str("inet6") | str("inet-vpn") | str("inet") | str("inet6-vpn") | str("iso-vpn") | str("iso") | str("evpn") | str("inet-mvpn") | str("inet6-mvpn") | str("inet-mdt") | str("route-target") | str("traffic-engineering"))
54909
54908
  ),
54910
54909
  b(str("protocol"),
54911
- (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf") | str("ospf2") | str("ospf3") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
54910
+ (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf3") | str("ospf2") | str("ospf") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
54912
54911
  ),
54913
54912
  a(str("rib"), arg),
54914
54913
  b(str("neighbor"),
@@ -55099,7 +55098,7 @@ module Junoser
55099
55098
  (str("inet6") | str("inet-vpn") | str("inet") | str("inet6-vpn") | str("iso-vpn") | str("iso") | str("evpn") | str("inet-mvpn") | str("inet6-mvpn") | str("inet-mdt") | str("route-target") | str("traffic-engineering"))
55100
55099
  ),
55101
55100
  b(str("protocol"),
55102
- (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf") | str("ospf2") | str("ospf3") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55101
+ (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf3") | str("ospf2") | str("ospf") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55103
55102
  ),
55104
55103
  a(str("rib"), arg),
55105
55104
  b(str("neighbor"),
@@ -55507,7 +55506,7 @@ module Junoser
55507
55506
  (str("inet6") | str("inet-vpn") | str("inet") | str("inet6-vpn") | str("iso-vpn") | str("iso") | str("evpn") | str("inet-mvpn") | str("inet6-mvpn") | str("inet-mdt") | str("route-target") | str("traffic-engineering"))
55508
55507
  ),
55509
55508
  b(str("protocol"),
55510
- (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf") | str("ospf2") | str("ospf3") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55509
+ (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf3") | str("ospf2") | str("ospf") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55511
55510
  ),
55512
55511
  a(str("rib"), arg),
55513
55512
  b(str("neighbor"),
@@ -55698,7 +55697,7 @@ module Junoser
55698
55697
  (str("inet6") | str("inet-vpn") | str("inet") | str("inet6-vpn") | str("iso-vpn") | str("iso") | str("evpn") | str("inet-mvpn") | str("inet6-mvpn") | str("inet-mdt") | str("route-target") | str("traffic-engineering"))
55699
55698
  ),
55700
55699
  b(str("protocol"),
55701
- (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf") | str("ospf2") | str("ospf3") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55700
+ (str("aggregate") | str("bgp") | str("direct") | str("dvmrp") | str("isis") | str("esis") | str("l-isis") | str("l2circuit") | str("l2vpn") | str("local") | str("ospf3") | str("ospf2") | str("ospf") | str("l-ospf") | str("pim") | str("rip") | str("ripng") | str("static") | str("arp") | str("frr") | str("mpls") | str("ldp") | str("rsvp") | str("msdp") | str("route-target") | str("access") | str("access-internal") | str("anchor") | str("bgp-static") | str("vpls") | str("evpn") | str("spring-te") | str("bgp-ls-epe") | str("rift") | str("l2-learned-host-routing"))
55702
55701
  ),
55703
55702
  a(str("rib"), arg),
55704
55703
  b(str("neighbor"),
@@ -56109,12 +56108,12 @@ module Junoser
56109
56108
  b(a(str("community"), arg),
56110
56109
  c(
56111
56110
  str("invert-match"),
56112
- a(str("members"), arg)
56111
+ a(str("members"), any)
56113
56112
  )
56114
56113
  ),
56115
56114
  b(a(str("route-distinguisher"), arg),
56116
56115
  c(
56117
- a(str("members"), arg)
56116
+ a(str("members"), any)
56118
56117
  )
56119
56118
  ),
56120
56119
  b(a(str("as-path"), arg),
@@ -61623,8 +61622,8 @@ module Junoser
61623
61622
  c(
61624
61623
  b(str("accept"),
61625
61624
  c(
61626
- str("inet"),
61627
- str("inet6")
61625
+ str("inet6"),
61626
+ str("inet")
61628
61627
  )
61629
61628
  )
61630
61629
  )
@@ -62165,8 +62164,8 @@ module Junoser
62165
62164
  c(
62166
62165
  b(str("accept"),
62167
62166
  c(
62168
- str("inet"),
62169
- str("inet6")
62167
+ str("inet6"),
62168
+ str("inet")
62170
62169
  )
62171
62170
  )
62172
62171
  )
@@ -62611,8 +62610,8 @@ module Junoser
62611
62610
  c(
62612
62611
  b(str("accept"),
62613
62612
  c(
62614
- str("inet"),
62615
- str("inet6")
62613
+ str("inet6"),
62614
+ str("inet")
62616
62615
  )
62617
62616
  )
62618
62617
  )
@@ -71622,8 +71621,8 @@ module Junoser
71622
71621
  sc(
71623
71622
  interface_unit,
71624
71623
  c(
71625
- str("inet"),
71626
- str("inet6")
71624
+ str("inet6"),
71625
+ str("inet")
71627
71626
  )
71628
71627
  )
71629
71628
  ).as(:oneline),
@@ -75527,7 +75526,7 @@ module Junoser
75527
75526
  b(str("confederation"),
75528
75527
  sc(
75529
75528
  arg,
75530
- a(str("members"), arg)
75529
+ a(str("members"), any)
75531
75530
  )
75532
75531
  ).as(:oneline),
75533
75532
  b(str("graceful-restart"),
@@ -99072,8 +99071,8 @@ module Junoser
99072
99071
  ).as(:oneline),
99073
99072
  b(str("web-authentication"),
99074
99073
  c(
99075
- str("http"),
99076
99074
  str("https"),
99075
+ str("http"),
99077
99076
  str("redirect-to-https")
99078
99077
  )
99079
99078
  ),
@@ -99315,8 +99314,8 @@ module Junoser
99315
99314
  ),
99316
99315
  b(str("web-authentication"),
99317
99316
  c(
99318
- str("http"),
99319
99317
  str("https"),
99318
+ str("http"),
99320
99319
  str("redirect-to-https")
99321
99320
  )
99322
99321
  ),
@@ -100050,8 +100049,8 @@ module Junoser
100050
100049
  str("netbios-dgm"),
100051
100050
  str("netbios-ssn"),
100052
100051
  str("imap"),
100053
- str("snmp"),
100054
100052
  str("snmptrap"),
100053
+ str("snmp"),
100055
100054
  str("xdmcp"),
100056
100055
  str("bgp"),
100057
100056
  str("ldap"),
@@ -100206,8 +100205,8 @@ module Junoser
100206
100205
  str("netbios-dgm"),
100207
100206
  str("netbios-ssn"),
100208
100207
  str("imap"),
100209
- str("snmp"),
100210
100208
  str("snmptrap"),
100209
+ str("snmp"),
100211
100210
  str("xdmcp"),
100212
100211
  str("bgp"),
100213
100212
  str("ldap"),
@@ -111552,8 +111551,8 @@ module Junoser
111552
111551
  ).as(:oneline),
111553
111552
  b(str("web-authentication"),
111554
111553
  c(
111555
- str("http"),
111556
111554
  str("https"),
111555
+ str("http"),
111557
111556
  str("redirect-to-https")
111558
111557
  )
111559
111558
  ),
@@ -111795,8 +111794,8 @@ module Junoser
111795
111794
  ),
111796
111795
  b(str("web-authentication"),
111797
111796
  c(
111798
- str("http"),
111799
111797
  str("https"),
111798
+ str("http"),
111800
111799
  str("redirect-to-https")
111801
111800
  )
111802
111801
  ),
@@ -117107,8 +117106,8 @@ module Junoser
117107
117106
  a(str("tcp"), arg),
117108
117107
  a(str("udp"), arg),
117109
117108
  a(str("ospf"), arg),
117110
- a(str("icmp"), arg),
117111
117109
  a(str("icmp6"), arg),
117110
+ a(str("icmp"), arg),
117112
117111
  a(str("others"), arg)
117113
117112
  )
117114
117113
  end
@@ -118177,7 +118176,7 @@ module Junoser
118177
118176
  end
118178
118177
 
118179
118178
  rule(:host_inbound_protocols_object_type) do
118180
- b(enum((str("all") | str("bfd") | str("bgp") | str("dvmrp") | str("igmp") | str("ldp") | str("msdp") | str("ndp") | str("nhrp") | str("ospf") | str("ospf3") | str("pgm") | str("pim") | str("rip") | str("ripng") | str("router-discovery") | str("rsvp") | str("sap") | str("vrrp"))).as(:arg),
118179
+ b(enum((str("all") | str("bfd") | str("bgp") | str("dvmrp") | str("igmp") | str("ldp") | str("msdp") | str("ndp") | str("nhrp") | str("ospf3") | str("ospf") | str("pgm") | str("pim") | str("rip") | str("ripng") | str("router-discovery") | str("rsvp") | str("sap") | str("vrrp"))).as(:arg),
118181
118180
  c(
118182
118181
  str("except")
118183
118182
  )
data/lib/junoser/ruler.rb CHANGED
@@ -14,10 +14,9 @@ module Junoser
14
14
  str = @rule.read
15
15
  str = remove_comments(str)
16
16
  str = process_reserved_element(str)
17
- str = str.split(/\n/).map {|l| format(process_line(l)) }.join("\n")
17
+ str = str.split(/\n/).map { |l| format(process_line(l)) }.join("\n")
18
18
  end
19
19
 
20
-
21
20
  private
22
21
 
23
22
  def remove_comments(str)
@@ -27,16 +26,16 @@ module Junoser
27
26
  def process_line(str)
28
27
  return str if str =~ /^(.* do|end)$/
29
28
 
30
- str.gsub!(/("[^"]+")/) { "str(#$1)" } # "foo" -> str("foo")
29
+ str.gsub!(/("[^"]+")/) { "str(#$1)" } # "foo" -> str("foo")
31
30
 
32
- str.gsub!(/^(\s*)arg(\.as\(:\S+\))? \($/) { "#{$1}b(arg#$2," } # arg ( -> b(arg,
33
- str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+)(\.as\(:\S+\))?(,?)$/) { "#{$1}a(#$2, #$3)#$4#$5" } # str("foo") bar -> a(str("foo"), bar)
34
- str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\)(,?)$/) { "#{$1}a(#$2, #$3#$4)#$5" } # str("foo") (a | b) -> a(str("foo"), a | b)
31
+ str.gsub!(/^(\s*)arg(\.as\(:\S+\))? \($/) { "#{$1}b(arg#$2," } # arg ( -> b(arg,
32
+ str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+)(\.as\(:\S+\))?(,?)$/) { "#{$1}a(#$2, #$3)#$4#$5" } # str("foo") bar -> a(str("foo"), bar)
33
+ str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\)(,?)$/) { "#{$1}a(#$2, #$3#$4)#$5" } # str("foo") (a | b) -> a(str("foo"), a | b)
35
34
 
36
- str.gsub!(/^(\s*)(str\(\S+\)) \($/) { "#{$1}b(#$2," } # str("foo") ( -> b(str("foo"),
37
- str.gsub!(/^(\s*)(enum)?(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#$2#$3#$4," } # (a | b) ( -> b((a | b),
38
- str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+) \($/) { "#{$1}b(a(#$2, #$3)," } # str("foo") bar ( -> b(a(str("foo"), bar),
39
- str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\) \($/) { "#{$1}a(#$2, #$3#$4," } # str("foo") (a | b) ( -> a(str("foo"), a | b,
35
+ str.gsub!(/^(\s*)(str\(\S+\)) \($/) { "#{$1}b(#$2," } # str("foo") ( -> b(str("foo"),
36
+ str.gsub!(/^(\s*)(enum)?(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#$2#$3#$4," } # (a | b) ( -> b((a | b),
37
+ str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+) \($/) { "#{$1}b(a(#$2, #$3)," } # str("foo") bar ( -> b(a(str("foo"), bar),
38
+ str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\) \($/) { "#{$1}a(#$2, #$3#$4," } # str("foo") (a | b) ( -> a(str("foo"), a | b,
40
39
 
41
40
  str
42
41
  end
@@ -66,18 +65,18 @@ module Junoser
66
65
 
67
66
  str.gsub!(/^rule\(:regular_expression\) do\s*((?!end).)*\s*end/) do
68
67
  <<~EOS
69
- rule(:regular_expression) do
70
- (quote | arg).as(:arg)
71
- end
68
+ rule(:regular_expression) do
69
+ (quote | arg).as(:arg)
70
+ end
72
71
  EOS
73
72
  end
74
73
 
75
74
  str.gsub!(/^rule\(:login_user_object\) do\s*arg\.as\(:arg\) \(\s*c\(\s*"full-name" arg,/) do
76
75
  <<~EOS
77
- rule(:login_user_object) do
78
- arg.as(:arg) (
79
- sc(
80
- "full-name" (quote | arg),
76
+ rule(:login_user_object) do
77
+ arg.as(:arg) (
78
+ sc(
79
+ "full-name" (quote | arg),
81
80
  EOS
82
81
  end
83
82
 
@@ -124,12 +123,20 @@ module Junoser
124
123
  #
125
124
  # Longer pattern first
126
125
  #
127
- str.gsub!(/"cspf"(.*)"cspf-link"/) { %["cspf-link"#$1"cspf"] }
128
- str.gsub!(/"http"(.*)"https"/) { %["https"#$1"http"] }
129
- str.gsub!(/"inet"(.*)"inet6"/) { %["inet6"#$1"inet"] }
130
- str.gsub!(/"icmp"(.*)"icmp6"/) { %["icmp6"#$1"icmp"] }
131
- str.gsub!(/"icmp"(.*)"icmpv6"/) { %["icmpv6"#$1"icmp"] }
132
- str.gsub!(/"snmp"(.*)"snmptrap"/) { %["snmptrap"#$1"snmp"] }
126
+ # covers:
127
+ # "inet" | "inet6"
128
+ #
129
+ # and even
130
+ #
131
+ # "inet",
132
+ # "inet6"
133
+ str.gsub!(/"cspf"(.*\s*.*)"cspf-link"/) { %["cspf-link"#$1"cspf"] }
134
+ str.gsub!(/"http"(.*\s*.*)"https"/) { %["https"#$1"http"] }
135
+ str.gsub!(/"inet"(.*\s*.*)"inet6"/) { %["inet6"#$1"inet"] }
136
+ str.gsub!(/"icmp"(.*\s*.*)"icmp6"/) { %["icmp6"#$1"icmp"] }
137
+ str.gsub!(/"icmp"(.*\s*.*)"icmpv6"/) { %["icmpv6"#$1"icmp"] }
138
+ str.gsub!(/"snmp"(.*\s*.*)"snmptrap"/) { %["snmptrap"#$1"snmp"] }
139
+ str.gsub!(/"ospf"(.*\s*.*)"ospf3"/) { %["ospf3"#$1"ospf"] }
133
140
 
134
141
  %w[ccc ethernet-over-atm tcc vpls bridge].each do |encap|
135
142
  str.gsub!(/"ethernet"(.*)"ethernet-#{encap}"/) { %["ethernet-#{encap}"#$1"ethernet"] }
@@ -202,15 +209,18 @@ module Junoser
202
209
  ], $1)
203
210
  end
204
211
 
212
+ # Fix .xsd: "members" accepts [ foo bar ]
213
+ str.gsub! '"members" arg', '"members" any'
214
+
205
215
  str
206
216
  end
207
217
 
208
- def format(str, offset=OFFSET)
218
+ def format(str, offset = OFFSET)
209
219
  case str
210
220
  when String
211
221
  str.empty? ? '' : offset + str
212
222
  when Array
213
- str.map {|s| s.empty? ? '' : offset + s.to_s }.join("\n")
223
+ str.map { |s| s.empty? ? '' : offset + s.to_s }.join("\n")
214
224
  end
215
225
  end
216
226
 
@@ -241,7 +251,7 @@ module Junoser
241
251
 
242
252
  begin
243
253
  # .xsd doesn't include "apply-groups"
244
- if line =~ /(.*)\\s+apply-groups\\s+(\\S+|\\[.*\\])$/
254
+ if line =~ /(.*)\\s+apply-groups(-except)?\\s+(\\S+|\\[.*\\])$/
245
255
  return \$1 == 'set' ? true : parse(\$1)
246
256
  end
247
257
 
@@ -1,3 +1,3 @@
1
1
  module Junoser
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-02 00:00:00.000000000 Z
11
+ date: 2021-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet