@sentriflow/core 0.1.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.
Files changed (71) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +86 -0
  3. package/package.json +60 -0
  4. package/src/constants.ts +77 -0
  5. package/src/engine/RuleExecutor.ts +256 -0
  6. package/src/engine/Runner.ts +312 -0
  7. package/src/engine/SandboxedExecutor.ts +208 -0
  8. package/src/errors.ts +88 -0
  9. package/src/helpers/arista/helpers.ts +1220 -0
  10. package/src/helpers/arista/index.ts +12 -0
  11. package/src/helpers/aruba/helpers.ts +637 -0
  12. package/src/helpers/aruba/index.ts +13 -0
  13. package/src/helpers/cisco/helpers.ts +534 -0
  14. package/src/helpers/cisco/index.ts +11 -0
  15. package/src/helpers/common/helpers.ts +265 -0
  16. package/src/helpers/common/index.ts +5 -0
  17. package/src/helpers/common/validation.ts +280 -0
  18. package/src/helpers/cumulus/helpers.ts +676 -0
  19. package/src/helpers/cumulus/index.ts +12 -0
  20. package/src/helpers/extreme/helpers.ts +422 -0
  21. package/src/helpers/extreme/index.ts +12 -0
  22. package/src/helpers/fortinet/helpers.ts +892 -0
  23. package/src/helpers/fortinet/index.ts +12 -0
  24. package/src/helpers/huawei/helpers.ts +790 -0
  25. package/src/helpers/huawei/index.ts +11 -0
  26. package/src/helpers/index.ts +53 -0
  27. package/src/helpers/juniper/helpers.ts +756 -0
  28. package/src/helpers/juniper/index.ts +12 -0
  29. package/src/helpers/mikrotik/helpers.ts +722 -0
  30. package/src/helpers/mikrotik/index.ts +12 -0
  31. package/src/helpers/nokia/helpers.ts +856 -0
  32. package/src/helpers/nokia/index.ts +11 -0
  33. package/src/helpers/paloalto/helpers.ts +939 -0
  34. package/src/helpers/paloalto/index.ts +12 -0
  35. package/src/helpers/vyos/helpers.ts +429 -0
  36. package/src/helpers/vyos/index.ts +12 -0
  37. package/src/index.ts +30 -0
  38. package/src/json-rules/ExpressionEvaluator.ts +292 -0
  39. package/src/json-rules/HelperRegistry.ts +177 -0
  40. package/src/json-rules/JsonRuleCompiler.ts +339 -0
  41. package/src/json-rules/JsonRuleValidator.ts +371 -0
  42. package/src/json-rules/index.ts +97 -0
  43. package/src/json-rules/schema.json +350 -0
  44. package/src/json-rules/types.ts +303 -0
  45. package/src/pack-loader/PackLoader.ts +332 -0
  46. package/src/pack-loader/index.ts +17 -0
  47. package/src/pack-loader/types.ts +135 -0
  48. package/src/parser/IncrementalParser.ts +527 -0
  49. package/src/parser/Sanitizer.ts +104 -0
  50. package/src/parser/SchemaAwareParser.ts +504 -0
  51. package/src/parser/VendorSchema.ts +72 -0
  52. package/src/parser/vendors/arista-eos.ts +206 -0
  53. package/src/parser/vendors/aruba-aoscx.ts +123 -0
  54. package/src/parser/vendors/aruba-aosswitch.ts +113 -0
  55. package/src/parser/vendors/aruba-wlc.ts +173 -0
  56. package/src/parser/vendors/cisco-ios.ts +110 -0
  57. package/src/parser/vendors/cisco-nxos.ts +107 -0
  58. package/src/parser/vendors/cumulus-linux.ts +161 -0
  59. package/src/parser/vendors/extreme-exos.ts +154 -0
  60. package/src/parser/vendors/extreme-voss.ts +167 -0
  61. package/src/parser/vendors/fortinet-fortigate.ts +217 -0
  62. package/src/parser/vendors/huawei-vrp.ts +192 -0
  63. package/src/parser/vendors/index.ts +1521 -0
  64. package/src/parser/vendors/juniper-junos.ts +230 -0
  65. package/src/parser/vendors/mikrotik-routeros.ts +274 -0
  66. package/src/parser/vendors/nokia-sros.ts +251 -0
  67. package/src/parser/vendors/paloalto-panos.ts +264 -0
  68. package/src/parser/vendors/vyos-vyos.ts +454 -0
  69. package/src/types/ConfigNode.ts +72 -0
  70. package/src/types/DeclarativeRule.ts +158 -0
  71. package/src/types/IRule.ts +270 -0
@@ -0,0 +1,230 @@
1
+ // packages/core/src/parser/vendors/juniper-junos.ts
2
+
3
+ import type { VendorSchema } from '../VendorSchema';
4
+
5
+ /**
6
+ * Juniper JunOS configuration schema.
7
+ *
8
+ * JunOS uses a hierarchical configuration model with curly braces { }
9
+ * to define configuration blocks. This is fundamentally different from
10
+ * Cisco's indentation-based approach.
11
+ *
12
+ * Key characteristics:
13
+ * - Brace-based hierarchy: blocks are delimited by { }
14
+ * - Set-style commands: "set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.1/24"
15
+ * - Hierarchical display: indented with braces
16
+ * - Comments: # for line comments, multi-line comments with markers
17
+ * - Semicolons terminate statements
18
+ *
19
+ * Configuration structure:
20
+ * ```
21
+ * system {
22
+ * host-name router1;
23
+ * }
24
+ * interfaces {
25
+ * ge-0/0/0 {
26
+ * unit 0 {
27
+ * family inet {
28
+ * address 10.0.0.1/24;
29
+ * }
30
+ * }
31
+ * }
32
+ * }
33
+ * ```
34
+ */
35
+ export const JuniperJunOSSchema: VendorSchema = {
36
+ id: 'juniper-junos',
37
+ name: 'Juniper JunOS',
38
+ useBraceHierarchy: true,
39
+
40
+ commentPatterns: [
41
+ /^#/,
42
+ /^\/\*.*\*\/$/,
43
+ /^inactive:/,
44
+ ],
45
+ sectionDelimiter: '}',
46
+
47
+ blockStarters: [
48
+ // ============ DEPTH 0: Top-level stanzas ============
49
+
50
+ // System configuration
51
+ { pattern: /^system\s*\{?$/i, depth: 0 },
52
+ { pattern: /^version\s+/i, depth: 0 },
53
+
54
+ // Chassis configuration
55
+ { pattern: /^chassis\s*\{?$/i, depth: 0 },
56
+
57
+ // Interfaces
58
+ { pattern: /^interfaces\s*\{?$/i, depth: 0 },
59
+
60
+ // SNMP
61
+ { pattern: /^snmp\s*\{?$/i, depth: 0 },
62
+
63
+ // Routing options (static routes, router-id, AS)
64
+ { pattern: /^routing-options\s*\{?$/i, depth: 0 },
65
+
66
+ // Protocols (BGP, OSPF, ISIS, MPLS, etc.)
67
+ { pattern: /^protocols\s*\{?$/i, depth: 0 },
68
+
69
+ // Policy options (prefix-lists, policy-statements, communities)
70
+ { pattern: /^policy-options\s*\{?$/i, depth: 0 },
71
+
72
+ // Class of Service (QoS)
73
+ { pattern: /^class-of-service\s*\{?$/i, depth: 0 },
74
+
75
+ // Firewall filters
76
+ { pattern: /^firewall\s*\{?$/i, depth: 0 },
77
+
78
+ // Security (SRX specific)
79
+ { pattern: /^security\s*\{?$/i, depth: 0 },
80
+
81
+ // Routing instances (VRF equivalent)
82
+ { pattern: /^routing-instances\s*\{?$/i, depth: 0 },
83
+
84
+ // VLANs (EX/QFX switches)
85
+ { pattern: /^vlans\s*\{?$/i, depth: 0 },
86
+
87
+ // Bridge domains (MX/EX)
88
+ { pattern: /^bridge-domains\s*\{?$/i, depth: 0 },
89
+
90
+ // Groups (configuration groups/templates)
91
+ { pattern: /^groups\s*\{?$/i, depth: 0 },
92
+
93
+ // Event options
94
+ { pattern: /^event-options\s*\{?$/i, depth: 0 },
95
+
96
+ // Services (NAT, stateful firewall, IDS)
97
+ { pattern: /^services\s*\{?$/i, depth: 0 },
98
+
99
+ // Access (802.1X, MAC authentication)
100
+ { pattern: /^access\s*\{?$/i, depth: 0 },
101
+
102
+ // Ethernet switching options
103
+ { pattern: /^ethernet-switching-options\s*\{?$/i, depth: 0 },
104
+
105
+ // Virtual chassis
106
+ { pattern: /^virtual-chassis\s*\{?$/i, depth: 0 },
107
+
108
+ // Forwarding options
109
+ { pattern: /^forwarding-options\s*\{?$/i, depth: 0 },
110
+
111
+ // Multi-chassis (MC-LAG)
112
+ { pattern: /^multi-chassis\s*\{?$/i, depth: 0 },
113
+
114
+ // ============ DEPTH 1: Inside top-level stanzas ============
115
+
116
+ // Interface names (inside interfaces {})
117
+ { pattern: /^(ge|xe|et|ae|lo|me|vme|irb|vlan|em|fxp|gr|lt|mt|ps|reth|st|vcp)-[\d\/:.]+\s*\{?$/i, depth: 1 },
118
+
119
+ // Protocol definitions (inside protocols {})
120
+ { pattern: /^bgp\s*\{?$/i, depth: 1 },
121
+ { pattern: /^ospf\s*\{?$/i, depth: 1 },
122
+ { pattern: /^ospf3\s*\{?$/i, depth: 1 },
123
+ { pattern: /^isis\s*\{?$/i, depth: 1 },
124
+ { pattern: /^ldp\s*\{?$/i, depth: 1 },
125
+ { pattern: /^rsvp\s*\{?$/i, depth: 1 },
126
+ { pattern: /^mpls\s*\{?$/i, depth: 1 },
127
+ { pattern: /^pim\s*\{?$/i, depth: 1 },
128
+ { pattern: /^igmp\s*\{?$/i, depth: 1 },
129
+ { pattern: /^lldp\s*\{?$/i, depth: 1 },
130
+ { pattern: /^lacp\s*\{?$/i, depth: 1 },
131
+ { pattern: /^rstp\s*\{?$/i, depth: 1 },
132
+ { pattern: /^mstp\s*\{?$/i, depth: 1 },
133
+ { pattern: /^vstp\s*\{?$/i, depth: 1 },
134
+ { pattern: /^evpn\s*\{?$/i, depth: 1 },
135
+ { pattern: /^bfd\s*\{?$/i, depth: 1 },
136
+
137
+ // Policy statements (inside policy-options {})
138
+ { pattern: /^policy-statement\s+\S+\s*\{?$/i, depth: 1 },
139
+ { pattern: /^prefix-list\s+\S+\s*\{?$/i, depth: 1 },
140
+ { pattern: /^community\s+\S+\s*/i, depth: 1 },
141
+ { pattern: /^as-path\s+\S+\s*/i, depth: 1 },
142
+ { pattern: /^as-path-group\s+\S+\s*\{?$/i, depth: 1 },
143
+
144
+ // Firewall filters (inside firewall {})
145
+ { pattern: /^filter\s+\S+\s*\{?$/i, depth: 1 },
146
+ { pattern: /^policer\s+\S+\s*\{?$/i, depth: 1 },
147
+
148
+ // Routing instances (inside routing-instances {})
149
+ { pattern: /^[\w-]+\s*\{$/i, depth: 1 },
150
+
151
+ // Security zones and policies (inside security {})
152
+ { pattern: /^zones\s*\{?$/i, depth: 1 },
153
+ { pattern: /^policies\s*\{?$/i, depth: 1 },
154
+ { pattern: /^nat\s*\{?$/i, depth: 1 },
155
+ { pattern: /^ike\s*\{?$/i, depth: 1 },
156
+ { pattern: /^ipsec\s*\{?$/i, depth: 1 },
157
+ { pattern: /^idp\s*\{?$/i, depth: 1 },
158
+ { pattern: /^utm\s*\{?$/i, depth: 1 },
159
+ { pattern: /^screen\s*\{?$/i, depth: 1 },
160
+
161
+ // System components (inside system {})
162
+ { pattern: /^login\s*\{?$/i, depth: 1 },
163
+ { pattern: /^services\s*\{?$/i, depth: 1 },
164
+ { pattern: /^syslog\s*\{?$/i, depth: 1 },
165
+ { pattern: /^ntp\s*\{?$/i, depth: 1 },
166
+ { pattern: /^authentication-order\s*/i, depth: 1 },
167
+ { pattern: /^radius-server\s*\{?$/i, depth: 1 },
168
+ { pattern: /^tacplus-server\s*\{?$/i, depth: 1 },
169
+ { pattern: /^name-server\s*/i, depth: 1 },
170
+
171
+ // ============ DEPTH 2: Nested inside depth-1 blocks ============
172
+
173
+ // Interface units (inside interface {})
174
+ { pattern: /^unit\s+\d+\s*\{?$/i, depth: 2 },
175
+
176
+ // BGP groups (inside bgp {})
177
+ { pattern: /^group\s+\S+\s*\{?$/i, depth: 2 },
178
+
179
+ // OSPF/ISIS areas (inside ospf/isis {})
180
+ { pattern: /^area\s+[\d.]+\s*\{?$/i, depth: 2 },
181
+ { pattern: /^level\s+\d+\s*\{?$/i, depth: 2 },
182
+
183
+ // Policy terms (inside policy-statement {})
184
+ { pattern: /^term\s+\S+\s*\{?$/i, depth: 2 },
185
+
186
+ // Filter terms (inside filter {})
187
+ // Note: shares pattern with policy terms
188
+
189
+ // Security zone definitions (inside zones {})
190
+ { pattern: /^security-zone\s+\S+\s*\{?$/i, depth: 2 },
191
+ { pattern: /^functional-zone\s+\S+\s*\{?$/i, depth: 2 },
192
+
193
+ // NAT rules (inside nat {})
194
+ { pattern: /^source\s*\{?$/i, depth: 2 },
195
+ { pattern: /^destination\s*\{?$/i, depth: 2 },
196
+ { pattern: /^static\s*\{?$/i, depth: 2 },
197
+
198
+ // ============ DEPTH 3: Deeply nested blocks ============
199
+
200
+ // Address family (inside interface unit {})
201
+ { pattern: /^family\s+(inet|inet6|mpls|ethernet-switching|ccc|vpls|bridge|iso)\s*\{?$/i, depth: 3 },
202
+
203
+ // BGP neighbors (inside group {})
204
+ { pattern: /^neighbor\s+[\d.:a-fA-F]+\s*\{?$/i, depth: 3 },
205
+
206
+ // Policy from/then blocks (inside term {})
207
+ { pattern: /^from\s*\{?$/i, depth: 3 },
208
+ { pattern: /^then\s*\{?$/i, depth: 3 },
209
+ { pattern: /^to\s*\{?$/i, depth: 3 },
210
+
211
+ // OSPF interfaces (inside area {})
212
+ { pattern: /^interface\s+\S+\s*\{?$/i, depth: 3 },
213
+
214
+ // Rule sets (inside NAT source/destination {})
215
+ { pattern: /^rule-set\s+\S+\s*\{?$/i, depth: 3 },
216
+
217
+ // ============ DEPTH 4: Very deeply nested ============
218
+
219
+ // Address entries (inside family inet {})
220
+ { pattern: /^address\s+[\d.\/]+\s*\{?$/i, depth: 4 },
221
+
222
+ // NAT rules (inside rule-set {})
223
+ { pattern: /^rule\s+\S+\s*\{?$/i, depth: 4 },
224
+ ],
225
+
226
+ blockEnders: [
227
+ /^\}$/,
228
+ /^\}\s*$/,
229
+ ],
230
+ };
@@ -0,0 +1,274 @@
1
+ // packages/core/src/parser/vendors/mikrotik-routeros.ts
2
+
3
+ import type { VendorSchema } from '../VendorSchema';
4
+
5
+ /**
6
+ * MikroTik RouterOS configuration schema.
7
+ *
8
+ * RouterOS uses a unique path-based configuration syntax where hierarchy
9
+ * is denoted by forward slashes (/interface, /ip address, etc.).
10
+ *
11
+ * Key characteristics:
12
+ * - Path declarations: /interface, /ip address, /system identity
13
+ * - Commands: add, set, remove, enable, disable
14
+ * - Property syntax: key=value (no spaces around =)
15
+ * - Find expressions: [ find default-name=ether1 ]
16
+ * - Comments: # at line start
17
+ * - Inline comments: comment="description" property
18
+ *
19
+ * Configuration structure (compact export format):
20
+ * ```
21
+ * # RouterOS Configuration Export
22
+ * /interface ethernet
23
+ * set [ find default-name=ether1 ] name=WAN comment="ISP Uplink"
24
+ * set [ find default-name=ether2 ] name=LAN
25
+ *
26
+ * /ip address
27
+ * add address=192.168.1.1/24 interface=LAN
28
+ * add address=10.0.0.2/30 interface=WAN
29
+ *
30
+ * /ip firewall filter
31
+ * add chain=input action=accept connection-state=established,related
32
+ * add chain=input action=drop in-interface=WAN
33
+ *
34
+ * /system identity
35
+ * set name=MikroTik-Router
36
+ * ```
37
+ *
38
+ * RouterOS supports both compact (default since v6rc1) and verbose export formats.
39
+ * This schema primarily targets the compact export format.
40
+ */
41
+ export const MikroTikRouterOSSchema: VendorSchema = {
42
+ id: 'mikrotik-routeros',
43
+ name: 'MikroTik RouterOS',
44
+ useBraceHierarchy: false, // Path-based, not brace-based
45
+
46
+ commentPatterns: [
47
+ /^#/, // Standard comments (# comment)
48
+ ],
49
+
50
+ sectionDelimiter: undefined, // No explicit delimiter - new path starts new block
51
+
52
+ blockStarters: [
53
+ // ============ DEPTH 0: Top-level path declarations ============
54
+ // These are the main configuration sections in RouterOS
55
+
56
+ // Interface configuration
57
+ { pattern: /^\/interface\s*$/i, depth: 0 },
58
+ { pattern: /^\/interface\s+ethernet\s*$/i, depth: 0 },
59
+ { pattern: /^\/interface\s+vlan\s*$/i, depth: 0 },
60
+ { pattern: /^\/interface\s+bridge\s*$/i, depth: 0 },
61
+ { pattern: /^\/interface\s+bridge\s+port\s*$/i, depth: 0 },
62
+ { pattern: /^\/interface\s+bridge\s+vlan\s*$/i, depth: 0 },
63
+ { pattern: /^\/interface\s+bridge\s+settings\s*$/i, depth: 0 },
64
+ { pattern: /^\/interface\s+bonding\s*$/i, depth: 0 },
65
+ { pattern: /^\/interface\s+wireguard\s*$/i, depth: 0 },
66
+ { pattern: /^\/interface\s+wireguard\s+peers\s*$/i, depth: 0 },
67
+ { pattern: /^\/interface\s+wireless\s*$/i, depth: 0 },
68
+ { pattern: /^\/interface\s+wireless\s+security-profiles\s*$/i, depth: 0 },
69
+ { pattern: /^\/interface\s+eoip\s*$/i, depth: 0 },
70
+ { pattern: /^\/interface\s+gre\s*$/i, depth: 0 },
71
+ { pattern: /^\/interface\s+ipip\s*$/i, depth: 0 },
72
+ { pattern: /^\/interface\s+vxlan\s*$/i, depth: 0 },
73
+ { pattern: /^\/interface\s+l2tp-client\s*$/i, depth: 0 },
74
+ { pattern: /^\/interface\s+pptp-client\s*$/i, depth: 0 },
75
+ { pattern: /^\/interface\s+sstp-client\s*$/i, depth: 0 },
76
+ { pattern: /^\/interface\s+ovpn-client\s*$/i, depth: 0 },
77
+ { pattern: /^\/interface\s+pppoe-client\s*$/i, depth: 0 },
78
+ { pattern: /^\/interface\s+lte\s*$/i, depth: 0 },
79
+ { pattern: /^\/interface\s+list\s*$/i, depth: 0 },
80
+ { pattern: /^\/interface\s+list\s+member\s*$/i, depth: 0 },
81
+
82
+ // IP configuration
83
+ { pattern: /^\/ip\s+address\s*$/i, depth: 0 },
84
+ { pattern: /^\/ip\s+route\s*$/i, depth: 0 },
85
+ { pattern: /^\/ip\s+firewall\s+filter\s*$/i, depth: 0 },
86
+ { pattern: /^\/ip\s+firewall\s+nat\s*$/i, depth: 0 },
87
+ { pattern: /^\/ip\s+firewall\s+mangle\s*$/i, depth: 0 },
88
+ { pattern: /^\/ip\s+firewall\s+raw\s*$/i, depth: 0 },
89
+ { pattern: /^\/ip\s+firewall\s+address-list\s*$/i, depth: 0 },
90
+ { pattern: /^\/ip\s+firewall\s+layer7-protocol\s*$/i, depth: 0 },
91
+ { pattern: /^\/ip\s+firewall\s+service-port\s*$/i, depth: 0 },
92
+ { pattern: /^\/ip\s+firewall\s+connection\s+tracking\s*$/i, depth: 0 },
93
+ { pattern: /^\/ip\s+dns\s*$/i, depth: 0 },
94
+ { pattern: /^\/ip\s+dns\s+static\s*$/i, depth: 0 },
95
+ { pattern: /^\/ip\s+dhcp-server\s*$/i, depth: 0 },
96
+ { pattern: /^\/ip\s+dhcp-server\s+network\s*$/i, depth: 0 },
97
+ { pattern: /^\/ip\s+dhcp-server\s+lease\s*$/i, depth: 0 },
98
+ { pattern: /^\/ip\s+dhcp-client\s*$/i, depth: 0 },
99
+ { pattern: /^\/ip\s+pool\s*$/i, depth: 0 },
100
+ { pattern: /^\/ip\s+service\s*$/i, depth: 0 },
101
+ { pattern: /^\/ip\s+neighbor\s+discovery-settings\s*$/i, depth: 0 },
102
+ { pattern: /^\/ip\s+arp\s*$/i, depth: 0 },
103
+ { pattern: /^\/ip\s+settings\s*$/i, depth: 0 },
104
+ { pattern: /^\/ip\s+cloud\s*$/i, depth: 0 },
105
+ { pattern: /^\/ip\s+ipsec\s*$/i, depth: 0 },
106
+ { pattern: /^\/ip\s+ipsec\s+peer\s*$/i, depth: 0 },
107
+ { pattern: /^\/ip\s+ipsec\s+profile\s*$/i, depth: 0 },
108
+ { pattern: /^\/ip\s+ipsec\s+proposal\s*$/i, depth: 0 },
109
+ { pattern: /^\/ip\s+ipsec\s+policy\s*$/i, depth: 0 },
110
+ { pattern: /^\/ip\s+ipsec\s+identity\s*$/i, depth: 0 },
111
+ { pattern: /^\/ip\s+ssh\s*$/i, depth: 0 },
112
+ { pattern: /^\/ip\s+socks\s*$/i, depth: 0 },
113
+ { pattern: /^\/ip\s+proxy\s*$/i, depth: 0 },
114
+ { pattern: /^\/ip\s+hotspot\s*$/i, depth: 0 },
115
+ { pattern: /^\/ip\s+smb\s*$/i, depth: 0 },
116
+ { pattern: /^\/ip\s+upnp\s*$/i, depth: 0 },
117
+ { pattern: /^\/ip\s+traffic-flow\s*$/i, depth: 0 },
118
+
119
+ // IPv6 configuration
120
+ { pattern: /^\/ipv6\s+address\s*$/i, depth: 0 },
121
+ { pattern: /^\/ipv6\s+route\s*$/i, depth: 0 },
122
+ { pattern: /^\/ipv6\s+firewall\s+filter\s*$/i, depth: 0 },
123
+ { pattern: /^\/ipv6\s+firewall\s+nat\s*$/i, depth: 0 },
124
+ { pattern: /^\/ipv6\s+firewall\s+mangle\s*$/i, depth: 0 },
125
+ { pattern: /^\/ipv6\s+firewall\s+address-list\s*$/i, depth: 0 },
126
+ { pattern: /^\/ipv6\s+nd\s*$/i, depth: 0 },
127
+ { pattern: /^\/ipv6\s+nd\s+prefix\s*$/i, depth: 0 },
128
+ { pattern: /^\/ipv6\s+dhcp-client\s*$/i, depth: 0 },
129
+ { pattern: /^\/ipv6\s+dhcp-server\s*$/i, depth: 0 },
130
+ { pattern: /^\/ipv6\s+settings\s*$/i, depth: 0 },
131
+
132
+ // Routing protocols
133
+ { pattern: /^\/routing\s+bgp\s*$/i, depth: 0 },
134
+ { pattern: /^\/routing\s+bgp\s+connection\s*$/i, depth: 0 },
135
+ { pattern: /^\/routing\s+bgp\s+template\s*$/i, depth: 0 },
136
+ { pattern: /^\/routing\s+bgp\s+network\s*$/i, depth: 0 },
137
+ { pattern: /^\/routing\s+ospf\s*$/i, depth: 0 },
138
+ { pattern: /^\/routing\s+ospf\s+instance\s*$/i, depth: 0 },
139
+ { pattern: /^\/routing\s+ospf\s+area\s*$/i, depth: 0 },
140
+ { pattern: /^\/routing\s+ospf\s+interface-template\s*$/i, depth: 0 },
141
+ { pattern: /^\/routing\s+ospf-v3\s*$/i, depth: 0 },
142
+ { pattern: /^\/routing\s+rip\s*$/i, depth: 0 },
143
+ { pattern: /^\/routing\s+filter\s*$/i, depth: 0 },
144
+ { pattern: /^\/routing\s+filter\s+rule\s*$/i, depth: 0 },
145
+ { pattern: /^\/routing\s+bfd\s*$/i, depth: 0 },
146
+ { pattern: /^\/routing\s+bfd\s+configuration\s*$/i, depth: 0 },
147
+ { pattern: /^\/routing\s+id\s*$/i, depth: 0 },
148
+ { pattern: /^\/routing\s+table\s*$/i, depth: 0 },
149
+
150
+ // System configuration
151
+ { pattern: /^\/system\s+identity\s*$/i, depth: 0 },
152
+ { pattern: /^\/system\s+logging\s*$/i, depth: 0 },
153
+ { pattern: /^\/system\s+logging\s+action\s*$/i, depth: 0 },
154
+ { pattern: /^\/system\s+ntp\s+client\s*$/i, depth: 0 },
155
+ { pattern: /^\/system\s+ntp\s+server\s*$/i, depth: 0 },
156
+ { pattern: /^\/system\s+ntp\s+client\s+servers\s*$/i, depth: 0 },
157
+ { pattern: /^\/system\s+clock\s*$/i, depth: 0 },
158
+ { pattern: /^\/system\s+scheduler\s*$/i, depth: 0 },
159
+ { pattern: /^\/system\s+script\s*$/i, depth: 0 },
160
+ { pattern: /^\/system\s+resource\s*$/i, depth: 0 },
161
+ { pattern: /^\/system\s+health\s*$/i, depth: 0 },
162
+ { pattern: /^\/system\s+note\s*$/i, depth: 0 },
163
+ { pattern: /^\/system\s+routerboard\s*$/i, depth: 0 },
164
+ { pattern: /^\/system\s+routerboard\s+settings\s*$/i, depth: 0 },
165
+ { pattern: /^\/system\s+package\s*$/i, depth: 0 },
166
+ { pattern: /^\/system\s+package\s+update\s*$/i, depth: 0 },
167
+ { pattern: /^\/system\s+backup\s*$/i, depth: 0 },
168
+ { pattern: /^\/system\s+watchdog\s*$/i, depth: 0 },
169
+ { pattern: /^\/system\s+upgrade\s*$/i, depth: 0 },
170
+ { pattern: /^\/system\s+leds\s*$/i, depth: 0 },
171
+ { pattern: /^\/system\s+leds\s+settings\s*$/i, depth: 0 },
172
+
173
+ // User management
174
+ { pattern: /^\/user\s*$/i, depth: 0 },
175
+ { pattern: /^\/user\s+group\s*$/i, depth: 0 },
176
+ { pattern: /^\/user\s+ssh-keys\s*$/i, depth: 0 },
177
+ { pattern: /^\/user\s+active\s*$/i, depth: 0 },
178
+ { pattern: /^\/user\s+aaa\s*$/i, depth: 0 },
179
+
180
+ // QoS and queues
181
+ { pattern: /^\/queue\s+simple\s*$/i, depth: 0 },
182
+ { pattern: /^\/queue\s+tree\s*$/i, depth: 0 },
183
+ { pattern: /^\/queue\s+type\s*$/i, depth: 0 },
184
+ { pattern: /^\/queue\s+interface\s*$/i, depth: 0 },
185
+
186
+ // SNMP
187
+ { pattern: /^\/snmp\s*$/i, depth: 0 },
188
+ { pattern: /^\/snmp\s+community\s*$/i, depth: 0 },
189
+
190
+ // Certificates
191
+ { pattern: /^\/certificate\s*$/i, depth: 0 },
192
+
193
+ // PPP configuration
194
+ { pattern: /^\/ppp\s+profile\s*$/i, depth: 0 },
195
+ { pattern: /^\/ppp\s+secret\s*$/i, depth: 0 },
196
+ { pattern: /^\/ppp\s+aaa\s*$/i, depth: 0 },
197
+ { pattern: /^\/ppp\s+l2tp-secret\s*$/i, depth: 0 },
198
+
199
+ // MPLS
200
+ { pattern: /^\/mpls\s*$/i, depth: 0 },
201
+ { pattern: /^\/mpls\s+ldp\s*$/i, depth: 0 },
202
+ { pattern: /^\/mpls\s+interface\s*$/i, depth: 0 },
203
+
204
+ // Radius
205
+ { pattern: /^\/radius\s*$/i, depth: 0 },
206
+ { pattern: /^\/radius\s+incoming\s*$/i, depth: 0 },
207
+
208
+ // Tools
209
+ { pattern: /^\/tool\s+bandwidth-server\s*$/i, depth: 0 },
210
+ { pattern: /^\/tool\s+netwatch\s*$/i, depth: 0 },
211
+ { pattern: /^\/tool\s+e-mail\s*$/i, depth: 0 },
212
+ { pattern: /^\/tool\s+graphing\s*$/i, depth: 0 },
213
+ { pattern: /^\/tool\s+mac-server\s*$/i, depth: 0 },
214
+ { pattern: /^\/tool\s+mac-server\s+mac-winbox\s*$/i, depth: 0 },
215
+ { pattern: /^\/tool\s+mac-server\s+ping\s*$/i, depth: 0 },
216
+ { pattern: /^\/tool\s+romon\s*$/i, depth: 0 },
217
+ { pattern: /^\/tool\s+sms\s*$/i, depth: 0 },
218
+ { pattern: /^\/tool\s+sniffer\s*$/i, depth: 0 },
219
+ { pattern: /^\/tool\s+traffic-generator\s*$/i, depth: 0 },
220
+
221
+ // CAPsMAN (wireless controller)
222
+ { pattern: /^\/caps-man\s*$/i, depth: 0 },
223
+ { pattern: /^\/caps-man\s+manager\s*$/i, depth: 0 },
224
+ { pattern: /^\/caps-man\s+interface\s*$/i, depth: 0 },
225
+ { pattern: /^\/caps-man\s+configuration\s*$/i, depth: 0 },
226
+ { pattern: /^\/caps-man\s+provisioning\s*$/i, depth: 0 },
227
+ { pattern: /^\/caps-man\s+channel\s*$/i, depth: 0 },
228
+ { pattern: /^\/caps-man\s+datapath\s*$/i, depth: 0 },
229
+ { pattern: /^\/caps-man\s+security\s*$/i, depth: 0 },
230
+ { pattern: /^\/caps-man\s+access-list\s*$/i, depth: 0 },
231
+
232
+ // Container (RouterOS 7+)
233
+ { pattern: /^\/container\s*$/i, depth: 0 },
234
+ { pattern: /^\/container\s+config\s*$/i, depth: 0 },
235
+ { pattern: /^\/container\s+envs\s*$/i, depth: 0 },
236
+ { pattern: /^\/container\s+mounts\s*$/i, depth: 0 },
237
+
238
+ // Disk/File
239
+ { pattern: /^\/disk\s*$/i, depth: 0 },
240
+ { pattern: /^\/file\s*$/i, depth: 0 },
241
+
242
+ // Port and special
243
+ { pattern: /^\/port\s*$/i, depth: 0 },
244
+ { pattern: /^\/special-login\s*$/i, depth: 0 },
245
+ { pattern: /^\/lcd\s*$/i, depth: 0 },
246
+ { pattern: /^\/partitions\s*$/i, depth: 0 },
247
+
248
+ // Layer 2 features
249
+ { pattern: /^\/interface\s+ethernet\s+switch\s*$/i, depth: 0 },
250
+ { pattern: /^\/interface\s+ethernet\s+switch\s+port\s*$/i, depth: 0 },
251
+ { pattern: /^\/interface\s+ethernet\s+switch\s+vlan\s*$/i, depth: 0 },
252
+ { pattern: /^\/interface\s+ethernet\s+switch\s+rule\s*$/i, depth: 0 },
253
+
254
+ // Generic path fallback (any /category pattern)
255
+ { pattern: /^\/[a-z][a-z0-9-]*(\s+[a-z][a-z0-9-]*)*\s*$/i, depth: 0 },
256
+
257
+ // ============ DEPTH 1: Commands inside path blocks ============
258
+ // These are the action commands that appear under path declarations
259
+
260
+ { pattern: /^add\s+/i, depth: 1 },
261
+ { pattern: /^set\s+/i, depth: 1 },
262
+ { pattern: /^remove\s+/i, depth: 1 },
263
+ { pattern: /^enable\s+/i, depth: 1 },
264
+ { pattern: /^disable\s+/i, depth: 1 },
265
+ { pattern: /^move\s+/i, depth: 1 },
266
+ { pattern: /^print\s*/i, depth: 1 },
267
+ { pattern: /^export\s*/i, depth: 1 },
268
+ ],
269
+
270
+ blockEnders: [
271
+ // New path declaration ends the current block
272
+ /^\/[a-z]/i,
273
+ ],
274
+ };