junoser 0.5.6 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test-linux.yaml +2 -2
- data/CHANGELOG.md +24 -0
- data/Gemfile.lock +7 -7
- data/Rakefile +15 -3
- data/lib/junoser/development.rb +1 -0
- data/lib/junoser/js_ruler.rb +44 -19
- data/lib/junoser/parser.rb +20042 -12833
- data/lib/junoser/rule_tree/node.rb +24 -0
- data/lib/junoser/rule_tree/parser.rb +66 -0
- data/lib/junoser/rule_tree.rb +2 -0
- data/lib/junoser/ruler.rb +32 -5
- data/lib/junoser/version.rb +1 -1
- data/sig/junoser/rule_tree/node.rbs +17 -0
- data/sig/junoser/rule_tree/parser.rbs +21 -0
- data/sig/junoser/ruler.rbs +9 -7
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d373ec94d7ebe3053b4f01d01d54beb15b49af4e2e8fbab4b29f9641632b5715
|
4
|
+
data.tar.gz: 046c510a4c5072759810abd68c8df4ce25c7cab976806182cdf0020dbd5b3f6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8acdf3b078ddc961ba28f3be6f9c2b3870b2f3ee85a81b7bec28fee09a390709e0783e520c67ef3b30fe87b15a317d7dcb879bdadd3d3b3d3d101a3fdb05c32
|
7
|
+
data.tar.gz: 9f4ff9fda7f65b1a318dcd43858874e7823e0008028071a0a2b20c951cdbdf04b6665e521044a572fd46f34626a345d543f2df9366524f55d07cf99dbfb55064
|
@@ -9,7 +9,7 @@ jobs:
|
|
9
9
|
strategy:
|
10
10
|
fail-fast: false
|
11
11
|
matrix:
|
12
|
-
ruby-version: ['3.
|
12
|
+
ruby-version: ['3.3', '3.2', '3.1']
|
13
13
|
os: [ubuntu-latest]
|
14
14
|
experimental: [false]
|
15
15
|
include:
|
@@ -19,7 +19,7 @@ jobs:
|
|
19
19
|
|
20
20
|
name: Test with ruby ${{ matrix.ruby-version }} on ${{ matrix.os }}
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v4
|
23
23
|
- name: Set up Ruby
|
24
24
|
uses: ruby/setup-ruby@v1
|
25
25
|
with:
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
## [0.7.0] - 2024-12-19
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
* Recreate parser based on MX 22.4R3-S2.11 xsd
|
6
|
+
* Newly supported syntax
|
7
|
+
* "groups xxx when"
|
8
|
+
* "snmp stats-cache-lifetime xxx"
|
9
|
+
|
10
|
+
|
11
|
+
## [0.6.0] - 2024-09-15
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
* Update vSRX syntax to 22.4R1.10
|
16
|
+
* "security"
|
17
|
+
* "chassis cluster"
|
18
|
+
* Newly supported syntax
|
19
|
+
* "interfaces xxx enable"
|
20
|
+
* "interfaces xxx unit xxx enable"
|
21
|
+
* Rake task
|
22
|
+
* `rule:tree` to show the dependency tree of rules
|
23
|
+
|
24
|
+
|
1
25
|
## [0.5.6] - 2024-05-01
|
2
26
|
|
3
27
|
### Fixed
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
junoser (0.
|
4
|
+
junoser (0.7.0)
|
5
5
|
parslet
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
mini_portile2 (2.8.
|
11
|
-
nokogiri (1.
|
10
|
+
mini_portile2 (2.8.8)
|
11
|
+
nokogiri (1.17.2)
|
12
12
|
mini_portile2 (~> 2.8.2)
|
13
13
|
racc (~> 1.4)
|
14
14
|
parslet (2.0.0)
|
15
|
-
power_assert (2.0.
|
16
|
-
racc (1.
|
15
|
+
power_assert (2.0.4)
|
16
|
+
racc (1.8.1)
|
17
17
|
rake (13.2.1)
|
18
|
-
test-unit (3.6.
|
18
|
+
test-unit (3.6.7)
|
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.
|
32
|
+
2.5.16
|
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'nokogiri'
|
|
4
4
|
require 'pathname'
|
5
5
|
require 'rake/testtask'
|
6
6
|
|
7
|
-
xsd_path = File.join(__dir__, 'tmp/junos-system-
|
7
|
+
xsd_path = File.join(__dir__, 'tmp/junos-system-22.4.xsd')
|
8
8
|
rule_path = File.join(__dir__, 'tmp/rule.rb')
|
9
9
|
ruby_parser_path = File.join(__dir__, 'lib/junoser/parser.rb')
|
10
10
|
js_parser_path = File.join(__dir__, 'tmp/junos.js')
|
@@ -20,7 +20,7 @@ def open_files(input, output, &block)
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def move_wildcards(element)
|
23
|
-
[
|
23
|
+
%w[ipaddr ipv6addr ipprefix].each do |pattern|
|
24
24
|
element.xpath(%[.//xsd:element[@type="#{pattern}"]/xsd:annotation/xsd:appinfo/flag[text()="nokeyword"]/../../..]).each do |wildcard|
|
25
25
|
parent = wildcard.parent
|
26
26
|
removed = wildcard.remove
|
@@ -60,12 +60,24 @@ task 'find-srx-methods' do
|
|
60
60
|
vmx = File.read('lib/junoser/parser.rb')
|
61
61
|
|
62
62
|
vsrx.scan(/^ +([0-9a-z_]+) *$/).flatten.uniq.sort.each do |method|
|
63
|
-
next if [
|
63
|
+
next if %w[arg end ipaddr time].include?(method)
|
64
64
|
|
65
65
|
puts method unless vsrx =~ /rule\(:#{method}\)/m || vmx =~ /rule\(:#{method}\)/m
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
namespace :rule do
|
70
|
+
desc 'Show rule tree'
|
71
|
+
task :tree, [:path] do |_, args|
|
72
|
+
if args.path
|
73
|
+
raise "File not found: #{args.path}" unless File.exist?(args.path)
|
74
|
+
Junoser::RuleTree::Parser.new(File.read(args.path)).print
|
75
|
+
else
|
76
|
+
Junoser::RuleTree::Parser.new($stdin.read).print
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
69
81
|
Rake::TestTask.new do |t|
|
70
82
|
t.libs << 'test'
|
71
83
|
|
data/lib/junoser/development.rb
CHANGED
data/lib/junoser/js_ruler.rb
CHANGED
@@ -25,6 +25,50 @@ module Junoser
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
def process_lines(str)
|
29
|
+
# set groups
|
30
|
+
str.gsub! /"groups" \(.*\s*s\(\s*any\s*\)\s*\)/, <<-EOS.strip
|
31
|
+
"groups" arg ( /* Configuration groups */
|
32
|
+
"when" ( /* Specify additional conditions for groups */
|
33
|
+
c(
|
34
|
+
"chassis" arg /* Chassis id */,
|
35
|
+
"member" arg /* Member of virtual chassis */,
|
36
|
+
"model" arg /* Model name */,
|
37
|
+
"node" arg /* Node of cluster */,
|
38
|
+
"peers" arg /* Hosts on which this group should be effective */,
|
39
|
+
"routing-engine" arg /* Routing Engine */,
|
40
|
+
"time" ( /* Time at which group should be effective */
|
41
|
+
"to" arg /* End time([yyyy-mm-dd.]hh:mm) */,
|
42
|
+
arg
|
43
|
+
)
|
44
|
+
)
|
45
|
+
)
|
46
|
+
)
|
47
|
+
EOS
|
48
|
+
|
49
|
+
# set protocols mpls path
|
50
|
+
str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
|
51
|
+
"#{$1}#{$2}s(#{$2}ipaddr,"
|
52
|
+
end
|
53
|
+
|
54
|
+
# set protocols iccp peer xxx liveness-detection single-hop
|
55
|
+
str.gsub!(/(^rule\(:peer_group\) do.*?\n(\s*)"detection-time" \(.*?c\(\s*"threshold" arg .*?\)\s*\))/m) do
|
56
|
+
"#{$1},\n#{format('"single-hop"', $2)}"
|
57
|
+
end
|
58
|
+
|
59
|
+
# set forwarding-options dhcp-relay server-group
|
60
|
+
str.gsub!(/^(rule\(:(?:v6_)?server_group_type\) do)\n(.*?)\nend/m) do
|
61
|
+
"#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
|
62
|
+
end
|
63
|
+
|
64
|
+
# set interfaces xxx enable
|
65
|
+
str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
|
66
|
+
%[#{$1}#{$2}"enable",#{$2}]
|
67
|
+
end
|
68
|
+
|
69
|
+
str
|
70
|
+
end
|
71
|
+
|
28
72
|
def process_line(str)
|
29
73
|
str = remove_undefined_variables(str)
|
30
74
|
str = process_common_syntax(str)
|
@@ -210,25 +254,6 @@ module Junoser
|
|
210
254
|
str
|
211
255
|
end
|
212
256
|
|
213
|
-
def process_lines(str)
|
214
|
-
# set protocols mpls path
|
215
|
-
str.gsub!(/("path" arg \(.*Route of a label-switched path.*)(\s*)c\(/) do
|
216
|
-
"#{$1}#{$2}s(#{$2}ipaddr,"
|
217
|
-
end
|
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
|
-
|
229
|
-
str
|
230
|
-
end
|
231
|
-
|
232
257
|
def finalize(lines)
|
233
258
|
lines = balance_parenthesis(lines)
|
234
259
|
objectize_arg_of_s(lines)
|