@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.
- package/LICENSE +190 -0
- package/README.md +86 -0
- package/package.json +60 -0
- package/src/constants.ts +77 -0
- package/src/engine/RuleExecutor.ts +256 -0
- package/src/engine/Runner.ts +312 -0
- package/src/engine/SandboxedExecutor.ts +208 -0
- package/src/errors.ts +88 -0
- package/src/helpers/arista/helpers.ts +1220 -0
- package/src/helpers/arista/index.ts +12 -0
- package/src/helpers/aruba/helpers.ts +637 -0
- package/src/helpers/aruba/index.ts +13 -0
- package/src/helpers/cisco/helpers.ts +534 -0
- package/src/helpers/cisco/index.ts +11 -0
- package/src/helpers/common/helpers.ts +265 -0
- package/src/helpers/common/index.ts +5 -0
- package/src/helpers/common/validation.ts +280 -0
- package/src/helpers/cumulus/helpers.ts +676 -0
- package/src/helpers/cumulus/index.ts +12 -0
- package/src/helpers/extreme/helpers.ts +422 -0
- package/src/helpers/extreme/index.ts +12 -0
- package/src/helpers/fortinet/helpers.ts +892 -0
- package/src/helpers/fortinet/index.ts +12 -0
- package/src/helpers/huawei/helpers.ts +790 -0
- package/src/helpers/huawei/index.ts +11 -0
- package/src/helpers/index.ts +53 -0
- package/src/helpers/juniper/helpers.ts +756 -0
- package/src/helpers/juniper/index.ts +12 -0
- package/src/helpers/mikrotik/helpers.ts +722 -0
- package/src/helpers/mikrotik/index.ts +12 -0
- package/src/helpers/nokia/helpers.ts +856 -0
- package/src/helpers/nokia/index.ts +11 -0
- package/src/helpers/paloalto/helpers.ts +939 -0
- package/src/helpers/paloalto/index.ts +12 -0
- package/src/helpers/vyos/helpers.ts +429 -0
- package/src/helpers/vyos/index.ts +12 -0
- package/src/index.ts +30 -0
- package/src/json-rules/ExpressionEvaluator.ts +292 -0
- package/src/json-rules/HelperRegistry.ts +177 -0
- package/src/json-rules/JsonRuleCompiler.ts +339 -0
- package/src/json-rules/JsonRuleValidator.ts +371 -0
- package/src/json-rules/index.ts +97 -0
- package/src/json-rules/schema.json +350 -0
- package/src/json-rules/types.ts +303 -0
- package/src/pack-loader/PackLoader.ts +332 -0
- package/src/pack-loader/index.ts +17 -0
- package/src/pack-loader/types.ts +135 -0
- package/src/parser/IncrementalParser.ts +527 -0
- package/src/parser/Sanitizer.ts +104 -0
- package/src/parser/SchemaAwareParser.ts +504 -0
- package/src/parser/VendorSchema.ts +72 -0
- package/src/parser/vendors/arista-eos.ts +206 -0
- package/src/parser/vendors/aruba-aoscx.ts +123 -0
- package/src/parser/vendors/aruba-aosswitch.ts +113 -0
- package/src/parser/vendors/aruba-wlc.ts +173 -0
- package/src/parser/vendors/cisco-ios.ts +110 -0
- package/src/parser/vendors/cisco-nxos.ts +107 -0
- package/src/parser/vendors/cumulus-linux.ts +161 -0
- package/src/parser/vendors/extreme-exos.ts +154 -0
- package/src/parser/vendors/extreme-voss.ts +167 -0
- package/src/parser/vendors/fortinet-fortigate.ts +217 -0
- package/src/parser/vendors/huawei-vrp.ts +192 -0
- package/src/parser/vendors/index.ts +1521 -0
- package/src/parser/vendors/juniper-junos.ts +230 -0
- package/src/parser/vendors/mikrotik-routeros.ts +274 -0
- package/src/parser/vendors/nokia-sros.ts +251 -0
- package/src/parser/vendors/paloalto-panos.ts +264 -0
- package/src/parser/vendors/vyos-vyos.ts +454 -0
- package/src/types/ConfigNode.ts +72 -0
- package/src/types/DeclarativeRule.ts +158 -0
- package/src/types/IRule.ts +270 -0
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// packages/core/src/parser/vendors/nokia-sros.ts
|
|
2
|
+
|
|
3
|
+
import type { VendorSchema } from '../VendorSchema';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Nokia SR OS (Service Router Operating System) configuration schema.
|
|
7
|
+
*
|
|
8
|
+
* Nokia SR OS uses a hierarchical command tree with indentation-based structure.
|
|
9
|
+
* The CLI is organized with `configure` as the root for all configuration contexts.
|
|
10
|
+
*
|
|
11
|
+
* SR OS CLI Hierarchy:
|
|
12
|
+
* - Root: A:router# - Initial CLI prompt
|
|
13
|
+
* - Configure: A:router>config# - Configuration mode (enter via `configure`)
|
|
14
|
+
* - Router: A:router>config>router# - IP routing configuration
|
|
15
|
+
* - System: A:router>config>system# - System-level settings
|
|
16
|
+
* - Port: A:router>config>port# - Physical port configuration
|
|
17
|
+
* - Service: A:router>config>service# - Service configuration (VPLS, VPRN, etc.)
|
|
18
|
+
*
|
|
19
|
+
* Configuration structure:
|
|
20
|
+
* - Top-level: configure, router, system, port, service, lag, etc.
|
|
21
|
+
* - Nested: interface inside router, security inside system
|
|
22
|
+
* - Deeply nested: bgp inside router, static-routes inside router
|
|
23
|
+
*
|
|
24
|
+
* Distinctive patterns:
|
|
25
|
+
* - Port notation: slot/mda/port (e.g., 1/1/1, 1/2/3)
|
|
26
|
+
* - Named interfaces: interface "name" or interface <name>
|
|
27
|
+
* - admin-state for enable/disable (admin-state up, admin-state disable)
|
|
28
|
+
* - exit to go back one level, exit all to return to root
|
|
29
|
+
* - shutdown for disabling (in some contexts)
|
|
30
|
+
* - # as comment character
|
|
31
|
+
* - echo command for comments in config files
|
|
32
|
+
*
|
|
33
|
+
* Example configuration:
|
|
34
|
+
* ```
|
|
35
|
+
* configure
|
|
36
|
+
* system
|
|
37
|
+
* name "SR-Router-1"
|
|
38
|
+
* snmp
|
|
39
|
+
* admin-state enable
|
|
40
|
+
* exit
|
|
41
|
+
* exit
|
|
42
|
+
* router "Base"
|
|
43
|
+
* interface "to-peer1"
|
|
44
|
+
* address 10.0.0.1/30
|
|
45
|
+
* port 1/1/1
|
|
46
|
+
* exit
|
|
47
|
+
* bgp
|
|
48
|
+
* admin-state enable
|
|
49
|
+
* router-id 10.10.10.1
|
|
50
|
+
* exit
|
|
51
|
+
* exit
|
|
52
|
+
* port 1/1/1
|
|
53
|
+
* admin-state enable
|
|
54
|
+
* description "To-Peer1"
|
|
55
|
+
* ethernet
|
|
56
|
+
* mode network
|
|
57
|
+
* exit
|
|
58
|
+
* exit
|
|
59
|
+
* exit
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export const NokiaSROSSchema: VendorSchema = {
|
|
63
|
+
id: 'nokia-sros',
|
|
64
|
+
name: 'Nokia SR OS',
|
|
65
|
+
useBraceHierarchy: false,
|
|
66
|
+
|
|
67
|
+
// Comments in SR OS config files start with #
|
|
68
|
+
// echo statements are also used as documentation
|
|
69
|
+
commentPatterns: [/^#/, /^echo\s+".*"$/],
|
|
70
|
+
sectionDelimiter: undefined,
|
|
71
|
+
|
|
72
|
+
blockStarters: [
|
|
73
|
+
// ============ DEPTH 0: Top-level configuration blocks ============
|
|
74
|
+
|
|
75
|
+
// Main configuration context
|
|
76
|
+
{ pattern: /^configure$/i, depth: 0 },
|
|
77
|
+
|
|
78
|
+
// System configuration
|
|
79
|
+
{ pattern: /^system$/i, depth: 0 },
|
|
80
|
+
|
|
81
|
+
// Router configuration (Base or named VRF/VPRN)
|
|
82
|
+
{ pattern: /^router\s+"?[^"]*"?$/i, depth: 0 },
|
|
83
|
+
{ pattern: /^router$/i, depth: 0 },
|
|
84
|
+
|
|
85
|
+
// Port configuration (physical ports)
|
|
86
|
+
{ pattern: /^port\s+\d+\/\d+\/\d+/i, depth: 0 },
|
|
87
|
+
{ pattern: /^port\s+\S+/i, depth: 0 },
|
|
88
|
+
|
|
89
|
+
// LAG (Link Aggregation Group)
|
|
90
|
+
{ pattern: /^lag\s+\d+/i, depth: 0 },
|
|
91
|
+
|
|
92
|
+
// Service configuration (VPLS, VPRN, Epipe, etc.)
|
|
93
|
+
{ pattern: /^service$/i, depth: 0 },
|
|
94
|
+
|
|
95
|
+
// Card and MDA configuration
|
|
96
|
+
{ pattern: /^card\s+\d+/i, depth: 0 },
|
|
97
|
+
|
|
98
|
+
// Log configuration
|
|
99
|
+
{ pattern: /^log$/i, depth: 0 },
|
|
100
|
+
|
|
101
|
+
// Filter configuration (IP filters, MAC filters)
|
|
102
|
+
{ pattern: /^filter$/i, depth: 0 },
|
|
103
|
+
|
|
104
|
+
// QoS configuration
|
|
105
|
+
{ pattern: /^qos$/i, depth: 0 },
|
|
106
|
+
|
|
107
|
+
// Policy configuration (route policies)
|
|
108
|
+
{ pattern: /^policy-options$/i, depth: 0 },
|
|
109
|
+
|
|
110
|
+
// MPLS configuration
|
|
111
|
+
{ pattern: /^mpls$/i, depth: 0 },
|
|
112
|
+
|
|
113
|
+
// RSVP configuration
|
|
114
|
+
{ pattern: /^rsvp$/i, depth: 0 },
|
|
115
|
+
|
|
116
|
+
// LDP configuration
|
|
117
|
+
{ pattern: /^ldp$/i, depth: 0 },
|
|
118
|
+
|
|
119
|
+
// Multicast configuration
|
|
120
|
+
{ pattern: /^multicast$/i, depth: 0 },
|
|
121
|
+
|
|
122
|
+
// ============ DEPTH 1: Inside configure or major blocks ============
|
|
123
|
+
|
|
124
|
+
// System sub-blocks
|
|
125
|
+
{ pattern: /^name\s+"[^"]*"$/i, depth: 1 },
|
|
126
|
+
{ pattern: /^snmp$/i, depth: 1 },
|
|
127
|
+
{ pattern: /^security$/i, depth: 1 },
|
|
128
|
+
{ pattern: /^time$/i, depth: 1 },
|
|
129
|
+
{ pattern: /^login-control$/i, depth: 1 },
|
|
130
|
+
{ pattern: /^management-interface$/i, depth: 1 },
|
|
131
|
+
{ pattern: /^netconf$/i, depth: 1 },
|
|
132
|
+
{ pattern: /^grpc$/i, depth: 1 },
|
|
133
|
+
{ pattern: /^cpm-filter$/i, depth: 1 },
|
|
134
|
+
{ pattern: /^management-access-filter$/i, depth: 1 },
|
|
135
|
+
{ pattern: /^aaa$/i, depth: 1 },
|
|
136
|
+
|
|
137
|
+
// Router sub-blocks (interfaces, protocols)
|
|
138
|
+
{ pattern: /^interface\s+"?[^"]*"?$/i, depth: 1 },
|
|
139
|
+
{ pattern: /^bgp$/i, depth: 1 },
|
|
140
|
+
{ pattern: /^ospf\s*\d*$/i, depth: 1 },
|
|
141
|
+
{ pattern: /^ospf3\s*\d*$/i, depth: 1 },
|
|
142
|
+
{ pattern: /^isis\s*\d*$/i, depth: 1 },
|
|
143
|
+
{ pattern: /^rip$/i, depth: 1 },
|
|
144
|
+
{ pattern: /^static-routes$/i, depth: 1 },
|
|
145
|
+
{ pattern: /^static-route-entry\s+/i, depth: 1 },
|
|
146
|
+
{ pattern: /^ecmp$/i, depth: 1 },
|
|
147
|
+
{ pattern: /^aggregation$/i, depth: 1 },
|
|
148
|
+
|
|
149
|
+
// Port sub-blocks
|
|
150
|
+
{ pattern: /^ethernet$/i, depth: 1 },
|
|
151
|
+
{ pattern: /^network$/i, depth: 1 },
|
|
152
|
+
{ pattern: /^access$/i, depth: 1 },
|
|
153
|
+
|
|
154
|
+
// Service types (VPLS, VPRN, Epipe, IES)
|
|
155
|
+
{ pattern: /^vpls\s+\d+/i, depth: 1 },
|
|
156
|
+
{ pattern: /^vprn\s+\d+/i, depth: 1 },
|
|
157
|
+
{ pattern: /^epipe\s+\d+/i, depth: 1 },
|
|
158
|
+
{ pattern: /^ies\s+\d+/i, depth: 1 },
|
|
159
|
+
{ pattern: /^customer\s+\d+/i, depth: 1 },
|
|
160
|
+
|
|
161
|
+
// Card sub-blocks
|
|
162
|
+
{ pattern: /^mda\s+\d+/i, depth: 1 },
|
|
163
|
+
|
|
164
|
+
// Log sub-blocks
|
|
165
|
+
{ pattern: /^log-id\s+\d+/i, depth: 1 },
|
|
166
|
+
{ pattern: /^syslog\s+\d+/i, depth: 1 },
|
|
167
|
+
{ pattern: /^snmp-trap-group\s+\d+/i, depth: 1 },
|
|
168
|
+
{ pattern: /^file-id\s+\d+/i, depth: 1 },
|
|
169
|
+
|
|
170
|
+
// Filter sub-blocks
|
|
171
|
+
{ pattern: /^ip-filter\s*\d*/i, depth: 1 },
|
|
172
|
+
{ pattern: /^ipv6-filter\s*\d*/i, depth: 1 },
|
|
173
|
+
{ pattern: /^mac-filter\s*\d*/i, depth: 1 },
|
|
174
|
+
|
|
175
|
+
// QoS sub-blocks
|
|
176
|
+
{ pattern: /^sap-ingress\s+\d+/i, depth: 1 },
|
|
177
|
+
{ pattern: /^sap-egress\s+\d+/i, depth: 1 },
|
|
178
|
+
{ pattern: /^network\s+\d+/i, depth: 1 },
|
|
179
|
+
{ pattern: /^scheduler-policy\s+"[^"]*"/i, depth: 1 },
|
|
180
|
+
|
|
181
|
+
// Policy sub-blocks
|
|
182
|
+
{ pattern: /^prefix-list\s+"[^"]*"/i, depth: 1 },
|
|
183
|
+
{ pattern: /^community\s+"[^"]*"/i, depth: 1 },
|
|
184
|
+
{ pattern: /^as-path\s+"[^"]*"/i, depth: 1 },
|
|
185
|
+
{ pattern: /^policy-statement\s+"[^"]*"/i, depth: 1 },
|
|
186
|
+
|
|
187
|
+
// ============ DEPTH 2: Deeply nested blocks ============
|
|
188
|
+
|
|
189
|
+
// BGP groups and neighbors
|
|
190
|
+
{ pattern: /^group\s+"[^"]*"/i, depth: 2 },
|
|
191
|
+
{ pattern: /^neighbor\s+[\d.:a-fA-F]+/i, depth: 2 },
|
|
192
|
+
|
|
193
|
+
// OSPF areas
|
|
194
|
+
{ pattern: /^area\s+[\d.]+/i, depth: 2 },
|
|
195
|
+
|
|
196
|
+
// ISIS levels
|
|
197
|
+
{ pattern: /^level\s+\d+/i, depth: 2 },
|
|
198
|
+
|
|
199
|
+
// Filter entries
|
|
200
|
+
{ pattern: /^entry\s+\d+/i, depth: 2 },
|
|
201
|
+
|
|
202
|
+
// Service SAPs (Service Access Points)
|
|
203
|
+
{ pattern: /^sap\s+\S+/i, depth: 2 },
|
|
204
|
+
|
|
205
|
+
// Service spoke-sdp and mesh-sdp
|
|
206
|
+
{ pattern: /^spoke-sdp\s+\d+:\d+/i, depth: 2 },
|
|
207
|
+
{ pattern: /^mesh-sdp\s+\d+:\d+/i, depth: 2 },
|
|
208
|
+
|
|
209
|
+
// Policy entries
|
|
210
|
+
{ pattern: /^entry\s+\d+/i, depth: 2 },
|
|
211
|
+
{ pattern: /^default-action\s+/i, depth: 2 },
|
|
212
|
+
|
|
213
|
+
// Interface sub-blocks in services
|
|
214
|
+
{ pattern: /^interface\s+"[^"]*"/i, depth: 2 },
|
|
215
|
+
|
|
216
|
+
// QoS queue configuration
|
|
217
|
+
{ pattern: /^queue\s+\d+/i, depth: 2 },
|
|
218
|
+
|
|
219
|
+
// ============ DEPTH 3: Very deeply nested ============
|
|
220
|
+
|
|
221
|
+
// BGP family inside group
|
|
222
|
+
{ pattern: /^family\s+\S+/i, depth: 3 },
|
|
223
|
+
|
|
224
|
+
// Address family configuration
|
|
225
|
+
{ pattern: /^address-family\s+\S+/i, depth: 3 },
|
|
226
|
+
|
|
227
|
+
// Interface inside area (OSPF)
|
|
228
|
+
{ pattern: /^interface\s+"[^"]*"/i, depth: 3 },
|
|
229
|
+
|
|
230
|
+
// Match and action in filters
|
|
231
|
+
{ pattern: /^match$/i, depth: 3 },
|
|
232
|
+
{ pattern: /^action$/i, depth: 3 },
|
|
233
|
+
|
|
234
|
+
// From/to/action in policies
|
|
235
|
+
{ pattern: /^from$/i, depth: 3 },
|
|
236
|
+
{ pattern: /^to$/i, depth: 3 },
|
|
237
|
+
|
|
238
|
+
// ============ DEPTH 4: Maximum nesting ============
|
|
239
|
+
|
|
240
|
+
// Protocol settings inside address-family
|
|
241
|
+
{ pattern: /^unicast$/i, depth: 4 },
|
|
242
|
+
{ pattern: /^multicast$/i, depth: 4 },
|
|
243
|
+
],
|
|
244
|
+
|
|
245
|
+
blockEnders: [
|
|
246
|
+
/^exit$/i,
|
|
247
|
+
/^exit\s+all$/i,
|
|
248
|
+
// back command (alias for exit in some contexts)
|
|
249
|
+
/^back$/i,
|
|
250
|
+
],
|
|
251
|
+
};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// packages/core/src/parser/vendors/paloalto-panos.ts
|
|
2
|
+
|
|
3
|
+
import type { VendorSchema } from '../VendorSchema';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Palo Alto PAN-OS configuration schema.
|
|
7
|
+
*
|
|
8
|
+
* PAN-OS uses a hierarchical configuration model that can be viewed in multiple formats:
|
|
9
|
+
* 1. XML format (native storage format)
|
|
10
|
+
* 2. Set command format (CLI style, similar to JunOS)
|
|
11
|
+
* 3. Hierarchical CLI format (indentation/brace based)
|
|
12
|
+
*
|
|
13
|
+
* This schema primarily targets the hierarchical CLI format and set command format.
|
|
14
|
+
*
|
|
15
|
+
* Key characteristics:
|
|
16
|
+
* - Hierarchical structure with brace-based blocks in display mode
|
|
17
|
+
* - Set commands: "set deviceconfig system hostname firewall1"
|
|
18
|
+
* - Network zones, security policies, NAT rules
|
|
19
|
+
* - Object-based configuration (address objects, service objects)
|
|
20
|
+
* - Panorama-specific constructs (device-groups, templates)
|
|
21
|
+
*
|
|
22
|
+
* Configuration structure (hierarchical format):
|
|
23
|
+
* ```
|
|
24
|
+
* deviceconfig {
|
|
25
|
+
* system {
|
|
26
|
+
* hostname firewall1;
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* network {
|
|
30
|
+
* interface {
|
|
31
|
+
* ethernet {
|
|
32
|
+
* ethernet1/1 {
|
|
33
|
+
* layer3 {
|
|
34
|
+
* ip {
|
|
35
|
+
* 10.0.0.1/24;
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* Set command format:
|
|
45
|
+
* ```
|
|
46
|
+
* set deviceconfig system hostname firewall1
|
|
47
|
+
* set network interface ethernet ethernet1/1 layer3 ip 10.0.0.1/24
|
|
48
|
+
* set rulebase security rules allow-web from trust to untrust application web-browsing action allow
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export const PaloAltoPANOSSchema: VendorSchema = {
|
|
52
|
+
id: 'paloalto-panos',
|
|
53
|
+
name: 'Palo Alto PAN-OS',
|
|
54
|
+
useBraceHierarchy: true,
|
|
55
|
+
|
|
56
|
+
commentPatterns: [
|
|
57
|
+
/^#/, // Hash comments (set command format)
|
|
58
|
+
/^\/\//, // Double-slash comments
|
|
59
|
+
/^\/\*.*\*\/$/, // Block comments
|
|
60
|
+
/^!.*$/, // Exclamation comments (some CLI modes)
|
|
61
|
+
],
|
|
62
|
+
sectionDelimiter: '}',
|
|
63
|
+
|
|
64
|
+
blockStarters: [
|
|
65
|
+
// ============ DEPTH 0: Top-level configuration stanzas ============
|
|
66
|
+
|
|
67
|
+
// Device configuration (system settings, management)
|
|
68
|
+
{ pattern: /^deviceconfig\s*\{?$/i, depth: 0 },
|
|
69
|
+
|
|
70
|
+
// Network configuration (interfaces, zones, routing)
|
|
71
|
+
{ pattern: /^network\s*\{?$/i, depth: 0 },
|
|
72
|
+
|
|
73
|
+
// Objects (address, service, application groups)
|
|
74
|
+
{ pattern: /^address\s*\{?$/i, depth: 0 },
|
|
75
|
+
{ pattern: /^address-group\s*\{?$/i, depth: 0 },
|
|
76
|
+
{ pattern: /^service\s*\{?$/i, depth: 0 },
|
|
77
|
+
{ pattern: /^service-group\s*\{?$/i, depth: 0 },
|
|
78
|
+
{ pattern: /^application\s*\{?$/i, depth: 0 },
|
|
79
|
+
{ pattern: /^application-group\s*\{?$/i, depth: 0 },
|
|
80
|
+
{ pattern: /^application-filter\s*\{?$/i, depth: 0 },
|
|
81
|
+
|
|
82
|
+
// Security rulebase (policies)
|
|
83
|
+
{ pattern: /^rulebase\s*\{?$/i, depth: 0 },
|
|
84
|
+
|
|
85
|
+
// Zone configuration
|
|
86
|
+
{ pattern: /^zone\s*\{?$/i, depth: 0 },
|
|
87
|
+
|
|
88
|
+
// Shared objects (Panorama)
|
|
89
|
+
{ pattern: /^shared\s*\{?$/i, depth: 0 },
|
|
90
|
+
|
|
91
|
+
// Device groups (Panorama)
|
|
92
|
+
{ pattern: /^device-group\s*\{?$/i, depth: 0 },
|
|
93
|
+
|
|
94
|
+
// Templates (Panorama)
|
|
95
|
+
{ pattern: /^template\s*\{?$/i, depth: 0 },
|
|
96
|
+
{ pattern: /^template-stack\s*\{?$/i, depth: 0 },
|
|
97
|
+
|
|
98
|
+
// Profiles (security, logging, etc.)
|
|
99
|
+
{ pattern: /^profiles\s*\{?$/i, depth: 0 },
|
|
100
|
+
|
|
101
|
+
// Log settings
|
|
102
|
+
{ pattern: /^log-settings\s*\{?$/i, depth: 0 },
|
|
103
|
+
|
|
104
|
+
// User-ID
|
|
105
|
+
{ pattern: /^user-identification\s*\{?$/i, depth: 0 },
|
|
106
|
+
{ pattern: /^user-id-agent\s*\{?$/i, depth: 0 },
|
|
107
|
+
|
|
108
|
+
// GlobalProtect
|
|
109
|
+
{ pattern: /^global-protect\s*\{?$/i, depth: 0 },
|
|
110
|
+
|
|
111
|
+
// High availability
|
|
112
|
+
{ pattern: /^high-availability\s*\{?$/i, depth: 0 },
|
|
113
|
+
|
|
114
|
+
// VSYS (virtual system)
|
|
115
|
+
{ pattern: /^vsys\s*\{?$/i, depth: 0 },
|
|
116
|
+
{ pattern: /^vsys\d+\s*\{?$/i, depth: 0 },
|
|
117
|
+
|
|
118
|
+
// Mgt-config (management configuration)
|
|
119
|
+
{ pattern: /^mgt-config\s*\{?$/i, depth: 0 },
|
|
120
|
+
|
|
121
|
+
// Set command format (flat configuration)
|
|
122
|
+
{ pattern: /^set\s+deviceconfig\s+/i, depth: 0 },
|
|
123
|
+
{ pattern: /^set\s+network\s+/i, depth: 0 },
|
|
124
|
+
{ pattern: /^set\s+rulebase\s+/i, depth: 0 },
|
|
125
|
+
{ pattern: /^set\s+address\s+/i, depth: 0 },
|
|
126
|
+
{ pattern: /^set\s+service\s+/i, depth: 0 },
|
|
127
|
+
{ pattern: /^set\s+zone\s+/i, depth: 0 },
|
|
128
|
+
|
|
129
|
+
// ============ DEPTH 1: Inside top-level stanzas ============
|
|
130
|
+
|
|
131
|
+
// Inside deviceconfig
|
|
132
|
+
{ pattern: /^system\s*\{?$/i, depth: 1 },
|
|
133
|
+
{ pattern: /^setting\s*\{?$/i, depth: 1 },
|
|
134
|
+
{ pattern: /^management\s*\{?$/i, depth: 1 },
|
|
135
|
+
{ pattern: /^high-availability\s*\{?$/i, depth: 1 },
|
|
136
|
+
|
|
137
|
+
// Inside network
|
|
138
|
+
{ pattern: /^interface\s*\{?$/i, depth: 1 },
|
|
139
|
+
{ pattern: /^virtual-router\s*\{?$/i, depth: 1 },
|
|
140
|
+
{ pattern: /^virtual-wire\s*\{?$/i, depth: 1 },
|
|
141
|
+
{ pattern: /^vlan\s*\{?$/i, depth: 1 },
|
|
142
|
+
{ pattern: /^ike\s*\{?$/i, depth: 1 },
|
|
143
|
+
{ pattern: /^ipsec\s*\{?$/i, depth: 1 },
|
|
144
|
+
{ pattern: /^tunnel\s*\{?$/i, depth: 1 },
|
|
145
|
+
{ pattern: /^qos\s*\{?$/i, depth: 1 },
|
|
146
|
+
{ pattern: /^dns-proxy\s*\{?$/i, depth: 1 },
|
|
147
|
+
{ pattern: /^dhcp\s*\{?$/i, depth: 1 },
|
|
148
|
+
|
|
149
|
+
// Inside rulebase
|
|
150
|
+
{ pattern: /^security\s*\{?$/i, depth: 1 },
|
|
151
|
+
{ pattern: /^nat\s*\{?$/i, depth: 1 },
|
|
152
|
+
{ pattern: /^pbf\s*\{?$/i, depth: 1 }, // Policy-based forwarding
|
|
153
|
+
{ pattern: /^qos\s*\{?$/i, depth: 1 },
|
|
154
|
+
{ pattern: /^decryption\s*\{?$/i, depth: 1 },
|
|
155
|
+
{ pattern: /^tunnel-inspect\s*\{?$/i, depth: 1 },
|
|
156
|
+
{ pattern: /^application-override\s*\{?$/i, depth: 1 },
|
|
157
|
+
{ pattern: /^authentication\s*\{?$/i, depth: 1 },
|
|
158
|
+
{ pattern: /^dos\s*\{?$/i, depth: 1 },
|
|
159
|
+
|
|
160
|
+
// Inside profiles
|
|
161
|
+
{ pattern: /^virus\s*\{?$/i, depth: 1 },
|
|
162
|
+
{ pattern: /^spyware\s*\{?$/i, depth: 1 },
|
|
163
|
+
{ pattern: /^vulnerability\s*\{?$/i, depth: 1 },
|
|
164
|
+
{ pattern: /^url-filtering\s*\{?$/i, depth: 1 },
|
|
165
|
+
{ pattern: /^file-blocking\s*\{?$/i, depth: 1 },
|
|
166
|
+
{ pattern: /^wildfire-analysis\s*\{?$/i, depth: 1 },
|
|
167
|
+
{ pattern: /^data-filtering\s*\{?$/i, depth: 1 },
|
|
168
|
+
{ pattern: /^dos-protection\s*\{?$/i, depth: 1 },
|
|
169
|
+
{ pattern: /^decryption\s*\{?$/i, depth: 1 },
|
|
170
|
+
{ pattern: /^gtp\s*\{?$/i, depth: 1 },
|
|
171
|
+
{ pattern: /^sctp\s*\{?$/i, depth: 1 },
|
|
172
|
+
|
|
173
|
+
// Zone definitions (inside zone)
|
|
174
|
+
{ pattern: /^\S+\s*\{$/i, depth: 1 }, // Named zones like "trust {", "untrust {"
|
|
175
|
+
|
|
176
|
+
// ============ DEPTH 2: Nested inside depth-1 blocks ============
|
|
177
|
+
|
|
178
|
+
// Interface types (inside interface)
|
|
179
|
+
{ pattern: /^ethernet\s*\{?$/i, depth: 2 },
|
|
180
|
+
{ pattern: /^loopback\s*\{?$/i, depth: 2 },
|
|
181
|
+
{ pattern: /^tunnel\s*\{?$/i, depth: 2 },
|
|
182
|
+
{ pattern: /^aggregate-ethernet\s*\{?$/i, depth: 2 },
|
|
183
|
+
{ pattern: /^vlan\s*\{?$/i, depth: 2 },
|
|
184
|
+
|
|
185
|
+
// Virtual router components
|
|
186
|
+
{ pattern: /^routing-table\s*\{?$/i, depth: 2 },
|
|
187
|
+
{ pattern: /^protocol\s*\{?$/i, depth: 2 },
|
|
188
|
+
{ pattern: /^ecmp\s*\{?$/i, depth: 2 },
|
|
189
|
+
{ pattern: /^multicast\s*\{?$/i, depth: 2 },
|
|
190
|
+
|
|
191
|
+
// Rules container
|
|
192
|
+
{ pattern: /^rules\s*\{?$/i, depth: 2 },
|
|
193
|
+
|
|
194
|
+
// Pre/Post rules (Panorama)
|
|
195
|
+
{ pattern: /^pre-rulebase\s*\{?$/i, depth: 2 },
|
|
196
|
+
{ pattern: /^post-rulebase\s*\{?$/i, depth: 2 },
|
|
197
|
+
|
|
198
|
+
// IKE/IPsec components
|
|
199
|
+
{ pattern: /^gateway\s*\{?$/i, depth: 2 },
|
|
200
|
+
{ pattern: /^crypto-profiles\s*\{?$/i, depth: 2 },
|
|
201
|
+
|
|
202
|
+
// ============ DEPTH 3: Deeply nested blocks ============
|
|
203
|
+
|
|
204
|
+
// Specific interface (e.g., ethernet1/1)
|
|
205
|
+
{ pattern: /^ethernet\d+\/\d+\s*\{?$/i, depth: 3 },
|
|
206
|
+
{ pattern: /^ae\d+\s*\{?$/i, depth: 3 }, // Aggregate interface
|
|
207
|
+
{ pattern: /^loopback\.\d+\s*\{?$/i, depth: 3 },
|
|
208
|
+
{ pattern: /^tunnel\.\d+\s*\{?$/i, depth: 3 },
|
|
209
|
+
|
|
210
|
+
// Individual rules (inside rules)
|
|
211
|
+
{ pattern: /^[\w-]+\s*\{$/i, depth: 3 }, // Named rules
|
|
212
|
+
|
|
213
|
+
// Routing protocols (inside protocol)
|
|
214
|
+
{ pattern: /^bgp\s*\{?$/i, depth: 3 },
|
|
215
|
+
{ pattern: /^ospf\s*\{?$/i, depth: 3 },
|
|
216
|
+
{ pattern: /^ospfv3\s*\{?$/i, depth: 3 },
|
|
217
|
+
{ pattern: /^rip\s*\{?$/i, depth: 3 },
|
|
218
|
+
{ pattern: /^static-route\s*\{?$/i, depth: 3 },
|
|
219
|
+
{ pattern: /^redist-profile\s*\{?$/i, depth: 3 },
|
|
220
|
+
|
|
221
|
+
// Crypto profiles types
|
|
222
|
+
{ pattern: /^ike-crypto-profiles\s*\{?$/i, depth: 3 },
|
|
223
|
+
{ pattern: /^ipsec-crypto-profiles\s*\{?$/i, depth: 3 },
|
|
224
|
+
{ pattern: /^global-protect-app-crypto-profiles\s*\{?$/i, depth: 3 },
|
|
225
|
+
|
|
226
|
+
// ============ DEPTH 4: Very deeply nested ============
|
|
227
|
+
|
|
228
|
+
// Interface mode configuration
|
|
229
|
+
{ pattern: /^layer3\s*\{?$/i, depth: 4 },
|
|
230
|
+
{ pattern: /^layer2\s*\{?$/i, depth: 4 },
|
|
231
|
+
{ pattern: /^virtual-wire\s*\{?$/i, depth: 4 },
|
|
232
|
+
{ pattern: /^tap\s*\{?$/i, depth: 4 },
|
|
233
|
+
{ pattern: /^ha\s*\{?$/i, depth: 4 },
|
|
234
|
+
|
|
235
|
+
// BGP components
|
|
236
|
+
{ pattern: /^peer-group\s*\{?$/i, depth: 4 },
|
|
237
|
+
{ pattern: /^dampening-profile\s*\{?$/i, depth: 4 },
|
|
238
|
+
{ pattern: /^auth-profile\s*\{?$/i, depth: 4 },
|
|
239
|
+
|
|
240
|
+
// OSPF areas
|
|
241
|
+
{ pattern: /^area\s*\{?$/i, depth: 4 },
|
|
242
|
+
|
|
243
|
+
// ============ DEPTH 5: Deepest nesting ============
|
|
244
|
+
|
|
245
|
+
// IP configuration (inside layer3)
|
|
246
|
+
{ pattern: /^ip\s*\{?$/i, depth: 5 },
|
|
247
|
+
{ pattern: /^ipv6\s*\{?$/i, depth: 5 },
|
|
248
|
+
{ pattern: /^ndp-proxy\s*\{?$/i, depth: 5 },
|
|
249
|
+
{ pattern: /^arp\s*\{?$/i, depth: 5 },
|
|
250
|
+
|
|
251
|
+
// BGP peer
|
|
252
|
+
{ pattern: /^peer\s*\{?$/i, depth: 5 },
|
|
253
|
+
|
|
254
|
+
// OSPF interfaces
|
|
255
|
+
{ pattern: /^interface\s+\S+\s*\{?$/i, depth: 5 },
|
|
256
|
+
],
|
|
257
|
+
|
|
258
|
+
blockEnders: [
|
|
259
|
+
/^\}$/,
|
|
260
|
+
/^\}\s*$/,
|
|
261
|
+
/^exit$/i,
|
|
262
|
+
/^quit$/i,
|
|
263
|
+
],
|
|
264
|
+
};
|