junoser 0.5.4 → 0.5.6

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: 3e3d7eddfe23eff9321fcd418687ab21af2d7f6a9188d1c3a7971c9f69393449
4
- data.tar.gz: d8496ad009be8d91d5c08d69f45ad44203683bca6b986896ecedb36b2946b709
3
+ metadata.gz: 4881a7d03899a61a155ba962e077a6ca784a6ca254ff526d58942e4d106156b8
4
+ data.tar.gz: bbe11bdff5a203610c548add8633484c799053dd6195f8e247eade567bb2e8a1
5
5
  SHA512:
6
- metadata.gz: 699d47a030b28169dc1d9daceb881e34aee2aed4f9a119f34e81f37bfae9b4f633c14f78ebe05974b9e0f4809280add29bb695d4c73f65c53637fed3a722b509
7
- data.tar.gz: 81df8499d1d55b562b1a571dd5328b3fcd8e1fb82de8babf2cd377a951f2b6770eeed58a7cb0bd52c5180a27d378e2c9c18f128435c16cc84194a5f09abdddfc
6
+ metadata.gz: 86cf2a739b40ce9254fd610b289af47734e21bd960b0687cc612c4765bd2e4e29241e39e6505a3902bd1c47cb5fea579ed047d9b3de850691407c644e8babdf3
7
+ data.tar.gz: b850d666c030f79dcbd5c5b269b7a411ab214c607efb3600c6170f8b417772887d2a5b0767adbce90d3d09387a5e122af45818e5a717056346c1d095585e0389
@@ -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,19 @@
1
+ ## [0.5.6] - 2024-05-01
2
+
3
+ ### Fixed
4
+
5
+ * "teardown" may appear outside of "prefix-limit" block
6
+ * "tcp-flags" should accept a quoted string as an argument
7
+ * Structured config with square brackets ( `[ ... ]` ) should be parsed even when it's split into multiple lines
8
+
9
+
10
+ ## [0.5.5] - 2023-11-14
11
+
12
+ ### Fixed
13
+
14
+ * junoser-squash unexpectedly removed non-idential lines
15
+
16
+
1
17
  ## [0.5.4] - 2023-07-15
2
18
 
3
19
  ### Added
data/Gemfile.lock CHANGED
@@ -1,21 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- junoser (0.5.4)
4
+ junoser (0.5.6)
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.6)
11
+ nokogiri (1.16.4)
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.7.3)
17
+ rake (13.2.1)
18
+ test-unit (3.6.2)
19
19
  power_assert
20
20
 
21
21
  PLATFORMS
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/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
@@ -20385,7 +20385,7 @@ module Junoser
20385
20385
  b(str("destination-prefix-list"),
20386
20386
  firewall_prefix_list
20387
20387
  ),
20388
- a(str("tcp-flags"), arg),
20388
+ a(str("tcp-flags"), quote | arg),
20389
20389
  str("tcp-initial"),
20390
20390
  str("tcp-established"),
20391
20391
  str("is-fragment")
@@ -20453,7 +20453,7 @@ module Junoser
20453
20453
  (str("af11") | str("af12") | str("af13") | str("af21") | str("af22") | str("af23") | str("af31") | str("af32") | str("af33") | str("af41") | str("af42") | str("af43") | str("ef") | str("cs0") | str("cs1") | str("cs2") | str("cs3") | str("cs4") | str("cs5") | str("cs6") | str("cs7") | str("be") | arg)
20454
20454
  )
20455
20455
  ),
20456
- a(str("tcp-flags"), arg),
20456
+ a(str("tcp-flags"), quote | arg),
20457
20457
  str("tcp-initial"),
20458
20458
  str("tcp-established")
20459
20459
  )
@@ -20899,7 +20899,7 @@ module Junoser
20899
20899
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
20900
20900
  )
20901
20901
  ),
20902
- a(str("tcp-flags"), arg),
20902
+ a(str("tcp-flags"), quote | arg),
20903
20903
  c(
20904
20904
  b(str("icmp-code"),
20905
20905
  (str("network-unreachable") | str("host-unreachable") | str("protocol-unreachable") | str("port-unreachable") | str("fragmentation-needed") | str("source-route-failed") | str("destination-network-unknown") | str("destination-host-unknown") | str("source-host-isolated") | str("destination-network-prohibited") | str("destination-host-prohibited") | str("network-unreachable-for-tos") | str("host-unreachable-for-tos") | str("communication-prohibited-by-filtering") | str("host-precedence-violation") | str("precedence-cutoff-in-effect") | str("redirect-for-network") | str("redirect-for-host") | str("redirect-for-tos-and-net") | str("redirect-for-tos-and-host") | str("ttl-eq-zero-during-transit") | str("ttl-eq-zero-during-reassembly") | str("ip-header-bad") | str("required-option-missing") | arg)
@@ -21271,7 +21271,7 @@ module Junoser
21271
21271
  b(str("destination-prefix-list"),
21272
21272
  firewall_prefix_list
21273
21273
  ),
21274
- a(str("tcp-flags"), arg),
21274
+ a(str("tcp-flags"), quote | arg),
21275
21275
  str("tcp-initial"),
21276
21276
  str("tcp-established"),
21277
21277
  str("is-fragment")
@@ -21339,7 +21339,7 @@ module Junoser
21339
21339
  (str("af11") | str("af12") | str("af13") | str("af21") | str("af22") | str("af23") | str("af31") | str("af32") | str("af33") | str("af41") | str("af42") | str("af43") | str("ef") | str("cs0") | str("cs1") | str("cs2") | str("cs3") | str("cs4") | str("cs5") | str("cs6") | str("cs7") | str("be") | arg)
21340
21340
  )
21341
21341
  ),
21342
- a(str("tcp-flags"), arg),
21342
+ a(str("tcp-flags"), quote | arg),
21343
21343
  str("tcp-initial"),
21344
21344
  str("tcp-established")
21345
21345
  )
@@ -27339,7 +27339,7 @@ module Junoser
27339
27339
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
27340
27340
  )
27341
27341
  ),
27342
- a(str("tcp-flags"), arg),
27342
+ a(str("tcp-flags"), quote | arg),
27343
27343
  str("tcp-initial"),
27344
27344
  str("tcp-established"),
27345
27345
  c(
@@ -27591,7 +27591,7 @@ module Junoser
27591
27591
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
27592
27592
  )
27593
27593
  ),
27594
- a(str("tcp-flags"), arg),
27594
+ a(str("tcp-flags"), quote | arg),
27595
27595
  str("tcp-initial"),
27596
27596
  str("tcp-established"),
27597
27597
  c(
@@ -27704,7 +27704,7 @@ module Junoser
27704
27704
  (str("any") | str("hop-by-hop") | str("routing") | str("mobility") | str("esp") | str("fragment") | str("dstopts") | str("ah") | arg)
27705
27705
  )
27706
27706
  ),
27707
- a(str("tcp-flags"), arg),
27707
+ a(str("tcp-flags"), quote | arg),
27708
27708
  str("tcp-initial"),
27709
27709
  str("tcp-established"),
27710
27710
  c(
@@ -29581,7 +29581,7 @@ module Junoser
29581
29581
  ),
29582
29582
  str("tcp-initial"),
29583
29583
  str("tcp-established"),
29584
- a(str("tcp-flags"), arg),
29584
+ a(str("tcp-flags"), quote | arg),
29585
29585
  b(str("interface"),
29586
29586
  match_interface_object
29587
29587
  ),
@@ -30037,7 +30037,7 @@ module Junoser
30037
30037
  a(str("ah-spi"), arg),
30038
30038
  a(str("ah-spi-except"), arg)
30039
30039
  ),
30040
- a(str("tcp-flags"), arg),
30040
+ a(str("tcp-flags"), quote | arg),
30041
30041
  c(
30042
30042
  b(str("loss-priority"),
30043
30043
  (str("low") | str("high") | str("medium-low") | str("medium-high"))
@@ -30216,7 +30216,7 @@ module Junoser
30216
30216
  ),
30217
30217
  str("tcp-initial"),
30218
30218
  str("tcp-established"),
30219
- a(str("tcp-flags"), arg),
30219
+ a(str("tcp-flags"), quote | arg),
30220
30220
  c(
30221
30221
  a(str("esp-spi"), arg),
30222
30222
  a(str("esp-spi-except"), arg)
@@ -30386,7 +30386,7 @@ module Junoser
30386
30386
  ),
30387
30387
  str("tcp-initial"),
30388
30388
  str("tcp-established"),
30389
- a(str("tcp-flags"), arg),
30389
+ a(str("tcp-flags"), quote | arg),
30390
30390
  c(
30391
30391
  a(str("esp-spi"), arg),
30392
30392
  a(str("esp-spi-except"), arg)
@@ -30875,7 +30875,7 @@ module Junoser
30875
30875
  a(str("fragment-offset-except"), arg)
30876
30876
  ),
30877
30877
  a(str("fragment-flags"), arg),
30878
- a(str("tcp-flags"), arg),
30878
+ a(str("tcp-flags"), quote | arg),
30879
30879
  c(
30880
30880
  a(str("ah-spi"), arg),
30881
30881
  a(str("ah-spi-except"), arg)
@@ -109012,7 +109012,7 @@ module Junoser
109012
109012
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
109013
109013
  )
109014
109014
  ),
109015
- a(str("tcp-flags"), arg),
109015
+ a(str("tcp-flags"), quote | arg),
109016
109016
  c(
109017
109017
  b(str("ip-protocol"),
109018
109018
  (str("icmp6") | str("icmpv6") | str("igmp") | str("ipip") | str("tcp") | str("egp") | str("udp") | str("rsvp") | str("gre") | str("esp") | str("ah") | str("icmp") | str("ospf") | str("pim") | str("sctp") | str("dstopts") | str("routing") | str("fragment") | str("hop-by-hop") | str("ipv6") | str("no-next-header") | str("vrrp") | arg)
@@ -109114,7 +109114,7 @@ module Junoser
109114
109114
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
109115
109115
  )
109116
109116
  ),
109117
- a(str("tcp-flags"), arg)
109117
+ a(str("tcp-flags"), quote | arg)
109118
109118
  )
109119
109119
  )
109120
109120
  )
@@ -122382,7 +122382,7 @@ module Junoser
122382
122382
  (str("ftp-data") | str("ftp") | str("ssh") | str("telnet") | str("smtp") | str("tacacs") | str("tacacs-ds") | str("domain") | str("dhcp") | str("bootps") | str("bootpc") | str("tftp") | str("finger") | str("https") | str("kerberos-sec") | str("pop3") | str("sunrpc") | str("ident") | str("nntp") | str("ntp") | str("netbios-ns") | str("netbios-dgm") | str("netbios-ssn") | str("imap") | str("snmptrap") | str("snmp") | str("xdmcp") | str("bgp") | str("ldap") | str("mobileip-agent") | str("mobilip-mn") | str("msdp") | str("http") | str("snpp") | str("biff") | str("exec") | str("login") | str("who") | str("cmd") | str("syslog") | str("printer") | str("talk") | str("ntalk") | str("rip") | str("timed") | str("klogin") | str("kshell") | str("ldp") | str("krb-prop") | str("krbupdate") | str("kpasswd") | str("socks") | str("afs") | str("pptp") | str("radius") | str("radacct") | str("zephyr-srv") | str("zephyr-clt") | str("zephyr-hm") | str("nfsd") | str("eklogin") | str("ekshell") | str("rkinit") | str("cvspserver") | arg)
122383
122383
  )
122384
122384
  ),
122385
- a(str("tcp-flags"), arg),
122385
+ a(str("tcp-flags"), quote | arg),
122386
122386
  c(
122387
122387
  b(str("icmp-code"),
122388
122388
  (str("network-unreachable") | str("host-unreachable") | str("protocol-unreachable") | str("port-unreachable") | str("fragmentation-needed") | str("source-route-failed") | str("destination-network-unknown") | str("destination-host-unknown") | str("source-host-isolated") | str("destination-network-prohibited") | str("destination-host-prohibited") | str("network-unreachable-for-tos") | str("host-unreachable-for-tos") | str("communication-prohibited-by-filtering") | str("host-precedence-violation") | str("precedence-cutoff-in-effect") | str("redirect-for-network") | str("redirect-for-host") | str("redirect-for-tos-and-net") | str("redirect-for-tos-and-host") | str("ttl-eq-zero-during-transit") | str("ttl-eq-zero-during-reassembly") | str("ip-header-bad") | str("required-option-missing") | arg)
data/lib/junoser/ruler.rb CHANGED
@@ -56,6 +56,7 @@ module Junoser
56
56
  str.gsub! '"message" arg', '"message" (quote | arg)'
57
57
  str.gsub! '"description" arg', '"description" (quote | arg)'
58
58
  str.gsub! '"as-path-prepend" arg', '"as-path-prepend" (quote | arg)'
59
+ str.gsub! '"tcp-flags" arg', '"tcp-flags" (quote | arg)'
59
60
 
60
61
  str.gsub!(/^(\s*)"as-path" arg \(\s*c\(\s*arg/) do
61
62
  format(['"as-path" arg (',
@@ -245,8 +246,8 @@ module Junoser
245
246
  str.gsub!(/^(rule\(:license_object\) do.*?"key") arg/m) { "#{$1} (quote | arg)" }
246
247
 
247
248
  # Fix .xsd: "prefix-limit teardown"
248
- str.gsub!(/^(\s*)"teardown" (\(.*?as\(:oneline\)\s*\)\s*\))/m) do
249
- "#{$1}\"teardown\" arg #{$2},\n#{$1}\"teardown\""
249
+ str.gsub!(/^((\s*)"maximum" arg,)\s*"teardown" (\(.*?as\(:oneline\)\s*\)\s*\))/m) do
250
+ "#{$1}\n#{$2}\"teardown\" arg #{$3},\n#{$2}\"teardown\""
250
251
  end
251
252
 
252
253
  # Fix .xsd: faster interface speed support
@@ -29,16 +29,18 @@ module Junoser
29
29
  end
30
30
 
31
31
  @lines.uniq!
32
- remove_subcommand(@lines).map(&:strip).join("\n")
32
+ remove_command_context(@lines).map(&:strip).join("\n")
33
33
  end
34
34
 
35
35
  private
36
36
 
37
- def remove_subcommand(lines)
37
+ def remove_command_context(lines)
38
38
  lines.each_with_index do |l, i|
39
39
  lines[i..-1].each do |l2|
40
- if l.include?(l2) and l != l2
41
- lines.delete(l2)
40
+ if l2[-1] == " " # l2 is a command context
41
+ lines.delete(l2) if l.include?(l2) and l != l2
42
+ else # l2 has argument
43
+ lines.delete(l2) if l.include?("#{l2} ")
42
44
  end
43
45
  end
44
46
  end
@@ -1,3 +1,3 @@
1
1
  module Junoser
2
- VERSION = "0.5.4"
2
+ VERSION = "0.5.6"
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.4
4
+ version: 0.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shintaro Kojima
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-16 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet