junoser 0.5.5 → 0.6.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: bd8a2424c80ebdcb0ed5600ad8288c998200c086d77959e54e06ef64d454e34d
4
- data.tar.gz: b5f2f4bcfd79fc44c64847b3ee5d56ae908711b704451250ef7e26943cf059ae
3
+ metadata.gz: a73208784003b23a9dc996cf06ef4941a3da1ad35143848885c3e37a0e921e84
4
+ data.tar.gz: ae1ded9c7e208d3af98a96cf4c9fe5839b51d79447f1921fb36807f4202017ad
5
5
  SHA512:
6
- metadata.gz: 95a0151dabc6e3b9a1c3c82c1e97cd9fe64546bfc2ca858767ce539fdade394b6b1b9891753a2fcdcf1a261754933c047f37e2d20f9d913beff5dd8c73cf313d
7
- data.tar.gz: 487285a5986e28319c1ce38fe64573402e662fad33791d049eff9781b2c140474fb02d819d2151f3e76fb84d553a779446dac48d9ae5428d1dcff1d10c785971
6
+ metadata.gz: 8ac8d0ca12b3dada5bea555115c5ac172cc7dd3123c3fb5b85ab01e7f7e116daed5b2e9faebfc6237569719ad363c182522359a0cb1d1f1892f3bb85cfb5cc47
7
+ data.tar.gz: c37c95e729cdbf60a517845c0561c80b5bbb6e43f5b1dfd0c6ed8a8f49e431028c12ffb6dd0b081e8ce15ce829af599e246635a60df8d7f528d567835271e154
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
@@ -9,7 +9,7 @@ jobs:
9
9
  strategy:
10
10
  fail-fast: false
11
11
  matrix:
12
- ruby-version: ['3.2', '3.1', '3.0']
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@v2
22
+ - uses: actions/checkout@v4
23
23
  - name: Set up Ruby
24
24
  uses: ruby/setup-ruby@v1
25
25
  with:
@@ -1,6 +1,6 @@
1
1
  repos:
2
2
  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
3
- rev: v5.0.0
3
+ rev: v9.13.0
4
4
  hooks:
5
5
  - id: commitlint
6
6
  stages: [commit-msg]
data/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## [0.6.0] - 2024-09-15
2
+
3
+ ### Added
4
+
5
+ * Update vSRX syntax to 22.4R1.10
6
+ * "security"
7
+ * "chassis cluster"
8
+ * Newly supported syntax
9
+ * "interfaces xxx enable"
10
+ * "interfaces xxx unit xxx enable"
11
+ * Rake task
12
+ * `rule:tree` to show the dependency tree of rules
13
+
14
+
15
+ ## [0.5.6] - 2024-05-01
16
+
17
+ ### Fixed
18
+
19
+ * "teardown" may appear outside of "prefix-limit" block
20
+ * "tcp-flags" should accept a quoted string as an argument
21
+ * Structured config with square brackets ( `[ ... ]` ) should be parsed even when it's split into multiple lines
22
+
23
+
1
24
  ## [0.5.5] - 2023-11-14
2
25
 
3
26
  ### Fixed
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.5.5)
4
+ junoser (0.6.0)
5
5
  parslet
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- mini_portile2 (2.8.2)
11
- nokogiri (1.15.3)
10
+ mini_portile2 (2.8.7)
11
+ nokogiri (1.16.7)
12
12
  mini_portile2 (~> 2.8.2)
13
13
  racc (~> 1.4)
14
14
  parslet (2.0.0)
15
15
  power_assert (2.0.3)
16
- racc (1.7.1)
17
- rake (13.0.6)
18
- test-unit (3.6.1)
16
+ racc (1.8.1)
17
+ rake (13.2.1)
18
+ test-unit (3.6.2)
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.4.1
32
+ 2.5.9
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2023 Shintaro Kojima
3
+ Copyright (c) 2015-2024 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-2023 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
106
+ Copyright (c) 2015-2024 Shintaro Kojima. Code released under the [MIT license](LICENSE.txt).
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ def open_files(input, output, &block)
20
20
  end
21
21
 
22
22
  def move_wildcards(element)
23
- ['ipaddr', 'ipv6addr', 'ipprefix'].each do |pattern|
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 ['arg', 'end', 'ipaddr', 'time'].include?(method)
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
 
@@ -2,3 +2,4 @@ require 'underscorable'
2
2
  require 'junoser/xsd/parsable'
3
3
  require 'junoser/ruler'
4
4
  require 'junoser/js_ruler'
5
+ require 'junoser/rule_tree'
data/lib/junoser/input.rb CHANGED
@@ -13,6 +13,7 @@ module Junoser
13
13
 
14
14
  content = remove_blank_and_comment_line(content)
15
15
  content = unify_carriage_return(content)
16
+ content = unify_square_brackets(content)
16
17
  end
17
18
 
18
19
 
@@ -30,5 +31,25 @@ module Junoser
30
31
  str.gsub! /\r\n?/, "\n"
31
32
  str
32
33
  end
34
+
35
+ # Statements or [ ... ] may be split into multiple lines. This method unifies them into one line.
36
+ def unify_square_brackets(str)
37
+ lines = []
38
+
39
+ open_brackets = 0
40
+ str.split("\n").each do |line|
41
+ raise "ERROR: invalid statement: #{line}" if open_brackets < 0
42
+
43
+ if open_brackets == 0
44
+ lines << line
45
+ else
46
+ lines.last << " " << line
47
+ end
48
+
49
+ open_brackets += line.count('[') - line.count(']')
50
+ end
51
+
52
+ lines.join("\n")
53
+ end
33
54
  end
34
55
  end
@@ -226,6 +226,11 @@ module Junoser
226
226
  "#{$1}\n arg.as(:arg) (\n#{$2}\n )\nend"
227
227
  end
228
228
 
229
+ # set interfaces xxx enable
230
+ str.gsub!(/^(rule\(:interfaces_type\) do\s*[^\n]*\s*c\()(\s*)/m) do
231
+ %[#{$1}#{$2}"enable",#{$2}]
232
+ end
233
+
229
234
  str
230
235
  end
231
236