junoser 0.7.6 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ad52f9bcc08bafe72ec4b432c96d85dce85d1db353c29053ebad6bbc7918690
4
- data.tar.gz: 8a54ab81259886f5d52b59fa438dd00df6e60b1436221a810aa47c9120306fee
3
+ metadata.gz: e9ac47fc453f310f6c29e7e240c10c66104e7e73f4ad4532990c0f9a461b763d
4
+ data.tar.gz: 7c3dbabc2eeb9f29c2d338bb30fbbf5800b00c3a6424c0669eb341d3643e3798
5
5
  SHA512:
6
- metadata.gz: b7b885fa0bfdb1668bea5613e65888488a42b88be667d0812052e0b72a2c68cc49772d4070f4bc24ef72c2b3c20ba69f2b563bd00f289341420bc33a2d27083e
7
- data.tar.gz: 50994ee96cf22cb5079fe2ded3ca5b13e82de325d91c68abfb00899c2c27dbcbbb9e11052f0ebd114dfce0aea23c03b86eeb79f39f55354140407cad3d120868
6
+ metadata.gz: b2d2ec957930f20fd7bd48dfee30137125af87e8c089a2da2c182e798cd5203f19149ce4075b84bf2c7700bce45bb1455661d1f85ed31e332ae1a4af5eb19c53
7
+ data.tar.gz: 1cf1c7c53c4c6051bdbdea54f61265f2e3ffd45e5f3f13d16bd9706ba43812b1933ba22d201b142b362e05d68d9677e3b677b9fa8819deccc11712812e6fe302
data/CHANGELOG.md CHANGED
@@ -1,3 +1,76 @@
1
+ ## [0.9.0] - 2026-11-15
2
+
3
+ ### Added
4
+
5
+ * Recreate parser based on vJunos 26.2R1.7 xsd
6
+ * Newly supported syntax
7
+ * "protocols mpls path xxx exclude xxx"
8
+
9
+ ### Changed
10
+
11
+ * Syntax that Junos 26.2 changed
12
+ * "protocols ldp longest-match xxx" is now "protocols ldp longest-match policy xxx"
13
+ * "protocols loop-detect enhanced interface xxx vlan-id xxx" now accepts "all" as well
14
+ * "interfaces xxx unit xxx input-vlan-map tag-protocol-id xxx" now accepts "$junos-tag-protocol-id" as well
15
+ * "security traceoptions" lost "filter fpc xxx", "filter pic xxx" and the flags "config", "thread", "high-availability" and "next-hop-tunnels"
16
+ * "firewall family any filter xxx term xxx from ip-version ipv6 icmp-type xxx" and "icmp-code xxx" take IPv6 values instead of IPv4 ones
17
+ * "system login password format" lost "sha1"
18
+ * "chassis fpc xxx pic xxx port xxx speed 1G" is now "1g"
19
+ * openconfig "acl-entry transport config tcp-flags" and the same under "policy-forwarding" and "qos classifiers" are now "explicit-tcp-flags"
20
+
21
+ ### Removed
22
+
23
+ * Syntax that Junos 26.2 dropped
24
+ * "services unified-access-control"
25
+ * "services web-proxy"
26
+ * "system management-traffic"
27
+ * "system processes datapath-trace-service"
28
+ * "system services subscriber-management mode control-plane" and "subscriber-group"
29
+ * "system services ssh hostkey-algorithm", replaced by "hostkey-algorithm-list"
30
+ * "system services ssh access-disable-external"
31
+ * "security ssh-known-hosts host xxx rsa1-key"
32
+ * "protocols mpls label-switched-path xxx lsp-attributes" and "intra-domain"
33
+ * "protocols mpls statistics no-transit-statistics-polling"
34
+ * "protocols isis interface xxx level xxx srv6-adjacency-segment protected"
35
+ * "protocols rsvp allow-bidirectional" and "protocols rsvp interface xxx aggregate"
36
+ * "protocols bier sub-domain xxx topology-name"
37
+ * "protocols source-packet-routing compute-profile xxx no-label-stack-compression", replaced by "no-sid-stack-compression"
38
+ * "routing-options source-packet-routing srv6 no-psp"
39
+ * "forwarding-options enhanced-hash-key mpls no-incoming-device"
40
+ * "access terminate-code dhcp no-offers"
41
+ * openconfig "network-instance xxx evpn ethernet-segments" and "network-instance xxx config enabled", "enabled-address-families" and "mtu"
42
+ * MX-only syntax that vJunos does not have
43
+ * "protocols openflow"
44
+ * "protocols ovsdb"
45
+ * "system secure-ztp"
46
+ * "chassis fpc xxx openflow" and "chassis afeb slot xxx openflow"
47
+
48
+ ### Fixed
49
+
50
+ * Keywords that begin with another keyword of the same choice were unexpectedly marked as invalid, for example
51
+ * "igmp-snooping vlan all immediate-leave-on-host-interface"
52
+ * "protocols bgp group xxx family inet unicast extended-nexthop-color"
53
+ * "system services ssh hostkey-algorithm-list rsa-sha2-256"
54
+ * "interfaces xxx ether-options loopback-remote"
55
+ * Keywords written without a space in between, such as "flag update detailsend", were unexpectedly accepted
56
+ * "rake build:config" failed on the 26.2 xsd with "Nokogiri::XML::XPath::SyntaxError"
57
+
58
+
59
+ ## [0.8.0] - 2026-10-17
60
+
61
+ ### Added
62
+
63
+ * Recreate parser based on MX 23.4R2-S7.4 xsd
64
+ * Newly supported syntax
65
+ * "mld-snooping vlan all disable"
66
+ * "poe fpc xxx"
67
+ * "chassis alarm fru-absence ignore fpc xxx pem xxx"
68
+ * "ethernet-switching-options voip interface xxx"
69
+ * Positional arguments of a choice
70
+ * "protocols mpls label-switched-path xxx priority xxx xxx"
71
+ * "routing-options aggregate route xxx as-path aggregator xxx xxx"
72
+
73
+
1
74
  ## [0.7.6] - 2026-10-01
2
75
 
3
76
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.7.6)
4
+ junoser (0.9.0)
5
5
  parslet
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Junoser
2
2
 
3
- [![Test on Ubuntu](https://github.com/codeout/junoser/actions/workflows/test-linux.yaml/badge.svg)](https://github.com/codeout/junoser/actions/workflows/test-linux.yaml)
3
+ [![Test](https://github.com/codeout/junoser/actions/workflows/test.yaml/badge.svg)](https://github.com/codeout/junoser/actions/workflows/test.yaml)
4
+ [![Lint](https://github.com/codeout/junoser/actions/workflows/lint.yaml/badge.svg)](https://github.com/codeout/junoser/actions/workflows/lint.yaml)
4
5
  [![Inline docs](http://inch-ci.org/github/codeout/junoser.svg)](http://inch-ci.org/github/codeout/junoser)
5
6
 
6
7
  Junoser is a JUNOS configuration PEG parser which can be automatically generated from Juniper's netconf.xsd. (XML Schema Definition for NETCONF)
data/Rakefile CHANGED
@@ -3,22 +3,19 @@
3
3
  require 'bundler/gem_tasks'
4
4
  require 'junoser/development'
5
5
  require 'nokogiri'
6
- require 'pathname'
7
6
  require 'rake/testtask'
8
7
 
9
- xsd_path = File.join(__dir__, 'tmp/junos-system-22.4.xsd')
8
+ xsd_path = File.join(__dir__, 'tmp/junos-system-26.2.xsd')
10
9
  rule_path = File.join(__dir__, 'tmp/rule.rb')
11
10
  ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
12
11
  js_parser_path = File.join(__dir__, 'tmp/junos.js')
13
12
 
14
13
  def open_files(input, output)
15
- i = File.open(input)
16
- o = File.open(output, 'w')
17
-
18
- yield i, o
19
-
20
- i.close
21
- o.close
14
+ File.open(input) do |i|
15
+ File.open(output, 'w') do |o|
16
+ yield i, o
17
+ end
18
+ end
22
19
  end
23
20
 
24
21
  def move_wildcards(element)
data/exe/junoser CHANGED
@@ -3,9 +3,8 @@
3
3
 
4
4
  require 'English'
5
5
  require 'optparse'
6
- require 'pathname'
7
6
 
8
- $LOAD_PATH << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
7
+ $LOAD_PATH << File.expand_path('../../lib', File.realpath(__FILE__))
9
8
 
10
9
  require 'junoser'
11
10
 
data/exe/junoser-squash CHANGED
@@ -3,9 +3,8 @@
3
3
 
4
4
  require 'English'
5
5
  require 'optparse'
6
- require 'pathname'
7
6
 
8
- $LOAD_PATH << File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
7
+ $LOAD_PATH << File.expand_path('../../lib', File.realpath(__FILE__))
9
8
  require 'junoser/squash'
10
9
 
11
10
  command = :squash
@@ -77,6 +77,7 @@ module Junoser
77
77
 
78
78
  def process_line(str)
79
79
  str = remove_undefined_variables(str)
80
+ str = process_placeholder_syntax(str)
80
81
  str = process_common_syntax(str)
81
82
  str = process_argument_syntax(str)
82
83
  str = process_structural_syntax(str)
@@ -90,6 +91,20 @@ module Junoser
90
91
 
91
92
  # "$junos-interface-unit" |
92
93
  str.gsub!(/"\$[\w-]+" \| /, '')
94
+ # | "$junos-pon-id-interface-set-name" (this one trails the other members)
95
+ str.gsub!(/ \| "\$[\w-]+"/, '')
96
+
97
+ str
98
+ end
99
+
100
+ def process_placeholder_syntax(str)
101
+ # The .xsd puts a placeholder name where an argument belongs, so the parser would accept only that word.
102
+ # Ruler does the same.
103
+ str.gsub!(/\((.*) \| "name"\)/) { "(#{$1} | arg)" }
104
+ str.gsub!(/\("name" \| (.*?)\)/) { "(#{$1} | arg)" }
105
+ str.gsub! '"vlan" ("all" | "vlan-name")', '"vlan" ("all" | arg)'
106
+ str.gsub! '("all" | "fpc-slot-number")', '("all" | arg)'
107
+ str.gsub! '("all" | "psu-slot-number")', '("all" | arg)'
93
108
 
94
109
  str
95
110
  end
@@ -134,19 +149,27 @@ module Junoser
134
149
  # "foo" arg ( -> "foo(arg)": {
135
150
  str.gsub!(/^(\s*)"(\S+)" arg \(/) { "#{$1}\"#{$2}(arg)\": {" }
136
151
 
137
- # "foo" (... | arg) /* doc */ -> "foo": "arg"
138
- str.gsub!(%r{^(\s*)"(\S+)" \(.* \| arg ?.*\) /\* (.*) \*/(,?)$}) { "#{$1}\"#{$2} | #{$3}\": arg#{$4}" }
152
+ # "foo" ("bar" | arg) /* doc */ -> "foo | doc": ["bar", "arg"]
153
+ str.gsub!(%r{^(\s*)"(\S+)" \((.* \| arg ?.*)\) /\* (.*) \*/(,?)$}) do
154
+ "#{$1}\"#{$2} | #{$4}\": #{array_members($3)}#{$5}"
155
+ end
139
156
 
140
- # "foo" (... | arg) ( /* doc */ -> "foo(arg)": {
141
- str.gsub!(%r{^(\s*)"(\S+)" \(.* \| arg ?.*\) \( /\* (.*) \*/$}) { "#{$1}\"#{$2}(arg) | #{$3}\": {" }
142
- # "foo" (... | arg) ( -> "foo(arg)": {
143
- str.gsub!(/^(\s*)"(\S+)" \(.* \| arg ?.*\) \($/) { "#{$1}\"#{$2}(arg)\": {" }
157
+ # "foo" ("bar" | arg) ( /* doc */ -> "foo(bar|arg) | doc": {
158
+ str.gsub!(%r{^(\s*)"(\S+)" \((.* \| arg ?.*)\) \( /\* (.*) \*/$}) do
159
+ "#{$1}\"#{$2}(#{pipe_members($3)}) | #{$4}\": {"
160
+ end
161
+ # "foo" ("bar" | arg) ( -> "foo(bar|arg)": {
162
+ str.gsub!(/^(\s*)"(\S+)" \((.* \| arg ?.*)\) \($/) { "#{$1}\"#{$2}(#{pipe_members($3)})\": {" }
144
163
 
145
- # "foo" (arg | ...) /* doc */ -> "foo": "arg"
146
- str.gsub!(%r{^(\s*)"(\S+)" \(arg ?.*\) /\* (.*) \*/(,?)$}) { "#{$1}\"#{$2} | #{$3}\": arg#{$4}" }
164
+ # "foo" (arg | "bar") /* doc */ -> "foo | doc": ["arg", "bar"]
165
+ str.gsub!(%r{^(\s*)"(\S+)" \((arg ?.*)\) /\* (.*) \*/(,?)$}) do
166
+ "#{$1}\"#{$2} | #{$4}\": #{array_members($3)}#{$5}"
167
+ end
147
168
 
148
- # "foo" (arg | ...) ( /* doc */ -> "foo(arg)": {
149
- str.gsub!(%r{^(\s*)"(\S+)" \(arg ?.*\) \( /\* (.*) \*/(,?)$}) { "#{$1}\"#{$2}(arg) | #{$3}\": {#{$4}" }
169
+ # "foo" (arg | "bar") ( /* doc */ -> "foo(arg|bar) | doc": {
170
+ str.gsub!(%r{^(\s*)"(\S+)" \((arg ?.*)\) \( /\* (.*) \*/(,?)$}) do
171
+ "#{$1}\"#{$2}(#{pipe_members($3)}) | #{$4}\": {#{$5}"
172
+ end
150
173
 
151
174
  # "foo" ("bar" | "baz") ( /* doc */ -> "foo(bar|baz)": {
152
175
  str.gsub!(%r{^(\s*)"(\S+)" \("([^)]+)"\) \( /\* (.*) \*/$}) do
@@ -182,9 +205,6 @@ module Junoser
182
205
  # "foo" ( -> "foo": (opts) => {
183
206
  str.gsub!(/^(\s*)"(\S+)" \($/) { "#{$1}\"#{$2}\": {" }
184
207
 
185
- # "foo" arg ( /* doc */ -> "foo | doc": (opts) => {
186
- str.gsub!(%r{^(\s*)"(\S+)" arg \( /\* (.*) \*/}) { "#{$1}\"#{$2} | #{$3}\": {" }
187
-
188
208
  str
189
209
  end
190
210
 
@@ -208,8 +228,13 @@ module Junoser
208
228
  # enum(("bar" | "baz")) -> "foo": new Enumeration(["bar", "baz"])
209
229
  str.gsub!(/^(\s*)enum\(\((.*)\)\)/) { "#{$1}new Enumeration(#{$2.gsub('"', '').split(' | ')})" }
210
230
 
211
- # (arg | "foo") -> ["arg", "foo"]
212
- str.gsub!(/^(\s*) \(arg( \| "[^"]+")+\)/) { "#{$1}[\"arg\"#{$2.split(' | ').join(', ')}]" }
231
+ # (arg | "foo" | "bar") -> ["arg", "foo", "bar"]
232
+ # capture the tail as a whole, because a repeated group keeps only its last match
233
+ str.gsub!(/^(\s*) \(arg((?: \| "[^"]+")+)\)/) do
234
+ indent = $1
235
+ members = ['"arg"'] + $2.scan(/"[^"]+"/)
236
+ "#{indent}[#{members.uniq.join(', ')}]"
237
+ end
213
238
 
214
239
  str
215
240
  end
@@ -261,6 +286,21 @@ module Junoser
261
286
  str
262
287
  end
263
288
 
289
+ # Join the members of a choice with a pipe, for the parentheses of a key: "all" | arg -> all|arg.
290
+ # Keep the keywords next to arg, because vscode-junos offers every member as a completion candidate.
291
+ def pipe_members(choice)
292
+ choice.gsub('"', '').split(' | ').join('|')
293
+ end
294
+
295
+ # Put the members of a choice in an array, for a value. A lone arg stays a scalar, which is the shape
296
+ # loadString handles.
297
+ def array_members(choice)
298
+ list = choice.gsub('"', '').split(' | ')
299
+ return 'arg' if list == ['arg']
300
+
301
+ "[#{list.map { |member| %("#{member}") }.join(', ')}]"
302
+ end
303
+
264
304
  def finalize(lines)
265
305
  lines = balance_parenthesis(lines)
266
306
  objectize_arg_of_s(lines)
@@ -292,7 +332,7 @@ module Junoser
292
332
  lines.gsub!(/([{,]\n\s*)([^ "(]+)/m) { "#{$1}\"null_#{sequence}\": #{$2}" }
293
333
 
294
334
  # "arg" -> "arg_1"
295
- lines.gsub('"arg":') { %("arg_#{sequence}":) }
335
+ lines.gsub!('"arg":') { %("arg_#{sequence}":) }
296
336
 
297
337
  conditional_groups(lines)
298
338
  end