@sentriflow/cli 0.11.0 → 0.13.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 (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +2192 -522
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -113,18 +113,28 @@ var CiscoIOSSchema = {
113
113
  };
114
114
 
115
115
  // ../core/src/parser/vendors/cisco-nxos.ts
116
+ var VLAN_BODY = /^(?:no\s+)?(?:name|state|shutdown|mode|vn-segment|private-vlan|remote-span|xconnect)\b/i;
117
+ var ROLE_BODY = /^(?:no\s+)?(?:rule\s+\d+|description\b|(?:vlan|vsan)\s+policy\b|permit\s+(?:vlan|vsan)\b|no\s+(?:interface|vrf)\s+policy\b)/i;
118
+ var AAA_GROUP_BODY = /^(?:no\s+)?(?:server|use-vrf|source-interface|deadtime)\b/i;
119
+ var LINE_BODY = /^(?:no\s+)?(?:exec-timeout|session-limit|absolute-timeout|logout-warning|(?:ip\s+|ipv6\s+)?access-class|databits|parity|speed|stopbits)\b/i;
120
+ var ROLE_POLICY_BLOCK = /^(?:interface|vrf)\s+policy\s+deny\b/i;
121
+ var ROLE_POLICY_BODY = /^(?:no\s+)?permit\s+(?:interface|vrf)\b/i;
122
+ var TOP_LEVEL_STATEMENTS = /^(?:no\s+)?(?:hostname\s+(?!dynamic\s*$)\S|switchname\s|version\s+\d+\.\d|feature\s|logging\s+(?:server|timestamp|source-interface|level|logfile|console|monitor|origin-id|module|message|rfc-strict)\b|ntp\s+(?:server|peer|authenticate|authentication-key|trusted-key|access-group|source|source-interface|logging|master|distribute|commit)\b|clock\s+(?:timezone|summer-time|protocol)\b|snmp-server\s|aaa\s+(?:authentication|authorization|accounting|user)\b|(?:tacacs|radius)-server\s|username\s|userpassphrase\s|password\s+(?:strength-check|secure-mode|prompt)\b|ssh\s|(?:system\s+)?login\s+(?:block-for|on-failure|on-success)\b|nxapi\s|copp\s+profile\b|boot\s+(?:nxos|kickstart|system|poap)\b|ip\s+source-route\s*$|system\s+default\s+switchport\b|spanning-tree\s+port\s+type\s+(?:edge|network|normal)\s+(?:bpduguard\s+|bpdufilter\s+)?default\b)/i;
116
123
  var CiscoNXOSSchema = {
117
124
  id: "cisco-nxos",
118
125
  name: "Cisco NX-OS",
119
126
  useBraceHierarchy: false,
120
127
  commentPatterns: [/^!/],
121
128
  sectionDelimiter: "!",
129
+ topLevelStatements: TOP_LEVEL_STATEMENTS,
122
130
  blockStarters: [
123
131
  // ============ DEPTH 0: Top-level blocks (NX-OS specific) ============
124
- // NX-OS specific features
125
- { pattern: /^feature\s+\S+/i, depth: 0 },
132
+ // NX-OS specific features. `feature` and `install feature-set` are one
133
+ // line: they end the blocks before them but have no body (see
134
+ // BlockStarterDef.body), also in flattened text.
135
+ { pattern: /^feature\s+\S+/i, depth: 0, body: false },
126
136
  { pattern: /^vdc\s+\S+/i, depth: 0 },
127
- { pattern: /^install\s+feature-set\s+\S+/i, depth: 0 },
137
+ { pattern: /^install\s+feature-set\s+\S+/i, depth: 0, body: false },
128
138
  // Port-channel and vPC (NX-OS specific)
129
139
  { pattern: /^vpc\s+domain\s+\d+/i, depth: 0 },
130
140
  // FabricPath (NX-OS specific)
@@ -133,27 +143,31 @@ var CiscoNXOSSchema = {
133
143
  { pattern: /^otv\s+site-identifier\s+\S+/i, depth: 0 },
134
144
  // Banners (text between delimiters, see opaqueBlocks)
135
145
  { pattern: /^banner\s+(motd|exec)\b/i, depth: 0 },
146
+ // Role policy sub-modes: before `interface` and `vrf`, which also match
147
+ { pattern: ROLE_POLICY_BLOCK, depth: 1, parents: [/^role\s+name\s/i], body: ROLE_POLICY_BODY },
136
148
  // Interface blocks (same as IOS)
137
149
  { pattern: /^interface\s+\S+/i, depth: 0 },
138
150
  // Routing protocol blocks
139
151
  { pattern: /^router\s+(?!router-id)\S+/i, depth: 0 },
140
152
  // VLAN
141
- { pattern: /^vlan\s+\d+/i, depth: 0 },
153
+ { pattern: /^vlan\s+\d+/i, depth: 0, body: VLAN_BODY },
142
154
  // ACL (NX-OS uses similar syntax)
143
155
  { pattern: /^ip\s+access-list\s+\S+/i, depth: 0 },
144
156
  { pattern: /^ipv6\s+access-list\s+\S+/i, depth: 0 },
145
157
  { pattern: /^mac\s+access-list\s+\S+/i, depth: 0 },
146
- // Route-map and prefix-list
147
- { pattern: /^route-map\s+\S+/i, depth: 0 },
148
- { pattern: /^ip\s+prefix-list\s+\S+/i, depth: 0 },
149
- { pattern: /^ipv6\s+prefix-list\s+\S+/i, depth: 0 },
158
+ // Route-map and prefix-list (a prefix-list entry is one line). Only the
159
+ // global form `route-map <name> [permit|deny|pbr-statistics] [<seq>]` opens a block: the
160
+ // neighbour address-family line `route-map <name> in|out` is a command.
161
+ { pattern: /^route-map\s+\S+(?:\s*$|\s+(?:permit|deny|pbr-statistics)(?:\s|$)|\s+\d+\s*$)/i, depth: 0 },
162
+ { pattern: /^ip\s+prefix-list\s+\S+/i, depth: 0, body: false },
163
+ { pattern: /^ipv6\s+prefix-list\s+\S+/i, depth: 0, body: false },
150
164
  // QoS (NX-OS Modular QoS CLI)
151
165
  { pattern: /^class-map\s+\S+/i, depth: 0 },
152
166
  { pattern: /^policy-map\s+\S+/i, depth: 0 },
153
- // Line and management
154
- { pattern: /^line\s+(vty|console)\s+\S+/i, depth: 0 },
167
+ // Line and management: NX-OS writes the bare `line console` and `line vty`
168
+ { pattern: /^line\s+(?:vty|console)\b/i, depth: 0, body: LINE_BODY },
155
169
  // AAA
156
- { pattern: /^aaa\s+group\s+server\s+\S+/i, depth: 0 },
170
+ { pattern: /^aaa\s+group\s+server\s+\S+/i, depth: 0, body: AAA_GROUP_BODY },
157
171
  // VRF definition (NX-OS style)
158
172
  { pattern: /^vrf\s+context\s+\S+/i, depth: 0 },
159
173
  // Zone-based firewall
@@ -163,22 +177,27 @@ var CiscoNXOSSchema = {
163
177
  // Spanning tree (MST configuration)
164
178
  { pattern: /^spanning-tree\s+mst\s+configuration/i, depth: 0 },
165
179
  // Role-based CLI
166
- { pattern: /^role\s+name\s+\S+/i, depth: 0 },
167
- // SNMP server
168
- { pattern: /^snmp-server\s+user\s+\S+/i, depth: 0 },
180
+ { pattern: /^role\s+name\s+\S+/i, depth: 0, body: ROLE_BODY },
181
+ // SNMP server (a user is one line)
182
+ { pattern: /^snmp-server\s+user\s+\S+/i, depth: 0, body: false },
169
183
  // ============ DEPTH 1: Inside routing protocols ============
170
184
  { pattern: /^address-family\s+\S+/i, depth: 1 },
171
- { pattern: /^vrf\s+member\s+\S+/i, depth: 1 },
185
+ // `vrf member <vrf>` is one line of an interface; the lines after it in
186
+ // unindented text are the interface's, not its body.
187
+ { pattern: /^vrf\s+member\s+\S+/i, depth: 1, body: false },
172
188
  // VRF sub-context inside router bgp (e.g., "vrf TENANT-A")
173
189
  // Uses negative lookahead (?!member\s) to avoid matching "vrf member X"
174
190
  // This removes the ordering dependency with the vrf member pattern above
175
191
  { pattern: /^vrf\s+(?!member\s)\S+/i, depth: 1 },
176
- { pattern: /^template\s+peer\s+\S+/i, depth: 1 },
192
+ { pattern: /^template\s+peer(?:-session|-policy)?\s+\S+/i, depth: 1 },
177
193
  { pattern: /^neighbor\s+\S+/i, depth: 1 },
178
194
  { pattern: /^class\s+\S+/i, depth: 1 },
179
195
  // ============ DEPTH 2: Inside neighbor / address-family ============
180
196
  // address-family inside neighbor block
181
197
  { pattern: /^address-family\s+\S+/i, depth: 2 },
198
+ // ============ DEPTH 3: Inside a VRF neighbour ============
199
+ // address-family of a neighbour under `vrf <name>` (router bgp > vrf > neighbor)
200
+ { pattern: /^address-family\s+\S+/i, depth: 3 },
182
201
  // Inside policy-map class (QoS)
183
202
  { pattern: /^police\s+/i, depth: 2 }
184
203
  ],
@@ -202,7 +221,7 @@ var JuniperJunOSSchema = {
202
221
  /^#/,
203
222
  /^\/\*.*\*\/$/,
204
223
  /^inactive:/,
205
- // CLI context captured with `show configuration` output (gecko#43): the
224
+ // CLI context captured with `show configuration` output: the
206
225
  // routing-engine, Virtual Chassis member or cluster-node state printed
207
226
  // above the prompt (`{master:0}`, `{backup}`, `{primary:node0}`,
208
227
  // `{master:member0-re0}`), optionally followed by the configuration-mode
@@ -735,7 +754,7 @@ var PaloAltoPANOSSchema = {
735
754
  // Block comments
736
755
  /^!.*$/,
737
756
  // Exclamation comments (some CLI modes)
738
- // CLI output captured with the configuration (gecko#43): the
757
+ // CLI output captured with the configuration: the
739
758
  // configuration-mode path (`[edit]`) and the prompt
740
759
  // (`admin@fw1>`, `admin@fw1(active-secondary)#`)
741
760
  /^\[edit(?:\s[^\]]*)?\]$/,
@@ -967,14 +986,14 @@ var AristaEOSSchema = {
967
986
  // Only at the top level: indented under a section the same words are
968
987
  // sub-commands (`spanning-tree portfast`, `lldp receive`, `ip pim
969
988
  // sparse-mode`, `mpls ip` under an interface; `bfd default` under a
970
- // router; `interface disabled default` under mpls ldp) (gecko#83)
989
+ // router; `interface disabled default` under mpls ldp)
971
990
  // Interface blocks (all interface types)
972
991
  { pattern: /^interface\s+\S+/i, depth: 0, parents: [] },
973
992
  // Routing protocols
974
993
  { pattern: /^router\s+(?!router-id)\S+/i, depth: 0, parents: [] },
975
994
  // VLAN configuration. Under router bgp, "vlan N" opens a MAC-VRF and
976
995
  // "vlan-aware-bundle" a bundle of them; inside a bundle "vlan 10-20"
977
- // only lists its VLANs (gecko#83)
996
+ // only lists its VLANs
978
997
  { pattern: /^vlan\s+\d+/i, depth: 0, parents: [] },
979
998
  { pattern: /^vlan\s+\d+$/i, depth: 1, parents: [/^router\s+bgp\b/i] },
980
999
  { pattern: /^vlan-aware-bundle\s+\S+/i, depth: 1, parents: [/^router\s+bgp\b/i] },
@@ -1069,7 +1088,7 @@ var AristaEOSSchema = {
1069
1088
  { pattern: /^ntp\s+\S+/i, depth: 0, parents: [] },
1070
1089
  // ============ DEPTH 1: Inside routing protocols ============
1071
1090
  // EOS has no neighbor, network or redistribute sub-mode: those lines are
1072
- // commands at every level, so they must not close a section (gecko#83)
1091
+ // commands at every level, so they must not close a section
1073
1092
  { pattern: /^address-family\s+\S+/i, depth: 1 },
1074
1093
  // A vrf sub-mode exists under router bgp (and other routers) and the
1075
1094
  // management services; under an interface `vrf X` only assigns the VRF
@@ -2429,7 +2448,6 @@ var MAX_LINE_COUNT = 1e5;
2429
2448
  var ALLOWED_CONFIG_EXTENSIONS = [".js", ".ts", ".mjs", ".cjs"];
2430
2449
  var ALLOWED_JSON_RULES_EXTENSIONS = [".json"];
2431
2450
  var MAX_CONFIG_FILE_SIZE = 1024 * 1024;
2432
- var MAX_ENCRYPTED_PACK_SIZE = 5 * 1024 * 1024;
2433
2451
  var RULE_PER_NODE_TIMEOUT_MS = 100;
2434
2452
  var RULE_ID_PATTERN = /^[A-Z][A-Z0-9_-]{2,49}$/;
2435
2453
  var MAX_PATTERN_LENGTH = 500;
@@ -3812,6 +3830,14 @@ function wholeLines(text, from, length) {
3812
3830
  const lastBreak = text.lastIndexOf("\n", end - 1);
3813
3831
  return lastBreak <= from || lastBreak < end - MAX_PARTIAL_LINE ? text.slice(from, end) : text.slice(from, lastBreak + 1);
3814
3832
  }
3833
+ var NXOS_STATEMENT_MARKERS = [
3834
+ /^version\s+\d+\.\d+\(\d+[^)\s]*\)/m,
3835
+ /^switchname\s+\S+/m,
3836
+ /^copp\s+profile\s+\S+/m,
3837
+ /^nxapi\s+(?:http|https|ssl)\b/m,
3838
+ /^userpassphrase\s+\S+/m,
3839
+ /^(?:no\s+)?password\s+strength-check\b/m
3840
+ ];
3815
3841
  function matchVendorPatterns(configText, notes) {
3816
3842
  const sampleText = detectionSample(configText);
3817
3843
  const lines = sampleText.split("\n");
@@ -4063,7 +4089,7 @@ function matchVendorPatterns(configText, notes) {
4063
4089
  if (/^vpc\s+domain\s+\d+/m.test(sampleText)) {
4064
4090
  return CiscoNXOSSchema;
4065
4091
  }
4066
- if (/^version\s+\d+\.\d+\(\d+[^)\s]*\)/m.test(sampleText)) {
4092
+ if (NXOS_STATEMENT_MARKERS.some((marker) => marker.test(sampleText))) {
4067
4093
  return CiscoNXOSSchema;
4068
4094
  }
4069
4095
  if (/^mlag\s+configuration/m.test(sampleText)) {
@@ -5188,7 +5214,13 @@ var SchemaAwareParser = class {
5188
5214
  indentedKinds.add(this.blockStarterIndex(line.sanitized));
5189
5215
  }
5190
5216
  });
5191
- const isOneLiner = (section, line) => indentedKinds.size > 0 && !line.sanitized.toLowerCase().startsWith(`${section.id.toLowerCase()} `) && (line.afterSeparator === true || !indentedKinds.has(this.blockStarterIndex(section.id)));
5217
+ const topLevel = this.vendor.topLevelStatements;
5218
+ const isOneLiner = (section, line) => {
5219
+ if (topLevel && line.indent === 0 && topLevel.test(line.sanitized)) return true;
5220
+ const body = this.blockBody(section.id);
5221
+ if (body instanceof RegExp && !body.test(line.sanitized)) return true;
5222
+ return indentedKinds.size > 0 && !line.sanitized.toLowerCase().startsWith(`${section.id.toLowerCase()} `) && (line.afterSeparator === true || !indentedKinds.has(this.blockStarterIndex(section.id)));
5223
+ };
5192
5224
  for (const currentLine of lineContexts) {
5193
5225
  let isBlockStarter = currentLine.isBlockStarter;
5194
5226
  let blockStarterDepth = currentLine.blockStarterDepth;
@@ -5314,7 +5346,7 @@ var SchemaAwareParser = class {
5314
5346
  } else {
5315
5347
  rootNodes.push(newNode2);
5316
5348
  }
5317
- if (!currentLine.opaque) {
5349
+ if (!currentLine.opaque && !(isBlockStarter && this.blockBody(currentLine.sanitized) === false)) {
5318
5350
  parentStack.push(newNode2);
5319
5351
  }
5320
5352
  }
@@ -5403,6 +5435,11 @@ var SchemaAwareParser = class {
5403
5435
  blockStarterIndex(sanitizedLine) {
5404
5436
  return this.vendor.blockStarters.findIndex((def) => def.pattern.test(sanitizedLine));
5405
5437
  }
5438
+ /** The body (BlockStarterDef.body) of the first block starter definition matching a line. */
5439
+ blockBody(sanitizedLine) {
5440
+ if (!this.vendor.blockStarters.some((def) => def.body !== void 0)) return void 0;
5441
+ return this.vendor.blockStarters.find((def) => def.pattern.test(sanitizedLine))?.body;
5442
+ }
5406
5443
  /**
5407
5444
  * Depths, in definition order, of the block starter definitions that match
5408
5445
  * a line and open a block under `parent` (the section it is indented under;
@@ -5888,7 +5925,7 @@ var STORAGE_WORDS = /* @__PURE__ */ new Set([
5888
5925
  ...AUTH_ALGORITHMS,
5889
5926
  ...PRIV_ALGORITHMS
5890
5927
  ]);
5891
- var KEY_NOT_SECRET = /* @__PURE__ */ new Set(["chain", "generate", "zeroize", "import", "export", "storage", "pubkey", "rsa", "ec"]);
5928
+ var KEY_NOT_SECRET = /* @__PURE__ */ new Set(["chain", "generate", "zeroize", "import", "export", "storage", "pubkey", "rsa", "dsa", "ec", "ecdsa"]);
5892
5929
  var SNMP_HOST_FLAGS = /* @__PURE__ */ new Set(["informs", "inform", "traps", "trap", "auth", "noauth", "priv", "community"]);
5893
5930
  var SNMP_HOST_OPTIONS = /* @__PURE__ */ new Set(["vrf", "version"]);
5894
5931
  var SNMP_HOST_NO_SECRET = /* @__PURE__ */ new Set(["use-vrf", "filter-vrf", "source-interface"]);
@@ -5915,6 +5952,11 @@ var SKIP_IKE = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "local", "remote"]);
5915
5952
  var SKIP_VRP_COMMUNITY = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "read", "write"]);
5916
5953
  var SKIP_TEXT = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "text"]);
5917
5954
  var SKIP_NONE = /* @__PURE__ */ new Set();
5955
+ var PASSWORD_POLICIES = ["strength-check", "secure-mode", "prompt username"];
5956
+ var isPasswordPolicy = (tokens, i) => {
5957
+ const rest = tokens.slice(i + 1).map((t) => t.word).join(" ");
5958
+ return PASSWORD_POLICIES.includes(rest);
5959
+ };
5918
5960
  var valueAfter = (scan, i) => {
5919
5961
  const { tokens, snmp } = scan;
5920
5962
  const word = tokens[i]?.word ?? "";
@@ -5925,6 +5967,7 @@ var valueAfter = (scan, i) => {
5925
5967
  let from;
5926
5968
  let skip = SKIP_ALWAYS;
5927
5969
  let storage = true;
5970
+ if (word === "password" && (i === 0 || i === 1 && first2 === "no") && isPasswordPolicy(tokens, i)) return -1;
5928
5971
  if (word === "password" && i === 0) {
5929
5972
  from = i + 1;
5930
5973
  skip = SKIP_AOS_PASSWORD;
@@ -7347,7 +7390,7 @@ var RuleEngine = class {
7347
7390
  /**
7348
7391
  * Run rules against nodes using the index for fast lookup.
7349
7392
  *
7350
- * Every result leaves the engine with its secrets masked (gecko#85): the
7393
+ * Every result leaves the engine with its secrets masked: the
7351
7394
  * nodeId as a configuration line (`maskSecretText`), and the nodeId,
7352
7395
  * message and remediation by the secret values of the lines the result
7353
7396
  * reports on (the checked node, the nodes on the result's line, its
@@ -9122,7 +9165,7 @@ var isPolicySection = (parents) => {
9122
9165
  for (const parent of parents) if (parent[0] === "policy-options") return true;
9123
9166
  return false;
9124
9167
  };
9125
- var isPasswordPolicy = (parents) => {
9168
+ var isPasswordPolicy2 = (parents) => {
9126
9169
  const nearest = parents[parents.length - 1];
9127
9170
  return nearest !== void 0 && nearest.length === 1 && nearest[0] === "password" && parents[parents.length - 2]?.[0] === "login";
9128
9171
  };
@@ -9139,7 +9182,7 @@ var notASecretSpans = (line, parents) => {
9139
9182
  const last = part.all[part.all.length - 1];
9140
9183
  if (!first2 || !last) continue;
9141
9184
  const text = line.slice(first2.start, last.end);
9142
- if (NOT_A_SECRET.some((re) => re.test(text)) || isPolicySection(part.parents) || isPasswordPolicy(part.parents)) out.push({ start: first2.start, end: last.end });
9185
+ if (NOT_A_SECRET.some((re) => re.test(text)) || isPolicySection(part.parents) || isPasswordPolicy2(part.parents)) out.push({ start: first2.start, end: last.end });
9143
9186
  }
9144
9187
  return out;
9145
9188
  };
@@ -12110,14 +12153,14 @@ var getInterfaceName = (node) => {
12110
12153
  const ifName = match?.[1]?.trim();
12111
12154
  return ifName && ifName.length > 0 ? ifName : void 0;
12112
12155
  };
12113
- var isAosCxPhysicalPort = (interfaceName) => {
12114
- return /^\d+\/\d+\/\d+$/.test(interfaceName.trim());
12156
+ var isAosCxPhysicalPort = (interfaceName2) => {
12157
+ return /^\d+\/\d+\/\d+$/.test(interfaceName2.trim());
12115
12158
  };
12116
- var isAosCxLag = (interfaceName) => {
12117
- return /^lag\s*\d+$/i.test(interfaceName.trim());
12159
+ var isAosCxLag = (interfaceName2) => {
12160
+ return /^lag\s*\d+$/i.test(interfaceName2.trim());
12118
12161
  };
12119
- var isAosCxVlanInterface = (interfaceName) => {
12120
- return /^vlan\s*\d+$/i.test(interfaceName.trim());
12162
+ var isAosCxVlanInterface = (interfaceName2) => {
12163
+ return /^vlan\s*\d+$/i.test(interfaceName2.trim());
12121
12164
  };
12122
12165
  var isAosCxTrunk = (node) => {
12123
12166
  return hasChildCommand(node, "vlan trunk");
@@ -12429,6 +12472,7 @@ __export(cisco_exports, {
12429
12472
  isLikelyTrunk: () => isLikelyTrunk,
12430
12473
  isLineConfigPassword: () => isLineConfigPassword,
12431
12474
  isLoopbackInterface: () => isLoopbackInterface,
12475
+ isNxosInterfaceEnabled: () => isNxosInterfaceEnabled,
12432
12476
  isPhoneOrAP: () => isPhoneOrAP,
12433
12477
  isPhysicalPort: () => isPhysicalPort,
12434
12478
  isShutdown: () => isShutdown3,
@@ -12449,8 +12493,16 @@ var isShutdown3 = (node) => {
12449
12493
  return child?.id && equalsIgnoreCase(child.id.trim(), "shutdown");
12450
12494
  });
12451
12495
  };
12452
- var isPhysicalPort = (interfaceName) => {
12453
- return !includesIgnoreCase(interfaceName, "loopback") && !includesIgnoreCase(interfaceName, "null") && !includesIgnoreCase(interfaceName, "vlan") && !includesIgnoreCase(interfaceName, "tunnel") && !includesIgnoreCase(interfaceName, "port-channel") && !includesIgnoreCase(interfaceName, "bvi") && !includesIgnoreCase(interfaceName, "nve");
12496
+ var isNxosInterfaceEnabled = (node) => {
12497
+ const children = node?.children ?? [];
12498
+ const has = (text) => children.some((child) => !!child?.id && equalsIgnoreCase(child.id.trim(), text));
12499
+ if (has("shutdown")) return false;
12500
+ const name = (node?.id ?? "").trim().replace(/^interface\s+/i, "");
12501
+ const defaultsDown = startsWithIgnoreCase(name, "ethernet") || startsWithIgnoreCase(name, "vlan");
12502
+ return defaultsDown ? has("no shutdown") : true;
12503
+ };
12504
+ var isPhysicalPort = (interfaceName2) => {
12505
+ return !includesIgnoreCase(interfaceName2, "loopback") && !includesIgnoreCase(interfaceName2, "null") && !includesIgnoreCase(interfaceName2, "vlan") && !includesIgnoreCase(interfaceName2, "tunnel") && !includesIgnoreCase(interfaceName2, "port-channel") && !includesIgnoreCase(interfaceName2, "bvi") && !includesIgnoreCase(interfaceName2, "nve");
12454
12506
  };
12455
12507
  var isLikelyTrunk = (node) => {
12456
12508
  const desc = getChildCommand(node, "description");
@@ -12672,14 +12724,14 @@ var isWanInterface = (node) => {
12672
12724
  if (!desc) return false;
12673
12725
  return descriptionWords(desc.id).some((w) => WAN_DESCRIPTION_WORDS.has(w));
12674
12726
  };
12675
- var isLoopbackInterface = (interfaceName) => {
12676
- return includesIgnoreCase(interfaceName, "loopback");
12727
+ var isLoopbackInterface = (interfaceName2) => {
12728
+ return includesIgnoreCase(interfaceName2, "loopback");
12677
12729
  };
12678
- var isTunnelInterface = (interfaceName) => {
12679
- return includesIgnoreCase(interfaceName, "tunnel");
12730
+ var isTunnelInterface = (interfaceName2) => {
12731
+ return includesIgnoreCase(interfaceName2, "tunnel");
12680
12732
  };
12681
- var isVlanInterface = (interfaceName) => {
12682
- return startsWithIgnoreCase(interfaceName, "interface vlan");
12733
+ var isVlanInterface = (interfaceName2) => {
12734
+ return startsWithIgnoreCase(interfaceName2, "interface vlan");
12683
12735
  };
12684
12736
  var hasPasswordEncryption = (node) => {
12685
12737
  return equalsIgnoreCase(node.id.trim(), "service password-encryption");
@@ -12795,32 +12847,32 @@ var isIfaceStanza = (node) => {
12795
12847
  var isAutoStanza = (node) => {
12796
12848
  return node.id.toLowerCase().startsWith("auto ");
12797
12849
  };
12798
- var isSwitchPort = (interfaceName) => {
12799
- const name = interfaceName.toLowerCase();
12850
+ var isSwitchPort = (interfaceName2) => {
12851
+ const name = interfaceName2.toLowerCase();
12800
12852
  return /swp\d+/.test(name);
12801
12853
  };
12802
- var isBondInterface = (interfaceName) => {
12803
- const name = interfaceName.toLowerCase();
12854
+ var isBondInterface = (interfaceName2) => {
12855
+ const name = interfaceName2.toLowerCase();
12804
12856
  return /bond\d+/.test(name);
12805
12857
  };
12806
- var isBridgeInterface = (interfaceName) => {
12807
- const name = interfaceName.toLowerCase();
12858
+ var isBridgeInterface = (interfaceName2) => {
12859
+ const name = interfaceName2.toLowerCase();
12808
12860
  return name.includes("bridge") || name === "br_default" || /^br\d+$/.test(name);
12809
12861
  };
12810
- var isVlanInterface2 = (interfaceName) => {
12811
- const name = interfaceName.toLowerCase();
12862
+ var isVlanInterface2 = (interfaceName2) => {
12863
+ const name = interfaceName2.toLowerCase();
12812
12864
  return /vlan\d+/.test(name) || /_vlan\d+$/.test(name);
12813
12865
  };
12814
- var isManagementInterface2 = (interfaceName) => {
12815
- const name = interfaceName.toLowerCase();
12866
+ var isManagementInterface2 = (interfaceName2) => {
12867
+ const name = interfaceName2.toLowerCase();
12816
12868
  return name === "eth0" || name === "mgmt";
12817
12869
  };
12818
- var isLoopback2 = (interfaceName) => {
12819
- const name = interfaceName.toLowerCase();
12870
+ var isLoopback2 = (interfaceName2) => {
12871
+ const name = interfaceName2.toLowerCase();
12820
12872
  return name === "lo" || name.startsWith("loopback");
12821
12873
  };
12822
- var isPeerlink = (interfaceName) => {
12823
- const name = interfaceName.toLowerCase();
12874
+ var isPeerlink = (interfaceName2) => {
12875
+ const name = interfaceName2.toLowerCase();
12824
12876
  return name.includes("peerlink");
12825
12877
  };
12826
12878
  var isVlanAwareBridge = (node) => {
@@ -12952,11 +13004,11 @@ var hasManagementVrf2 = (node) => {
12952
13004
  (child) => child.id.toLowerCase().includes("vrf mgmt") || child.id.toLowerCase() === "vrf mgmt"
12953
13005
  );
12954
13006
  };
12955
- var isManagementVrf = (interfaceName) => {
12956
- return interfaceName.toLowerCase() === "mgmt";
13007
+ var isManagementVrf = (interfaceName2) => {
13008
+ return interfaceName2.toLowerCase() === "mgmt";
12957
13009
  };
12958
- var isPeerlinkSubinterface = (interfaceName) => {
12959
- return interfaceName.toLowerCase().includes("peerlink.4094");
13010
+ var isPeerlinkSubinterface = (interfaceName2) => {
13011
+ return interfaceName2.toLowerCase().includes("peerlink.4094");
12960
13012
  };
12961
13013
  var hasClagdPeerIp = (node) => {
12962
13014
  return node.children.some(
@@ -13020,8 +13072,8 @@ var getBridgePvid = (node) => {
13020
13072
  if (!match?.[1]) return null;
13021
13073
  return parseInt(match[1], 10);
13022
13074
  };
13023
- var isVniInterface = (interfaceName) => {
13024
- return /^vni\d+$/i.test(interfaceName) || /^vni[a-zA-Z]+$/i.test(interfaceName);
13075
+ var isVniInterface = (interfaceName2) => {
13076
+ return /^vni\d+$/i.test(interfaceName2) || /^vni[a-zA-Z]+$/i.test(interfaceName2);
13025
13077
  };
13026
13078
  var hasVxlanLocalTunnelip = (node) => {
13027
13079
  return node.children.some(
@@ -13110,8 +13162,8 @@ var getMtu = (node) => {
13110
13162
  if (!match?.[1]) return null;
13111
13163
  return parseInt(match[1], 10);
13112
13164
  };
13113
- var isUplinkInterface = (interfaceName) => {
13114
- const name = interfaceName.toLowerCase();
13165
+ var isUplinkInterface = (interfaceName2) => {
13166
+ const name = interfaceName2.toLowerCase();
13115
13167
  return /swp5[0-9]/.test(name);
13116
13168
  };
13117
13169
  var hasStormControl = (node) => {
@@ -14008,18 +14060,18 @@ var isEnabled = (node) => {
14008
14060
  return rawText === "undo shutdown";
14009
14061
  });
14010
14062
  };
14011
- var isPhysicalPort2 = (interfaceName) => {
14012
- const name = interfaceName.toLowerCase();
14063
+ var isPhysicalPort2 = (interfaceName2) => {
14064
+ const name = interfaceName2.toLowerCase();
14013
14065
  return !name.includes("vlanif") && !name.includes("loopback") && !name.includes("null") && !name.includes("tunnel") && !name.includes("eth-trunk") && !name.includes("nve") && !name.includes("vbdif");
14014
14066
  };
14015
- var isVlanInterface3 = (interfaceName) => {
14016
- return interfaceName.toLowerCase().includes("vlanif");
14067
+ var isVlanInterface3 = (interfaceName2) => {
14068
+ return interfaceName2.toLowerCase().includes("vlanif");
14017
14069
  };
14018
- var isLoopbackInterface2 = (interfaceName) => {
14019
- return interfaceName.toLowerCase().includes("loopback");
14070
+ var isLoopbackInterface2 = (interfaceName2) => {
14071
+ return interfaceName2.toLowerCase().includes("loopback");
14020
14072
  };
14021
- var isEthTrunk = (interfaceName) => {
14022
- return interfaceName.toLowerCase().includes("eth-trunk");
14073
+ var isEthTrunk = (interfaceName2) => {
14074
+ return interfaceName2.toLowerCase().includes("eth-trunk");
14023
14075
  };
14024
14076
  var isTrunkPort3 = (node) => {
14025
14077
  if (!node?.children) return false;
@@ -14565,14 +14617,14 @@ var isDisabled = (node) => {
14565
14617
  if (!node?.children) return false;
14566
14618
  return node.children.some((child) => child?.id && equalsIgnoreCase(child.id.trim(), "disable"));
14567
14619
  };
14568
- var isPhysicalJunosPort = (interfaceName) => {
14569
- return startsWithIgnoreCase(interfaceName, "ge-") || startsWithIgnoreCase(interfaceName, "xe-") || startsWithIgnoreCase(interfaceName, "et-") || startsWithIgnoreCase(interfaceName, "ae") || startsWithIgnoreCase(interfaceName, "em") || startsWithIgnoreCase(interfaceName, "fxp");
14620
+ var isPhysicalJunosPort = (interfaceName2) => {
14621
+ return startsWithIgnoreCase(interfaceName2, "ge-") || startsWithIgnoreCase(interfaceName2, "xe-") || startsWithIgnoreCase(interfaceName2, "et-") || startsWithIgnoreCase(interfaceName2, "ae") || startsWithIgnoreCase(interfaceName2, "em") || startsWithIgnoreCase(interfaceName2, "fxp");
14570
14622
  };
14571
- var isLoopback3 = (interfaceName) => {
14572
- return startsWithIgnoreCase(interfaceName, "lo") || equalsIgnoreCase(interfaceName, "lo0");
14623
+ var isLoopback3 = (interfaceName2) => {
14624
+ return startsWithIgnoreCase(interfaceName2, "lo") || equalsIgnoreCase(interfaceName2, "lo0");
14573
14625
  };
14574
- var isIrbInterface = (interfaceName) => {
14575
- return startsWithIgnoreCase(interfaceName, "irb");
14626
+ var isIrbInterface = (interfaceName2) => {
14627
+ return startsWithIgnoreCase(interfaceName2, "irb");
14576
14628
  };
14577
14629
  var parseJunosAddress = (address) => {
14578
14630
  const parts = address.split("/");
@@ -15091,32 +15143,32 @@ var getCommandText = (nodeOrCommand) => {
15091
15143
  };
15092
15144
  var textOf = (nodeOrCommand) => getCommandText(nodeOrCommand);
15093
15145
  var isDisabledResource = (nodeOrCommand) => parseProperty(textOf(nodeOrCommand), "disabled")?.toLowerCase() === "yes";
15094
- var isPhysicalInterface = (interfaceName) => {
15095
- const name = interfaceName.toLowerCase();
15146
+ var isPhysicalInterface = (interfaceName2) => {
15147
+ const name = interfaceName2.toLowerCase();
15096
15148
  return /^ether\d+$/.test(name) || /^sfp\d+$/.test(name) || /^sfp-sfpplus\d+$/.test(name) || /^combo\d+$/.test(name) || /^qsfp\d+$/.test(name);
15097
15149
  };
15098
- var isLoopback4 = (interfaceName) => {
15099
- const name = interfaceName.toLowerCase();
15150
+ var isLoopback4 = (interfaceName2) => {
15151
+ const name = interfaceName2.toLowerCase();
15100
15152
  return name === "lo" || name.startsWith("loopback");
15101
15153
  };
15102
- var isBridgeInterface2 = (interfaceName) => {
15103
- const name = interfaceName.toLowerCase();
15154
+ var isBridgeInterface2 = (interfaceName2) => {
15155
+ const name = interfaceName2.toLowerCase();
15104
15156
  return name.startsWith("bridge") || /^br\d+$/.test(name);
15105
15157
  };
15106
- var isVlanInterface4 = (interfaceName) => {
15107
- const name = interfaceName.toLowerCase();
15158
+ var isVlanInterface4 = (interfaceName2) => {
15159
+ const name = interfaceName2.toLowerCase();
15108
15160
  return name.startsWith("vlan") || /^vlan\d+$/.test(name);
15109
15161
  };
15110
- var isBondingInterface = (interfaceName) => {
15111
- const name = interfaceName.toLowerCase();
15162
+ var isBondingInterface = (interfaceName2) => {
15163
+ const name = interfaceName2.toLowerCase();
15112
15164
  return name.startsWith("bonding") || /^bond\d+$/.test(name);
15113
15165
  };
15114
- var isWireGuardInterface = (interfaceName) => {
15115
- const name = interfaceName.toLowerCase();
15166
+ var isWireGuardInterface = (interfaceName2) => {
15167
+ const name = interfaceName2.toLowerCase();
15116
15168
  return name.startsWith("wireguard") || /^wg\d+$/.test(name);
15117
15169
  };
15118
- var isTunnelInterface2 = (interfaceName) => {
15119
- const name = interfaceName.toLowerCase();
15170
+ var isTunnelInterface2 = (interfaceName2) => {
15171
+ const name = interfaceName2.toLowerCase();
15120
15172
  return name.startsWith("eoip") || name.startsWith("gre") || name.startsWith("ipip") || name.startsWith("vxlan") || name.startsWith("l2tp") || name.startsWith("pptp") || name.startsWith("sstp") || name.startsWith("ovpn") || name.startsWith("pppoe");
15121
15173
  };
15122
15174
  var QUOTED_STRING2 = /"(?:[^"\\]|\\.)*"/g;
@@ -15587,8 +15639,8 @@ var isLagPort = (portName) => {
15587
15639
  const name = portName.toLowerCase();
15588
15640
  return name.includes("lag");
15589
15641
  };
15590
- var isSystemInterface = (interfaceName) => {
15591
- const name = interfaceName.toLowerCase();
15642
+ var isSystemInterface = (interfaceName2) => {
15643
+ const name = interfaceName2.toLowerCase();
15592
15644
  return name.includes("system") || name.includes("loopback") || name === '"system"';
15593
15645
  };
15594
15646
  var getPortMode = (node) => {
@@ -16308,17 +16360,17 @@ var isHAConfigured = (deviceconfigNode) => {
16308
16360
  if (!ha?.children) return false;
16309
16361
  return ha.children.length > 0;
16310
16362
  };
16311
- var isPhysicalEthernetPort = (interfaceName) => {
16312
- return /^ethernet\d+\/\d+$/i.test(interfaceName);
16363
+ var isPhysicalEthernetPort = (interfaceName2) => {
16364
+ return /^ethernet\d+\/\d+$/i.test(interfaceName2);
16313
16365
  };
16314
- var isLoopbackInterface3 = (interfaceName) => {
16315
- return /^loopback\.\d+$/i.test(interfaceName);
16366
+ var isLoopbackInterface3 = (interfaceName2) => {
16367
+ return /^loopback\.\d+$/i.test(interfaceName2);
16316
16368
  };
16317
- var isTunnelInterface3 = (interfaceName) => {
16318
- return /^tunnel\.\d+$/i.test(interfaceName);
16369
+ var isTunnelInterface3 = (interfaceName2) => {
16370
+ return /^tunnel\.\d+$/i.test(interfaceName2);
16319
16371
  };
16320
- var isAggregateInterface = (interfaceName) => {
16321
- return /^ae\d+$/i.test(interfaceName);
16372
+ var isAggregateInterface = (interfaceName2) => {
16373
+ return /^ae\d+$/i.test(interfaceName2);
16322
16374
  };
16323
16375
  var getZoneName2 = (zoneNode) => {
16324
16376
  return zoneNode.id.split(/\s+/)[0] || zoneNode.id;
@@ -16706,31 +16758,31 @@ var isDisabled2 = (node) => {
16706
16758
  if (!node?.children) return false;
16707
16759
  return node.children.some((child) => child?.id?.toLowerCase().trim() === "disable");
16708
16760
  };
16709
- var isPhysicalVyosPort = (interfaceName) => {
16710
- const name = interfaceName.toLowerCase();
16761
+ var isPhysicalVyosPort = (interfaceName2) => {
16762
+ const name = interfaceName2.toLowerCase();
16711
16763
  if (name.startsWith("ethernet eth")) {
16712
16764
  return true;
16713
16765
  }
16714
16766
  return /^eth\d+$/.test(name);
16715
16767
  };
16716
- var isLoopback5 = (interfaceName) => {
16717
- const name = interfaceName.toLowerCase();
16768
+ var isLoopback5 = (interfaceName2) => {
16769
+ const name = interfaceName2.toLowerCase();
16718
16770
  return name.includes("loopback") || name === "lo";
16719
16771
  };
16720
- var isBondingInterface2 = (interfaceName) => {
16721
- const name = interfaceName.toLowerCase();
16772
+ var isBondingInterface2 = (interfaceName2) => {
16773
+ const name = interfaceName2.toLowerCase();
16722
16774
  return name.includes("bonding") || /^bond\d+$/.test(name);
16723
16775
  };
16724
- var isBridgeInterface3 = (interfaceName) => {
16725
- const name = interfaceName.toLowerCase();
16776
+ var isBridgeInterface3 = (interfaceName2) => {
16777
+ const name = interfaceName2.toLowerCase();
16726
16778
  return name.includes("bridge") || /^br\d+$/.test(name);
16727
16779
  };
16728
- var isWireGuardInterface2 = (interfaceName) => {
16729
- const name = interfaceName.toLowerCase();
16780
+ var isWireGuardInterface2 = (interfaceName2) => {
16781
+ const name = interfaceName2.toLowerCase();
16730
16782
  return name.includes("wireguard") || /^wg\d+$/.test(name);
16731
16783
  };
16732
- var isTunnelInterface4 = (interfaceName) => {
16733
- const name = interfaceName.toLowerCase();
16784
+ var isTunnelInterface4 = (interfaceName2) => {
16785
+ const name = interfaceName2.toLowerCase();
16734
16786
  return name.includes("tunnel") || name.includes("vti") || name.includes("vxlan") || /^(tun|vti|vxlan)\d+$/.test(name);
16735
16787
  };
16736
16788
  var parseVyosAddress = (address) => {
@@ -18333,17 +18385,17 @@ var JsonRuleCompiler = class {
18333
18385
  * Check if any matching child's id matches the pattern.
18334
18386
  */
18335
18387
  childMatches(node, selector, pattern, flags) {
18336
- const matchingChildren = this.getMatchingChildren(node, selector);
18388
+ const matchingChildren2 = this.getMatchingChildren(node, selector);
18337
18389
  const regex = this.getRegex(pattern, flags);
18338
- return matchingChildren.some((child) => testRulePattern(regex, child.id));
18390
+ return matchingChildren2.some((child) => testRulePattern(regex, child.id));
18339
18391
  }
18340
18392
  /**
18341
18393
  * Check if any matching child's id contains the text.
18342
18394
  */
18343
18395
  childContains(node, selector, text) {
18344
18396
  const textLower = text.toLowerCase();
18345
- const matchingChildren = this.getMatchingChildren(node, selector);
18346
- return matchingChildren.some(
18397
+ const matchingChildren2 = this.getMatchingChildren(node, selector);
18398
+ return matchingChildren2.some(
18347
18399
  (child) => child.id.toLowerCase().includes(textLower)
18348
18400
  );
18349
18401
  }
@@ -19750,7 +19802,7 @@ var InterfaceDescriptionRequired = {
19750
19802
  remediation: 'Add a description to the interface using the "description" command.'
19751
19803
  },
19752
19804
  check: (node, context) => {
19753
- const interfaceName = node.id;
19805
+ const interfaceName2 = node.id;
19754
19806
  const scope = interfaceScope(context, node);
19755
19807
  if (scope === "nokia") {
19756
19808
  return {
@@ -19782,7 +19834,7 @@ var InterfaceDescriptionRequired = {
19782
19834
  loc: node.loc
19783
19835
  };
19784
19836
  }
19785
- if (includesIgnoreCase(interfaceName, "null") || includesIgnoreCase(interfaceName, "loopback")) {
19837
+ if (includesIgnoreCase(interfaceName2, "null") || includesIgnoreCase(interfaceName2, "loopback")) {
19786
19838
  return {
19787
19839
  passed: true,
19788
19840
  message: "Loopback/Null interface - description optional.",
@@ -19792,7 +19844,7 @@ var InterfaceDescriptionRequired = {
19792
19844
  loc: node.loc
19793
19845
  };
19794
19846
  }
19795
- if (includesIgnoreCase(interfaceName, "lo0")) {
19847
+ if (includesIgnoreCase(interfaceName2, "lo0")) {
19796
19848
  return {
19797
19849
  passed: true,
19798
19850
  message: "Loopback interface - description optional.",
@@ -20601,16 +20653,26 @@ var SnmpNoDefaultCommunity = {
20601
20653
  return { passed: true, message: "SNMP community is not default.", ruleId: "NET-SNMP-002", nodeId: node.id, level: "info", loc: node.loc };
20602
20654
  }
20603
20655
  };
20656
+ var isSnmpReadWrite = (node) => {
20657
+ const words = node.params.slice(3).map((w) => w.toLowerCase());
20658
+ for (let i = 0; i < words.length; i++) {
20659
+ const w = words[i];
20660
+ if (w === "rw") return true;
20661
+ if (w === "ro") return false;
20662
+ if (w === "view" || w === "group" || w === "ipv6" || w === "use-acl" || w === "use-ipv4acl" || w === "use-ipv6acl") i++;
20663
+ }
20664
+ return false;
20665
+ };
20604
20666
  var SnmpNoRwAccess = {
20605
20667
  id: "NET-SNMP-004",
20606
20668
  selector: "snmp-server community",
20607
- vendor: "cisco-ios",
20669
+ vendor: ["cisco-ios", "cisco-nxos"],
20608
20670
  category: "Protocol-Security",
20609
20671
  metadata: {
20610
20672
  level: "warning",
20611
20673
  obu: "Security",
20612
20674
  owner: "SecOps",
20613
- remediation: "Remove SNMP RW access unless specifically required. Use RO for monitoring.",
20675
+ remediation: 'Remove SNMP RW access unless specifically required. Use RO for monitoring. On NX-OS, use "ro" or "group network-operator".',
20614
20676
  security: {
20615
20677
  cwe: ["CWE-284"],
20616
20678
  cvssScore: 7.5
@@ -20621,8 +20683,7 @@ var SnmpNoRwAccess = {
20621
20683
  ]
20622
20684
  },
20623
20685
  check: (node) => {
20624
- const rawText = node.rawText.toUpperCase();
20625
- if (rawText.includes(" RW")) {
20686
+ if (isSnmpReadWrite(node)) {
20626
20687
  return {
20627
20688
  passed: false,
20628
20689
  message: "SNMP RW (write) access is configured. This is a security risk.",
@@ -20632,7 +20693,7 @@ var SnmpNoRwAccess = {
20632
20693
  loc: node.loc
20633
20694
  };
20634
20695
  }
20635
- return { passed: true, message: "SNMP is read-only.", ruleId: "NET-SNMP-004", nodeId: node.id, level: "info", loc: node.loc };
20696
+ return { passed: true, message: 'This SNMP community line does not use the "rw" keyword.', ruleId: "NET-SNMP-004", nodeId: node.id, level: "info", loc: node.loc };
20636
20697
  }
20637
20698
  };
20638
20699
  var globalStatementsCache = /* @__PURE__ */ new WeakMap();
@@ -20650,7 +20711,7 @@ var globalStatementsOf = (ast) => {
20650
20711
  if (n.type === "comment") continue;
20651
20712
  const id = n.id.trim().toLowerCase();
20652
20713
  statements.add(id);
20653
- if (/^(feature\s|vrf context\s|vdc\s)/.test(id)) nxos = true;
20714
+ if (/^(feature\s|vrf context\s|vdc\s)/.test(id) || NXOS_STATEMENT_MARKERS.some((m) => m.test(id))) nxos = true;
20654
20715
  }
20655
20716
  };
20656
20717
  walk(ast);
@@ -20661,6 +20722,11 @@ var globalStatementsOf = (ast) => {
20661
20722
  globalStatementsCache.set(ast, result2);
20662
20723
  return result2;
20663
20724
  };
20725
+ var isAdminDown = (node, context) => isNxosConfiguration(context) ? !isNxosInterfaceEnabled(node) : isShutdown3(node);
20726
+ var isNxosConfiguration = (context) => {
20727
+ const ast = context?.getAst?.();
20728
+ return ast !== void 0 && globalStatementsOf(ast).nxos;
20729
+ };
20664
20730
  var isCdpDisabledGlobally = (ast) => {
20665
20731
  if (!ast) return false;
20666
20732
  const { statements, nxos } = globalStatementsOf(ast);
@@ -21022,6 +21088,7 @@ var bgpKeyNotJudged = (ast, node) => {
21022
21088
  return head === "neighbor" && kind !== void 0 || head === "template" && kind === "peer" && name !== void 0;
21023
21089
  });
21024
21090
  };
21091
+ var NXOS_PASSWORD_POLICIES = /* @__PURE__ */ new Set(["strength-check", "secure-mode", "prompt username"]);
21025
21092
  var CiscoNoPlaintextPasswords = {
21026
21093
  id: "NET-SEC-001",
21027
21094
  selector: "password",
@@ -21063,13 +21130,20 @@ var CiscoNoPlaintextPasswords = {
21063
21130
  };
21064
21131
  }
21065
21132
  const onLine = ast ? isLineConfigPassword(ast, node) : false;
21066
- return evaluatePasswordStorage({
21133
+ if (!onLine && NXOS_PASSWORD_POLICIES.has(params.slice(1).join(" ").toLowerCase())) {
21134
+ return notApplicable2;
21135
+ }
21136
+ const result2 = evaluatePasswordStorage({
21067
21137
  ruleId: "NET-SEC-001",
21068
21138
  node,
21069
21139
  label: onLine ? "line password" : '"password" command',
21070
21140
  fix: onLine ? 'Line passwords cannot use strong storage: use "login local" with "username <name> secret" (type 8/9) or AAA instead.' : `Use "secret" with ${STRONG_STORAGE_HINT} where the platform supports it.`,
21071
21141
  args: params.slice(1)
21072
21142
  });
21143
+ if (onLine && NXOS_PASSWORD_POLICIES.has(params.slice(1).join(" ").toLowerCase())) {
21144
+ return { ...result2, nodeId: "password ****" };
21145
+ }
21146
+ return result2;
21073
21147
  }
21074
21148
  };
21075
21149
  var CiscoNoPlaintextUsernamePasswords = {
@@ -21423,16 +21497,17 @@ var CiscoBgpNeighborAuthentication = {
21423
21497
  return passResult("CISCO-BGP-002", node, "All BGP neighbors have authentication.");
21424
21498
  }
21425
21499
  };
21500
+ var isDynamicAsPrefixPeer = (peer) => peer.id.includes("/") && peer.remoteAs.toLowerCase() === "route-map";
21426
21501
  var CiscoBgpTtlSecurity = {
21427
21502
  id: "CISCO-BGP-003",
21428
21503
  selector: "router bgp",
21429
- vendor: "cisco-ios",
21504
+ vendor: ["cisco-ios", "cisco-nxos"],
21430
21505
  category: "Routing",
21431
21506
  metadata: {
21432
21507
  level: "warning",
21433
21508
  obu: "Security",
21434
21509
  owner: "SecOps",
21435
- remediation: 'Configure "neighbor <ip> ttl-security hops <1-254>" for eBGP peers.',
21510
+ remediation: 'Configure "neighbor <ip> ttl-security hops <1-254>" for eBGP peers. On NX-OS, configure "ttl-security hops <1-254>" under "neighbor <ip>" or its "template peer".',
21436
21511
  security: {
21437
21512
  cwe: ["CWE-290"]
21438
21513
  },
@@ -21443,19 +21518,20 @@ var CiscoBgpTtlSecurity = {
21443
21518
  },
21444
21519
  check: (node) => {
21445
21520
  const ebgp = bgpPeers(node).filter(
21446
- (p) => bgpSessionKind(node, p) !== "ibgp" && !findBgpNeighborCommand(p.lines, "ebgp-multihop")
21521
+ (p) => bgpSessionKind(node, p) !== "ibgp" && (isDynamicAsPrefixPeer(p) || !findBgpNeighborCommand(p.lines, "ebgp-multihop"))
21447
21522
  );
21448
21523
  if (ebgp.length === 0) {
21449
21524
  return passResult("CISCO-BGP-003", node, "No eBGP neighbors configured.");
21450
21525
  }
21451
- const findings = ebgp.filter((p) => !findBgpNeighborCommand(p.lines, "ttl-security")).map(
21452
- (p) => offenderResult(
21526
+ const findings = ebgp.filter((p) => !findBgpNeighborCommand(p.lines, "ttl-security")).map((p) => {
21527
+ const line = peerLine(p, node);
21528
+ return offenderResult(
21453
21529
  "CISCO-BGP-003",
21454
- peerLine(p, node),
21455
- `eBGP peer ${p.id} has no TTL security (GTSM). Configure "neighbor ${p.id} ttl-security hops 1".`,
21530
+ line,
21531
+ `eBGP peer ${p.id} has no TTL security (GTSM). Configure ${line.children.length > 0 ? `"ttl-security hops 1" under "neighbor ${p.id}" or its "template peer"` : `"neighbor ${p.id} ttl-security hops 1"`}.`,
21456
21532
  "warning"
21457
- )
21458
- );
21533
+ );
21534
+ });
21459
21535
  if (findings.length > 0) return findings;
21460
21536
  return passResult("CISCO-BGP-003", node, "eBGP peers have TTL security configured.");
21461
21537
  }
@@ -21463,44 +21539,62 @@ var CiscoBgpTtlSecurity = {
21463
21539
  var CiscoBgpMaxPrefix = {
21464
21540
  id: "CISCO-BGP-004",
21465
21541
  selector: "router bgp",
21466
- vendor: "cisco-ios",
21542
+ vendor: ["cisco-ios", "cisco-nxos"],
21467
21543
  category: "Routing",
21468
21544
  metadata: {
21469
21545
  level: "warning",
21470
21546
  obu: "Network Engineering",
21471
21547
  owner: "NetOps",
21472
- remediation: 'Configure "neighbor <ip> maximum-prefix <limit> <threshold> restart <minutes>" to prevent route table exhaustion.'
21548
+ remediation: `Configure "neighbor <ip> maximum-prefix <limit> <threshold> restart <minutes>" to prevent route table exhaustion. On NX-OS, configure "maximum-prefix <limit>" under the neighbor's address family or its "template peer-policy".`
21473
21549
  },
21474
21550
  check: (node) => {
21475
21551
  const peers = bgpPeers(node);
21476
21552
  if (peers.length === 0) {
21477
21553
  return passResult("CISCO-BGP-004", node, "No BGP neighbors configured.");
21478
21554
  }
21479
- const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "maximum-prefix")).map(
21480
- (p) => offenderResult(
21555
+ const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "maximum-prefix")).map((p) => {
21556
+ const line = peerLine(p, node);
21557
+ return offenderResult(
21481
21558
  "CISCO-BGP-004",
21482
- peerLine(p, node),
21483
- `BGP peer ${p.id} has no maximum-prefix limit. Configure one to prevent route table exhaustion.`,
21559
+ line,
21560
+ `BGP peer ${p.id} has no maximum-prefix limit. Configure ${line.children.length > 0 ? `"maximum-prefix <limit>" under the neighbor's address family or its "template peer-policy"` : "one to prevent route table exhaustion"}.`,
21484
21561
  "warning"
21485
- )
21486
- );
21562
+ );
21563
+ });
21487
21564
  if (findings.length > 0) return findings;
21488
21565
  return passResult("CISCO-BGP-004", node, "BGP peers have maximum-prefix configured.");
21489
21566
  }
21490
21567
  };
21568
+ var NXOS_LOG_NEIGHBOR_CHANGES = /^(?:no\s+)?log-neighbor-changes\s*$/i;
21569
+ var NXOS_BGP_CHILD = /^(?:vrf\s+\S|template\s+peer\s+\S)/i;
21491
21570
  var CiscoBgpLogNeighborChanges = {
21492
21571
  id: "CISCO-BGP-005",
21493
21572
  selector: "router bgp",
21494
- vendor: "cisco-ios",
21573
+ vendor: ["cisco-ios", "cisco-nxos"],
21495
21574
  category: "Routing",
21496
21575
  metadata: {
21497
21576
  level: "info",
21498
21577
  obu: "Network Engineering",
21499
21578
  owner: "NetOps",
21500
- remediation: 'Configure "bgp log-neighbor-changes" under BGP process.'
21579
+ remediation: 'Configure "bgp log-neighbor-changes" under BGP process. On NX-OS, configure "log-neighbor-changes" under "router bgp".'
21501
21580
  },
21502
- check: (node) => {
21581
+ check: (node, context) => {
21582
+ const nxosLine = node.children.filter((c) => NXOS_LOG_NEIGHBOR_CHANGES.test(c.id.trim())).pop();
21583
+ if (nxosLine && !/^no\s/i.test(nxosLine.id.trim())) {
21584
+ return passResult("CISCO-BGP-005", nxosLine, "BGP log-neighbor-changes is enabled.");
21585
+ }
21503
21586
  if (!hasBgpLogNeighborChanges2(node)) {
21587
+ const nxos = nxosLine !== void 0 || isNxosConfiguration(context) || node.children.some((c) => NXOS_BGP_CHILD.test(c.id.trim()) || /^neighbor\s/i.test(c.id.trim()) && c.children.length > 0);
21588
+ if (nxos) {
21589
+ return {
21590
+ passed: false,
21591
+ message: 'BGP neighbor-change logging is not configured. Configure "log-neighbor-changes" under "router bgp".',
21592
+ ruleId: "CISCO-BGP-005",
21593
+ nodeId: node.id,
21594
+ level: "info",
21595
+ loc: node.loc
21596
+ };
21597
+ }
21504
21598
  const explicitOff = hasChildCommand(node, "no bgp log-neighbor-changes");
21505
21599
  return {
21506
21600
  passed: false,
@@ -21514,10 +21608,19 @@ var CiscoBgpLogNeighborChanges = {
21514
21608
  return passResult("CISCO-BGP-005", node, "BGP log-neighbor-changes is enabled.");
21515
21609
  }
21516
21610
  };
21611
+ var systemDefaultSwitchport = (ast) => {
21612
+ let on = false;
21613
+ for (const n of ast.flatMap((x) => x.type === "virtual_root" ? x.children : [x])) {
21614
+ const id = n.id.trim().toLowerCase();
21615
+ if (id === "system default switchport") on = true;
21616
+ else if (id === "no system default switchport") on = false;
21617
+ }
21618
+ return on;
21619
+ };
21517
21620
  var CiscoWanUrpf = {
21518
21621
  id: "CISCO-DATA-001",
21519
21622
  selector: "interface",
21520
- vendor: "cisco-ios",
21623
+ vendor: ["cisco-ios", "cisco-nxos"],
21521
21624
  category: "Protocol-Security",
21522
21625
  metadata: {
21523
21626
  level: "warning",
@@ -21532,8 +21635,10 @@ var CiscoWanUrpf = {
21532
21635
  { type: "general", label: "urpf" }
21533
21636
  ]
21534
21637
  },
21535
- check: (node) => {
21536
- if (isShutdown3(node) || isLoopbackInterface(node.id) || isTunnelInterface(node.id)) {
21638
+ check: (node, context) => {
21639
+ const ast = context?.getAst?.();
21640
+ const nxosSwitchport = isNxosConfiguration(context) && !hasChildCommand(node, "no switchport") && (node.children.some((c) => /^switchport(?:\s|$)/i.test(c.id.trim())) || ast !== void 0 && systemDefaultSwitchport(ast));
21641
+ if (isAdminDown(node, context) || isLoopbackInterface(node.id) || isTunnelInterface(node.id) || nxosSwitchport) {
21537
21642
  return passResult("CISCO-DATA-001", node, "Not applicable.");
21538
21643
  }
21539
21644
  if (!isWanInterface(node)) {
@@ -21650,7 +21755,7 @@ var CiscoWanNoProxyArp = {
21650
21755
  var CiscoNoDirectedBroadcast = {
21651
21756
  id: "CISCO-DATA-005",
21652
21757
  selector: "interface",
21653
- vendor: "cisco-ios",
21758
+ vendor: ["cisco-ios", "cisco-nxos"],
21654
21759
  category: "Service-Hardening",
21655
21760
  metadata: {
21656
21761
  level: "error",
@@ -21666,8 +21771,8 @@ var CiscoNoDirectedBroadcast = {
21666
21771
  { type: "general", label: "smurf-attack" }
21667
21772
  ]
21668
21773
  },
21669
- check: (node) => {
21670
- if (isShutdown3(node) || isLoopbackInterface(node.id)) {
21774
+ check: (node, context) => {
21775
+ if (isAdminDown(node, context) || isLoopbackInterface(node.id)) {
21671
21776
  return passResult("CISCO-DATA-005", node, "Not applicable.");
21672
21777
  }
21673
21778
  if (hasChildCommand(node, "ip directed-broadcast") && !hasNoDirectedBroadcast(node)) {
@@ -21686,7 +21791,7 @@ var CiscoNoDirectedBroadcast = {
21686
21791
  var CiscoSnmpNoDefaultCommunity = {
21687
21792
  id: "CISCO-SNMP-001",
21688
21793
  selector: "snmp-server community",
21689
- vendor: "cisco-ios",
21794
+ vendor: ["cisco-ios", "cisco-nxos"],
21690
21795
  category: "Protocol-Security",
21691
21796
  metadata: {
21692
21797
  level: "error",
@@ -21876,7 +21981,7 @@ var CiscoUndefinedFilterAcl = {
21876
21981
  )
21877
21982
  };
21878
21983
  var ACL_USAGE_EFFECTS = {
21879
- "management-filter": "IOS does not document what a missing ACL does here; it may admit every host or none.",
21984
+ "management-filter": "Cisco's ACL guide says all packets pass when an access list referenced by name does not exist. It does not say so for this command or for numbered ACLs, so assume this filter admits every host.",
21880
21985
  "route-map-match": "The route-map entry does not match what was intended.",
21881
21986
  "class-map-match": "The class does not classify the intended traffic.",
21882
21987
  "crypto-match": "The crypto map (or GETVPN group) protects no traffic, or not the intended traffic.",
@@ -22232,26 +22337,34 @@ var NxosSecretStorage = {
22232
22337
  },
22233
22338
  check: judgeWholeConfig("CISCO-SEC-002", "No RADIUS or TACACS+ key is stored in plain text or as type 7.", (ast, scope) => {
22234
22339
  const findings = [];
22340
+ const radsec = /* @__PURE__ */ new Set();
22235
22341
  let aes = false;
22342
+ let tls = false;
22236
22343
  walkStatements(ast, (node) => {
22237
22344
  if (/^feature\s+password\s+encryption\s+aes\b/i.test(node.id)) aes = true;
22345
+ if (/^radius-server\s+secure\s+tls\s*$/i.test(node.id)) tls = true;
22238
22346
  const match = nxosAaaSecret(node);
22239
22347
  const value2 = match?.value;
22240
22348
  if (!match || !value2 || value2.storage === "ok") return;
22241
22349
  if (value2.storage === "plain" && isPlaceholderSecret(node.params.slice(value2.from, value2.to).join(" "))) return;
22242
22350
  const masked = maskSecretParams(node.params, value2.from);
22243
22351
  const plain = value2.storage === "plain";
22244
- findings.push({
22352
+ const finding = {
22245
22353
  node,
22246
22354
  level: plain ? "error" : "warning",
22247
22355
  message: plain ? `${match.label} is stored in plain text: "${masked}". ${NXOS_TYPE6}` : `${match.label} is stored as type 7, a reversible encoding: "${masked}". ${NXOS_TYPE6}`,
22248
22356
  masked
22249
- });
22357
+ };
22358
+ findings.push(finding);
22359
+ if (node.params[0]?.toLowerCase() === "radius-server" && value2.to === value2.from + 1 && node.params[value2.from]?.toLowerCase() === "radsec") {
22360
+ radsec.add(finding);
22361
+ }
22250
22362
  });
22363
+ const judged = tls ? findings.filter((f) => !radsec.has(f)) : findings;
22251
22364
  if (!aes && !scope.snippet) {
22252
- for (const f of findings) f.message += ' This configuration has no "feature password encryption aes".';
22365
+ for (const f of judged) f.message += ' This configuration has no "feature password encryption aes".';
22253
22366
  }
22254
- return findings;
22367
+ return judged;
22255
22368
  })
22256
22369
  };
22257
22370
  var allCiscoRules = [
@@ -22279,7 +22392,7 @@ var allCiscoRules = [
22279
22392
  EnableSecretStrong,
22280
22393
  CiscoNoPlaintextPasswords,
22281
22394
  CiscoNoPlaintextUsernamePasswords,
22282
- // Ported from the former commercial set (decision 0001 S3a)
22395
+ // Ported rules
22283
22396
  CiscoSshVersion2,
22284
22397
  NxosTelnetFeature,
22285
22398
  CiscoLoginBannerNoDisclosure,
@@ -22295,16 +22408,16 @@ var allCiscoRules = [
22295
22408
  CiscoWanNoIpUnreachables,
22296
22409
  CiscoWanNoProxyArp,
22297
22410
  CiscoNoDirectedBroadcast,
22298
- // Paid-only rules opened (gecko#60)
22411
+ // More ported rules
22299
22412
  CiscoSnmpNoDefaultCommunity,
22300
22413
  CiscoHsrpMd5Authentication,
22301
- // Reference rules on the symbol table (gecko#59, experimental)
22414
+ // Reference rules on the symbol table
22302
22415
  CiscoUndefinedFilterAcl,
22303
22416
  CiscoUndefinedAclReference,
22304
22417
  CiscoUndefinedRouteMap,
22305
22418
  CiscoUndefinedPrefixList,
22306
22419
  CiscoUnusedObject,
22307
- // Secret storage (gecko#60)
22420
+ // Secret storage
22308
22421
  CiscoSecretStorage,
22309
22422
  NxosSecretStorage
22310
22423
  ];
@@ -22315,6 +22428,1593 @@ var isTopLevel = (node, context) => {
22315
22428
  return !ast || ast.includes(node);
22316
22429
  };
22317
22430
 
22431
+ // ../rules-default/src/cisco/nxos-rules.ts
22432
+ var nxosIndexCache = /* @__PURE__ */ new WeakMap();
22433
+ var WHOLE_MARKER = /^(?:hostname|switchname|version)\s+\S/i;
22434
+ var buildNxosIndex = (ast) => {
22435
+ const top = [];
22436
+ for (const node of ast) {
22437
+ if (node.type === "comment") continue;
22438
+ if (node.type === "virtual_root") {
22439
+ for (const child of node.children) {
22440
+ if (child.type !== "comment") top.push({ node: child, text: child.id.trim() });
22441
+ }
22442
+ continue;
22443
+ }
22444
+ top.push({ node, text: node.id.trim() });
22445
+ }
22446
+ const anchor = top[0]?.node;
22447
+ const whole = anchor !== void 0 && anchor.source !== "snippet" && top.some((l) => WHOLE_MARKER.test(l.text));
22448
+ return { top, anchor, whole };
22449
+ };
22450
+ var nxosIndexOf = (context) => {
22451
+ const ast = context?.getAst?.();
22452
+ if (!ast) return void 0;
22453
+ let index = nxosIndexCache.get(ast);
22454
+ if (!index) {
22455
+ index = buildNxosIndex(ast);
22456
+ nxosIndexCache.set(ast, index);
22457
+ }
22458
+ return index;
22459
+ };
22460
+ var judgedOnce = (judge) => (node, context) => {
22461
+ const index = nxosIndexOf(context);
22462
+ if (!index || index.anchor !== node) return [];
22463
+ return judge(index, node);
22464
+ };
22465
+ var topMatching = (index, pattern) => index.top.filter((l) => pattern.test(l.text));
22466
+ var NO_FORM = /^no\s/i;
22467
+ var lastSettings = (index, name, key = () => "") => {
22468
+ const pattern = new RegExp(`^(?:no\\s+)?${name.source}`, "i");
22469
+ const last = /* @__PURE__ */ new Map();
22470
+ for (const l of index.top) {
22471
+ if (!pattern.test(l.text)) continue;
22472
+ const negated = NO_FORM.test(l.text);
22473
+ const k = key(l.text.replace(/^no\s+/i, "").split(/\s+/));
22474
+ if (k === void 0) {
22475
+ if (negated) last.clear();
22476
+ continue;
22477
+ }
22478
+ last.delete(k);
22479
+ last.set(k, l);
22480
+ }
22481
+ return [...last.values()].filter((l) => !NO_FORM.test(l.text));
22482
+ };
22483
+ var lastSetting = (index, name) => lastSettings(index, name)[0];
22484
+ var liveLines = (index, name, key) => {
22485
+ const pattern = new RegExp(`^(?:no\\s+)?${name.source}`, "i");
22486
+ let live = [];
22487
+ for (const l of index.top) {
22488
+ if (!pattern.test(l.text)) continue;
22489
+ const k = key(l.text.replace(/^no\s+/i, "").split(/\s+/));
22490
+ if (NO_FORM.test(l.text)) live = live.filter((x) => x.key !== k);
22491
+ else live.push({ line: l, key: k });
22492
+ }
22493
+ return live.map((x) => x.line);
22494
+ };
22495
+ var passAt = (ruleId, node, message) => ({
22496
+ passed: true,
22497
+ message,
22498
+ ruleId,
22499
+ nodeId: maskSecretLine(node),
22500
+ level: "info",
22501
+ loc: locOf(node)
22502
+ });
22503
+ var failAt = (ruleId, node, level, message, absent) => ({
22504
+ passed: false,
22505
+ message,
22506
+ ruleId,
22507
+ nodeId: maskSecretLine(node),
22508
+ level,
22509
+ loc: locOf(node),
22510
+ ...absent === true ? { absent: true } : {}
22511
+ });
22512
+ var tags = (...labels) => labels.map((label) => ({ type: "general", label }));
22513
+ var SSH_KEY_TYPES = /* @__PURE__ */ new Set(["rsa", "dsa", "ecdsa"]);
22514
+ var sshKeyOf = (words) => {
22515
+ if (words.some((w) => w.toLowerCase() === "export")) return "export";
22516
+ const type = words[2]?.toLowerCase();
22517
+ return type !== void 0 && SSH_KEY_TYPES.has(type) ? type : void 0;
22518
+ };
22519
+ var NxosSshKeyStrength = {
22520
+ id: "NXOS-MGMT-001",
22521
+ vendor: "cisco-nxos",
22522
+ category: "Protocol-Security",
22523
+ metadata: {
22524
+ level: "warning",
22525
+ obu: "Security",
22526
+ owner: "SecOps",
22527
+ description: "SSH server key must be RSA of at least 2048 bits or ECDSA (NX-OS)",
22528
+ remediation: 'Disable SSH ("no feature ssh"), generate an RSA key of 2048 bits or more ("ssh key rsa 2048 force") or an ECDSA key ("ssh key ecdsa 256 force"), then enable SSH again ("feature ssh").',
22529
+ security: { cwe: ["CWE-326"] },
22530
+ tags: tags("ssh", "encryption", "management")
22531
+ },
22532
+ check: judgedOnce((index, anchor) => {
22533
+ const id = "NXOS-MGMT-001";
22534
+ const keys = lastSettings(index, /ssh\s+key(?:\s|$)/, sshKeyOf).filter((l) => !/\bexport\b/i.test(l.text));
22535
+ if (keys.length === 0) {
22536
+ const feature = topMatching(index, /^(?:no\s+)?feature\s+ssh\s*$/i).pop();
22537
+ if (index.whole && !(feature && NO_FORM.test(feature.text))) {
22538
+ return [
22539
+ failAt(
22540
+ id,
22541
+ anchor,
22542
+ "info",
22543
+ 'No "ssh key" line: the switch uses its default server key, RSA 1024 bits.',
22544
+ true
22545
+ )
22546
+ ];
22547
+ }
22548
+ return [passAt(id, anchor, "No SSH server key is configured here.")];
22549
+ }
22550
+ const results = [];
22551
+ for (const key of keys) {
22552
+ const m = key.text.match(/^ssh\s+key\s+(\S+)(?:\s+(\d+))?/i);
22553
+ const type = m?.[1]?.toLowerCase();
22554
+ if (type === "dsa") {
22555
+ results.push(failAt(id, key.node, "warning", "The SSH server key is DSA, which is always 1024 bits and deprecated: use RSA of 2048 bits or more, or ECDSA."));
22556
+ } else if (type === "rsa") {
22557
+ const bits = m?.[2] === void 0 ? null : parseInteger(m[2]);
22558
+ if (bits === null || bits < 2048) {
22559
+ results.push(
22560
+ failAt(id, key.node, "warning", `The SSH server key is RSA of ${bits ?? 1024} bits: use 2048 bits or more, or ECDSA.`)
22561
+ );
22562
+ }
22563
+ }
22564
+ }
22565
+ if (results.length > 0) return results;
22566
+ const first2 = keys[0];
22567
+ return [passAt(id, first2 ? first2.node : anchor, "The SSH server key is RSA of 2048 bits or more, or ECDSA.")];
22568
+ })
22569
+ };
22570
+ var NxosSshAlgorithms = {
22571
+ id: "NXOS-MGMT-002",
22572
+ vendor: "cisco-nxos",
22573
+ category: "Protocol-Security",
22574
+ metadata: {
22575
+ level: "warning",
22576
+ obu: "Security",
22577
+ owner: "SecOps",
22578
+ description: "SSH must not enable all or weak algorithms (NX-OS)",
22579
+ remediation: 'Remove "ssh ciphers all", "ssh kexalgos all", "ssh macs all" and "ssh cipher-mode weak" so the switch offers only its strong default algorithms; name a single algorithm only where a client needs it.',
22580
+ security: { cwe: ["CWE-327"] },
22581
+ tags: tags("ssh", "encryption")
22582
+ },
22583
+ check: judgedOnce((index, anchor) => {
22584
+ const id = "NXOS-MGMT-002";
22585
+ const weak = lastSettings(index, /ssh\s+(?:ciphers|kexalgos|macs|cipher-mode)(?:\s|$)/, (words) => words[1]?.toLowerCase()).filter(
22586
+ (l) => /^ssh\s+(?:(?:ciphers|kexalgos|macs)\s+all|cipher-mode\s+weak)\s*$/i.test(l.text)
22587
+ );
22588
+ if (weak.length === 0) return [passAt(id, anchor, "SSH offers only its default or named algorithms.")];
22589
+ return weak.map(
22590
+ (l) => failAt(id, l.node, "warning", `"${l.text}" lets SSH negotiate weak algorithms: keep the strong defaults.`)
22591
+ );
22592
+ })
22593
+ };
22594
+ var NxosSshLoginAttempts = {
22595
+ id: "NXOS-MGMT-003",
22596
+ vendor: "cisco-nxos",
22597
+ category: "Authentication",
22598
+ metadata: {
22599
+ level: "warning",
22600
+ obu: "Security",
22601
+ owner: "SecOps",
22602
+ description: "SSH must allow at most 3 login attempts (NX-OS)",
22603
+ remediation: 'Set "ssh login-attempts 3" or lower (3 is the default).',
22604
+ security: { cwe: ["CWE-307"] },
22605
+ tags: tags("ssh", "brute-force")
22606
+ },
22607
+ check: judgedOnce((index, anchor) => {
22608
+ const id = "NXOS-MGMT-003";
22609
+ const line = lastSetting(index, /ssh\s+login-attempts(?:\s|$)/);
22610
+ if (!line) return [passAt(id, anchor, "SSH login attempts are at the default of 3.")];
22611
+ const attempts = parseInteger(line.text.match(/^ssh\s+login-attempts\s+(\d+)\s*$/i)?.[1] ?? "");
22612
+ if (attempts !== null && attempts > 3) {
22613
+ return [failAt(id, line.node, "warning", `SSH allows ${attempts} login attempts per session: set 3 or fewer.`)];
22614
+ }
22615
+ return [passAt(id, line.node, "SSH allows at most 3 login attempts.")];
22616
+ })
22617
+ };
22618
+ var NxosLoginBlockFor = {
22619
+ id: "NXOS-MGMT-004",
22620
+ vendor: "cisco-nxos",
22621
+ category: "Authentication",
22622
+ metadata: {
22623
+ level: "warning",
22624
+ obu: "Security",
22625
+ owner: "SecOps",
22626
+ description: "Repeated failed logins must start a quiet period (NX-OS)",
22627
+ remediation: 'Configure "system login block-for <seconds> attempts <tries> within <seconds>" (written "login block-for ..." on releases before the rename), for example "system login block-for 120 attempts 3 within 60".',
22628
+ security: { cwe: ["CWE-307"] },
22629
+ tags: tags("login", "brute-force")
22630
+ },
22631
+ check: judgedOnce((index, anchor) => {
22632
+ const id = "NXOS-MGMT-004";
22633
+ const setting2 = lastSetting(index, /(?:system\s+)?login\s+block-for(?:\s|$)/);
22634
+ const line = setting2 && /^(?:system\s+)?login\s+block-for\s+\d+\s+attempts\s+\d+\s+within\s+\d+/i.test(setting2.text) ? setting2 : void 0;
22635
+ if (line) return [passAt(id, line.node, "Repeated failed logins start a quiet period.")];
22636
+ if (index.whole) {
22637
+ return [
22638
+ failAt(
22639
+ id,
22640
+ anchor,
22641
+ "warning",
22642
+ 'No "system login block-for" is configured: repeated failed Telnet and SSH logins are never blocked.',
22643
+ true
22644
+ )
22645
+ ];
22646
+ }
22647
+ return [passAt(id, anchor, "Not a whole configuration: the login quiet period is not judged.")];
22648
+ })
22649
+ };
22650
+ var LINE_CONSOLE = /^line\s+console\s*$/i;
22651
+ var LINE_VTY = /^line\s+vty\s*$/i;
22652
+ var NxosConsoleExecTimeout = {
22653
+ id: "NXOS-MGMT-005",
22654
+ selector: "line console",
22655
+ vendor: "cisco-nxos",
22656
+ category: "Session-Management",
22657
+ metadata: {
22658
+ level: "warning",
22659
+ obu: "Security",
22660
+ owner: "SecOps",
22661
+ description: "Console sessions must time out within 15 minutes (NX-OS)",
22662
+ remediation: 'Configure "exec-timeout <minutes>" under "line console" with 15 minutes or less (the NX-OS default is 30; 0 disables the timeout).',
22663
+ security: { cwe: ["CWE-613"] },
22664
+ tags: tags("session-management", "timeout", "console")
22665
+ },
22666
+ check: (node) => {
22667
+ const id = "NXOS-MGMT-005";
22668
+ if (!LINE_CONSOLE.test(node.id.trim())) return [];
22669
+ const timeout = node.children.filter((c) => /^exec-timeout\b/i.test(c.id.trim())).pop();
22670
+ if (!timeout) {
22671
+ return failAt(id, node, "warning", "The console has no exec-timeout: idle sessions end after the default 30 minutes.");
22672
+ }
22673
+ const minutes = parseInteger(timeout.params[1] ?? "");
22674
+ if (minutes === 0) {
22675
+ return failAt(id, timeout, "warning", "The console exec-timeout is 0, which disables the timeout: set 15 minutes or less.");
22676
+ }
22677
+ if (minutes !== null && minutes > 15) {
22678
+ return failAt(id, timeout, "warning", `The console exec-timeout is ${minutes} minutes: set 15 minutes or less.`);
22679
+ }
22680
+ return passAt(id, timeout, "The console exec-timeout is 15 minutes or less.");
22681
+ }
22682
+ };
22683
+ var VTY_ACCESS_CLASS_IN = /^(?:ip\s+)?access-class\s+\S+\s+in\s*$/i;
22684
+ var NxosVtyAccessClass = {
22685
+ id: "NXOS-MGMT-006",
22686
+ selector: "line vty",
22687
+ vendor: "cisco-nxos",
22688
+ category: "Session-Management",
22689
+ metadata: {
22690
+ level: "warning",
22691
+ obu: "Security",
22692
+ owner: "SecOps",
22693
+ description: "VTY lines must restrict sources with an inbound access class (NX-OS)",
22694
+ remediation: 'Define an ACL of management hosts and apply it under "line vty" with "ip access-class <acl> in" (shown as "access-class <acl> in" in the running configuration); add "ipv6 access-class <acl> in" when the switch is managed over IPv6.',
22695
+ security: { cwe: ["CWE-284"] },
22696
+ tags: tags("management", "access-control", "vty")
22697
+ },
22698
+ check: (node) => {
22699
+ const id = "NXOS-MGMT-006";
22700
+ if (!LINE_VTY.test(node.id.trim())) return [];
22701
+ const ipv4 = node.children.find((c) => VTY_ACCESS_CLASS_IN.test(c.id.trim()));
22702
+ if (ipv4) return passAt(id, ipv4, "VTY lines accept connections only from the sources the access class permits.");
22703
+ const ipv6Only = node.children.some((c) => /^ipv6\s+access-class\s+\S+\s+in\s*$/i.test(c.id.trim()));
22704
+ return failAt(
22705
+ id,
22706
+ node,
22707
+ "warning",
22708
+ ipv6Only ? "VTY lines have only an IPv6 access class: IPv4 management connections are accepted from any source." : "VTY lines have no inbound access class: management connections are accepted from any source."
22709
+ );
22710
+ }
22711
+ };
22712
+ var NxosBannerRequired = {
22713
+ id: "NXOS-MGMT-007",
22714
+ vendor: "cisco-nxos",
22715
+ category: "Documentation",
22716
+ metadata: {
22717
+ level: "info",
22718
+ obu: "Security",
22719
+ owner: "SecOps",
22720
+ description: "A login banner (MOTD) must be configured (NX-OS)",
22721
+ remediation: 'Configure a warning banner with "banner motd #<text>#" that says the system is for authorised use only; agree the wording with legal counsel.',
22722
+ tags: tags("banner", "legal", "management")
22723
+ },
22724
+ check: judgedOnce((index, anchor) => {
22725
+ const id = "NXOS-MGMT-007";
22726
+ const banner = lastSetting(index, /banner\s+motd\b/);
22727
+ if (banner) return [passAt(id, banner.node, "A MOTD banner is configured.")];
22728
+ if (index.whole) {
22729
+ return [
22730
+ failAt(
22731
+ id,
22732
+ anchor,
22733
+ "info",
22734
+ 'No "banner motd" is configured: logins show the default "User Access Verification" text.',
22735
+ true
22736
+ )
22737
+ ];
22738
+ }
22739
+ return [passAt(id, anchor, "Not a whole configuration: the MOTD banner is not judged.")];
22740
+ })
22741
+ };
22742
+ var NxosBannerDisclosure = {
22743
+ id: "NXOS-MGMT-008",
22744
+ selector: "banner motd",
22745
+ vendor: "cisco-nxos",
22746
+ category: "Service-Hardening",
22747
+ metadata: {
22748
+ level: "warning",
22749
+ obu: "Security",
22750
+ owner: "SecOps",
22751
+ description: "The MOTD banner must not name the platform or software version (NX-OS)",
22752
+ remediation: 'Remove vendor, model, software and host details from "banner motd"; keep a generic legal warning.',
22753
+ security: { cwe: ["CWE-200"] },
22754
+ tags: tags("banner", "information-disclosure")
22755
+ },
22756
+ check: (node) => {
22757
+ const id = "NXOS-MGMT-008";
22758
+ if (!/^banner\s+motd\b/i.test(node.id.trim())) return [];
22759
+ if (/\b(?:cisco|nexus|nx-os|nxos)\b|\bversion\s+\d+\.\d+/i.test(node.rawText)) {
22760
+ return failAt(
22761
+ id,
22762
+ node,
22763
+ "warning",
22764
+ "The MOTD banner names the platform or software version: keep it a generic legal warning."
22765
+ );
22766
+ }
22767
+ return passAt(id, node, "The MOTD banner does not name the platform or software version.");
22768
+ }
22769
+ };
22770
+ var NxosNxapiHttp = {
22771
+ id: "NXOS-MGMT-009",
22772
+ vendor: "cisco-nxos",
22773
+ category: "Protocol-Security",
22774
+ metadata: {
22775
+ level: "error",
22776
+ obu: "Security",
22777
+ owner: "SecOps",
22778
+ description: "NX-API must not listen on HTTP (NX-OS)",
22779
+ remediation: 'Remove the HTTP listener ("no nxapi http") and use NX-API over HTTPS only ("nxapi https port 443"); NX-API sends the username and password with every request.',
22780
+ security: { cwe: ["CWE-319"] },
22781
+ tags: tags("nxapi", "cleartext", "management")
22782
+ },
22783
+ check: judgedOnce((index, anchor) => {
22784
+ const id = "NXOS-MGMT-009";
22785
+ const http = lastSetting(index, /nxapi\s+http(?:\s|$)/);
22786
+ if (!http || !/^nxapi\s+http\s+port\s+\d+/i.test(http.text)) return [passAt(id, anchor, "NX-API does not listen on HTTP.")];
22787
+ return [failAt(id, http.node, "error", "NX-API listens on HTTP: the username and password cross the network in clear text.")];
22788
+ })
22789
+ };
22790
+ var OLD_TLS = /* @__PURE__ */ new Set(["tlsv1", "tlsv1.0", "tlsv1.1"]);
22791
+ var NxosNxapiTls = {
22792
+ id: "NXOS-MGMT-010",
22793
+ vendor: "cisco-nxos",
22794
+ category: "Protocol-Security",
22795
+ metadata: {
22796
+ level: "warning",
22797
+ obu: "Security",
22798
+ owner: "SecOps",
22799
+ description: "NX-API must not enable weak TLS ciphers or versions (NX-OS)",
22800
+ remediation: 'Remove "nxapi ssl ciphers weak" and set "nxapi ssl protocols TLSv1.2 TLSv1.3" (TLSv1.2 alone is the default).',
22801
+ security: { cwe: ["CWE-327"] },
22802
+ tags: tags("nxapi", "tls", "encryption")
22803
+ },
22804
+ check: judgedOnce((index, anchor) => {
22805
+ const id = "NXOS-MGMT-010";
22806
+ const results = [];
22807
+ const settings = [lastSetting(index, /nxapi\s+ssl[\s-]ciphers\s+weak\s*$/), lastSetting(index, /nxapi\s+ssl[\s-]protocols(?:\s|$)/)].filter((l) => l !== void 0).sort((a, b) => index.top.indexOf(a) - index.top.indexOf(b));
22808
+ for (const l of settings) {
22809
+ if (/^nxapi\s+ssl[\s-]ciphers\s+weak\s*$/i.test(l.text)) {
22810
+ results.push(failAt(id, l.node, "warning", 'NX-API allows weak TLS ciphers: remove "nxapi ssl ciphers weak".'));
22811
+ continue;
22812
+ }
22813
+ const list = l.text.match(/^nxapi\s+ssl[\s-]protocols\s+(.+)$/i)?.[1];
22814
+ if (list && list.split(/\s+/).some((t) => OLD_TLS.has(t.toLowerCase()))) {
22815
+ results.push(failAt(id, l.node, "warning", "NX-API enables TLS 1.0 or 1.1: allow TLSv1.2 and TLSv1.3 only."));
22816
+ }
22817
+ }
22818
+ if (results.length > 0) return results;
22819
+ return [passAt(id, anchor, "NX-API allows no weak TLS ciphers or versions.")];
22820
+ })
22821
+ };
22822
+ var NxosPasswordStrengthCheck = {
22823
+ id: "NXOS-AAA-001",
22824
+ vendor: "cisco-nxos",
22825
+ category: "Authentication",
22826
+ metadata: {
22827
+ level: "warning",
22828
+ obu: "Security",
22829
+ owner: "SecOps",
22830
+ description: "Password strength checking must not be disabled (NX-OS)",
22831
+ remediation: 'Enable password strength checking ("password strength-check"; it is on by default), then reset local passwords set while it was off: existing passwords are not re-checked.',
22832
+ security: { cwe: ["CWE-521"] },
22833
+ tags: tags("password", "local-accounts")
22834
+ },
22835
+ check: judgedOnce((index, anchor) => {
22836
+ const id = "NXOS-AAA-001";
22837
+ const line = topMatching(index, /^(?:no\s+)?password\s+strength-check\s*$/i).pop();
22838
+ if (line && /^no\s/i.test(line.text)) {
22839
+ return [failAt(id, line.node, "warning", "Password strength checking is disabled: weak local passwords are accepted.")];
22840
+ }
22841
+ return [passAt(id, line ? line.node : anchor, "Password strength checking is enabled.")];
22842
+ })
22843
+ };
22844
+ var NxosPasswordMinLength = {
22845
+ id: "NXOS-AAA-002",
22846
+ vendor: "cisco-nxos",
22847
+ category: "Authentication",
22848
+ metadata: {
22849
+ level: "warning",
22850
+ obu: "Security",
22851
+ owner: "SecOps",
22852
+ description: "Minimum password length must be at least 8 characters (NX-OS)",
22853
+ remediation: 'Set "userpassphrase min-length 8" or more (with "max-length" as needed).',
22854
+ security: { cwe: ["CWE-521"] },
22855
+ tags: tags("password", "local-accounts")
22856
+ },
22857
+ check: judgedOnce((index, anchor) => {
22858
+ const id = "NXOS-AAA-002";
22859
+ const line = lastSetting(index, /userpassphrase\b.*\bmin-length\b/);
22860
+ if (!line) return [passAt(id, anchor, "No minimum password length below 8 is configured.")];
22861
+ const length = parseInteger(line.text.match(/\bmin-length\s+(\d+)/i)?.[1] ?? "");
22862
+ if (length !== null && length < 8) {
22863
+ return [failAt(id, line.node, "warning", `The minimum password length is ${length}: set 8 or more.`)];
22864
+ }
22865
+ return [passAt(id, line.node, "The minimum password length is 8 or more.")];
22866
+ })
22867
+ };
22868
+ var LOGIN_GROUP = /^aaa\s+authentication\s+login\s+default\s+group\s+(\S+)/i;
22869
+ var loginGroup = (index) => {
22870
+ const line = lastSetting(index, /aaa\s+authentication\s+login\s+default(?:\s|$)/);
22871
+ const group = line?.text.match(LOGIN_GROUP)?.[1];
22872
+ return line && group ? { line, group } : void 0;
22873
+ };
22874
+ var NxosRemoteAaaLogin = {
22875
+ id: "NXOS-AAA-003",
22876
+ vendor: "cisco-nxos",
22877
+ category: "Authentication",
22878
+ metadata: {
22879
+ level: "warning",
22880
+ obu: "Security",
22881
+ owner: "SecOps",
22882
+ description: "Login must use a TACACS+ or RADIUS server group (NX-OS)",
22883
+ remediation: 'Define a TACACS+ or RADIUS server group ("aaa group server tacacs+ <group>") and use it for login ("aaa authentication login default group <group>"); local accounts remain the fallback when no server answers.',
22884
+ security: { cwe: ["CWE-1390"] },
22885
+ tags: tags("aaa", "tacacs", "radius")
22886
+ },
22887
+ check: judgedOnce((index, anchor) => {
22888
+ const id = "NXOS-AAA-003";
22889
+ const login = loginGroup(index);
22890
+ if (login) return [passAt(id, login.line.node, `Login authenticates against the "${login.group}" server group.`)];
22891
+ if (index.whole) {
22892
+ return [
22893
+ failAt(
22894
+ id,
22895
+ anchor,
22896
+ "warning",
22897
+ 'No "aaa authentication login default group" is configured: login uses only local accounts.',
22898
+ true
22899
+ )
22900
+ ];
22901
+ }
22902
+ return [passAt(id, anchor, "Not a whole configuration: the login method is not judged.")];
22903
+ })
22904
+ };
22905
+ var NxosAaaNoneMethod = {
22906
+ id: "NXOS-AAA-004",
22907
+ vendor: "cisco-nxos",
22908
+ category: "Authentication",
22909
+ metadata: {
22910
+ level: "error",
22911
+ obu: "Security",
22912
+ owner: "SecOps",
22913
+ description: "Login authentication must not fall back to no authentication (NX-OS)",
22914
+ remediation: 'Remove "none" from "aaa authentication login default|console ..."; without it the switch falls back to local accounts when no AAA server answers.',
22915
+ security: { cwe: ["CWE-287"] },
22916
+ tags: tags("aaa", "login")
22917
+ },
22918
+ check: judgedOnce((index, anchor) => {
22919
+ const id = "NXOS-AAA-004";
22920
+ const offenders = lastSettings(index, /aaa\s+authentication\s+login\s+(?:default|console)\b/, (words) => words[3]?.toLowerCase()).filter(
22921
+ (l) => l.text.toLowerCase().split(/\s+/).slice(4).includes("none")
22922
+ );
22923
+ if (offenders.length === 0) return [passAt(id, anchor, 'No login method list ends in "none".')];
22924
+ return offenders.map(
22925
+ (l) => failAt(id, l.node, "error", `"${l.text}" lets anyone log in without authentication when the servers do not answer: remove "none".`)
22926
+ );
22927
+ })
22928
+ };
22929
+ var NxosAaaAccounting = {
22930
+ id: "NXOS-AAA-005",
22931
+ vendor: "cisco-nxos",
22932
+ category: "Logging",
22933
+ metadata: {
22934
+ level: "warning",
22935
+ obu: "Security",
22936
+ owner: "SecOps",
22937
+ description: "AAA accounting must be sent to a server group (NX-OS)",
22938
+ remediation: 'Configure "aaa accounting default group <group>" so every command entered is recorded on the AAA servers.',
22939
+ tags: tags("aaa", "accounting")
22940
+ },
22941
+ check: judgedOnce((index, anchor) => {
22942
+ const id = "NXOS-AAA-005";
22943
+ const login = loginGroup(index);
22944
+ if (!login) return [];
22945
+ const accounting = lastSetting(index, /aaa\s+accounting\s+default(?:\s|$)/);
22946
+ if (accounting && /^aaa\s+accounting\s+default\s+group\s+\S+/i.test(accounting.text)) {
22947
+ return [passAt(id, accounting.node, "AAA accounting is sent to a server group.")];
22948
+ }
22949
+ if (!index.whole) return [passAt(id, anchor, "Not a whole configuration: AAA accounting is not judged.")];
22950
+ return [
22951
+ failAt(
22952
+ id,
22953
+ login.line.node,
22954
+ "warning",
22955
+ `Login uses the "${login.group}" server group but no "aaa accounting default group" is configured: commands entered are not recorded on the AAA servers.`,
22956
+ true
22957
+ )
22958
+ ];
22959
+ })
22960
+ };
22961
+ var NxosAaaCommandAuthorization = {
22962
+ id: "NXOS-AAA-006",
22963
+ vendor: "cisco-nxos",
22964
+ category: "Authentication",
22965
+ metadata: {
22966
+ level: "info",
22967
+ obu: "Security",
22968
+ owner: "SecOps",
22969
+ description: "Commands must be authorised by TACACS+ when TACACS+ handles login (NX-OS)",
22970
+ remediation: 'Configure "aaa authorization commands default group <group> local" and "aaa authorization config-commands default group <group> local".',
22971
+ security: { cwe: ["CWE-862"] },
22972
+ tags: tags("aaa", "tacacs", "authorization")
22973
+ },
22974
+ check: judgedOnce((index, anchor) => {
22975
+ const id = "NXOS-AAA-006";
22976
+ const login = loginGroup(index);
22977
+ if (!login) return [];
22978
+ const tacacs = login.group.toLowerCase() === "tacacs+" || index.top.some((l) => l.text.match(/^aaa\s+group\s+server\s+tacacs\+\s+(\S+)/i)?.[1] === login.group);
22979
+ if (!tacacs) return [];
22980
+ const authz = lastSettings(index, /aaa\s+authorization\s+(?:config-)?commands\s+default(?:\s|$)/, (words) => words[2]?.toLowerCase()).find(
22981
+ (l) => /^aaa\s+authorization\s+(?:config-)?commands\s+default\s+group\s+\S+/i.test(l.text)
22982
+ );
22983
+ if (authz) return [passAt(id, authz.node, "Commands are authorised by a server group.")];
22984
+ if (!index.whole) return [passAt(id, anchor, "Not a whole configuration: command authorization is not judged.")];
22985
+ return [
22986
+ failAt(
22987
+ id,
22988
+ login.line.node,
22989
+ "info",
22990
+ `Login uses the TACACS+ group "${login.group}" but no "aaa authorization commands default group" is configured: the TACACS+ server does not authorise each command.`,
22991
+ true
22992
+ )
22993
+ ];
22994
+ })
22995
+ };
22996
+ var NxosAaaServerKey = {
22997
+ id: "NXOS-AAA-007",
22998
+ vendor: "cisco-nxos",
22999
+ category: "Authentication",
23000
+ metadata: {
23001
+ level: "error",
23002
+ obu: "Security",
23003
+ owner: "SecOps",
23004
+ description: "TACACS+ and RADIUS servers must have a shared key (NX-OS)",
23005
+ remediation: 'Configure a key for every server: a global "tacacs-server key <key>" or "radius-server key <key>", or "key <key>" on each "tacacs-server host" or "radius-server host" line.',
23006
+ security: { cwe: ["CWE-319"] },
23007
+ tags: tags("aaa", "tacacs", "radius")
23008
+ },
23009
+ check: judgedOnce((index, anchor) => {
23010
+ const id = "NXOS-AAA-007";
23011
+ const results = [];
23012
+ for (const protocol of ["tacacs", "radius"]) {
23013
+ const globalKey = lastSetting(index, protocol === "tacacs" ? /tacacs-server\s+key(?:\s|$)/ : /radius-server\s+key(?:\s|$)/);
23014
+ if (globalKey && /^\S+\s+key\s+\S/i.test(globalKey.text)) continue;
23015
+ const hosts = /* @__PURE__ */ new Map();
23016
+ for (const l of index.top) {
23017
+ const negated = NO_FORM.test(l.text);
23018
+ const words = l.text.split(/\s+/).slice(negated ? 1 : 0);
23019
+ const host = words[2];
23020
+ if (words[0]?.toLowerCase() !== `${protocol}-server` || words[1]?.toLowerCase() !== "host" || !host) continue;
23021
+ if (negated) {
23022
+ if (words.length === 3) hosts.delete(host);
23023
+ continue;
23024
+ }
23025
+ const keyed = words.some((w) => w.toLowerCase() === "key");
23026
+ const seen = hosts.get(host);
23027
+ if (seen) seen.keyed ||= keyed;
23028
+ else hosts.set(host, { first: l, keyed });
23029
+ }
23030
+ const name = protocol === "tacacs" ? "TACACS+" : "RADIUS";
23031
+ for (const [host, { first: first2, keyed }] of hosts) {
23032
+ if (keyed) continue;
23033
+ results.push(
23034
+ index.whole ? failAt(
23035
+ id,
23036
+ first2.node,
23037
+ "error",
23038
+ `The ${name} server ${host} has no key and no global "${protocol}-server key" is set: the switch cannot authenticate to it.`
23039
+ ) : passAt(
23040
+ id,
23041
+ first2.node,
23042
+ `The ${name} server ${host} has no key on its lines, and the global "${protocol}-server key" is not in this text, so it is not judged.`
23043
+ )
23044
+ );
23045
+ }
23046
+ }
23047
+ if (results.length > 0) return results;
23048
+ return [passAt(id, anchor, "Every TACACS+ and RADIUS server has a key.")];
23049
+ })
23050
+ };
23051
+ var NxosLoginFailureLog = {
23052
+ id: "NXOS-AAA-008",
23053
+ vendor: "cisco-nxos",
23054
+ category: "Logging",
23055
+ metadata: {
23056
+ level: "info",
23057
+ obu: "Security",
23058
+ owner: "SecOps",
23059
+ description: "Failed login attempts must be logged (NX-OS)",
23060
+ remediation: 'Configure "login on-failure log" and "logging level authpriv 6" so failed logins reach the syslog server.',
23061
+ tags: tags("aaa", "logging", "login")
23062
+ },
23063
+ check: judgedOnce((index, anchor) => {
23064
+ const id = "NXOS-AAA-008";
23065
+ const line = lastSetting(index, /login\s+on-failure\s+log\s*$/);
23066
+ if (line) return [passAt(id, line.node, "Failed logins are logged.")];
23067
+ if (index.whole) {
23068
+ return [
23069
+ failAt(
23070
+ id,
23071
+ anchor,
23072
+ "info",
23073
+ 'No "login on-failure log" is configured: failed logins are not logged (it needs "logging level authpriv 6" too).',
23074
+ true
23075
+ )
23076
+ ];
23077
+ }
23078
+ return [passAt(id, anchor, "Not a whole configuration: failed-login logging is not judged.")];
23079
+ })
23080
+ };
23081
+ var loggingServers = (index) => liveLines(index, /logging\s+server\s+(?!dns-refresh-interval\b)\S+/, (words) => words[2]?.toLowerCase());
23082
+ var NxosSyslogServer = {
23083
+ id: "NXOS-LOG-001",
23084
+ vendor: "cisco-nxos",
23085
+ category: "Logging",
23086
+ metadata: {
23087
+ level: "warning",
23088
+ obu: "Security",
23089
+ owner: "SecOps",
23090
+ description: "System messages must be sent to a remote syslog server (NX-OS)",
23091
+ remediation: 'Configure "logging server <host> [<severity>] use-vrf <vrf>", for example "logging server 192.0.2.20 6 use-vrf management".',
23092
+ tags: tags("logging", "syslog")
23093
+ },
23094
+ check: judgedOnce((index, anchor) => {
23095
+ const id = "NXOS-LOG-001";
23096
+ const servers = loggingServers(index);
23097
+ const first2 = servers[0];
23098
+ if (first2) return [passAt(id, first2.node, "System messages are sent to a remote syslog server.")];
23099
+ if (index.whole) {
23100
+ return [failAt(id, anchor, "warning", 'No "logging server" is configured: system messages stay on the switch.', true)];
23101
+ }
23102
+ return [passAt(id, anchor, "Not a whole configuration: the syslog server is not judged.")];
23103
+ })
23104
+ };
23105
+ var NxosLogTimestamps = {
23106
+ id: "NXOS-LOG-002",
23107
+ vendor: "cisco-nxos",
23108
+ category: "Logging",
23109
+ metadata: {
23110
+ level: "info",
23111
+ obu: "Security",
23112
+ owner: "SecOps",
23113
+ description: "Log timestamps must have millisecond precision (NX-OS)",
23114
+ remediation: 'Configure "logging timestamp milliseconds".',
23115
+ tags: tags("logging", "timestamp")
23116
+ },
23117
+ check: judgedOnce((index, anchor) => {
23118
+ const id = "NXOS-LOG-002";
23119
+ const line = lastSetting(index, /logging\s+timestamp(?:\s|$)/);
23120
+ const unit = line?.text.split(/\s+/)[2]?.toLowerCase();
23121
+ if (line && (unit === "milliseconds" || unit === "microseconds")) {
23122
+ return [passAt(id, line.node, "Log timestamps have sub-second precision.")];
23123
+ }
23124
+ if (line) return [failAt(id, line.node, "info", "Log timestamps are in seconds: events from different devices cannot be ordered closely.")];
23125
+ if (index.whole) {
23126
+ return [failAt(id, anchor, "info", 'No "logging timestamp" is configured: the default is seconds.', true)];
23127
+ }
23128
+ return [passAt(id, anchor, "Not a whole configuration: the log timestamp unit is not judged.")];
23129
+ })
23130
+ };
23131
+ var NxosLogSourceInterface = {
23132
+ id: "NXOS-LOG-003",
23133
+ vendor: "cisco-nxos",
23134
+ category: "Logging",
23135
+ metadata: {
23136
+ level: "info",
23137
+ obu: "Security",
23138
+ owner: "SecOps",
23139
+ description: "Remote logging must use a fixed source interface (NX-OS)",
23140
+ remediation: 'Configure "logging source-interface <interface>", for example "logging source-interface loopback 0".',
23141
+ tags: tags("logging", "syslog", "source-interface")
23142
+ },
23143
+ check: judgedOnce((index, anchor) => {
23144
+ const id = "NXOS-LOG-003";
23145
+ const first2 = loggingServers(index)[0];
23146
+ if (!first2) return [];
23147
+ const line = lastSetting(index, /logging\s+source-interface\b/);
23148
+ if (line) return [passAt(id, line.node, "Remote logging uses a fixed source interface.")];
23149
+ if (index.whole) {
23150
+ return [
23151
+ failAt(
23152
+ id,
23153
+ first2.node,
23154
+ "info",
23155
+ 'No "logging source-interface" is configured: the source address of log messages follows the outgoing interface.',
23156
+ true
23157
+ )
23158
+ ];
23159
+ }
23160
+ return [passAt(id, anchor, "Not a whole configuration: the logging source interface is not judged.")];
23161
+ })
23162
+ };
23163
+ var ntpSources = (index) => liveLines(index, /ntp\s+(?:server|peer)\s+\S+/, (words) => words[2]?.toLowerCase());
23164
+ var ntpKeyId = (line) => {
23165
+ const words = line.text.split(/\s+/);
23166
+ const at2 = words.findIndex((w, i) => i > 2 && w.toLowerCase() === "key");
23167
+ const id = at2 < 0 ? void 0 : words[at2 + 1];
23168
+ const n = id !== void 0 && /^\d+$/.test(id) ? parseInteger(id) : null;
23169
+ return n === null || n === void 0 ? void 0 : n;
23170
+ };
23171
+ var idsOf = (index, pattern, firstOnly) => {
23172
+ const ids = /* @__PURE__ */ new Set();
23173
+ for (const l of topMatching(index, pattern)) {
23174
+ const negated = NO_FORM.test(l.text);
23175
+ const words = l.text.replace(/^no\s+/i, "").split(/\s+/).slice(2);
23176
+ for (const w of firstOnly ? words.slice(0, 1) : words) {
23177
+ const n = /^\d+$/.test(w) ? parseInteger(w) : null;
23178
+ if (n === null) continue;
23179
+ if (negated) ids.delete(n);
23180
+ else ids.add(n);
23181
+ }
23182
+ }
23183
+ return ids;
23184
+ };
23185
+ var NxosNtpServers = {
23186
+ id: "NXOS-NTP-001",
23187
+ vendor: "cisco-nxos",
23188
+ category: "Time-Synchronization",
23189
+ metadata: {
23190
+ level: "warning",
23191
+ obu: "Network Engineering",
23192
+ owner: "NetOps",
23193
+ description: "At least two NTP servers must be configured (NX-OS)",
23194
+ remediation: 'Configure two or more NTP servers, each with "ntp server <ip> use-vrf <vrf>".',
23195
+ tags: tags("ntp", "time")
23196
+ },
23197
+ check: judgedOnce((index, anchor) => {
23198
+ const id = "NXOS-NTP-001";
23199
+ const sources = ntpSources(index);
23200
+ const distinct = new Set(sources.map((l) => l.text.split(/\s+/)[2]?.toLowerCase()));
23201
+ const first2 = sources[0];
23202
+ if (first2 && distinct.size >= 2) return [passAt(id, first2.node, "Two or more NTP time sources are configured.")];
23203
+ if (first2) {
23204
+ return [failAt(id, first2.node, "info", "Only one NTP time source is configured: there is no redundancy if it fails or is wrong.")];
23205
+ }
23206
+ if (index.whole) {
23207
+ return [failAt(id, anchor, "warning", "No NTP server is configured: the clock, and so the log times, can drift.", true)];
23208
+ }
23209
+ return [passAt(id, anchor, "Not a whole configuration: NTP servers are not judged.")];
23210
+ })
23211
+ };
23212
+ var NxosNtpAuthenticate = {
23213
+ id: "NXOS-NTP-002",
23214
+ vendor: "cisco-nxos",
23215
+ category: "Protocol-Security",
23216
+ metadata: {
23217
+ level: "warning",
23218
+ obu: "Security",
23219
+ owner: "SecOps",
23220
+ description: "NTP authentication must be enabled (NX-OS)",
23221
+ remediation: 'Define a key ("ntp authentication-key <id> md5 <key>" or "aes128cmac"), trust it ("ntp trusted-key <id>"), name it on each server ("ntp server <ip> key <id>"), and turn checking on with "ntp authenticate".',
23222
+ security: { cwe: ["CWE-345"] },
23223
+ tags: tags("ntp", "authentication")
23224
+ },
23225
+ check: judgedOnce((index, anchor) => {
23226
+ const id = "NXOS-NTP-002";
23227
+ const first2 = ntpSources(index)[0];
23228
+ if (!first2) return [];
23229
+ const line = lastSetting(index, /ntp\s+authenticate\s*$/);
23230
+ if (!line) {
23231
+ if (index.whole) {
23232
+ return [failAt(id, first2.node, "warning", "NTP authentication is not enabled: any source can set the clock.", true)];
23233
+ }
23234
+ return [passAt(id, anchor, "Not a whole configuration: NTP authentication is not judged.")];
23235
+ }
23236
+ return [passAt(id, line.node, "NTP authentication is enabled.")];
23237
+ })
23238
+ };
23239
+ var NxosNtpServerKeys = {
23240
+ id: "NXOS-NTP-003",
23241
+ vendor: "cisco-nxos",
23242
+ category: "Protocol-Security",
23243
+ metadata: {
23244
+ level: "warning",
23245
+ obu: "Security",
23246
+ owner: "SecOps",
23247
+ description: "Each NTP server must use a trusted authentication key (NX-OS)",
23248
+ remediation: 'Add "key <id>" to every "ntp server" and "ntp peer" line, with "ntp trusted-key <id>" and "ntp authentication-key <id> ..." for that id.',
23249
+ security: { cwe: ["CWE-345"] },
23250
+ tags: tags("ntp", "authentication", "keys")
23251
+ },
23252
+ check: judgedOnce((index, anchor) => {
23253
+ const id = "NXOS-NTP-003";
23254
+ if (!lastSetting(index, /ntp\s+authenticate\s*$/)) return [];
23255
+ const sources = ntpSources(index);
23256
+ const trusted = idsOf(index, /^(?:no\s+)?ntp\s+trusted-key\s+\S+/i, false);
23257
+ const defined = idsOf(index, /^(?:no\s+)?ntp\s+authentication-key\s+\S+/i, true);
23258
+ const results = [];
23259
+ for (const l of sources) {
23260
+ const key = ntpKeyId(l);
23261
+ let problem;
23262
+ if (key === void 0) problem = 'has no "key": it will continue to operate without authentication.';
23263
+ else if (index.whole && !trusted.has(key)) problem = `uses key ${key}, which is not named by any "ntp trusted-key".`;
23264
+ else if (index.whole && !defined.has(key)) problem = `uses key ${key}, which has no "ntp authentication-key" line.`;
23265
+ if (problem) results.push(failAt(id, l.node, "warning", `This NTP source ${problem}`));
23266
+ }
23267
+ const first2 = sources[0];
23268
+ if (results.length > 0) return results;
23269
+ return [passAt(id, first2 ? first2.node : anchor, "Every NTP source uses a trusted authentication key.")];
23270
+ })
23271
+ };
23272
+ var snmpUserWords = (node) => node.params.slice(3).map((w) => w.toLowerCase());
23273
+ var isSnmpUserDefinition = (words) => {
23274
+ const first2 = words[0];
23275
+ if (words.length === 1 && first2 === "enforcepriv") return false;
23276
+ return first2 !== "use-ipv4acl" && first2 !== "use-ipv6acl";
23277
+ };
23278
+ var SNMP_USER_PRIV_ABSENT = "This SNMPv3 user has neither authentication nor privacy.";
23279
+ var SNMP_USER_AUTH_ONLY = "This SNMPv3 user has authentication but no privacy: its messages are not encrypted.";
23280
+ var SNMP_AUTH_ALGORITHM = /^(?:md5|sha(?:-\d+)?)$/;
23281
+ var snmpUsers = (index) => {
23282
+ const users = /* @__PURE__ */ new Map();
23283
+ for (const l of topMatching(index, /^no\s+snmp-server\s+user\s+\S|^snmp-server\s+user\s+\S/i)) {
23284
+ if (NO_FORM.test(l.text)) {
23285
+ const removed = l.node.params[3];
23286
+ if (removed !== void 0 && l.node.params.length === 4) users.delete(removed);
23287
+ continue;
23288
+ }
23289
+ const name = l.node.params[2];
23290
+ if (name === void 0 || !isSnmpUserDefinition(snmpUserWords(l.node))) continue;
23291
+ const lines = users.get(name);
23292
+ if (lines) lines.push(l);
23293
+ else users.set(name, [l]);
23294
+ }
23295
+ return users;
23296
+ };
23297
+ var snmpLevel = (node) => {
23298
+ const words = snmpUserWords(node);
23299
+ const authAt = words.findIndex((w, i) => w === "auth" && SNMP_AUTH_ALGORITHM.test(words[i + 1] ?? "") && words.length >= i + 3);
23300
+ if (authAt < 0) return "none";
23301
+ return words.slice(authAt + 3).includes("priv") ? "authpriv" : "auth";
23302
+ };
23303
+ var NxosSnmpUserPriv = {
23304
+ id: "NXOS-SNMP-001",
23305
+ vendor: "cisco-nxos",
23306
+ category: "Protocol-Security",
23307
+ metadata: {
23308
+ level: "warning",
23309
+ obu: "Security",
23310
+ owner: "SecOps",
23311
+ description: "SNMPv3 users must use authentication and privacy (NX-OS)",
23312
+ remediation: 'Configure each SNMPv3 user with authentication and privacy: "snmp-server user <name> <group> auth sha <auth-passphrase> priv aes-128 <priv-passphrase>".',
23313
+ security: { cwe: ["CWE-319"] },
23314
+ tags: tags("snmp", "encryption", "management")
23315
+ },
23316
+ check: judgedOnce((index) => {
23317
+ const id = "NXOS-SNMP-001";
23318
+ const results = [];
23319
+ for (const lines of snmpUsers(index).values()) {
23320
+ const first2 = lines[0];
23321
+ if (!first2) continue;
23322
+ const levels = lines.map((l) => snmpLevel(l.node));
23323
+ if (levels.includes("authpriv")) {
23324
+ results.push(passAt(id, (lines[levels.indexOf("authpriv")] ?? first2).node, "This SNMPv3 user uses authentication and privacy."));
23325
+ } else if (levels.includes("auth")) {
23326
+ results.push(failAt(id, first2.node, "warning", SNMP_USER_AUTH_ONLY));
23327
+ } else {
23328
+ results.push(failAt(id, first2.node, "warning", SNMP_USER_PRIV_ABSENT));
23329
+ }
23330
+ }
23331
+ return results;
23332
+ })
23333
+ };
23334
+ var firstLiveSnmpLine = (index) => {
23335
+ let live = [];
23336
+ for (const l of topMatching(index, /^(?:no\s+)?snmp-server\s+(?:user|community)\s+\S/i)) {
23337
+ const negated = NO_FORM.test(l.text);
23338
+ const params = negated ? l.node.params.slice(1) : l.node.params;
23339
+ const kind = params[1]?.toLowerCase() ?? "";
23340
+ const name = params[2];
23341
+ if (!negated) live.push({ line: l, kind, name });
23342
+ else {
23343
+ const removes = kind === "community" ? !communityHasAcl(params.slice(3)) : params.length === 3;
23344
+ if (removes) live = live.filter((x) => !(x.kind === kind && x.name === name));
23345
+ }
23346
+ }
23347
+ return live[0]?.line;
23348
+ };
23349
+ var SNMP_ENFORCE_FAIL = "SNMPv3 privacy is not enforced: the agent accepts messages without authentication and encryption.";
23350
+ var NxosSnmpEnforcePriv = {
23351
+ id: "NXOS-SNMP-002",
23352
+ vendor: "cisco-nxos",
23353
+ category: "Protocol-Security",
23354
+ metadata: {
23355
+ level: "info",
23356
+ obu: "Security",
23357
+ owner: "SecOps",
23358
+ description: "SNMP must require privacy for every SNMPv3 message (NX-OS)",
23359
+ remediation: 'Configure "snmp-server globalEnforcePriv" (or "snmp-server user <name> enforcePriv" for each user).',
23360
+ security: { cwe: ["CWE-319"] },
23361
+ tags: tags("snmp", "encryption", "management")
23362
+ },
23363
+ check: judgedOnce((index, anchor) => {
23364
+ const id = "NXOS-SNMP-002";
23365
+ const first2 = firstLiveSnmpLine(index);
23366
+ if (!first2) return [];
23367
+ const globals = topMatching(index, /^(?:no\s+)?snmp-server\s+globalEnforcePriv(?=\s|$)/i);
23368
+ const last = globals[globals.length - 1];
23369
+ if (last && !/^no\s/i.test(last.text)) {
23370
+ return [passAt(id, last.node, 'Privacy is enforced for every SNMPv3 message ("snmp-server globalEnforcePriv").')];
23371
+ }
23372
+ const hasCommunity = snmpCommunities(index).size > 0;
23373
+ if (!hasCommunity) {
23374
+ const defined = [...snmpUsers(index).keys()];
23375
+ const enforced = /* @__PURE__ */ new Map();
23376
+ for (const l of topMatching(index, /^(?:no\s+)?snmp-server\s+user\s+\S/i)) {
23377
+ const negated = NO_FORM.test(l.text);
23378
+ const params = negated ? l.node.params.slice(1) : l.node.params;
23379
+ const name = params[2];
23380
+ if (name === void 0 || params.length !== 4 || params[3]?.toLowerCase() !== "enforcepriv") continue;
23381
+ if (negated) enforced.delete(name);
23382
+ else if (!enforced.has(name)) enforced.set(name, l);
23383
+ }
23384
+ const proof = defined.length > 0 ? enforced.get(defined[0] ?? "") : void 0;
23385
+ if (proof && defined.every((name) => enforced.has(name))) {
23386
+ return [passAt(id, proof.node, "Privacy is enforced for every SNMPv3 user.")];
23387
+ }
23388
+ }
23389
+ if (!index.whole) return [passAt(id, anchor, "Not a whole configuration: SNMPv3 privacy enforcement is not judged.")];
23390
+ return [failAt(id, first2.node, "info", SNMP_ENFORCE_FAIL, true)];
23391
+ })
23392
+ };
23393
+ var SNMP_ACL_WORDS = /* @__PURE__ */ new Set(["use-acl", "use-ipv4acl", "use-ipv6acl"]);
23394
+ var communityHasAcl = (after2) => {
23395
+ const words = after2.map((w) => w.toLowerCase());
23396
+ for (let i = 0; i < words.length; i++) {
23397
+ const w = words[i];
23398
+ if (w === "group") i++;
23399
+ else if (w !== void 0 && SNMP_ACL_WORDS.has(w)) return true;
23400
+ }
23401
+ return false;
23402
+ };
23403
+ var snmpCommunities = (index) => {
23404
+ const communities = /* @__PURE__ */ new Map();
23405
+ for (const l of topMatching(index, /^(?:no\s+)?snmp-server\s+community\s+\S/i)) {
23406
+ const at2 = NO_FORM.test(l.text) ? 3 : 2;
23407
+ const name = l.node.params[at2] ?? "";
23408
+ const restricted = communityHasAcl(l.node.params.slice(at2 + 1));
23409
+ const seen = communities.get(name);
23410
+ if (at2 === 3) {
23411
+ if (restricted && seen) seen.restricted = false;
23412
+ else if (!restricted) communities.delete(name);
23413
+ } else if (seen) seen.restricted ||= restricted;
23414
+ else communities.set(name, { first: l, restricted });
23415
+ }
23416
+ return communities;
23417
+ };
23418
+ var NxosSnmpCommunityAcl = {
23419
+ id: "NXOS-SNMP-003",
23420
+ vendor: "cisco-nxos",
23421
+ category: "Protocol-Security",
23422
+ metadata: {
23423
+ level: "warning",
23424
+ obu: "Security",
23425
+ owner: "SecOps",
23426
+ description: "SNMP communities must be restricted by an ACL (NX-OS)",
23427
+ remediation: 'Restrict each community to its management hosts with "snmp-server community <name> use-ipv4acl <acl>" ("use-acl" on older releases), or move to SNMPv3.',
23428
+ security: { cwe: ["CWE-284"] },
23429
+ tags: tags("snmp", "access-control", "management")
23430
+ },
23431
+ check: judgedOnce((index, anchor) => {
23432
+ const id = "NXOS-SNMP-003";
23433
+ const communities = snmpCommunities(index);
23434
+ const results = [];
23435
+ for (const { first: first2, restricted } of communities.values()) {
23436
+ if (!restricted) {
23437
+ results.push(
23438
+ failAt(id, first2.node, "warning", "This SNMP community is not restricted by an ACL: any host that knows the community string can use it.")
23439
+ );
23440
+ }
23441
+ }
23442
+ if (results.length > 0) return results;
23443
+ return [
23444
+ passAt(id, anchor, communities.size === 0 ? "No SNMP community is configured." : "Every SNMP community is restricted by an ACL.")
23445
+ ];
23446
+ })
23447
+ };
23448
+ var COPP_PROFILE = /^copp\s+profile\s+(?:strict|moderate|lenient|dense)(?=\s|$)/i;
23449
+ var CONTROL_PLANE_POLICY = /^service-policy\s+input\s+\S+/i;
23450
+ var NxosCopp = {
23451
+ id: "NXOS-CTRL-001",
23452
+ vendor: "cisco-nxos",
23453
+ category: "Service-Hardening",
23454
+ metadata: {
23455
+ level: "warning",
23456
+ obu: "Security",
23457
+ owner: "SecOps",
23458
+ description: "Control-plane policing must be applied (NX-OS)",
23459
+ remediation: 'Apply a CoPP policy: "copp profile strict" (or moderate, lenient, dense), or a "policy-map type control-plane" applied with "service-policy input <policy>" under "control-plane".',
23460
+ security: { cwe: ["CWE-400"] },
23461
+ tags: tags("copp", "control-plane", "dos")
23462
+ },
23463
+ check: judgedOnce((index, anchor) => {
23464
+ const id = "NXOS-CTRL-001";
23465
+ const profile = lastSetting(index, /copp\s+profile(?:\s|$)/);
23466
+ if (profile && COPP_PROFILE.test(profile.text)) return [passAt(id, profile.node, "A CoPP policy is applied.")];
23467
+ const plane = topMatching(index, /^control-plane\s*$/i).find((l) => {
23468
+ const policy = l.node.children.filter((c) => /^(?:no\s+)?service-policy\s+input(?:\s|$)/i.test(c.id.trim())).pop();
23469
+ return policy !== void 0 && CONTROL_PLANE_POLICY.test(policy.id.trim());
23470
+ });
23471
+ if (plane) return [passAt(id, plane.node, "A CoPP policy is applied.")];
23472
+ if (!index.whole) return [passAt(id, anchor, "Not a whole configuration: control-plane policing is not judged.")];
23473
+ return [
23474
+ failAt(id, anchor, "warning", "No CoPP policy is applied: the control plane can be vulnerable to denial-of-service attacks.", true)
23475
+ ];
23476
+ })
23477
+ };
23478
+ var interfaceName = (node) => node.id.trim().replace(/^interface\s+/i, "");
23479
+ var childrenMatching = (node, pattern) => node.children.filter((c) => pattern.test(c.id.trim()));
23480
+ var hasChildMatching = (node, pattern) => node.children.some((c) => pattern.test(c.id.trim()));
23481
+ var topIsOn = (index, pattern) => {
23482
+ const last = index ? topMatching(index, pattern).pop() : void 0;
23483
+ return last !== void 0 && !NO_FORM.test(last.text);
23484
+ };
23485
+ var SYSTEM_DEFAULT_SWITCHPORT = /^(?:no\s+)?system\s+default\s+switchport\s*$/i;
23486
+ var EDGE_DEFAULT = /^(?:no\s+)?spanning-tree\s+port\s+type\s+edge\s+default\s*$/i;
23487
+ var EDGE_BPDUGUARD_DEFAULT = /^(?:no\s+)?spanning-tree\s+port\s+type\s+edge\s+bpduguard\s+default\s*$/i;
23488
+ var isLayer3 = (node) => hasChildMatching(node, /^ip\s+address\s+\S+/i);
23489
+ var isLayer2Port = (node, index) => {
23490
+ if (hasChildMatching(node, /^no\s+switchport\s*$/i) || /\.\d+$/.test(interfaceName(node))) return false;
23491
+ if (hasChildMatching(node, /^switchport(?:\s|$)/i)) return true;
23492
+ return topIsOn(index, SYSTEM_DEFAULT_SWITCHPORT) && !isLayer3(node) && !hasChildMatching(node, /^vrf\s+member\s+\S/i);
23493
+ };
23494
+ var isEdgePort = (node, index) => {
23495
+ if (!/^(?:ethernet|port-channel)\d/i.test(interfaceName(node))) return false;
23496
+ if (!isNxosInterfaceEnabled(node) || !isLayer2Port(node, index)) return false;
23497
+ const accessMode = !hasChildMatching(node, /^switchport\s+mode\s+(?!access\s*$|private-vlan\s+host\s*$)/i);
23498
+ if (hasChildMatching(node, /^spanning-tree\s+port\s+type\s+edge\s+trunk\s*$/i)) return true;
23499
+ if (hasChildMatching(node, /^spanning-tree\s+port\s+type\s+edge\s*$/i)) return accessMode;
23500
+ return topIsOn(index, EDGE_DEFAULT) && accessMode && !hasChildMatching(node, /^spanning-tree\s+port\s+type\s+(?:normal|network)(?:\s|$)/i);
23501
+ };
23502
+ var isFexHostInterface = (node) => /^ethernet1\d\d\/\d+\/\d+$/i.test(interfaceName(node));
23503
+ var LOCAL_PROXY_ARP = /^(?:no\s+)?ip\s+local-proxy-arp(?:\s+(?:reachable|no-hw-flooding|hw-flooding))*\s*$/i;
23504
+ var NxosBpduGuard = {
23505
+ id: "NXOS-L2-001",
23506
+ selector: "interface",
23507
+ vendor: "cisco-nxos",
23508
+ category: "Network-Segmentation",
23509
+ metadata: {
23510
+ level: "warning",
23511
+ obu: "Network Engineering",
23512
+ owner: "NetOps",
23513
+ description: "Spanning-tree edge ports must have BPDU Guard (NX-OS)",
23514
+ remediation: 'Enable BPDU Guard on edge ports: "spanning-tree port type edge bpduguard default" for all edge ports, or "spanning-tree bpduguard enable" on the interface.',
23515
+ tags: tags("spanning-tree", "bpdu-guard", "layer2")
23516
+ },
23517
+ check: (node, context) => {
23518
+ const id = "NXOS-L2-001";
23519
+ const index = nxosIndexOf(context);
23520
+ if (!isEdgePort(node, index)) {
23521
+ return passAt(id, node, "This interface is not an enabled Layer 2 edge port: BPDU Guard is not judged.");
23522
+ }
23523
+ if (isFexHostInterface(node)) {
23524
+ return passAt(id, node, "Fabric Extender host interfaces always run BPDU Guard, which cannot be disabled.");
23525
+ }
23526
+ const setting2 = childrenMatching(node, /^spanning-tree\s+bpduguard\s+(?:enable|disable)\s*$/i).pop();
23527
+ if (setting2) {
23528
+ return /disable$/i.test(setting2.id.trim()) ? failAt(id, setting2, "warning", 'BPDU Guard is disabled on this edge port: remove "spanning-tree bpduguard disable" or use "spanning-tree bpduguard enable".') : passAt(id, setting2, "BPDU Guard is enabled on this edge port.");
23529
+ }
23530
+ if (topIsOn(index, EDGE_BPDUGUARD_DEFAULT)) {
23531
+ return passAt(id, node, 'BPDU Guard is enabled on edge ports by "spanning-tree port type edge bpduguard default".');
23532
+ }
23533
+ if (index?.whole !== true) {
23534
+ return passAt(
23535
+ id,
23536
+ node,
23537
+ 'This edge port has no "spanning-tree bpduguard enable", and the global "spanning-tree port type edge bpduguard default" is not in this text, so BPDU Guard is not judged.'
23538
+ );
23539
+ }
23540
+ return failAt(id, node, "warning", "This edge port has no BPDU Guard, per interface or by default.");
23541
+ }
23542
+ };
23543
+ var NxosStormControl = {
23544
+ id: "NXOS-L2-002",
23545
+ selector: "interface",
23546
+ vendor: "cisco-nxos",
23547
+ category: "Network-Segmentation",
23548
+ metadata: {
23549
+ level: "info",
23550
+ obu: "Network Engineering",
23551
+ owner: "NetOps",
23552
+ description: "Spanning-tree edge ports should limit broadcast storms (NX-OS)",
23553
+ remediation: 'Configure traffic storm control on edge ports, for example "storm-control broadcast level 1.00" and "storm-control multicast level 1.00", with levels chosen from measured traffic.',
23554
+ tags: tags("storm-control", "broadcast", "layer2")
23555
+ },
23556
+ check: (node, context) => {
23557
+ const id = "NXOS-L2-002";
23558
+ if (!isEdgePort(node, nxosIndexOf(context))) {
23559
+ return passAt(id, node, "This interface is not an enabled Layer 2 edge port: storm control is not judged.");
23560
+ }
23561
+ const levels = childrenMatching(node, /^storm-control\s+(?:broadcast|multicast|unicast)\s+level\b/i);
23562
+ const unlimited = (c) => Number(c.id.trim().split(/\s+/)[3]) >= 100;
23563
+ const limit = levels.find((c) => !unlimited(c));
23564
+ if (limit) return passAt(id, limit, "This edge port has a storm-control level.");
23565
+ if (levels.length > 0) {
23566
+ return levels.map(
23567
+ (c) => failAt(id, c, "info", "This storm-control level is 100 percent, which means no traffic storm control: set a lower level.")
23568
+ );
23569
+ }
23570
+ return failAt(id, node, "info", "This edge port has no storm-control level: broadcast, multicast and unicast traffic is not rate limited.");
23571
+ }
23572
+ };
23573
+ var NxosVpcPeerKeepalive = {
23574
+ id: "NXOS-L2-003",
23575
+ selector: "vpc domain",
23576
+ vendor: "cisco-nxos",
23577
+ category: "High-Availability",
23578
+ metadata: {
23579
+ level: "warning",
23580
+ obu: "Network Engineering",
23581
+ owner: "NetOps",
23582
+ description: "A vPC domain must have a peer-keepalive link (NX-OS)",
23583
+ remediation: 'Configure "peer-keepalive destination <peer-ip> source <local-ip> vrf <vrf>" under "vpc domain <id>", preferably in a VRF of its own.',
23584
+ tags: tags("vpc", "peer-keepalive", "high-availability")
23585
+ },
23586
+ check: (node) => {
23587
+ const id = "NXOS-L2-003";
23588
+ if (!/^vpc\s+domain\s+\d+/i.test(node.id.trim())) return [];
23589
+ const keepalive = childrenMatching(node, /^peer-keepalive\s+destination\s+\S+/i)[0];
23590
+ if (keepalive) return passAt(id, keepalive, "This vPC domain has a peer-keepalive destination.");
23591
+ return failAt(
23592
+ id,
23593
+ node,
23594
+ "warning",
23595
+ "This vPC domain has no peer-keepalive destination: the vPC peer-link cannot come up without the peer-keepalive link."
23596
+ );
23597
+ }
23598
+ };
23599
+ var NxosSourceRoute = {
23600
+ id: "NXOS-DATA-001",
23601
+ vendor: "cisco-nxos",
23602
+ category: "Service-Hardening",
23603
+ metadata: {
23604
+ level: "warning",
23605
+ obu: "Security",
23606
+ owner: "SecOps",
23607
+ description: "IP source routing must be disabled (NX-OS)",
23608
+ remediation: 'Configure "no ip source-route" (IP source routing is enabled by default on NX-OS).',
23609
+ security: { cwe: ["CWE-284"] },
23610
+ tags: tags("source-routing", "hardening")
23611
+ },
23612
+ check: judgedOnce((index, anchor) => {
23613
+ const id = "NXOS-DATA-001";
23614
+ const line = topMatching(index, /^(?:no\s+)?ip\s+source-route\s*$/i).pop();
23615
+ if (line) {
23616
+ return [
23617
+ NO_FORM.test(line.text) ? passAt(id, line.node, 'IP source routing is disabled ("no ip source-route").') : failAt(id, line.node, "warning", 'IP source routing is enabled: configure "no ip source-route".')
23618
+ ];
23619
+ }
23620
+ if (index.whole) {
23621
+ return [failAt(id, anchor, "warning", 'No "no ip source-route" is configured: IP source routing is enabled by default.', true)];
23622
+ }
23623
+ return [passAt(id, anchor, "Not a whole configuration: IP source routing is not judged.")];
23624
+ })
23625
+ };
23626
+ var NxosIcmpRedirects = {
23627
+ id: "NXOS-DATA-002",
23628
+ selector: "interface",
23629
+ vendor: "cisco-nxos",
23630
+ category: "Service-Hardening",
23631
+ metadata: {
23632
+ level: "warning",
23633
+ obu: "Security",
23634
+ owner: "SecOps",
23635
+ description: "Layer 3 interfaces must not send ICMP redirects (NX-OS)",
23636
+ remediation: 'Configure "no ip redirects" on every Layer 3 interface (NX-OS sends ICMP redirects by default).',
23637
+ security: { cwe: ["CWE-284"] },
23638
+ tags: tags("icmp", "redirects", "hardening")
23639
+ },
23640
+ check: (node) => {
23641
+ const id = "NXOS-DATA-002";
23642
+ if (!isNxosInterfaceEnabled(node) || !isLayer3(node) || /^(?:loopback|mgmt)/i.test(interfaceName(node)) || childrenMatching(node, LOCAL_PROXY_ARP).some((c) => !NO_FORM.test(c.id.trim()))) {
23643
+ return passAt(
23644
+ id,
23645
+ node,
23646
+ "This is not an enabled Layer 3 interface (loopback, management and local-proxy-ARP interfaces excluded): ICMP redirects are not judged."
23647
+ );
23648
+ }
23649
+ const setting2 = childrenMatching(node, /^(?:no\s+)?ip\s+redirects\s*$/i).pop();
23650
+ if (setting2 && NO_FORM.test(setting2.id.trim())) return passAt(id, setting2, "ICMP redirects are disabled on this interface.");
23651
+ return failAt(id, setting2 ?? node, "warning", 'This Layer 3 interface sends ICMP redirects: configure "no ip redirects".');
23652
+ }
23653
+ };
23654
+ var NxosProxyArp = {
23655
+ id: "NXOS-DATA-003",
23656
+ selector: "interface",
23657
+ vendor: "cisco-nxos",
23658
+ category: "Service-Hardening",
23659
+ metadata: {
23660
+ level: "warning",
23661
+ obu: "Security",
23662
+ owner: "SecOps",
23663
+ description: "Proxy ARP must not be enabled on interfaces (NX-OS)",
23664
+ remediation: 'Remove "ip proxy-arp" and "ip local-proxy-arp" from the interface; proxy ARP is disabled by default on NX-OS.',
23665
+ security: { cwe: ["CWE-290"] },
23666
+ tags: tags("proxy-arp", "arp", "hardening")
23667
+ },
23668
+ check: (node) => {
23669
+ const id = "NXOS-DATA-003";
23670
+ if (!isNxosInterfaceEnabled(node)) return passAt(id, node, "This interface is not enabled: proxy ARP is not judged.");
23671
+ const enabled = [/^(?:no\s+)?ip\s+proxy-arp\s*$/i, LOCAL_PROXY_ARP].map((pattern) => childrenMatching(node, pattern).pop()).filter((c) => c !== void 0 && !NO_FORM.test(c.id.trim())).sort((a, b) => node.children.indexOf(a) - node.children.indexOf(b));
23672
+ if (enabled.length === 0) return passAt(id, node, "Proxy ARP is not enabled on this interface.");
23673
+ return enabled.map(
23674
+ (c) => failAt(id, c, "warning", `"${c.id.trim()}" enables proxy ARP on this interface: remove it (proxy ARP is disabled by default).`)
23675
+ );
23676
+ }
23677
+ };
23678
+ var ospfArea = (text) => {
23679
+ if (/^\d{1,10}$/.test(text)) {
23680
+ const n = Number(text);
23681
+ return n > 4294967295 ? void 0 : [n >>> 24, n >>> 16 & 255, n >>> 8 & 255, n & 255].join(".");
23682
+ }
23683
+ const quad = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(text);
23684
+ return quad && quad.slice(1).every((octet) => Number(octet) <= 255) ? text : void 0;
23685
+ };
23686
+ var ROUTER_BLOCK = /^router\s+(ospf|eigrp)\s+(\S+)\s*$/i;
23687
+ var ROUTER_OSPF = /^router\s+ospf\s+\S+\s*$/i;
23688
+ var VRF_SECTION = /^vrf\s+(\S+)\s*$/i;
23689
+ var routerBlock = (ast, kind, tag, vrf) => {
23690
+ const block = ast.flatMap((n) => n.type === "virtual_root" ? n.children : [n]).find((n) => {
23691
+ const m = ROUTER_BLOCK.exec(n.id.trim());
23692
+ return m?.[1]?.toLowerCase() === kind && m[2] === tag;
23693
+ });
23694
+ if (!block || vrf === void 0) return block;
23695
+ return block.children.find((c) => VRF_SECTION.exec(c.id.trim())?.[1] === vrf);
23696
+ };
23697
+ var interfaceVrf = (node) => node.children.map((c) => /^vrf\s+member\s+(\S+)/i.exec(c.id.trim())?.[1]).filter((v) => v !== void 0).pop();
23698
+ var matchingChildren = (node, pattern) => node.children.flatMap((line) => {
23699
+ const m = pattern.exec(line.id.trim());
23700
+ return m ? [{ line, m }] : [];
23701
+ });
23702
+ var processScope = (context, kind, tag, vrf) => {
23703
+ const ast = context?.getAst?.() ?? [];
23704
+ const router = routerBlock(ast, kind, tag, void 0);
23705
+ return {
23706
+ router,
23707
+ scope: vrf === void 0 ? router : routerBlock(ast, kind, tag, vrf),
23708
+ where: vrf === void 0 ? `"router ${kind} ${tag}"` : `"vrf ${vrf}" of "router ${kind} ${tag}"`,
23709
+ fragment: router === void 0 && !nxosIndexOf(context)?.whole
23710
+ };
23711
+ };
23712
+ var NOT_JUDGED_DOWN = (what) => `This interface is not enabled, or is a loopback: its ${what} is not judged.`;
23713
+ var OSPF_MEMBERSHIP = /^ip\s+router\s+ospf\s+(\S+)\s+area\s+(\S+)/i;
23714
+ var OSPF_IF_AUTH = /^(no\s+)?ip\s+ospf\s+authentication(?:\s+(\S+).*)?$/i;
23715
+ var OSPF_IF_PASSIVE = /^(no\s+|default\s+)?ip\s+ospf\s+passive-interface\s*$/i;
23716
+ var PASSIVE_DEFAULT = /^(?:no\s+)?passive-interface\s+default\s*$/i;
23717
+ var AREA_AUTH = /^(no\s+)?area\s+(\S+)\s+authentication(?:\s+(\S+))?\s*$/i;
23718
+ var ospfInterfaceAuth = (node) => {
23719
+ let mode;
23720
+ let modeLine;
23721
+ let chain;
23722
+ for (const { line, m } of matchingChildren(node, OSPF_IF_AUTH)) {
23723
+ const negated = m[1] !== void 0;
23724
+ const word = m[2]?.toLowerCase();
23725
+ if (word === "key-chain") {
23726
+ chain = negated ? void 0 : line;
23727
+ if (!negated && mode === "null") [mode, modeLine] = [void 0, void 0];
23728
+ } else if (negated) {
23729
+ [mode, modeLine] = [void 0, void 0];
23730
+ } else {
23731
+ mode = word === void 0 ? "clear" : word === "null" ? "null" : "md";
23732
+ modeLine = line;
23733
+ if (mode === "null") chain = void 0;
23734
+ }
23735
+ }
23736
+ if (chain) return { state: "strong", line: chain };
23737
+ if (mode === "md") return { state: "strong", line: modeLine };
23738
+ return mode === void 0 ? { state: "none", line: void 0 } : { state: mode, line: modeLine };
23739
+ };
23740
+ var areaAuthOf = (section) => {
23741
+ const out = /* @__PURE__ */ new Map();
23742
+ for (const { line, m } of matchingChildren(section, AREA_AUTH)) {
23743
+ const area = m[2] ?? "";
23744
+ const on = m[1] === void 0;
23745
+ out.set(ospfArea(area) ?? area, { area, line, on, bare: on && m[3] === void 0 });
23746
+ }
23747
+ return out;
23748
+ };
23749
+ var isOspfPassive = (node, scope, router) => {
23750
+ let state;
23751
+ for (const { m } of matchingChildren(node, OSPF_IF_PASSIVE)) {
23752
+ const prefix = m[1]?.trim().toLowerCase();
23753
+ state = prefix === void 0 ? true : prefix === "no" ? false : void 0;
23754
+ }
23755
+ if (state !== void 0) return state;
23756
+ for (const section of [scope, router]) {
23757
+ const last = section ? childrenMatching(section, PASSIVE_DEFAULT).pop() : void 0;
23758
+ if (last) return !NO_FORM.test(last.id.trim());
23759
+ }
23760
+ return false;
23761
+ };
23762
+ var NxosOspfAuthentication = {
23763
+ id: "NXOS-OSPF-001",
23764
+ selector: "interface",
23765
+ vendor: "cisco-nxos",
23766
+ category: "Routing",
23767
+ metadata: {
23768
+ level: "warning",
23769
+ obu: "Security",
23770
+ owner: "SecOps",
23771
+ description: "OSPF interfaces must authenticate their adjacencies (NX-OS)",
23772
+ remediation: 'Authenticate OSPF with "area <area-id> authentication message-digest" under "router ospf <tag>" and "ip ospf message-digest-key <id> md5 <key>" on each interface, or with "ip ospf authentication message-digest" (or "ip ospf authentication key-chain <name>") on the interface.',
23773
+ security: { cwe: ["CWE-306"] },
23774
+ tags: tags("ospf", "authentication", "routing")
23775
+ },
23776
+ check: (node, context) => {
23777
+ const id = "NXOS-OSPF-001";
23778
+ if (!isNxosInterfaceEnabled(node) || isLoopbackInterface(node.id)) return passAt(id, node, NOT_JUDGED_DOWN("OSPF authentication"));
23779
+ const instances = matchingChildren(node, OSPF_MEMBERSHIP);
23780
+ if (instances.length === 0) {
23781
+ return passAt(id, node, 'This interface is not in an OSPFv2 instance ("ip router ospf <tag> area <area>"): OSPF authentication is not judged.');
23782
+ }
23783
+ const vrf = interfaceVrf(node);
23784
+ const own = ospfInterfaceAuth(node);
23785
+ return instances.map(({ m }) => {
23786
+ const tag = m[1] ?? "";
23787
+ const areaText = m[2] ?? "";
23788
+ const { router, scope, where, fragment } = processScope(context, "ospf", tag, vrf);
23789
+ if (isOspfPassive(node, scope, router)) {
23790
+ return passAt(id, node, `This interface is passive for OSPF instance ${tag}, so no adjacency forms: authentication is not judged.`);
23791
+ }
23792
+ if (own.state === "null") {
23793
+ return failAt(
23794
+ id,
23795
+ node,
23796
+ "warning",
23797
+ `"ip ospf authentication null" switches OSPF authentication off on this interface (instance ${tag}, area ${areaText}), overriding any area authentication.`
23798
+ );
23799
+ }
23800
+ if (own.line) return passAt(id, own.line, "This interface sets its own OSPF authentication mode (keys are not checked).");
23801
+ if (fragment) return passAt(id, node, `"router ospf ${tag}" is not in this text, so area authentication is not judged.`);
23802
+ const set = scope ? areaAuthOf(scope).get(ospfArea(areaText) ?? areaText) : void 0;
23803
+ if (set?.on) return passAt(id, set.line, `Area ${areaText} sets OSPF authentication for this interface under ${where} (keys are not checked).`);
23804
+ return failAt(
23805
+ id,
23806
+ node,
23807
+ "warning",
23808
+ `OSPF adjacencies of instance ${tag}, area ${areaText} on this interface are not authenticated: configure "ip ospf authentication message-digest" here or "area ${areaText} authentication message-digest" under ${where}.`
23809
+ );
23810
+ });
23811
+ }
23812
+ };
23813
+ var NxosOspfCleartext = {
23814
+ id: "NXOS-OSPF-002",
23815
+ selectors: ["interface", "router ospf"],
23816
+ vendor: "cisco-nxos",
23817
+ category: "Routing",
23818
+ metadata: {
23819
+ level: "warning",
23820
+ obu: "Security",
23821
+ owner: "SecOps",
23822
+ description: "OSPF must not use clear-text authentication (NX-OS)",
23823
+ remediation: 'Use message-digest or key-chain authentication ("area <area-id> authentication message-digest", "ip ospf authentication message-digest" or "ip ospf authentication key-chain <name>") and remove "ip ospf authentication-key".',
23824
+ security: { cwe: ["CWE-319"] },
23825
+ tags: tags("ospf", "clear-text", "authentication")
23826
+ },
23827
+ check: (node) => {
23828
+ const id = "NXOS-OSPF-002";
23829
+ const text = node.id.trim();
23830
+ if (/^interface\s+\S/i.test(text)) {
23831
+ const { state, line } = ospfInterfaceAuth(node);
23832
+ if (state === "clear" && line) {
23833
+ return failAt(
23834
+ id,
23835
+ line,
23836
+ "warning",
23837
+ 'This interface uses clear-text OSPF authentication ("ip ospf authentication" without "message-digest" or "key-chain"): use "ip ospf authentication message-digest" or "ip ospf authentication key-chain <name>".'
23838
+ );
23839
+ }
23840
+ return passAt(id, node, 'This interface has no clear-text "ip ospf authentication" line.');
23841
+ }
23842
+ if (!ROUTER_OSPF.test(text)) return [];
23843
+ const clear = [node, ...node.children.filter((c) => VRF_SECTION.test(c.id.trim()))].flatMap((section) => [...areaAuthOf(section).values()]).filter((a) => a.bare);
23844
+ if (clear.length === 0) return passAt(id, node, "No area of this OSPF instance uses clear-text authentication.");
23845
+ return clear.map(
23846
+ (a) => failAt(id, a.line, "warning", `Area ${a.area} uses clear-text OSPF authentication: configure "area ${a.area} authentication message-digest".`)
23847
+ );
23848
+ }
23849
+ };
23850
+ var NxosOspfLogAdjacency = {
23851
+ id: "NXOS-OSPF-003",
23852
+ selector: "router ospf",
23853
+ vendor: "cisco-nxos",
23854
+ category: "Logging",
23855
+ metadata: {
23856
+ level: "info",
23857
+ obu: "Network Engineering",
23858
+ owner: "NetOps",
23859
+ description: "OSPF must log adjacency changes (NX-OS)",
23860
+ remediation: 'Configure "log-adjacency-changes" under "router ospf <tag>".',
23861
+ tags: tags("ospf", "logging", "adjacency")
23862
+ },
23863
+ check: (node, context) => {
23864
+ const id = "NXOS-OSPF-003";
23865
+ if (!ROUTER_OSPF.test(node.id.trim()) || !isTopLevel(node, context)) return [];
23866
+ const setting2 = childrenMatching(node, /^(?:no\s+)?log-adjacency-changes(?:\s|$)/i).pop();
23867
+ if (setting2 && !NO_FORM.test(setting2.id.trim())) return passAt(id, setting2, "OSPF adjacency changes are logged.");
23868
+ return failAt(id, node, "info", `OSPF adjacency changes are not logged: configure "log-adjacency-changes" under "${node.id.trim()}".`);
23869
+ }
23870
+ };
23871
+ var EIGRP_MEMBERSHIP = /^ip\s+router\s+eigrp\s+(\S+)/i;
23872
+ var EIGRP_IF_AUTH = /^(no\s+)?ip\s+authentication\s+mode\s+eigrp\s+(\S+)\s+md5\s*$/i;
23873
+ var EIGRP_IF_PASSIVE = /^(no\s+)?ip\s+passive-interface\s+eigrp\s+(\S+)\s*$/i;
23874
+ var EIGRP_MODE = /^(?:no\s+)?authentication\s+mode\s+md5\s*$/i;
23875
+ var EIGRP_IPV4_AF = /^address-family\s+ipv4\s+unicast\s*$/i;
23876
+ var lastForTag = (node, pattern, tag) => {
23877
+ const last = matchingChildren(node, pattern).filter(({ m }) => m[2] === tag).pop();
23878
+ return last && { line: last.line, on: last.m[1] === void 0 };
23879
+ };
23880
+ var NxosEigrpAuthentication = {
23881
+ id: "NXOS-EIGRP-001",
23882
+ selector: "interface",
23883
+ vendor: "cisco-nxos",
23884
+ category: "Routing",
23885
+ metadata: {
23886
+ level: "warning",
23887
+ obu: "Security",
23888
+ owner: "SecOps",
23889
+ description: "EIGRP interfaces must authenticate their neighbours (NX-OS)",
23890
+ remediation: 'Configure EIGRP MD5 authentication: "authentication mode md5" and "authentication key-chain <name>" under "router eigrp <tag>" (or its address family or VRF), or "ip authentication mode eigrp <tag> md5" and "ip authentication key-chain eigrp <tag> <name>" on the interface.',
23891
+ security: { cwe: ["CWE-306"] },
23892
+ tags: tags("eigrp", "authentication", "routing")
23893
+ },
23894
+ check: (node, context) => {
23895
+ const id = "NXOS-EIGRP-001";
23896
+ if (!isNxosInterfaceEnabled(node) || isLoopbackInterface(node.id)) return passAt(id, node, NOT_JUDGED_DOWN("EIGRP authentication"));
23897
+ const instances = matchingChildren(node, EIGRP_MEMBERSHIP);
23898
+ if (instances.length === 0) {
23899
+ return passAt(id, node, 'This interface is not in an EIGRP instance ("ip router eigrp <tag>"): EIGRP authentication is not judged.');
23900
+ }
23901
+ const vrf = interfaceVrf(node);
23902
+ return instances.map(({ m }) => {
23903
+ const tag = m[1] ?? "";
23904
+ if (lastForTag(node, EIGRP_IF_PASSIVE, tag)?.on) {
23905
+ return passAt(id, node, `This interface is passive for EIGRP instance ${tag}, so no neighbour forms: authentication is not judged.`);
23906
+ }
23907
+ const own = lastForTag(node, EIGRP_IF_AUTH, tag);
23908
+ if (own?.on) return passAt(id, own.line, `This interface sets MD5 authentication mode for EIGRP instance ${tag} ("ip authentication mode eigrp ${tag} md5"; the key chain is not checked).`);
23909
+ const { scope, where, fragment } = processScope(context, "eigrp", tag, vrf);
23910
+ if (fragment) return passAt(id, node, `"router eigrp ${tag}" is not in this text, so process authentication is not judged.`);
23911
+ const af = scope?.children.find((c) => EIGRP_IPV4_AF.test(c.id.trim()));
23912
+ for (const [section, place] of [
23913
+ [af, `${where} address-family ipv4 unicast`],
23914
+ [scope, where]
23915
+ ]) {
23916
+ const setting2 = section ? childrenMatching(section, EIGRP_MODE).pop() : void 0;
23917
+ if (!setting2) continue;
23918
+ if (NO_FORM.test(setting2.id.trim())) break;
23919
+ return passAt(id, setting2, `EIGRP instance ${tag} sets MD5 authentication mode ("authentication mode md5") for this interface, under ${place} (the key chain is not checked).`);
23920
+ }
23921
+ return failAt(
23922
+ id,
23923
+ node,
23924
+ "warning",
23925
+ `EIGRP neighbours of instance ${tag} on this interface are not authenticated: configure "authentication mode md5" under ${where}, or "ip authentication mode eigrp ${tag} md5" here.`
23926
+ );
23927
+ });
23928
+ }
23929
+ };
23930
+ var HSRP_GROUP = /^hsrp\s+\d+(?:\s|$)/i;
23931
+ var FHRP_GROUP = /^(?:hsrp\s+\d|vrrp\s|vrrpv3\s)/i;
23932
+ var HSRP_AUTH = /^authentication\s+(text|md5)(?:\s|$)/i;
23933
+ var HSRP_NO_AUTH = /^no\s+authentication(?:\s|$)/i;
23934
+ var NxosHsrpMd5 = {
23935
+ id: "NXOS-FHRP-001",
23936
+ selector: "interface",
23937
+ vendor: "cisco-nxos",
23938
+ category: "High-Availability",
23939
+ metadata: {
23940
+ level: "warning",
23941
+ obu: "Security",
23942
+ owner: "SecOps",
23943
+ description: "HSRP groups must use MD5 authentication (NX-OS)",
23944
+ remediation: 'Configure "authentication md5 key-chain <name>" (or "authentication md5 key-string <key>") in each "hsrp <group>", with the same key on every group member. MD5 authentication needs HSRP version 2 ("hsrp version 2" on the interface); changing the version reinitializes the groups, so plan the change.',
23945
+ security: { cwe: ["CWE-306"] },
23946
+ tags: tags("hsrp", "authentication", "first-hop-redundancy")
23947
+ },
23948
+ check: (node) => {
23949
+ const id = "NXOS-FHRP-001";
23950
+ if (!isNxosInterfaceEnabled(node)) return passAt(id, node, "This interface is not enabled: its HSRP groups are not judged.");
23951
+ const groups = node.children.filter((c) => HSRP_GROUP.test(c.id.trim()));
23952
+ if (groups.length === 0) return passAt(id, node, "This interface has no HSRP group.");
23953
+ return groups.map((group) => {
23954
+ const from = node.children.indexOf(group) + 1;
23955
+ const stop = node.children.findIndex((c, j) => j >= from && FHRP_GROUP.test(c.id.trim()));
23956
+ const to = stop < 0 ? node.children.length : stop;
23957
+ let setting2;
23958
+ for (const line of [...group.children, ...node.children.slice(from, to)]) {
23959
+ const text = line.id.trim();
23960
+ const m = HSRP_AUTH.exec(text);
23961
+ if (m?.[1]) setting2 = { kind: m[1].toLowerCase(), line };
23962
+ else if (HSRP_NO_AUTH.test(text)) setting2 = void 0;
23963
+ }
23964
+ const name = group.id.trim();
23965
+ if (setting2?.kind === "md5") return passAt(id, setting2.line, `HSRP "${name}" has MD5 authentication configured (the key is not checked).`);
23966
+ if (setting2) return failAt(id, setting2.line, "warning", `HSRP "${name}" uses clear-text authentication: configure "authentication md5 key-chain <name>".`);
23967
+ return failAt(
23968
+ id,
23969
+ group,
23970
+ "warning",
23971
+ `HSRP "${name}" has no authentication, so it uses the default clear-text string "cisco": configure "authentication md5 key-chain <name>".`
23972
+ );
23973
+ });
23974
+ }
23975
+ };
23976
+ var allNxosRules = [
23977
+ NxosSshKeyStrength,
23978
+ NxosSshAlgorithms,
23979
+ NxosSshLoginAttempts,
23980
+ NxosLoginBlockFor,
23981
+ NxosConsoleExecTimeout,
23982
+ NxosVtyAccessClass,
23983
+ NxosBannerRequired,
23984
+ NxosBannerDisclosure,
23985
+ NxosNxapiHttp,
23986
+ NxosNxapiTls,
23987
+ NxosPasswordStrengthCheck,
23988
+ NxosPasswordMinLength,
23989
+ NxosRemoteAaaLogin,
23990
+ NxosAaaNoneMethod,
23991
+ NxosAaaAccounting,
23992
+ NxosAaaCommandAuthorization,
23993
+ NxosAaaServerKey,
23994
+ NxosLoginFailureLog,
23995
+ NxosSyslogServer,
23996
+ NxosLogTimestamps,
23997
+ NxosLogSourceInterface,
23998
+ NxosNtpServers,
23999
+ NxosNtpAuthenticate,
24000
+ NxosNtpServerKeys,
24001
+ NxosSnmpUserPriv,
24002
+ NxosSnmpEnforcePriv,
24003
+ NxosSnmpCommunityAcl,
24004
+ NxosCopp,
24005
+ NxosBpduGuard,
24006
+ NxosStormControl,
24007
+ NxosVpcPeerKeepalive,
24008
+ NxosSourceRoute,
24009
+ NxosIcmpRedirects,
24010
+ NxosProxyArp,
24011
+ NxosOspfAuthentication,
24012
+ NxosOspfCleartext,
24013
+ NxosOspfLogAdjacency,
24014
+ NxosEigrpAuthentication,
24015
+ NxosHsrpMd5
24016
+ ];
24017
+
22318
24018
  // ../rules-default/src/juniper/junos-rules.ts
22319
24019
  var idIs = (node, name) => node !== void 0 && equalsIgnoreCase(node.id.trim(), name);
22320
24020
  var enclosingBlocks = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
@@ -24367,7 +26067,7 @@ var allJuniperRules = [
24367
26067
  JunosFirewallDefaultDeny,
24368
26068
  JunosSnmpNoCommunity,
24369
26069
  JunosLldpExternal,
24370
- // Ported from the former commercial set (decision 0001 S3b)
26070
+ // Ported rules
24371
26071
  JunosInsecureServices,
24372
26072
  JunosSshRootLogin,
24373
26073
  JunosAaaRequired,
@@ -24393,7 +26093,7 @@ var allJuniperRules = [
24393
26093
  JunosFlowMonitoring,
24394
26094
  JunosNonstopRouting,
24395
26095
  JunosSecretStorage,
24396
- // Paid-only rules opened (gecko#60)
26096
+ // More ported rules
24397
26097
  JunosOspfInterfaceAuth,
24398
26098
  JunosIcmpRateLimit,
24399
26099
  JunosBgpTtlSecurity,
@@ -24407,7 +26107,7 @@ var allJuniperRules = [
24407
26107
  var generalTags2 = (...labels) => labels.map((label) => ({ type: "general", label }));
24408
26108
  var textOf2 = (node) => node.id.trim().replace(/\s+/g, " ").toLowerCase();
24409
26109
  var wordsOf2 = (node) => node.params.map((p) => p.toLowerCase());
24410
- var passAt = (ruleId, node, message) => ({
26110
+ var passAt2 = (ruleId, node, message) => ({
24411
26111
  passed: true,
24412
26112
  message,
24413
26113
  ruleId,
@@ -24415,7 +26115,7 @@ var passAt = (ruleId, node, message) => ({
24415
26115
  level: "info",
24416
26116
  loc: locOf(node)
24417
26117
  });
24418
- var failAt = (ruleId, at2, message, level) => ({
26118
+ var failAt2 = (ruleId, at2, message, level) => ({
24419
26119
  passed: false,
24420
26120
  message,
24421
26121
  ruleId,
@@ -24424,7 +26124,7 @@ var failAt = (ruleId, at2, message, level) => ({
24424
26124
  loc: locOf(at2)
24425
26125
  });
24426
26126
  var failAbsent = (ruleId, anchor, message, level) => ({
24427
- ...failAt(ruleId, anchor, message, level),
26127
+ ...failAt2(ruleId, anchor, message, level),
24428
26128
  nodeId: maskSecretLine(anchor),
24429
26129
  absent: true
24430
26130
  });
@@ -24497,7 +26197,7 @@ var SshEnabled = {
24497
26197
  },
24498
26198
  check: configWide("aoscx", (statements, anchor) => {
24499
26199
  const enabled = statements.find((s) => /^ssh server vrf \S+$/.test(textOf2(s)));
24500
- if (enabled) return passAt("ARU-SEC-001", enabled, "SSH server is enabled on a VRF.");
26200
+ if (enabled) return passAt2("ARU-SEC-001", enabled, "SSH server is enabled on a VRF.");
24501
26201
  return failAbsent(
24502
26202
  "ARU-SEC-001",
24503
26203
  anchor,
@@ -24572,10 +26272,10 @@ var TelnetDisabled = {
24572
26272
  check: (node, context) => {
24573
26273
  const text = textOf2(node);
24574
26274
  if (text.startsWith("telnet")) {
24575
- return failAt("ARU-SEC-003", node, "Telnet is enabled. Consider disabling and using SSH instead.", "warning");
26275
+ return failAt2("ARU-SEC-003", node, "Telnet is enabled. Consider disabling and using SSH instead.", "warning");
24576
26276
  }
24577
26277
  if (/^no telnet-server\b/.test(text)) {
24578
- return passAt("ARU-SEC-003", node, "Telnet server is disabled.");
26278
+ return passAt2("ARU-SEC-003", node, "Telnet server is disabled.");
24579
26279
  }
24580
26280
  const index = indexOf(context);
24581
26281
  if (!index || index.statements[0] !== node || index.platform !== "aosswitch") return [];
@@ -24608,7 +26308,7 @@ var NtpConfigured = {
24608
26308
  },
24609
26309
  check: configWideOn(["aoscx", "wlc"], (_platform, statements, anchor) => {
24610
26310
  const server = statements.find((s) => NTP_SERVER.test(textOf2(s)));
24611
- if (server) return passAt("ARU-NTP-001", server, "NTP server is configured.");
26311
+ if (server) return passAt2("ARU-NTP-001", server, "NTP server is configured.");
24612
26312
  return failAbsent("ARU-NTP-001", anchor, 'No NTP server is configured ("ntp server <address>").', "warning");
24613
26313
  })
24614
26314
  };
@@ -24626,8 +26326,8 @@ var SntpConfigured = {
24626
26326
  const server = statements.find((s) => SNTP_SERVER.test(textOf2(s)));
24627
26327
  if (!server) return [];
24628
26328
  const has = (text) => statements.some((s) => textOf2(s) === text);
24629
- if (has("timesync sntp") && has("sntp unicast")) return passAt("ARU-NTP-002", server, "SNTP servers are in use.");
24630
- return failAt(
26329
+ if (has("timesync sntp") && has("sntp unicast")) return passAt2("ARU-NTP-002", server, "SNTP servers are in use.");
26330
+ return failAt2(
24631
26331
  "ARU-NTP-002",
24632
26332
  server,
24633
26333
  'SNTP servers are configured but not used: add "timesync sntp" and "sntp unicast".',
@@ -24654,7 +26354,7 @@ var LoggingConfigured = {
24654
26354
  },
24655
26355
  check: configWideOn(["aoscx", "aosswitch", "wlc"], (_platform, statements, anchor) => {
24656
26356
  const server = statements.find((s) => /^logging \S*[.:]/.test(textOf2(s)));
24657
- if (server) return passAt("ARU-LOG-001", server, "Remote syslog server is configured.");
26357
+ if (server) return passAt2("ARU-LOG-001", server, "Remote syslog server is configured.");
24658
26358
  return failAbsent("ARU-LOG-001", anchor, 'No remote syslog server is configured ("logging <address>").', "warning");
24659
26359
  })
24660
26360
  };
@@ -24683,7 +26383,7 @@ var AaaConfigured = {
24683
26383
  },
24684
26384
  check: configWideOn(["aoscx", "aosswitch", "wlc"], (platform, statements, anchor) => {
24685
26385
  const remote = statements.find(platform === "wlc" ? isWlcManagementServerGroup : isRemoteAuthentication);
24686
- if (remote) return passAt("ARU-AAA-001", remote, "Management logins use a remote authentication server.");
26386
+ if (remote) return passAt2("ARU-AAA-001", remote, "Management logins use a remote authentication server.");
24687
26387
  return failAbsent(
24688
26388
  "ARU-AAA-001",
24689
26389
  anchor,
@@ -24722,7 +26422,7 @@ var RadiusKeyConfigured = {
24722
26422
  check: (node, context) => {
24723
26423
  const missing = serverKeyMissing(node, context, "radius");
24724
26424
  if (missing === void 0) {
24725
- return passAt("ARU-RAD-001", node, "Not a RADIUS server host statement.");
26425
+ return passAt2("ARU-RAD-001", node, "Not a RADIUS server host statement.");
24726
26426
  }
24727
26427
  if (missing) {
24728
26428
  return {
@@ -24765,7 +26465,7 @@ var TacacsKeyConfigured = {
24765
26465
  check: (node, context) => {
24766
26466
  const missing = serverKeyMissing(node, context, "tacacs");
24767
26467
  if (missing === void 0) {
24768
- return passAt("ARU-TAC-001", node, "Not a TACACS+ server host statement.");
26468
+ return passAt2("ARU-TAC-001", node, "Not a TACACS+ server host statement.");
24769
26469
  }
24770
26470
  if (missing) {
24771
26471
  return {
@@ -24812,8 +26512,8 @@ var AaaAccountingEnabled = {
24812
26512
  if (!index?.platform || !isRemoteAuthentication(node)) return [];
24813
26513
  if (index.statements.find(isRemoteAuthentication) !== node) return [];
24814
26514
  const accounting = index.statements.find(isRemoteAccounting);
24815
- if (accounting) return passAt("ARU-AAA-003", accounting, "AAA accounting is sent to a server.");
24816
- return failAt(
26515
+ if (accounting) return passAt2("ARU-AAA-003", accounting, "AAA accounting is sent to a server.");
26516
+ return failAt2(
24817
26517
  "ARU-AAA-003",
24818
26518
  node,
24819
26519
  'Login authentication uses a remote server, but no "aaa accounting" sends records to one; accounting stays on the switch (or is off).',
@@ -24831,7 +26531,7 @@ var allArubaCommonRules = [
24831
26531
  AaaConfigured,
24832
26532
  RadiusKeyConfigured,
24833
26533
  TacacsKeyConfigured,
24834
- // Ported from the former commercial set (decision 0001 S3b)
26534
+ // Ported rules
24835
26535
  AaaAccountingEnabled
24836
26536
  ];
24837
26537
 
@@ -25317,10 +27017,10 @@ var AosCxUsbDisabled = {
25317
27017
  },
25318
27018
  check: configWide("aoscx", (statements, anchor) => {
25319
27019
  const disabled = statements.find((s) => textOf2(s) === "no usb");
25320
- if (disabled) return passAt("ARU-HARD-001", disabled, "USB auxiliary port is disabled.");
27020
+ if (disabled) return passAt2("ARU-HARD-001", disabled, "USB auxiliary port is disabled.");
25321
27021
  const enabled = statements.find((s) => textOf2(s) === "usb");
25322
27022
  if (enabled) {
25323
- return failAt("ARU-HARD-001", enabled, 'USB auxiliary port is enabled. Disable with "no usb" when not in use.', "warning");
27023
+ return failAt2("ARU-HARD-001", enabled, 'USB auxiliary port is enabled. Disable with "no usb" when not in use.', "warning");
25324
27024
  }
25325
27025
  return failAbsent(
25326
27026
  "ARU-HARD-001",
@@ -25357,7 +27057,7 @@ var AosCxPasswordComplexity = {
25357
27057
  );
25358
27058
  }
25359
27059
  if (!block.children.some((c) => textOf2(c) === "enable")) {
25360
- return failAt(
27060
+ return failAt2(
25361
27061
  "ARU-HARD-002",
25362
27062
  block,
25363
27063
  'Password complexity is not enabled: add "enable" in the password complexity context.',
@@ -25371,7 +27071,7 @@ var AosCxPasswordComplexity = {
25371
27071
  if (minLength === null || minLength < 12) {
25372
27072
  const shown2 = lengthValue === void 0 ? "8 (the default)" : lengthValue;
25373
27073
  results.push(
25374
- failAt(
27074
+ failAt2(
25375
27075
  "ARU-HARD-002",
25376
27076
  lengthCmd ?? block,
25377
27077
  `Password minimum length is ${shown2}. Recommended minimum is 12 characters.`,
@@ -25382,7 +27082,7 @@ var AosCxPasswordComplexity = {
25382
27082
  for (const child of block.children) {
25383
27083
  if (COMPLEXITY_CLASS.test(textOf2(child))) {
25384
27084
  results.push(
25385
- failAt(
27085
+ failAt2(
25386
27086
  "ARU-HARD-002",
25387
27087
  child,
25388
27088
  `"${child.id.trim()}" removes a character-class requirement. Require uppercase, lowercase, numeric, and special characters.`,
@@ -25391,7 +27091,7 @@ var AosCxPasswordComplexity = {
25391
27091
  );
25392
27092
  }
25393
27093
  }
25394
- return results.length > 0 ? results : passAt("ARU-HARD-002", block, "Password complexity is properly configured.");
27094
+ return results.length > 0 ? results : passAt2("ARU-HARD-002", block, "Password complexity is properly configured.");
25395
27095
  })
25396
27096
  };
25397
27097
  var GENERIC_HOSTNAME = /^(?:switch|aruba|cx\d*)$/i;
@@ -25412,9 +27112,9 @@ var AosCxHostname = {
25412
27112
  return failAbsent("ARU-HARD-003", anchor, 'Hostname is not configured; the switch uses the default name "switch".', "warning");
25413
27113
  }
25414
27114
  if (GENERIC_HOSTNAME.test(hostname)) {
25415
- return failAt("ARU-HARD-003", statement2, `Generic hostname "${hostname}" detected. Use a descriptive hostname.`, "warning");
27115
+ return failAt2("ARU-HARD-003", statement2, `Generic hostname "${hostname}" detected. Use a descriptive hostname.`, "warning");
25416
27116
  }
25417
- return passAt("ARU-HARD-003", statement2, `Hostname "${hostname}" is configured.`);
27117
+ return passAt2("ARU-HARD-003", statement2, `Hostname "${hostname}" is configured.`);
25418
27118
  })
25419
27119
  };
25420
27120
  var AosCxNtpAuthentication = {
@@ -25436,7 +27136,7 @@ var AosCxNtpAuthentication = {
25436
27136
  const words = wordsOf2(node);
25437
27137
  if (words[1] !== "server" || words[2] === void 0) return [];
25438
27138
  if (!words.slice(3).includes("key")) {
25439
- return failAt(
27139
+ return failAt2(
25440
27140
  "ARU-HARD-004",
25441
27141
  node,
25442
27142
  `NTP server ${node.params[2] ?? ""} configured without authentication key. Use "ntp server <ip> key <id>".`,
@@ -25445,14 +27145,14 @@ var AosCxNtpAuthentication = {
25445
27145
  }
25446
27146
  const statements = indexOf(context)?.statements;
25447
27147
  if (statements && !statements.some((s) => textOf2(s) === "ntp authentication")) {
25448
- return failAt(
27148
+ return failAt2(
25449
27149
  "ARU-HARD-004",
25450
27150
  node,
25451
27151
  'NTP server has a key, but "ntp authentication" is not in the configuration. Enable it so the key is checked.',
25452
27152
  "info"
25453
27153
  );
25454
27154
  }
25455
- return passAt("ARU-HARD-004", node, "NTP server uses an authentication key.");
27155
+ return passAt2("ARU-HARD-004", node, "NTP server uses an authentication key.");
25456
27156
  }
25457
27157
  };
25458
27158
  var AosCxBanner = {
@@ -25468,7 +27168,7 @@ var AosCxBanner = {
25468
27168
  },
25469
27169
  check: configWide("aoscx", (statements, anchor) => {
25470
27170
  const banner = statements.find((s) => /^banner (motd|exec)\b/.test(textOf2(s)));
25471
- if (banner) return passAt("ARU-HARD-006", banner, "Login banner is configured.");
27171
+ if (banner) return passAt2("ARU-HARD-006", banner, "Login banner is configured.");
25472
27172
  return failAbsent(
25473
27173
  "ARU-HARD-006",
25474
27174
  anchor,
@@ -25496,9 +27196,9 @@ var AosCxSshVrfMgmt = {
25496
27196
  const vrf = wordsOf2(node)[3];
25497
27197
  if (vrf === void 0) return [];
25498
27198
  if (vrf === "default") {
25499
- return failAt("ARU-MGMT-001", node, "SSH is enabled on default VRF. Restrict to management VRF for security.", "warning");
27199
+ return failAt2("ARU-MGMT-001", node, "SSH is enabled on default VRF. Restrict to management VRF for security.", "warning");
25500
27200
  }
25501
- return passAt("ARU-MGMT-001", node, `SSH is enabled on VRF ${node.params[3] ?? vrf}.`);
27201
+ return passAt2("ARU-MGMT-001", node, `SSH is enabled on VRF ${node.params[3] ?? vrf}.`);
25502
27202
  }
25503
27203
  };
25504
27204
  var AosCxLoginLockout = {
@@ -25527,14 +27227,14 @@ var AosCxLoginLockout = {
25527
27227
  }
25528
27228
  const attempts = parseInteger(statement2.params[3] ?? "");
25529
27229
  if (attempts === null || attempts > 5) {
25530
- return failAt(
27230
+ return failAt2(
25531
27231
  "ARU-MGMT-004",
25532
27232
  statement2,
25533
27233
  `Max login attempts is ${statement2.params[3] ?? "unset"}. Recommended maximum is 3-5.`,
25534
27234
  "warning"
25535
27235
  );
25536
27236
  }
25537
- return passAt("ARU-MGMT-004", statement2, `Login attempt limit set to ${attempts}.`);
27237
+ return passAt2("ARU-MGMT-004", statement2, `Login attempt limit set to ${attempts}.`);
25538
27238
  })
25539
27239
  };
25540
27240
  var AosCxSessionTimeout = {
@@ -25555,21 +27255,21 @@ var AosCxSessionTimeout = {
25555
27255
  const cliSession = statements.find((s) => textOf2(s) === "cli-session");
25556
27256
  const timeoutCmd = (cliSession && childStarting(cliSession, "timeout")) ?? statements.find((s) => wordsOf2(s)[0] === "session-timeout");
25557
27257
  if (!timeoutCmd) {
25558
- return passAt("ARU-MGMT-005", anchor, "CLI session idle timeout is the default of 30 minutes.");
27258
+ return passAt2("ARU-MGMT-005", anchor, "CLI session idle timeout is the default of 30 minutes.");
25559
27259
  }
25560
27260
  const timeout = parseInteger(timeoutCmd.params[1] ?? "");
25561
27261
  if (timeout === 0) {
25562
- return failAt("ARU-MGMT-005", timeoutCmd, "Session timeout is disabled (0). Configure a reasonable timeout.", "warning");
27262
+ return failAt2("ARU-MGMT-005", timeoutCmd, "Session timeout is disabled (0). Configure a reasonable timeout.", "warning");
25563
27263
  }
25564
27264
  if (timeout !== null && timeout > 30) {
25565
- return failAt(
27265
+ return failAt2(
25566
27266
  "ARU-MGMT-005",
25567
27267
  timeoutCmd,
25568
27268
  `Session timeout is ${timeout} minutes. Recommended is 10-15 minutes.`,
25569
27269
  "warning"
25570
27270
  );
25571
27271
  }
25572
- return passAt("ARU-MGMT-005", timeoutCmd, "Session timeout is configured.");
27272
+ return passAt2("ARU-MGMT-005", timeoutCmd, "Session timeout is configured.");
25573
27273
  })
25574
27274
  };
25575
27275
  var isDhcpSnoopingOn = (text) => text === "dhcpv4-snooping" || text === "dhcp-snooping";
@@ -25589,7 +27289,7 @@ var AosCxDhcpSnooping = {
25589
27289
  },
25590
27290
  check: configWide("aoscx", (statements, anchor) => {
25591
27291
  const vlans = accessVlansOf(statements);
25592
- if (vlans.size === 0) return passAt("ARU-L2-001", anchor, "No active access ports.");
27292
+ if (vlans.size === 0) return passAt2("ARU-L2-001", anchor, "No active access ports.");
25593
27293
  const global = statements.find((s) => isDhcpSnoopingOn(textOf2(s)));
25594
27294
  if (!global) {
25595
27295
  return failAbsent(
@@ -25604,10 +27304,10 @@ var AosCxDhcpSnooping = {
25604
27304
  const block = vlanBlockOf(statements, vlan);
25605
27305
  if (block?.children.some((c) => isDhcpSnoopingOn(textOf2(c)))) continue;
25606
27306
  results.push(
25607
- failAt("ARU-L2-001", block ?? port, `DHCP snooping is not enabled in access VLAN ${vlan}.`, "warning")
27307
+ failAt2("ARU-L2-001", block ?? port, `DHCP snooping is not enabled in access VLAN ${vlan}.`, "warning")
25608
27308
  );
25609
27309
  }
25610
- return results.length > 0 ? results : passAt("ARU-L2-001", global, "DHCP snooping is enabled on every access VLAN.");
27310
+ return results.length > 0 ? results : passAt2("ARU-L2-001", global, "DHCP snooping is enabled on every access VLAN.");
25611
27311
  })
25612
27312
  };
25613
27313
  var AosCxArpInspection = {
@@ -25626,16 +27326,16 @@ var AosCxArpInspection = {
25626
27326
  },
25627
27327
  check: configWide("aoscx", (statements, anchor) => {
25628
27328
  const vlans = accessVlansOf(statements);
25629
- if (vlans.size === 0) return passAt("ARU-L2-002", anchor, "No active access ports.");
27329
+ if (vlans.size === 0) return passAt2("ARU-L2-002", anchor, "No active access ports.");
25630
27330
  const results = [];
25631
27331
  for (const [vlan, port] of vlans) {
25632
27332
  const block = vlanBlockOf(statements, vlan);
25633
27333
  if (block?.children.some((c) => textOf2(c) === "arp inspection")) continue;
25634
27334
  results.push(
25635
- failAt("ARU-L2-002", block ?? port, `Dynamic ARP inspection is not enabled in access VLAN ${vlan} ("arp inspection").`, "info")
27335
+ failAt2("ARU-L2-002", block ?? port, `Dynamic ARP inspection is not enabled in access VLAN ${vlan} ("arp inspection").`, "info")
25636
27336
  );
25637
27337
  }
25638
- return results.length > 0 ? results : passAt("ARU-L2-002", anchor, "ARP inspection is enabled on every access VLAN.");
27338
+ return results.length > 0 ? results : passAt2("ARU-L2-002", anchor, "ARP inspection is enabled on every access VLAN.");
25639
27339
  })
25640
27340
  };
25641
27341
  var AosCxPortSecurity = {
@@ -25654,11 +27354,11 @@ var AosCxPortSecurity = {
25654
27354
  tags: generalTags2("layer2-security", "mac-flooding")
25655
27355
  },
25656
27356
  check: (node) => {
25657
- if (!isActiveAccessPort(node)) return passAt("ARU-L2-003", node, "Not an active access port.");
27357
+ if (!isActiveAccessPort(node)) return passAt2("ARU-L2-003", node, "Not an active access port.");
25658
27358
  if (hasAosCxPortSecurity(node) || hasAosCxDot1x(node) || hasAosCxMacAuth(node)) {
25659
- return passAt("ARU-L2-003", node, "Port security or port-access authentication is enabled.");
27359
+ return passAt2("ARU-L2-003", node, "Port security or port-access authentication is enabled.");
25660
27360
  }
25661
- return failAt("ARU-L2-003", node, `Access port ${getInterfaceName(node) ?? ""} should have port security enabled.`, "warning");
27361
+ return failAt2("ARU-L2-003", node, `Access port ${getInterfaceName(node) ?? ""} should have port security enabled.`, "warning");
25662
27362
  }
25663
27363
  };
25664
27364
  var AosCxMstpRegion = {
@@ -25673,12 +27373,12 @@ var AosCxMstpRegion = {
25673
27373
  },
25674
27374
  check: configWide("aoscx", (statements, anchor) => {
25675
27375
  const enabled = statements.find((s) => textOf2(s) === "spanning-tree");
25676
- if (!enabled) return passAt("ARU-STP-001", anchor, "Spanning tree is not enabled.");
27376
+ if (!enabled) return passAt2("ARU-STP-001", anchor, "Spanning tree is not enabled.");
25677
27377
  const mode = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "spanning-tree mode")?.params[2]?.toLowerCase();
25678
- if (mode !== void 0 && mode !== "mstp") return passAt("ARU-STP-001", enabled, `Spanning tree runs in ${mode} mode.`);
27378
+ if (mode !== void 0 && mode !== "mstp") return passAt2("ARU-STP-001", enabled, `Spanning tree runs in ${mode} mode.`);
25679
27379
  const name = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "spanning-tree config-name");
25680
- if (name) return passAt("ARU-STP-001", name, "MSTP region name is configured.");
25681
- return failAt(
27380
+ if (name) return passAt2("ARU-STP-001", name, "MSTP region name is configured.");
27381
+ return failAt2(
25682
27382
  "ARU-STP-001",
25683
27383
  enabled,
25684
27384
  "MSTP region name is not configured; the default (the switch MAC address) puts each switch in its own region.",
@@ -25704,10 +27404,10 @@ var AosCxRootGuard = {
25704
27404
  check: (node) => {
25705
27405
  const ifName = getInterfaceName(node);
25706
27406
  if (!ifName || !(isAosCxPhysicalPort(ifName) || isAosCxLag(ifName)) || !isAosCxTrunk(node) || !isActive(node)) {
25707
- return passAt("ARU-STP-003", node, "Not an active trunk port.");
27407
+ return passAt2("ARU-STP-003", node, "Not an active trunk port.");
25708
27408
  }
25709
- if (hasAosCxRootGuard(node)) return passAt("ARU-STP-003", node, "Root guard is enabled.");
25710
- return failAt("ARU-STP-003", node, `Trunk port ${ifName} should consider root-guard for downstream switch protection.`, "info");
27409
+ if (hasAosCxRootGuard(node)) return passAt2("ARU-STP-003", node, "Root guard is enabled.");
27410
+ return failAt2("ARU-STP-003", node, `Trunk port ${ifName} should consider root-guard for downstream switch protection.`, "info");
25711
27411
  }
25712
27412
  };
25713
27413
  var AosCxLoopProtect = {
@@ -25726,9 +27426,9 @@ var AosCxLoopProtect = {
25726
27426
  tags: generalTags2("layer2-security", "loop-prevention")
25727
27427
  },
25728
27428
  check: (node) => {
25729
- if (!isActiveAccessPort(node)) return passAt("ARU-STP-004", node, "Not an active access port.");
25730
- if (hasAosCxLoopProtect(node)) return passAt("ARU-STP-004", node, "Loop protection is enabled.");
25731
- return failAt("ARU-STP-004", node, `Access port ${getInterfaceName(node) ?? ""} should have loop-protect enabled.`, "warning");
27429
+ if (!isActiveAccessPort(node)) return passAt2("ARU-STP-004", node, "Not an active access port.");
27430
+ if (hasAosCxLoopProtect(node)) return passAt2("ARU-STP-004", node, "Loop protection is enabled.");
27431
+ return failAt2("ARU-STP-004", node, `Access port ${getInterfaceName(node) ?? ""} should have loop-protect enabled.`, "warning");
25732
27432
  }
25733
27433
  };
25734
27434
  var AosCxStormControl = {
@@ -25749,10 +27449,10 @@ var AosCxStormControl = {
25749
27449
  check: (node) => {
25750
27450
  const ifName = getInterfaceName(node);
25751
27451
  if (!ifName || !isAosCxPhysicalPort(ifName) || !(isAosCxAccess(node) || isAosCxTrunk(node)) || !isActive(node)) {
25752
- return passAt("ARU-STP-005", node, "Not an active layer 2 port.");
27452
+ return passAt2("ARU-STP-005", node, "Not an active layer 2 port.");
25753
27453
  }
25754
- if (hasAosCxStormControl(node)) return passAt("ARU-STP-005", node, "Storm control is configured.");
25755
- return failAt("ARU-STP-005", node, `Interface ${ifName} should have storm control (rate-limit) configured.`, "warning");
27454
+ if (hasAosCxStormControl(node)) return passAt2("ARU-STP-005", node, "Storm control is configured.");
27455
+ return failAt2("ARU-STP-005", node, `Interface ${ifName} should have storm control (rate-limit) configured.`, "warning");
25756
27456
  }
25757
27457
  };
25758
27458
  var AosCxDot1xOnAccess = {
@@ -25771,11 +27471,11 @@ var AosCxDot1xOnAccess = {
25771
27471
  tags: generalTags2("authentication", "network-access-control")
25772
27472
  },
25773
27473
  check: (node) => {
25774
- if (!isActiveAccessPort(node)) return passAt("ARU-DOT1X-001", node, "Not an active access port.");
27474
+ if (!isActiveAccessPort(node)) return passAt2("ARU-DOT1X-001", node, "Not an active access port.");
25775
27475
  if (hasAosCxDot1x(node) || hasAosCxMacAuth(node)) {
25776
- return passAt("ARU-DOT1X-001", node, "Port access authentication is enabled.");
27476
+ return passAt2("ARU-DOT1X-001", node, "Port access authentication is enabled.");
25777
27477
  }
25778
- return failAt(
27478
+ return failAt2(
25779
27479
  "ARU-DOT1X-001",
25780
27480
  node,
25781
27481
  `Access port ${getInterfaceName(node) ?? ""} should have 802.1X or MAC authentication enabled.`,
@@ -25808,7 +27508,7 @@ var AosCxOspfAuth = {
25808
27508
  const ifName = getInterfaceName(node) ?? "";
25809
27509
  const ospf = node.children.map(wordsOf2).find((w) => w[0] === "ip" && w[1] === "ospf" && /^\d+$/.test(w[2] ?? "") && w[3] === "area");
25810
27510
  if (!ospf || /^loopback/i.test(ifName) || node.children.some((c) => textOf2(c) === "ip ospf passive")) {
25811
- return passAt("ARU-RTG-001", node, "No active OSPF adjacency on this interface.");
27511
+ return passAt2("ARU-RTG-001", node, "No active OSPF adjacency on this interface.");
25812
27512
  }
25813
27513
  let type = node.children.map(wordsOf2).map((w) => w[0] === "ip" && w[1] === "ospf" ? ospfAuthType(w, 2) : void 0).find((t) => t !== void 0);
25814
27514
  if (type === void 0) {
@@ -25817,7 +27517,7 @@ var AosCxOspfAuth = {
25817
27517
  type = router?.children.map(wordsOf2).map((w) => w[0] === "area" && normalizeArea(w[1] ?? "") === area ? ospfAuthType(w, 2) : void 0).find((t) => t !== void 0);
25818
27518
  }
25819
27519
  if (type === void 0 || type === "null") {
25820
- return failAt(
27520
+ return failAt2(
25821
27521
  "ARU-RTG-001",
25822
27522
  node,
25823
27523
  "OSPF interface has no authentication configured. Enable message-digest or keychain authentication.",
@@ -25825,9 +27525,9 @@ var AosCxOspfAuth = {
25825
27525
  );
25826
27526
  }
25827
27527
  if (type === "simple-text") {
25828
- return failAt("ARU-RTG-001", node, "OSPF uses simple-text authentication, which sends the key in clear text. Use message-digest or keychain.", "warning");
27528
+ return failAt2("ARU-RTG-001", node, "OSPF uses simple-text authentication, which sends the key in clear text. Use message-digest or keychain.", "warning");
25829
27529
  }
25830
- return passAt("ARU-RTG-001", node, "OSPF authentication is configured.");
27530
+ return passAt2("ARU-RTG-001", node, "OSPF authentication is configured.");
25831
27531
  }
25832
27532
  };
25833
27533
  var AosCxBgpAuth = {
@@ -25875,9 +27575,9 @@ var AosCxBgpAuth = {
25875
27575
  const group = entry.peerGroup ? neighbors.get(entry.peerGroup) : void 0;
25876
27576
  if (entry.password || group?.password) continue;
25877
27577
  const name = key.split(" ")[1] ?? key;
25878
- results.push(failAt("ARU-RTG-002", entry.peer, `BGP neighbor ${name} has no password configured.`, "warning"));
27578
+ results.push(failAt2("ARU-RTG-002", entry.peer, `BGP neighbor ${name} has no password configured.`, "warning"));
25879
27579
  }
25880
- return results.length > 0 ? results : passAt("ARU-RTG-002", node, "BGP authentication is configured.");
27580
+ return results.length > 0 ? results : passAt2("ARU-RTG-002", node, "BGP authentication is configured.");
25881
27581
  }
25882
27582
  };
25883
27583
  var AosCxVsxKeepaliveVrf = {
@@ -25895,18 +27595,18 @@ var AosCxVsxKeepaliveVrf = {
25895
27595
  check: (node) => {
25896
27596
  if (textOf2(node) !== "vsx") return [];
25897
27597
  const keepalive = node.children.find((c) => wordsOf2(c)[0] === "keepalive" && wordsOf2(c)[1] === "peer");
25898
- if (!keepalive) return failAt("ARU-HA-001", node, "VSX keepalive is not configured.", "warning");
27598
+ if (!keepalive) return failAt2("ARU-HA-001", node, "VSX keepalive is not configured.", "warning");
25899
27599
  const words = wordsOf2(keepalive);
25900
27600
  const vrf = words[words.indexOf("vrf") + 1];
25901
27601
  if (!words.includes("vrf") || vrf === void 0 || vrf === "default") {
25902
- return failAt(
27602
+ return failAt2(
25903
27603
  "ARU-HA-001",
25904
27604
  keepalive,
25905
27605
  "VSX keepalive runs in the default VRF; use a dedicated VRF so it does not traverse VSX LAG paths.",
25906
27606
  "warning"
25907
27607
  );
25908
27608
  }
25909
- return passAt("ARU-HA-001", keepalive, `VSX keepalive is configured in VRF ${vrf}.`);
27609
+ return passAt2("ARU-HA-001", keepalive, `VSX keepalive is configured in VRF ${vrf}.`);
25910
27610
  }
25911
27611
  };
25912
27612
  var AosCxMacsecCipher = {
@@ -25926,17 +27626,17 @@ var AosCxMacsecCipher = {
25926
27626
  },
25927
27627
  check: (node) => {
25928
27628
  const cipher = childStarting(node, "cipher-suite");
25929
- if (!cipher) return passAt("ARU-MACSEC-001", node, "MACsec uses the default cipher suite gcm-aes-xpn-256.");
27629
+ if (!cipher) return passAt2("ARU-MACSEC-001", node, "MACsec uses the default cipher suite gcm-aes-xpn-256.");
25930
27630
  const weak = wordsOf2(cipher).slice(1).filter((suite) => suite.endsWith("-128"));
25931
27631
  if (weak.length > 0) {
25932
- return failAt(
27632
+ return failAt2(
25933
27633
  "ARU-MACSEC-001",
25934
27634
  cipher,
25935
27635
  `MACsec policy allows ${weak.join(", ")}. Consider using gcm-aes-256 (or gcm-aes-xpn-256) for strongest MACsec encryption.`,
25936
27636
  "warning"
25937
27637
  );
25938
27638
  }
25939
- return passAt("ARU-MACSEC-001", cipher, "MACsec is using 256-bit encryption.");
27639
+ return passAt2("ARU-MACSEC-001", cipher, "MACsec is using 256-bit encryption.");
25940
27640
  }
25941
27641
  };
25942
27642
  var DEFAULT_COMMUNITIES = /* @__PURE__ */ new Set(["public", "private"]);
@@ -25957,7 +27657,7 @@ var AosCxSnmpv3Required = {
25957
27657
  },
25958
27658
  check: configWide("aoscx", (statements, anchor) => {
25959
27659
  const agent = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "snmp-server vrf");
25960
- if (!agent) return passAt("ARU-LOG-003", anchor, "SNMP is not enabled (no snmp-server vrf).");
27660
+ if (!agent) return passAt2("ARU-LOG-003", anchor, "SNMP is not enabled (no snmp-server vrf).");
25961
27661
  const communities = statements.filter((s) => wordsOf2(s).slice(0, 2).join(" ") === "snmp-server community");
25962
27662
  if (communities.length === 0) {
25963
27663
  return failAbsent(
@@ -25968,14 +27668,14 @@ var AosCxSnmpv3Required = {
25968
27668
  );
25969
27669
  }
25970
27670
  const results = communities.filter((c) => !DEFAULT_COMMUNITIES.has((c.params[2] ?? "").toLowerCase())).map(
25971
- (c) => failAt(
27671
+ (c) => failAt2(
25972
27672
  "ARU-LOG-003",
25973
27673
  c,
25974
27674
  "SNMPv2c community string detected. Consider using SNMPv3 with authentication and privacy.",
25975
27675
  "warning"
25976
27676
  )
25977
27677
  );
25978
- return results.length > 0 ? results : passAt("ARU-LOG-003", agent, "Only default-named communities, reported by ARU-SEC-002.");
27678
+ return results.length > 0 ? results : passAt2("ARU-LOG-003", agent, "Only default-named communities, reported by ARU-SEC-002.");
25979
27679
  })
25980
27680
  };
25981
27681
  var AosCxSnmpv3AuthPriv = {
@@ -25995,11 +27695,11 @@ var AosCxSnmpv3AuthPriv = {
25995
27695
  },
25996
27696
  check: (node) => {
25997
27697
  const words = wordsOf2(node).slice(3);
25998
- if (!words.includes("auth")) return failAt("ARU-LOG-002", node, "SNMPv3 user has no authentication configured.", "warning");
27698
+ if (!words.includes("auth")) return failAt2("ARU-LOG-002", node, "SNMPv3 user has no authentication configured.", "warning");
25999
27699
  if (!words.includes("priv")) {
26000
- return failAt("ARU-LOG-002", node, "SNMPv3 user has authentication but no privacy (encryption).", "warning");
27700
+ return failAt2("ARU-LOG-002", node, "SNMPv3 user has authentication but no privacy (encryption).", "warning");
26001
27701
  }
26002
- return passAt("ARU-LOG-002", node, "SNMPv3 user has authentication and privacy enabled.");
27702
+ return passAt2("ARU-LOG-002", node, "SNMPv3 user has authentication and privacy enabled.");
26003
27703
  }
26004
27704
  };
26005
27705
  var allAosCxRules = [
@@ -26013,7 +27713,7 @@ var allAosCxRules = [
26013
27713
  AosCxOspfRouterId,
26014
27714
  AosCxBgpRouterId,
26015
27715
  AosCxLagLacp,
26016
- // Ported from the former commercial set (decision 0001 S3b)
27716
+ // Ported rules
26017
27717
  AosCxUsbDisabled,
26018
27718
  AosCxPasswordComplexity,
26019
27719
  AosCxHostname,
@@ -26212,14 +27912,14 @@ var AosSwitchSshEnabled = {
26212
27912
  check: configWide("aosswitch", (statements, anchor) => {
26213
27913
  const disabled = statements.find((s) => textOf2(s) === "no ip ssh");
26214
27914
  if (disabled) {
26215
- return failAt(
27915
+ return failAt2(
26216
27916
  "AOSSW-SEC-003",
26217
27917
  disabled,
26218
27918
  'SSH server is disabled ("no ip ssh"). Enable it with "ip ssh" and disable Telnet.',
26219
27919
  "error"
26220
27920
  );
26221
27921
  }
26222
- return passAt("AOSSW-SEC-003", anchor, "SSH server is on (the AOS-Switch default).");
27922
+ return passAt2("AOSSW-SEC-003", anchor, "SSH server is on (the AOS-Switch default).");
26223
27923
  })
26224
27924
  };
26225
27925
  var AosSwitchSpanningTree = {
@@ -26388,11 +28088,11 @@ var AosSwitchTimesync = {
26388
28088
  check: configWide("aosswitch", (statements, anchor) => {
26389
28089
  const lines = statements.flatMap((s) => [s, ...s.children]);
26390
28090
  const server = lines.find((s) => NTP_SERVER.test(textOf2(s)) || SNTP_SERVER.test(textOf2(s)));
26391
- if (server) return passAt("AOSSW-TIME-001", server, "Time server is configured.");
28091
+ if (server) return passAt2("AOSSW-TIME-001", server, "Time server is configured.");
26392
28092
  const sntpMode = statements.some((s) => textOf2(s) === "timesync sntp") ? statements.find((s) => SNTP_LEARNED_MODE.test(textOf2(s))) : void 0;
26393
- if (sntpMode) return passAt("AOSSW-TIME-001", sntpMode, "SNTP learns its time server by DHCP or broadcast.");
28093
+ if (sntpMode) return passAt2("AOSSW-TIME-001", sntpMode, "SNTP learns its time server by DHCP or broadcast.");
26394
28094
  const timep = lines.find((s) => TIMEP.test(textOf2(s)));
26395
- if (timep) return passAt("AOSSW-TIME-001", timep, "TimeP time synchronization is configured.");
28095
+ if (timep) return passAt2("AOSSW-TIME-001", timep, "TimeP time synchronization is configured.");
26396
28096
  return failAbsent(
26397
28097
  "AOSSW-TIME-001",
26398
28098
  anchor,
@@ -26417,10 +28117,10 @@ var HttpDisabled = {
26417
28117
  },
26418
28118
  check: configWide("aosswitch", (statements, anchor) => {
26419
28119
  const disabled = statements.find((s) => ["no web-management", "no web-management plaintext"].includes(textOf2(s)));
26420
- if (disabled) return passAt("ARU-HTTP-001", disabled, "Plaintext web management (HTTP) is disabled.");
28120
+ if (disabled) return passAt2("ARU-HTTP-001", disabled, "Plaintext web management (HTTP) is disabled.");
26421
28121
  const enabled = statements.find((s) => textOf2(s) === "web-management" || textOf2(s) === "web-management plaintext");
26422
28122
  if (enabled) {
26423
- return failAt("ARU-HTTP-001", enabled, "Plaintext web management (HTTP) is enabled. Disable it and use HTTPS only.", "warning");
28123
+ return failAt2("ARU-HTTP-001", enabled, "Plaintext web management (HTTP) is enabled. Disable it and use HTTPS only.", "warning");
26424
28124
  }
26425
28125
  return failAbsent(
26426
28126
  "ARU-HTTP-001",
@@ -26528,9 +28228,9 @@ var allAosSwitchRules = [
26528
28228
  AosSwitchMgmtVlanIp,
26529
28229
  AosSwitchConsoleTimeout,
26530
28230
  AosSwitchTimesync,
26531
- // Ported from the former commercial set (decision 0001 S3b)
28231
+ // Ported rules
26532
28232
  HttpDisabled,
26533
- // Secret storage (gecko#60)
28233
+ // Secret storage
26534
28234
  AosSwitchSecretStorage
26535
28235
  ];
26536
28236
 
@@ -27025,9 +28725,9 @@ var WlcCpsecEnabled = {
27025
28725
  if (textOf2(node) !== "control-plane-security") return [];
27026
28726
  const disabled = node.children.find((c) => textOf2(c) === "no cpsec-enable");
27027
28727
  if (disabled) {
27028
- return failAt("ARU-WLC-001", disabled, "Control Plane Security (CPsec) is disabled. Enable for secure AP communication.", "warning");
28728
+ return failAt2("ARU-WLC-001", disabled, "Control Plane Security (CPsec) is disabled. Enable for secure AP communication.", "warning");
27029
28729
  }
27030
- return passAt("ARU-WLC-001", node, "Control Plane Security (CPsec) is enabled.");
28730
+ return passAt2("ARU-WLC-001", node, "Control Plane Security (CPsec) is enabled.");
27031
28731
  }
27032
28732
  };
27033
28733
  var WlcUserRoleFirewall = {
@@ -27053,9 +28753,9 @@ var WlcUserRoleFirewall = {
27053
28753
  return words[0] === "access-list" && ["session", "eth", "mac"].includes(words[1] ?? "") && words[2] !== void 0;
27054
28754
  });
27055
28755
  if (!hasPolicy) {
27056
- return failAt("ARU-WLC-004", node, `User role "${name}" has no firewall policy (access-list session) configured.`, "warning");
28756
+ return failAt2("ARU-WLC-004", node, `User role "${name}" has no firewall policy (access-list session) configured.`, "warning");
27057
28757
  }
27058
- return passAt("ARU-WLC-004", node, `User role "${name}" has firewall policy configured.`);
28758
+ return passAt2("ARU-WLC-004", node, `User role "${name}" has firewall policy configured.`);
27059
28759
  }
27060
28760
  };
27061
28761
  var WlcSsidLimit = {
@@ -27074,14 +28774,14 @@ var WlcSsidLimit = {
27074
28774
  const name = profileNameOf(node);
27075
28775
  const vaps = new Set(getApGroupVirtualAps(node).map((v) => v.trim().toLowerCase()));
27076
28776
  if (vaps.size > 4) {
27077
- return failAt(
28777
+ return failAt2(
27078
28778
  "ARU-WLC-005",
27079
28779
  node,
27080
28780
  `AP group "${name}" has ${vaps.size} virtual-APs. Best practice is 4 or fewer.`,
27081
28781
  "warning"
27082
28782
  );
27083
28783
  }
27084
- return passAt("ARU-WLC-005", node, `AP group "${name}" has ${vaps.size} virtual-AP(s).`);
28784
+ return passAt2("ARU-WLC-005", node, `AP group "${name}" has ${vaps.size} virtual-AP(s).`);
27085
28785
  }
27086
28786
  };
27087
28787
  var opmodesOf = (node) => {
@@ -27109,12 +28809,12 @@ var WlcWpa3Enterprise = {
27109
28809
  const name = profileNameOf(node);
27110
28810
  const modes = opmodesOf(node);
27111
28811
  if (modes.length === 0 || modes.every((m) => m === "opensystem" || m === "open")) {
27112
- return passAt("ARU-WIFI-001", node, `SSID profile "${name}" is open; reported by ARUWLC-WLAN-001.`);
28812
+ return passAt2("ARU-WIFI-001", node, `SSID profile "${name}" is open; reported by ARUWLC-WLAN-001.`);
27113
28813
  }
27114
28814
  if (modes.some(isWpa3OrOwe)) {
27115
- return passAt("ARU-WIFI-001", node, `SSID profile "${name}" offers WPA3 (${modes.join(", ")}).`);
28815
+ return passAt2("ARU-WIFI-001", node, `SSID profile "${name}" offers WPA3 (${modes.join(", ")}).`);
27116
28816
  }
27117
- return failAt(
28817
+ return failAt2(
27118
28818
  "ARU-WIFI-001",
27119
28819
  node,
27120
28820
  `SSID profile "${name}" uses ${modes.join(", ")} without WPA3. Consider WPA3-Enterprise for enhanced security.`,
@@ -27143,9 +28843,9 @@ var WlcWpa3SaePassphrase = {
27143
28843
  const name = profileNameOf(node);
27144
28844
  const hasPassphrase = node.children.some((c) => wordsOf2(c)[0] === "wpa-passphrase" && c.params.length > 1);
27145
28845
  if (!hasPassphrase) {
27146
- return failAt("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has no wpa-passphrase configured.`, "warning");
28846
+ return failAt2("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has no wpa-passphrase configured.`, "warning");
27147
28847
  }
27148
- return passAt("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has a passphrase configured.`);
28848
+ return passAt2("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has a passphrase configured.`);
27149
28849
  }
27150
28850
  };
27151
28851
  var WlcSsidMaxClients = {
@@ -27163,14 +28863,14 @@ var WlcSsidMaxClients = {
27163
28863
  const name = profileNameOf(node);
27164
28864
  const maxClients = getMaxClients(node);
27165
28865
  if (maxClients === null) {
27166
- return failAt(
28866
+ return failAt2(
27167
28867
  "ARUWLC-WLAN-004",
27168
28868
  node,
27169
28869
  `SSID profile "${name}" has no max-clients limit (the default is the AP maximum). Consider setting one.`,
27170
28870
  "info"
27171
28871
  );
27172
28872
  }
27173
- return passAt("ARUWLC-WLAN-004", node, `SSID profile "${name}" has max-clients ${maxClients}.`);
28873
+ return passAt2("ARUWLC-WLAN-004", node, `SSID profile "${name}" has max-clients ${maxClients}.`);
27174
28874
  }
27175
28875
  };
27176
28876
  var allWlcRules = [
@@ -27187,7 +28887,7 @@ var allWlcRules = [
27187
28887
  WlcApGroupRegDomain,
27188
28888
  WlcArmProfile,
27189
28889
  WlcRadioArmProfile,
27190
- // Ported from the former commercial set (decision 0001 S3b)
28890
+ // Ported rules
27191
28891
  WlcCpsecEnabled,
27192
28892
  WlcUserRoleFirewall,
27193
28893
  WlcSsidLimit,
@@ -28758,7 +30458,7 @@ var allPaloAltoRules = [
28758
30458
  NatRuleDescription,
28759
30459
  HARecommended,
28760
30460
  VirtualRouterDefaultRoute,
28761
- // Ported from the former commercial set (decision 0001 S3b)
30461
+ // Ported rules
28762
30462
  PasswordComplexityRequired,
28763
30463
  SnmpSecurityRequired,
28764
30464
  InterfaceManagementSecure,
@@ -30835,7 +32535,7 @@ var allAristaRules = [
30835
32535
  AaaConfigured2,
30836
32536
  ManagementSshEnabled,
30837
32537
  VrfDescription,
30838
- // Ported from the former commercial set (decision 0001 S3a)
32538
+ // Ported rules
30839
32539
  EosUsernamePasswordEncryption,
30840
32540
  EosEnableSecretEncryption,
30841
32541
  EosHttpServerDisabled,
@@ -30871,7 +32571,7 @@ var allAristaRules = [
30871
32571
  EosVrrpAuthentication,
30872
32572
  EosVirtualRouterMac,
30873
32573
  EosSecretStorage,
30874
- // Paid-only rules opened (gecko#60)
32574
+ // More ported rules
30875
32575
  EosEapiHttpWithHttps
30876
32576
  ];
30877
32577
 
@@ -33820,7 +35520,7 @@ var exosIndexOf = (context) => {
33820
35520
  }
33821
35521
  return index;
33822
35522
  };
33823
- var passAt2 = (ruleId, node, message) => ({
35523
+ var passAt3 = (ruleId, node, message) => ({
33824
35524
  passed: true,
33825
35525
  message,
33826
35526
  ruleId,
@@ -33828,7 +35528,7 @@ var passAt2 = (ruleId, node, message) => ({
33828
35528
  level: "info",
33829
35529
  loc: locOf(node)
33830
35530
  });
33831
- var failAt2 = (ruleId, at2, level, message, absent = false) => ({
35531
+ var failAt3 = (ruleId, at2, level, message, absent = false) => ({
33832
35532
  passed: false,
33833
35533
  message,
33834
35534
  ruleId,
@@ -33837,7 +35537,7 @@ var failAt2 = (ruleId, at2, level, message, absent = false) => ({
33837
35537
  loc: locOf(at2),
33838
35538
  ...absent ? { absent: true } : {}
33839
35539
  });
33840
- var judgedOnce = (judge) => (node, context) => {
35540
+ var judgedOnce2 = (judge) => (node, context) => {
33841
35541
  const index = exosIndexOf(context);
33842
35542
  if (!index || index.anchor !== node) return [];
33843
35543
  return judge(index, node);
@@ -33865,12 +35565,12 @@ var ExosSysnameRequired = {
33865
35565
  owner: "NetOps",
33866
35566
  remediation: 'Configure sysname using: configure snmp sysname "<name>"'
33867
35567
  },
33868
- check: judgedOnce((index, anchor) => {
35568
+ check: judgedOnce2((index, anchor) => {
33869
35569
  const id = "EXOS-SYS-001";
33870
35570
  const sysname = lastMatching(index, /^configure\s+snmp\s+sysname\s+\S/i);
33871
35571
  if (!sysname) {
33872
35572
  return [
33873
- failAt2(
35573
+ failAt3(
33874
35574
  id,
33875
35575
  anchor,
33876
35576
  "warning",
@@ -33880,7 +35580,7 @@ var ExosSysnameRequired = {
33880
35580
  ];
33881
35581
  }
33882
35582
  const name = sysname.text.match(/sysname\s+["']?([^"'\s]+)["']?/i)?.[1] ?? "configured";
33883
- return [passAt2(id, sysname.node, `SNMP sysname is configured: ${name}`)];
35583
+ return [passAt3(id, sysname.node, `SNMP sysname is configured: ${name}`)];
33884
35584
  })
33885
35585
  };
33886
35586
  var SNTP_SERVER2 = /^configure\s+sntp-client\s+(?:primary|secondary)\s+(?:server\s+)?\S+/i;
@@ -33895,13 +35595,13 @@ var ExosSntpRequired = {
33895
35595
  owner: "SecOps",
33896
35596
  remediation: "Configure SNTP using: configure sntp-client primary <ip> vr VR-Mgmt (or NTP: configure ntp server add <ip> vr VR-Mgmt)"
33897
35597
  },
33898
- check: judgedOnce((index, anchor) => {
35598
+ check: judgedOnce2((index, anchor) => {
33899
35599
  const id = "EXOS-SYS-002";
33900
35600
  const server = matching(index, SNTP_SERVER2)[0] ?? matching(index, NTP_SERVER2)[0];
33901
35601
  if (!server) {
33902
- return [failAt2(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
35602
+ return [failAt3(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
33903
35603
  }
33904
- return [passAt2(id, server.node, "A time server is configured.")];
35604
+ return [passAt3(id, server.node, "A time server is configured.")];
33905
35605
  })
33906
35606
  };
33907
35607
  var ExosSntpEnabled = {
@@ -33914,30 +35614,30 @@ var ExosSntpEnabled = {
33914
35614
  owner: "SecOps",
33915
35615
  remediation: "Enable SNTP client: enable sntp-client (for NTP servers: enable ntp)"
33916
35616
  },
33917
- check: judgedOnce((index, anchor) => {
35617
+ check: judgedOnce2((index, anchor) => {
33918
35618
  const id = "EXOS-SYS-003";
33919
35619
  const sntpServer = matching(index, SNTP_SERVER2)[0];
33920
35620
  const ntpServer = matching(index, NTP_SERVER2)[0];
33921
35621
  const sntp = lastMatching(index, /^(?:enable|disable)\s+sntp-client\s*$/i);
33922
35622
  const ntp = lastMatching(index, /^(?:enable|disable)\s+ntp\s*$/i);
33923
35623
  const on = [sntp, ntp].find((l) => l !== void 0 && /^enable/i.test(l.text));
33924
- if (on) return [passAt2(id, on.node, "A time synchronization client is enabled.")];
35624
+ if (on) return [passAt3(id, on.node, "A time synchronization client is enabled.")];
33925
35625
  if (!sntpServer && !ntpServer && !sntp && !ntp) {
33926
- return [passAt2(id, anchor, "SNTP and NTP are not configured (a missing time source is reported by EXOS-SYS-002).")];
35626
+ return [passAt3(id, anchor, "SNTP and NTP are not configured (a missing time source is reported by EXOS-SYS-002).")];
33927
35627
  }
33928
35628
  const results = [];
33929
35629
  if (sntp) {
33930
- results.push(failAt2(id, sntp.node, "warning", "The SNTP client is disabled; the switch clock is not synchronized."));
35630
+ results.push(failAt3(id, sntp.node, "warning", "The SNTP client is disabled; the switch clock is not synchronized."));
33931
35631
  } else if (sntpServer) {
33932
35632
  results.push(
33933
- failAt2(id, sntpServer.node, "warning", "SNTP servers are configured, but the SNTP client is not enabled: enable sntp-client.", true)
35633
+ failAt3(id, sntpServer.node, "warning", "SNTP servers are configured, but the SNTP client is not enabled: enable sntp-client.", true)
33934
35634
  );
33935
35635
  }
33936
35636
  if (ntp) {
33937
- results.push(failAt2(id, ntp.node, "warning", "NTP is disabled; the switch clock is not synchronized."));
35637
+ results.push(failAt3(id, ntp.node, "warning", "NTP is disabled; the switch clock is not synchronized."));
33938
35638
  } else if (ntpServer) {
33939
35639
  results.push(
33940
- failAt2(id, ntpServer.node, "warning", "NTP servers are configured, but NTP is not enabled (disabled by default): enable ntp.", true)
35640
+ failAt3(id, ntpServer.node, "warning", "NTP servers are configured, but NTP is not enabled (disabled by default): enable ntp.", true)
33941
35641
  );
33942
35642
  }
33943
35643
  return results;
@@ -33960,16 +35660,16 @@ var ExosSyslogRequired = {
33960
35660
  { type: "general", label: "monitoring" }
33961
35661
  ]
33962
35662
  },
33963
- check: judgedOnce((index, anchor) => {
35663
+ check: judgedOnce2((index, anchor) => {
33964
35664
  const id = "EXOS-SYS-004";
33965
35665
  const server = matching(index, /^configure\s+syslog\s+add\s+\S+/i)[0];
33966
35666
  if (!server) {
33967
- return [failAt2(id, anchor, "warning", "Remote syslog is not configured. Centralized logging is recommended.", true)];
35667
+ return [failAt3(id, anchor, "warning", "Remote syslog is not configured. Centralized logging is recommended.", true)];
33968
35668
  }
33969
35669
  const state = lastMatching(index, /^(?:enable|disable)\s+syslog\s*$/i);
33970
35670
  if (!state) {
33971
35671
  return [
33972
- failAt2(
35672
+ failAt3(
33973
35673
  id,
33974
35674
  server.node,
33975
35675
  "warning",
@@ -33979,9 +35679,9 @@ var ExosSyslogRequired = {
33979
35679
  ];
33980
35680
  }
33981
35681
  if (/^disable/i.test(state.text)) {
33982
- return [failAt2(id, state.node, "warning", "Remote syslog is disabled; messages are not sent to the configured servers.")];
35682
+ return [failAt3(id, state.node, "warning", "Remote syslog is disabled; messages are not sent to the configured servers.")];
33983
35683
  }
33984
- return [passAt2(id, server.node, "Remote syslog is configured and enabled.")];
35684
+ return [passAt3(id, server.node, "Remote syslog is configured and enabled.")];
33985
35685
  })
33986
35686
  };
33987
35687
  var ExosSsh2Enabled = {
@@ -34001,16 +35701,16 @@ var ExosSsh2Enabled = {
34001
35701
  { type: "general", label: "management-plane" }
34002
35702
  ]
34003
35703
  },
34004
- check: judgedOnce((index, anchor) => {
35704
+ check: judgedOnce2((index, anchor) => {
34005
35705
  const id = "EXOS-SEC-001";
34006
35706
  const last = lastMatching(index, /^(?:enable|disable)\s+ssh2(?:\s|$)/i);
34007
35707
  if (!last) {
34008
- return [failAt2(id, anchor, "warning", "SSH2 is not enabled (disabled by default). Secure management access is recommended.", true)];
35708
+ return [failAt3(id, anchor, "warning", "SSH2 is not enabled (disabled by default). Secure management access is recommended.", true)];
34009
35709
  }
34010
35710
  if (/^disable/i.test(last.text)) {
34011
- return [failAt2(id, last.node, "warning", "SSH2 is disabled. Secure management access is recommended.")];
35711
+ return [failAt3(id, last.node, "warning", "SSH2 is disabled. Secure management access is recommended.")];
34012
35712
  }
34013
- return [passAt2(id, last.node, "SSH2 is enabled for secure management.")];
35713
+ return [passAt3(id, last.node, "SSH2 is enabled for secure management.")];
34014
35714
  })
34015
35715
  };
34016
35716
  var ExosTelnetDisabled = {
@@ -34032,16 +35732,16 @@ var ExosTelnetDisabled = {
34032
35732
  { type: "general", label: "management-plane" }
34033
35733
  ]
34034
35734
  },
34035
- check: judgedOnce((index, anchor) => {
35735
+ check: judgedOnce2((index, anchor) => {
34036
35736
  const id = "EXOS-SEC-002";
34037
35737
  const last = lastMatching(index, /^(?:enable|disable)\s+telnet\s*$/i);
34038
35738
  if (!last) {
34039
- return [failAt2(id, anchor, "warning", "Telnet is not disabled (enabled by default). Use SSH2 for secure management.", true)];
35739
+ return [failAt3(id, anchor, "warning", "Telnet is not disabled (enabled by default). Use SSH2 for secure management.", true)];
34040
35740
  }
34041
35741
  if (/^enable/i.test(last.text)) {
34042
- return [failAt2(id, last.node, "warning", "Telnet is enabled. Use SSH2 for secure management.")];
35742
+ return [failAt3(id, last.node, "warning", "Telnet is enabled. Use SSH2 for secure management.")];
34043
35743
  }
34044
- return [passAt2(id, last.node, "Telnet is disabled.")];
35744
+ return [passAt3(id, last.node, "Telnet is disabled.")];
34045
35745
  })
34046
35746
  };
34047
35747
  var RADIUS_MGMT_SERVER = /^configure\s+radius\s+(?:mgmt-access\s+)?(?:primary|secondary|\d+)\s+server\s+\S+/i;
@@ -34059,23 +35759,23 @@ var ExosAaaRequired = {
34059
35759
  cwe: ["CWE-287"]
34060
35760
  }
34061
35761
  },
34062
- check: judgedOnce((index, anchor) => {
35762
+ check: judgedOnce2((index, anchor) => {
34063
35763
  const id = "EXOS-SEC-003";
34064
35764
  const radius = matching(index, RADIUS_MGMT_SERVER);
34065
35765
  const tacacs = matching(index, TACACS_SERVER);
34066
35766
  const radiusState = lastMatching(index, /^(?:enable|disable)\s+radius(?:\s+mgmt-access)?\s*$/i);
34067
35767
  const tacacsState = lastMatching(index, /^(?:enable|disable)\s+tacacs\s*$/i);
34068
35768
  const isOn3 = (l) => l !== void 0 && /^enable/i.test(l.text);
34069
- if (radius[0] && isOn3(radiusState)) return [passAt2(id, radius[0].node, "AAA (RADIUS) is configured for management access.")];
34070
- if (tacacs[0] && isOn3(tacacsState)) return [passAt2(id, tacacs[0].node, "AAA (TACACS+) is configured for management access.")];
35769
+ if (radius[0] && isOn3(radiusState)) return [passAt3(id, radius[0].node, "AAA (RADIUS) is configured for management access.")];
35770
+ if (tacacs[0] && isOn3(tacacsState)) return [passAt3(id, tacacs[0].node, "AAA (TACACS+) is configured for management access.")];
34071
35771
  const off = (radius[0] ? radiusState : void 0) ?? (tacacs[0] ? tacacsState : void 0);
34072
35772
  if (off) {
34073
- return [failAt2(id, off.node, "info", "AAA (RADIUS/TACACS+) servers are configured, but management authentication is disabled.")];
35773
+ return [failAt3(id, off.node, "info", "AAA (RADIUS/TACACS+) servers are configured, but management authentication is disabled.")];
34074
35774
  }
34075
35775
  const server = matching(index, new RegExp(`${RADIUS_MGMT_SERVER.source}|${TACACS_SERVER.source}`, "i"))[0];
34076
35776
  if (server) {
34077
35777
  return [
34078
- failAt2(
35778
+ failAt3(
34079
35779
  id,
34080
35780
  server.node,
34081
35781
  "info",
@@ -34085,7 +35785,7 @@ var ExosAaaRequired = {
34085
35785
  ];
34086
35786
  }
34087
35787
  return [
34088
- failAt2(id, anchor, "info", "AAA (RADIUS/TACACS) is not configured for management access. Centralized authentication is recommended.", true)
35788
+ failAt3(id, anchor, "info", "AAA (RADIUS/TACACS) is not configured for management access. Centralized authentication is recommended.", true)
34089
35789
  ];
34090
35790
  })
34091
35791
  };
@@ -34244,13 +35944,13 @@ var ExosEapsControlVlan = {
34244
35944
  owner: "NetOps",
34245
35945
  remediation: "Configure EAPS control VLAN: configure eaps <name> add control vlan <vlan>"
34246
35946
  },
34247
- check: judgedOnce((index, anchor) => {
35947
+ check: judgedOnce2((index, anchor) => {
34248
35948
  const id = "EXOS-EAPS-001";
34249
35949
  const domains = index.lines.flatMap((l) => {
34250
35950
  const name = l.text.match(/^create\s+eaps\s+(\S+)\s*$/i)?.[1];
34251
35951
  return name ? [{ line: l, name }] : [];
34252
35952
  });
34253
- if (domains.length === 0) return [passAt2(id, anchor, "EAPS is not configured.")];
35953
+ if (domains.length === 0) return [passAt3(id, anchor, "EAPS is not configured.")];
34254
35954
  const withControl = new Set(
34255
35955
  index.lines.flatMap((l) => {
34256
35956
  const name = l.text.match(/^configure\s+eaps\s+(\S+)\s+add\s+control\s+(?:vlan\s+)?\S+/i)?.[1];
@@ -34258,9 +35958,9 @@ var ExosEapsControlVlan = {
34258
35958
  })
34259
35959
  );
34260
35960
  const results = domains.filter((d) => !withControl.has(exosName(d.name))).map(
34261
- (d) => failAt2(id, d.line.node, "error", `EAPS domain ${d.name} has no control VLAN; the domain does not run without one.`)
35961
+ (d) => failAt3(id, d.line.node, "error", `EAPS domain ${d.name} has no control VLAN; the domain does not run without one.`)
34262
35962
  );
34263
- return results.length > 0 ? results : [passAt2(id, domains[0]?.line.node ?? anchor, "Every EAPS domain has a control VLAN.")];
35963
+ return results.length > 0 ? results : [passAt3(id, domains[0]?.line.node ?? anchor, "Every EAPS domain has a control VLAN.")];
34264
35964
  })
34265
35965
  };
34266
35966
  var ExosStackingPriority = {
@@ -34273,12 +35973,12 @@ var ExosStackingPriority = {
34273
35973
  owner: "NetOps",
34274
35974
  remediation: 'Configure stacking priority: configure stacking [node-address <mac> | slot <slot>] priority <1-100>; check it with "show stacking configuration"'
34275
35975
  },
34276
- check: judgedOnce((index, anchor) => {
35976
+ check: judgedOnce2((index, anchor) => {
34277
35977
  const id = "EXOS-STACK-001";
34278
35978
  const stacking = matching(index, /^(?:enable|configure)\s+stacking(?:\s|$)/i)[0];
34279
35979
  if (!stacking) {
34280
35980
  return [
34281
- passAt2(
35981
+ passAt3(
34282
35982
  id,
34283
35983
  anchor,
34284
35984
  'No stacking commands in this configuration: stacking settings, including node priority, are stored in the NVRAM of each node, not in the configuration file. Check them with "show stacking configuration".'
@@ -34287,15 +35987,15 @@ var ExosStackingPriority = {
34287
35987
  }
34288
35988
  const priorities = matching(index, /^configure\s+stacking\s+(?:(?:node-address|slot)\s+\S+\s+)?priority\s+\S+/i);
34289
35989
  const numeric = priorities.find((l) => /\bpriority\s+\d+\s*$/i.test(l.text));
34290
- if (numeric) return [passAt2(id, numeric.node, "Stacking node priority is configured.")];
35990
+ if (numeric) return [passAt3(id, numeric.node, "Stacking node priority is configured.")];
34291
35991
  const automatic = priorities[priorities.length - 1];
34292
35992
  if (automatic) {
34293
35993
  return [
34294
- failAt2(id, automatic.node, "info", "Stacking priority is automatic: the master-capable node with the lowest slot number becomes master.")
35994
+ failAt3(id, automatic.node, "info", "Stacking priority is automatic: the master-capable node with the lowest slot number becomes master.")
34295
35995
  ];
34296
35996
  }
34297
35997
  return [
34298
- failAt2(
35998
+ failAt3(
34299
35999
  id,
34300
36000
  stacking.node,
34301
36001
  "info",
@@ -34315,13 +36015,13 @@ var ExosMlagIsc = {
34315
36015
  owner: "NetOps",
34316
36016
  remediation: "Configure MLAG ISC: configure mlag peer <name> ipaddress <ip> vr VR-Default"
34317
36017
  },
34318
- check: judgedOnce((index, anchor) => {
36018
+ check: judgedOnce2((index, anchor) => {
34319
36019
  const id = "EXOS-MLAG-001";
34320
36020
  const peers = index.lines.flatMap((l) => {
34321
36021
  const name = l.text.match(/^create\s+mlag\s+peer\s+(\S+)/i)?.[1];
34322
36022
  return name ? [{ line: l, name }] : [];
34323
36023
  });
34324
- if (peers.length === 0) return [passAt2(id, anchor, "MLAG is not configured.")];
36024
+ if (peers.length === 0) return [passAt3(id, anchor, "MLAG is not configured.")];
34325
36025
  const withAddress = new Set(
34326
36026
  index.lines.flatMap((l) => {
34327
36027
  const name = l.text.match(/^configure\s+mlag\s+peer\s+(\S+)\s+ipaddress\s+\S+/i)?.[1];
@@ -34329,14 +36029,14 @@ var ExosMlagIsc = {
34329
36029
  })
34330
36030
  );
34331
36031
  const results = peers.filter((p) => !withAddress.has(exosName(p.name))).map(
34332
- (p) => failAt2(
36032
+ (p) => failAt3(
34333
36033
  id,
34334
36034
  p.line.node,
34335
36035
  "error",
34336
36036
  `MLAG peer ${p.name} has no peer IP address; the Inter-Switch Connection cannot exchange keep-alives or checkpoint state.`
34337
36037
  )
34338
36038
  );
34339
- return results.length > 0 ? results : [passAt2(id, peers[0]?.line.node ?? anchor, "Every MLAG peer has a peer IP address.")];
36039
+ return results.length > 0 ? results : [passAt3(id, peers[0]?.line.node ?? anchor, "Every MLAG peer has a peer IP address.")];
34340
36040
  })
34341
36041
  };
34342
36042
  var MAX_IDLE_MINUTES = 10;
@@ -34355,29 +36055,29 @@ var ExosIdleTimeout = {
34355
36055
  },
34356
36056
  tags: EXOS_TAGS("session-management", "management-plane")
34357
36057
  },
34358
- check: judgedOnce((index, anchor) => {
36058
+ check: judgedOnce2((index, anchor) => {
34359
36059
  const id = "EXOS-MGMT-004";
34360
36060
  const results = [];
34361
36061
  const timer = lastMatching(index, /^(?:enable|disable)\s+(?:cli\s+)?idle-?timeout\s*$/i);
34362
36062
  if (timer && /^disable/i.test(timer.text)) {
34363
- results.push(failAt2(id, timer.node, "warning", "The CLI idle timer is disabled: console and Telnet sessions never time out, SSH2 sessions only after 60 minutes."));
36063
+ results.push(failAt3(id, timer.node, "warning", "The CLI idle timer is disabled: console and Telnet sessions never time out, SSH2 sessions only after 60 minutes."));
34364
36064
  }
34365
36065
  const cli = lastMatching(index, /^configure\s+(?:cli\s+idle-timeout|idletimeout)\s+\d+/i);
34366
36066
  const cliValue = cli?.text.match(/(?:idle-timeout|idletimeout)\s+(\d+)/i)?.[1];
34367
36067
  const cliMinutes = cliValue === void 0 ? void 0 : Number(cliValue);
34368
36068
  if (cli && cliMinutes !== void 0 && cliMinutes > MAX_IDLE_MINUTES) {
34369
- results.push(failAt2(id, cli.node, "warning", `CLI idle timeout is ${cliMinutes} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
36069
+ results.push(failAt3(id, cli.node, "warning", `CLI idle timeout is ${cliMinutes} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
34370
36070
  }
34371
36071
  const ssh = lastMatching(index, /^configure\s+ssh2\s+idletimeout\s+\S+/i);
34372
36072
  const sshValue = ssh?.text.match(/idletimeout\s+(\S+)/i)?.[1]?.toLowerCase();
34373
36073
  if (ssh && sshValue === "none") {
34374
- results.push(failAt2(id, ssh.node, "warning", "SSH2 idle timeout is disabled (none)."));
36074
+ results.push(failAt3(id, ssh.node, "warning", "SSH2 idle timeout is disabled (none)."));
34375
36075
  } else if (ssh && sshValue !== void 0 && Number(sshValue) > MAX_IDLE_MINUTES) {
34376
- results.push(failAt2(id, ssh.node, "warning", `SSH2 idle timeout is ${sshValue} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
36076
+ results.push(failAt3(id, ssh.node, "warning", `SSH2 idle timeout is ${sshValue} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
34377
36077
  }
34378
36078
  if (!cli && results.length === 0) {
34379
36079
  results.push(
34380
- failAt2(
36080
+ failAt3(
34381
36081
  id,
34382
36082
  anchor,
34383
36083
  "warning",
@@ -34386,7 +36086,7 @@ var ExosIdleTimeout = {
34386
36086
  )
34387
36087
  );
34388
36088
  }
34389
- return results.length > 0 ? results : [passAt2(id, cli?.node ?? anchor, "Idle management sessions time out.")];
36089
+ return results.length > 0 ? results : [passAt3(id, cli?.node ?? anchor, "Idle management sessions time out.")];
34390
36090
  })
34391
36091
  };
34392
36092
  var ExosSnmpv3UserSecurity = {
@@ -34405,10 +36105,10 @@ var ExosSnmpv3UserSecurity = {
34405
36105
  },
34406
36106
  tags: EXOS_TAGS("snmp", "encryption", "management-plane")
34407
36107
  },
34408
- check: judgedOnce((index, anchor) => {
36108
+ check: judgedOnce2((index, anchor) => {
34409
36109
  const id = "EXOS-MGMT-007";
34410
36110
  const users = matching(index, /^configure\s+snmpv3\s+add\s+user\s+/i).filter((l) => !/\bclone-from\b/i.test(l.text));
34411
- if (users.length === 0) return [passAt2(id, anchor, "No SNMPv3 users are configured.")];
36111
+ if (users.length === 0) return [passAt3(id, anchor, "No SNMPv3 users are configured.")];
34412
36112
  const results = [];
34413
36113
  for (const l of users) {
34414
36114
  const tokens = l.text.split(/\s+/).map((t) => t.toLowerCase());
@@ -34416,15 +36116,15 @@ var ExosSnmpv3UserSecurity = {
34416
36116
  const authAt = tokens.indexOf("authentication");
34417
36117
  const privAt = tokens.indexOf("privacy");
34418
36118
  if (authAt < 0 || privAt < 0) {
34419
- results.push(failAt2(id, l.node, "error", `SNMPv3 user ${name} has no ${authAt < 0 ? "authentication or privacy" : "privacy (encryption)"}.`));
36119
+ results.push(failAt3(id, l.node, "error", `SNMPv3 user ${name} has no ${authAt < 0 ? "authentication or privacy" : "privacy (encryption)"}.`));
34420
36120
  continue;
34421
36121
  }
34422
36122
  const algorithm = tokens.slice(privAt + 1).find((t) => !["encrypted", "hex", "localized-key"].includes(t));
34423
36123
  if (algorithm !== "aes" && algorithm !== "3des") {
34424
- results.push(failAt2(id, l.node, "warning", `SNMPv3 user ${name} uses DES privacy (the default); use AES.`));
36124
+ results.push(failAt3(id, l.node, "warning", `SNMPv3 user ${name} uses DES privacy (the default); use AES.`));
34425
36125
  }
34426
36126
  }
34427
- return results.length > 0 ? results : [passAt2(id, anchor, "SNMPv3 users use authentication and privacy.")];
36127
+ return results.length > 0 ? results : [passAt3(id, anchor, "SNMPv3 users use authentication and privacy.")];
34428
36128
  })
34429
36129
  };
34430
36130
  var ExosSnmpV1V2cDisabled = {
@@ -34443,13 +36143,13 @@ var ExosSnmpV1V2cDisabled = {
34443
36143
  },
34444
36144
  tags: EXOS_TAGS("snmp", "cleartext-transmission")
34445
36145
  },
34446
- check: judgedOnce((index, anchor) => {
36146
+ check: judgedOnce2((index, anchor) => {
34447
36147
  const id = "EXOS-MGMT-008";
34448
36148
  const last = lastMatching(index, /^(?:enable|disable)\s+snmp\s+access(?:\s+snmp-v1v2c)?\s*$/i);
34449
36149
  if (last && /^enable/i.test(last.text)) {
34450
- return [failAt2(id, last.node, "error", "SNMPv1/v2c access is enabled; community strings travel in cleartext. Disable it and use SNMPv3.")];
36150
+ return [failAt3(id, last.node, "error", "SNMPv1/v2c access is enabled; community strings travel in cleartext. Disable it and use SNMPv3.")];
34451
36151
  }
34452
- return [passAt2(id, last?.node ?? anchor, last ? "SNMPv1/v2c access is disabled." : "SNMP access is not enabled (disabled by default).")];
36152
+ return [passAt3(id, last?.node ?? anchor, last ? "SNMPv1/v2c access is disabled." : "SNMP access is not enabled (disabled by default).")];
34453
36153
  })
34454
36154
  };
34455
36155
  var ExosLoginLockout = {
@@ -34466,15 +36166,15 @@ var ExosLoginLockout = {
34466
36166
  },
34467
36167
  tags: EXOS_TAGS("authentication", "brute-force-protection")
34468
36168
  },
34469
- check: judgedOnce((index, anchor) => {
36169
+ check: judgedOnce2((index, anchor) => {
34470
36170
  const id = "EXOS-MGMT-009";
34471
36171
  const lines = matching(index, /^configure\s+account\s+\S+\s+password-policy\s+lockout-on-login-failures\s+(?:on|off)\b/i);
34472
- const results = lines.filter((l) => /\boff\b/i.test(l.text)).map((l) => failAt2(id, l.node, "warning", `Account lockout is turned off: ${l.text}`));
36172
+ const results = lines.filter((l) => /\boff\b/i.test(l.text)).map((l) => failAt3(id, l.node, "warning", `Account lockout is turned off: ${l.text}`));
34473
36173
  const on = lines.find((l) => /\bon\b/i.test(l.text));
34474
36174
  if (!on && results.length === 0) {
34475
- results.push(failAt2(id, anchor, "warning", "Account lockout after failed logins is not configured (by default accounts are never locked out).", true));
36175
+ results.push(failAt3(id, anchor, "warning", "Account lockout after failed logins is not configured (by default accounts are never locked out).", true));
34476
36176
  }
34477
- return results.length > 0 ? results : [passAt2(id, on?.node ?? anchor, "Accounts lock out after failed logins.")];
36177
+ return results.length > 0 ? results : [passAt3(id, on?.node ?? anchor, "Accounts lock out after failed logins.")];
34478
36178
  })
34479
36179
  };
34480
36180
  var ExosLoginBanner = {
@@ -34488,17 +36188,17 @@ var ExosLoginBanner = {
34488
36188
  remediation: "Configure a pre-login legal banner and keep it in the configuration: configure banner before-login save-to-configuration",
34489
36189
  tags: EXOS_TAGS("legal", "management-plane")
34490
36190
  },
34491
- check: judgedOnce((index, anchor) => {
36191
+ check: judgedOnce2((index, anchor) => {
34492
36192
  const id = "EXOS-MGMT-010";
34493
36193
  const banners = matching(index, /^configure\s+banner\b/i);
34494
36194
  const beforeLogin = banners.find((l) => !/\bafter-login\b/i.test(l.text));
34495
- if (beforeLogin) return [passAt2(id, beforeLogin.node, "A pre-login banner is configured.")];
36195
+ if (beforeLogin) return [passAt3(id, beforeLogin.node, "A pre-login banner is configured.")];
34496
36196
  const afterLogin = banners[0];
34497
36197
  if (afterLogin) {
34498
- return [failAt2(id, afterLogin.node, "warning", "Only an after-login banner is configured; the legal warning must be shown before login.")];
36198
+ return [failAt3(id, afterLogin.node, "warning", "Only an after-login banner is configured; the legal warning must be shown before login.")];
34499
36199
  }
34500
36200
  return [
34501
- failAt2(
36201
+ failAt3(
34502
36202
  id,
34503
36203
  anchor,
34504
36204
  "info",
@@ -34522,19 +36222,19 @@ var ExosDosProtection = {
34522
36222
  },
34523
36223
  tags: EXOS_TAGS("dos-protection", "control-plane")
34524
36224
  },
34525
- check: judgedOnce((index, anchor) => {
36225
+ check: judgedOnce2((index, anchor) => {
34526
36226
  const id = "EXOS-CTRL-001";
34527
36227
  const last = lastMatching(index, /^(?:enable|disable)\s+dos-protect(?:\s+simulated)?\s*$/i);
34528
36228
  if (!last) {
34529
- return [failAt2(id, anchor, "warning", "DoS protection is not enabled (disabled by default).", true)];
36229
+ return [failAt3(id, anchor, "warning", "DoS protection is not enabled (disabled by default).", true)];
34530
36230
  }
34531
36231
  if (/^disable/i.test(last.text)) {
34532
- return [failAt2(id, last.node, "warning", "DoS protection is disabled.")];
36232
+ return [failAt3(id, last.node, "warning", "DoS protection is disabled.")];
34533
36233
  }
34534
36234
  if (/\bsimulated\b/i.test(last.text)) {
34535
- return [failAt2(id, last.node, "warning", "DoS protection runs in simulated mode, which creates no ACLs.")];
36235
+ return [failAt3(id, last.node, "warning", "DoS protection runs in simulated mode, which creates no ACLs.")];
34536
36236
  }
34537
- return [passAt2(id, last.node, "DoS protection is enabled.")];
36237
+ return [passAt3(id, last.node, "DoS protection is enabled.")];
34538
36238
  })
34539
36239
  };
34540
36240
  var ExosMacLearningLimit = {
@@ -34551,15 +36251,15 @@ var ExosMacLearningLimit = {
34551
36251
  },
34552
36252
  tags: EXOS_TAGS("port-security", "mac-flooding")
34553
36253
  },
34554
- check: judgedOnce((index, anchor) => {
36254
+ check: judgedOnce2((index, anchor) => {
34555
36255
  const id = "EXOS-CTRL-003";
34556
36256
  const access = firstAccessPort(index);
34557
- if (!access) return [passAt2(id, anchor, "No untagged access ports outside the Default VLAN.")];
36257
+ if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
34558
36258
  const limit = index.lines.find(
34559
36259
  (l) => /^configure\s+ports\s+\S+\s+(?:tagged\s+\S+\s+)?vlan\s+\S+\s+(?:limit-learning|lock-learning)\b/i.test(l.text) || /^enable\s+mac-locking\s+ports\s+\S+/i.test(l.text)
34560
36260
  );
34561
- if (limit) return [passAt2(id, limit.node, "MAC learning is limited on ports.")];
34562
- return [failAt2(id, access, "info", "Access ports learn an unlimited number of MAC addresses (no limit-learning, lock-learning or MAC locking).", true)];
36261
+ if (limit) return [passAt3(id, limit.node, "MAC learning is limited on ports.")];
36262
+ return [failAt3(id, access, "info", "Access ports learn an unlimited number of MAC addresses (no limit-learning, lock-learning or MAC locking).", true)];
34563
36263
  })
34564
36264
  };
34565
36265
  var ExosMacLocking = {
@@ -34576,19 +36276,19 @@ var ExosMacLocking = {
34576
36276
  },
34577
36277
  tags: EXOS_TAGS("mac-security", "port-security")
34578
36278
  },
34579
- check: judgedOnce((index, anchor) => {
36279
+ check: judgedOnce2((index, anchor) => {
34580
36280
  const id = "EXOS-CTRL-004";
34581
36281
  const ports = matching(index, /^enable\s+mac-locking\s+ports\s+\S+/i);
34582
36282
  const global = lastMatching(index, /^(?:enable|disable)\s+mac-locking\s*$/i);
34583
36283
  const globalOn = global !== void 0 && /^enable/i.test(global.text);
34584
36284
  if (ports.length > 0 && !globalOn) {
34585
- return ports.map((l) => failAt2(id, l.node, "info", "MAC locking is enabled on ports but not on the switch (enable mac-locking), so it has no effect."));
36285
+ return ports.map((l) => failAt3(id, l.node, "info", "MAC locking is enabled on ports but not on the switch (enable mac-locking), so it has no effect."));
34586
36286
  }
34587
36287
  if (globalOn && global && ports.length === 0) {
34588
- return [failAt2(id, global.node, "info", "MAC locking is enabled on the switch but on no port.")];
36288
+ return [failAt3(id, global.node, "info", "MAC locking is enabled on the switch but on no port.")];
34589
36289
  }
34590
- if (globalOn) return [passAt2(id, global?.node ?? anchor, "MAC locking is enabled on the switch and on ports.")];
34591
- return [passAt2(id, anchor, "MAC locking is not configured (MAC learning limits are judged by EXOS-CTRL-003).")];
36290
+ if (globalOn) return [passAt3(id, global?.node ?? anchor, "MAC locking is enabled on the switch and on ports.")];
36291
+ return [passAt3(id, anchor, "MAC locking is not configured (MAC learning limits are judged by EXOS-CTRL-003).")];
34592
36292
  })
34593
36293
  };
34594
36294
  var ExosDhcpSnooping = {
@@ -34605,16 +36305,16 @@ var ExosDhcpSnooping = {
34605
36305
  },
34606
36306
  tags: EXOS_TAGS("dhcp-snooping", "data-plane", "spoofing-prevention")
34607
36307
  },
34608
- check: judgedOnce((index, anchor) => {
36308
+ check: judgedOnce2((index, anchor) => {
34609
36309
  const id = "EXOS-DATA-002";
34610
36310
  const snooping = matching(index, /^enable\s+ip-security\s+dhcp-snooping\s+/i);
34611
- const results = snooping.filter((l) => /\bviolation-action\s+none\b/i.test(l.text)).map((l) => failAt2(id, l.node, "warning", "DHCP snooping uses violation-action none, so rogue DHCP server packets are not dropped."));
36311
+ const results = snooping.filter((l) => /\bviolation-action\s+none\b/i.test(l.text)).map((l) => failAt3(id, l.node, "warning", "DHCP snooping uses violation-action none, so rogue DHCP server packets are not dropped."));
34612
36312
  if (results.length > 0) return results;
34613
36313
  const first2 = snooping[0];
34614
- if (first2) return [passAt2(id, first2.node, "DHCP snooping is enabled.")];
36314
+ if (first2) return [passAt3(id, first2.node, "DHCP snooping is enabled.")];
34615
36315
  const access = firstAccessPort(index);
34616
- if (!access) return [passAt2(id, anchor, "No untagged access ports outside the Default VLAN.")];
34617
- return [failAt2(id, access, "warning", "DHCP snooping is not enabled (disabled by default); rogue DHCP servers are not blocked.", true)];
36316
+ if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
36317
+ return [failAt3(id, access, "warning", "DHCP snooping is not enabled (disabled by default); rogue DHCP servers are not blocked.", true)];
34618
36318
  })
34619
36319
  };
34620
36320
  var ExosDhcpTrustedPorts = {
@@ -34631,15 +36331,15 @@ var ExosDhcpTrustedPorts = {
34631
36331
  },
34632
36332
  tags: EXOS_TAGS("dhcp-snooping", "data-plane")
34633
36333
  },
34634
- check: judgedOnce((index, anchor) => {
36334
+ check: judgedOnce2((index, anchor) => {
34635
36335
  const id = "EXOS-DATA-003";
34636
36336
  const snooping = matching(index, /^enable\s+ip-security\s+dhcp-snooping\s+/i)[0];
34637
- if (!snooping) return [passAt2(id, anchor, "DHCP snooping is not enabled.")];
36337
+ if (!snooping) return [passAt3(id, anchor, "DHCP snooping is not enabled.")];
34638
36338
  const trusted = index.lines.find(
34639
36339
  (l) => /^configure\s+trusted-ports\s+\S+\s+trust-for\s+dhcp-server\b/i.test(l.text) || /^configure\s+trusted-servers\s+.*\badd\s+server\s+\S+\s+trust-for\s+dhcp-server\b/i.test(l.text)
34640
36340
  );
34641
- if (trusted) return [passAt2(id, trusted.node, "DHCP snooping has trusted ports or servers.")];
34642
- return [failAt2(id, snooping.node, "warning", "DHCP snooping is enabled but no trusted port or trusted DHCP server is configured.", true)];
36341
+ if (trusted) return [passAt3(id, trusted.node, "DHCP snooping has trusted ports or servers.")];
36342
+ return [failAt3(id, snooping.node, "warning", "DHCP snooping is enabled but no trusted port or trusted DHCP server is configured.", true)];
34643
36343
  })
34644
36344
  };
34645
36345
  var ExosArpValidation = {
@@ -34656,13 +36356,13 @@ var ExosArpValidation = {
34656
36356
  },
34657
36357
  tags: EXOS_TAGS("arp-inspection", "data-plane", "spoofing-prevention")
34658
36358
  },
34659
- check: judgedOnce((index, anchor) => {
36359
+ check: judgedOnce2((index, anchor) => {
34660
36360
  const id = "EXOS-DATA-004";
34661
36361
  const validation = matching(index, /^enable\s+ip-security\s+arp\s+validation\b/i)[0];
34662
- if (validation) return [passAt2(id, validation.node, "ARP validation is enabled.")];
36362
+ if (validation) return [passAt3(id, validation.node, "ARP validation is enabled.")];
34663
36363
  const access = firstAccessPort(index);
34664
- if (!access) return [passAt2(id, anchor, "No untagged access ports outside the Default VLAN.")];
34665
- return [failAt2(id, access, "warning", "ARP validation is not enabled (disabled by default); ARP spoofing is not blocked.", true)];
36364
+ if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
36365
+ return [failAt3(id, access, "warning", "ARP validation is not enabled (disabled by default); ARP spoofing is not blocked.", true)];
34666
36366
  })
34667
36367
  };
34668
36368
  var ExosSourceIpLockdown = {
@@ -34679,13 +36379,13 @@ var ExosSourceIpLockdown = {
34679
36379
  },
34680
36380
  tags: EXOS_TAGS("ip-source-guard", "data-plane", "spoofing-prevention")
34681
36381
  },
34682
- check: judgedOnce((index, anchor) => {
36382
+ check: judgedOnce2((index, anchor) => {
34683
36383
  const id = "EXOS-DATA-005";
34684
36384
  const lockdown = matching(index, /^enable\s+ip-security\s+source-ip-lockdown\s+ports\s+\S+/i)[0];
34685
- if (lockdown) return [passAt2(id, lockdown.node, "Source IP lockdown is enabled.")];
36385
+ if (lockdown) return [passAt3(id, lockdown.node, "Source IP lockdown is enabled.")];
34686
36386
  const access = firstAccessPort(index);
34687
- if (!access) return [passAt2(id, anchor, "No untagged access ports outside the Default VLAN.")];
34688
- return [failAt2(id, access, "warning", "Source IP lockdown is not enabled (disabled by default); IP spoofing is not blocked.", true)];
36387
+ if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
36388
+ return [failAt3(id, access, "warning", "Source IP lockdown is not enabled (disabled by default); IP spoofing is not blocked.", true)];
34689
36389
  })
34690
36390
  };
34691
36391
  var BGP_LINE = /^(?:create\s+bgp\s+neighbor|configure\s+bgp\s+as-number|enable\s+bgp\s*$)/i;
@@ -34753,15 +36453,15 @@ var ExosBgpAuthentication = {
34753
36453
  },
34754
36454
  tags: EXOS_TAGS("bgp", "authentication", "routing-security")
34755
36455
  },
34756
- check: judgedOnce((index, anchor) => {
36456
+ check: judgedOnce2((index, anchor) => {
34757
36457
  const id = "EXOS-BGP-001";
34758
36458
  const bgp = exosBgp(index);
34759
- if (bgp.neighbors.length === 0) return [passAt2(id, anchor, "No BGP neighbors are configured.")];
36459
+ if (bgp.neighbors.length === 0) return [passAt3(id, anchor, "No BGP neighbors are configured.")];
34760
36460
  const results = bgp.neighbors.filter((n) => {
34761
36461
  const password = bgpSetting(index, n, "password");
34762
36462
  return password === void 0 || password.toLowerCase() === "none";
34763
- }).map((n) => failAt2(id, n.node, "error", `BGP neighbor ${n.address} has no MD5 password.`));
34764
- return results.length > 0 ? results : [passAt2(id, bgp.first ?? anchor, "All BGP neighbors use MD5 authentication.")];
36463
+ }).map((n) => failAt3(id, n.node, "error", `BGP neighbor ${n.address} has no MD5 password.`));
36464
+ return results.length > 0 ? results : [passAt3(id, bgp.first ?? anchor, "All BGP neighbors use MD5 authentication.")];
34765
36465
  })
34766
36466
  };
34767
36467
  var ExosBgpMaxPrefix = {
@@ -34778,16 +36478,16 @@ var ExosBgpMaxPrefix = {
34778
36478
  },
34779
36479
  tags: EXOS_TAGS("bgp", "resource-exhaustion", "routing-security")
34780
36480
  },
34781
- check: judgedOnce((index, anchor) => {
36481
+ check: judgedOnce2((index, anchor) => {
34782
36482
  const id = "EXOS-BGP-002";
34783
36483
  const bgp = exosBgp(index);
34784
36484
  const ebgp = bgp.neighbors.filter((n) => !isIbgp(bgp, n));
34785
- if (ebgp.length === 0) return [passAt2(id, anchor, "No eBGP neighbors are configured.")];
36485
+ if (ebgp.length === 0) return [passAt3(id, anchor, "No eBGP neighbors are configured.")];
34786
36486
  const results = ebgp.filter((n) => {
34787
36487
  const limit = bgpSetting(index, n, "maximum-prefix");
34788
36488
  return limit === void 0 || Number(limit) === 0;
34789
- }).map((n) => failAt2(id, n.node, "warning", `eBGP neighbor ${n.address} has no maximum-prefix limit.`));
34790
- return results.length > 0 ? results : [passAt2(id, bgp.first ?? anchor, "eBGP neighbors have maximum-prefix limits.")];
36489
+ }).map((n) => failAt3(id, n.node, "warning", `eBGP neighbor ${n.address} has no maximum-prefix limit.`));
36490
+ return results.length > 0 ? results : [passAt3(id, bgp.first ?? anchor, "eBGP neighbors have maximum-prefix limits.")];
34791
36491
  })
34792
36492
  };
34793
36493
  var ExosBgpRoutePolicy = {
@@ -34804,16 +36504,16 @@ var ExosBgpRoutePolicy = {
34804
36504
  },
34805
36505
  tags: EXOS_TAGS("bgp", "route-filtering", "routing-security")
34806
36506
  },
34807
- check: judgedOnce((index, anchor) => {
36507
+ check: judgedOnce2((index, anchor) => {
34808
36508
  const id = "EXOS-BGP-003";
34809
36509
  const bgp = exosBgp(index);
34810
36510
  const ebgp = bgp.neighbors.filter((n) => !isIbgp(bgp, n));
34811
- if (ebgp.length === 0) return [passAt2(id, anchor, "No eBGP neighbors are configured.")];
36511
+ if (ebgp.length === 0) return [passAt3(id, anchor, "No eBGP neighbors are configured.")];
34812
36512
  const results = ebgp.filter((n) => {
34813
36513
  const policy = bgpSetting(index, n, "route-policy\\s+in");
34814
36514
  return policy === void 0 || policy.toLowerCase() === "none";
34815
- }).map((n) => failAt2(id, n.node, "warning", `eBGP neighbor ${n.address} has no inbound route policy.`));
34816
- return results.length > 0 ? results : [passAt2(id, bgp.first ?? anchor, "eBGP neighbors have inbound route policies.")];
36515
+ }).map((n) => failAt3(id, n.node, "warning", `eBGP neighbor ${n.address} has no inbound route policy.`));
36516
+ return results.length > 0 ? results : [passAt3(id, bgp.first ?? anchor, "eBGP neighbors have inbound route policies.")];
34817
36517
  })
34818
36518
  };
34819
36519
  var ExosBgpRouterId = {
@@ -34827,16 +36527,16 @@ var ExosBgpRouterId = {
34827
36527
  remediation: "Configure the BGP router ID: configure bgp routerid <ip>",
34828
36528
  tags: EXOS_TAGS("bgp", "routing-stability")
34829
36529
  },
34830
- check: judgedOnce((index, anchor) => {
36530
+ check: judgedOnce2((index, anchor) => {
34831
36531
  const id = "EXOS-BGP-004";
34832
36532
  const bgp = exosBgp(index);
34833
- if (!bgp.first) return [passAt2(id, anchor, "BGP is not configured.")];
36533
+ if (!bgp.first) return [passAt3(id, anchor, "BGP is not configured.")];
34834
36534
  const routerId = lastMatching(index, /^configure\s+bgp\s+routerid\s+\S+/i);
34835
- if (!routerId) return [failAt2(id, bgp.first, "warning", "BGP router ID is not configured.", true)];
36535
+ if (!routerId) return [failAt3(id, bgp.first, "warning", "BGP router ID is not configured.", true)];
34836
36536
  if (/\s0\.0\.0\.0\s*$/.test(routerId.text)) {
34837
- return [failAt2(id, routerId.node, "warning", "BGP router ID is 0.0.0.0 (removed).")];
36537
+ return [failAt3(id, routerId.node, "warning", "BGP router ID is 0.0.0.0 (removed).")];
34838
36538
  }
34839
- return [passAt2(id, routerId.node, "BGP router ID is configured.")];
36539
+ return [passAt3(id, routerId.node, "BGP router ID is configured.")];
34840
36540
  })
34841
36541
  };
34842
36542
  var ExosBgpGracefulRestart = {
@@ -34850,14 +36550,14 @@ var ExosBgpGracefulRestart = {
34850
36550
  remediation: "Enable graceful restart (with BGP disabled): configure bgp restart both",
34851
36551
  tags: EXOS_TAGS("bgp", "high-availability")
34852
36552
  },
34853
- check: judgedOnce((index, anchor) => {
36553
+ check: judgedOnce2((index, anchor) => {
34854
36554
  const id = "EXOS-BGP-005";
34855
36555
  const bgp = exosBgp(index);
34856
- if (!bgp.first) return [passAt2(id, anchor, "BGP is not configured.")];
36556
+ if (!bgp.first) return [passAt3(id, anchor, "BGP is not configured.")];
34857
36557
  const restart = lastMatching(index, /^configure\s+bgp\s+restart\s+(?:none|planned|unplanned|both|aware-only)\s*$/i);
34858
- if (!restart) return [failAt2(id, bgp.first, "info", "BGP graceful restart is not configured (default none).", true)];
34859
- if (/\snone\s*$/i.test(restart.text)) return [failAt2(id, restart.node, "info", "BGP graceful restart is disabled.")];
34860
- return [passAt2(id, restart.node, "BGP graceful restart is configured.")];
36558
+ if (!restart) return [failAt3(id, bgp.first, "info", "BGP graceful restart is not configured (default none).", true)];
36559
+ if (/\snone\s*$/i.test(restart.text)) return [failAt3(id, restart.node, "info", "BGP graceful restart is disabled.")];
36560
+ return [passAt3(id, restart.node, "BGP graceful restart is configured.")];
34861
36561
  })
34862
36562
  };
34863
36563
  var exosOspfInterfaces = (index) => index.lines.flatMap((l) => {
@@ -34900,20 +36600,20 @@ var ExosOspfAuthentication = {
34900
36600
  },
34901
36601
  tags: EXOS_TAGS("ospf", "authentication", "routing-security")
34902
36602
  },
34903
- check: judgedOnce((index, anchor) => {
36603
+ check: judgedOnce2((index, anchor) => {
34904
36604
  const id = "EXOS-OSPF-001";
34905
36605
  const active = exosOspfInterfaces(index).filter((i) => !i.passive);
34906
- if (active.length === 0) return [passAt2(id, anchor, "No active OSPF interfaces are configured.")];
36606
+ if (active.length === 0) return [passAt3(id, anchor, "No active OSPF interfaces are configured.")];
34907
36607
  const results = [];
34908
36608
  for (const intf of active) {
34909
36609
  const auth = ospfAuthOf(index, intf);
34910
36610
  if (auth === "simple") {
34911
- results.push(failAt2(id, intf.node, "error", `OSPF VLAN ${intf.vlan} uses cleartext simple-password authentication; use MD5.`));
36611
+ results.push(failAt3(id, intf.node, "error", `OSPF VLAN ${intf.vlan} uses cleartext simple-password authentication; use MD5.`));
34912
36612
  } else if (auth === "none") {
34913
- results.push(failAt2(id, intf.node, "error", `OSPF VLAN ${intf.vlan} has no authentication.`));
36613
+ results.push(failAt3(id, intf.node, "error", `OSPF VLAN ${intf.vlan} has no authentication.`));
34914
36614
  }
34915
36615
  }
34916
- return results.length > 0 ? results : [passAt2(id, active[0]?.node ?? anchor, "Active OSPF interfaces use MD5 authentication.")];
36616
+ return results.length > 0 ? results : [passAt3(id, active[0]?.node ?? anchor, "Active OSPF interfaces use MD5 authentication.")];
34917
36617
  })
34918
36618
  };
34919
36619
  var ExosOspfRouterId = {
@@ -34927,16 +36627,16 @@ var ExosOspfRouterId = {
34927
36627
  remediation: "Configure the OSPF router ID: configure ospf routerid <ip>",
34928
36628
  tags: EXOS_TAGS("ospf", "routing-stability")
34929
36629
  },
34930
- check: judgedOnce((index, anchor) => {
36630
+ check: judgedOnce2((index, anchor) => {
34931
36631
  const id = "EXOS-OSPF-002";
34932
36632
  const first2 = exosOspfInterfaces(index)[0]?.node ?? matching(index, /^enable\s+ospf\s*$/i)[0]?.node;
34933
- if (!first2) return [passAt2(id, anchor, "OSPF is not configured.")];
36633
+ if (!first2) return [passAt3(id, anchor, "OSPF is not configured.")];
34934
36634
  const routerId = lastMatching(index, /^configure\s+ospf\s+routerid\s+\S+/i);
34935
- if (!routerId) return [failAt2(id, first2, "warning", "OSPF router ID is not configured (default automatic).", true)];
36635
+ if (!routerId) return [failAt3(id, first2, "warning", "OSPF router ID is not configured (default automatic).", true)];
34936
36636
  if (/\s(?:automatic|0\.0\.0\.0)\s*$/i.test(routerId.text)) {
34937
- return [failAt2(id, routerId.node, "warning", "OSPF router ID is chosen automatically; set it explicitly.")];
36637
+ return [failAt3(id, routerId.node, "warning", "OSPF router ID is chosen automatically; set it explicitly.")];
34938
36638
  }
34939
- return [passAt2(id, routerId.node, "OSPF router ID is configured.")];
36639
+ return [passAt3(id, routerId.node, "OSPF router ID is configured.")];
34940
36640
  })
34941
36641
  };
34942
36642
  var ExosOspfPassive = {
@@ -34953,18 +36653,18 @@ var ExosOspfPassive = {
34953
36653
  },
34954
36654
  tags: EXOS_TAGS("ospf", "routing-security")
34955
36655
  },
34956
- check: judgedOnce((index, anchor) => {
36656
+ check: judgedOnce2((index, anchor) => {
34957
36657
  const id = "EXOS-OSPF-003";
34958
36658
  const interfaces = exosOspfInterfaces(index);
34959
36659
  const first2 = interfaces[0];
34960
- if (!first2) return [passAt2(id, anchor, "No OSPF interfaces are configured.")];
36660
+ if (!first2) return [passAt3(id, anchor, "No OSPF interfaces are configured.")];
34961
36661
  const allActive = interfaces.filter((i) => i.vlan === "all" && !i.passive);
34962
36662
  if (allActive.length > 0) {
34963
- return allActive.map((i) => failAt2(id, i.node, "info", "OSPF is enabled on all VLANs, including host-facing ones; add those as passive."));
36663
+ return allActive.map((i) => failAt3(id, i.node, "info", "OSPF is enabled on all VLANs, including host-facing ones; add those as passive."));
34964
36664
  }
34965
36665
  const passive = interfaces.find((i) => i.passive);
34966
- if (passive) return [passAt2(id, passive.node, "Some OSPF VLANs are passive.")];
34967
- return [failAt2(id, first2.node, "info", "No OSPF VLAN is passive; add host-facing VLANs as passive.", true)];
36666
+ if (passive) return [passAt3(id, passive.node, "Some OSPF VLANs are passive.")];
36667
+ return [failAt3(id, first2.node, "info", "No OSPF VLAN is passive; add host-facing VLANs as passive.", true)];
34968
36668
  })
34969
36669
  };
34970
36670
  var ExosSflow = {
@@ -34978,16 +36678,16 @@ var ExosSflow = {
34978
36678
  remediation: "Enable sFlow: configure sflow collector <ip> port <port> vr VR-Default; enable sflow; enable sflow ports <ports>",
34979
36679
  tags: EXOS_TAGS("monitoring", "traffic-analysis")
34980
36680
  },
34981
- check: judgedOnce((index, anchor) => {
36681
+ check: judgedOnce2((index, anchor) => {
34982
36682
  const id = "EXOS-SYS-005";
34983
36683
  const enabled = lastMatching(index, /^(?:enable|disable)\s+sflow\s*$/i);
34984
36684
  if (!enabled || /^disable/i.test(enabled.text)) {
34985
- return [failAt2(id, enabled?.node ?? anchor, "info", "sFlow is not enabled (disabled by default).", !enabled)];
36685
+ return [failAt3(id, enabled?.node ?? anchor, "info", "sFlow is not enabled (disabled by default).", !enabled)];
34986
36686
  }
34987
36687
  if (!matching(index, /^configure\s+sflow\s+collector\s+/i)[0]) {
34988
- return [failAt2(id, enabled.node, "info", "sFlow is enabled but no collector is configured.", true)];
36688
+ return [failAt3(id, enabled.node, "info", "sFlow is enabled but no collector is configured.", true)];
34989
36689
  }
34990
- return [passAt2(id, enabled.node, "sFlow is enabled with a collector.")];
36690
+ return [passAt3(id, enabled.node, "sFlow is enabled with a collector.")];
34991
36691
  })
34992
36692
  };
34993
36693
  var isGlobalDot1x = (text) => {
@@ -35011,13 +36711,13 @@ var ExosDot1xEnabled = {
35011
36711
  },
35012
36712
  tags: EXOS_TAGS("802.1x", "network-access-control")
35013
36713
  },
35014
- check: judgedOnce((index, anchor) => {
36714
+ check: judgedOnce2((index, anchor) => {
35015
36715
  const id = "EXOS-NAC-001";
35016
36716
  const dot1x = index.lines.find((l) => isGlobalDot1x(l.text));
35017
- if (dot1x) return [passAt2(id, dot1x.node, "802.1X network login is enabled.")];
36717
+ if (dot1x) return [passAt3(id, dot1x.node, "802.1X network login is enabled.")];
35018
36718
  const access = firstAccessPort(index);
35019
- if (!access) return [passAt2(id, anchor, "No untagged access ports outside the Default VLAN.")];
35020
- return [failAt2(id, access, "info", "802.1X network login is not enabled (disabled by default).", true)];
36719
+ if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
36720
+ return [failAt3(id, access, "info", "802.1X network login is not enabled (disabled by default).", true)];
35021
36721
  })
35022
36722
  };
35023
36723
  var ExosNetloginPorts = {
@@ -35034,18 +36734,18 @@ var ExosNetloginPorts = {
35034
36734
  },
35035
36735
  tags: EXOS_TAGS("802.1x", "network-access-control")
35036
36736
  },
35037
- check: judgedOnce((index, anchor) => {
36737
+ check: judgedOnce2((index, anchor) => {
35038
36738
  const id = "EXOS-NAC-002";
35039
36739
  const global = index.lines.find((l) => isGlobalDot1x(l.text));
35040
36740
  const ports = index.lines.filter((l) => isPortDot1x(l.text));
35041
36741
  if (ports.length > 0 && !global) {
35042
- return ports.map((l) => failAt2(id, l.node, "info", "802.1X is enabled on ports but not on the switch (enable netlogin dot1x), so it has no effect."));
36742
+ return ports.map((l) => failAt3(id, l.node, "info", "802.1X is enabled on ports but not on the switch (enable netlogin dot1x), so it has no effect."));
35043
36743
  }
35044
36744
  if (global && ports.length === 0) {
35045
- return [failAt2(id, global.node, "info", "802.1X is enabled on the switch but on no port (enable netlogin ports <ports> dot1x).", true)];
36745
+ return [failAt3(id, global.node, "info", "802.1X is enabled on the switch but on no port (enable netlogin ports <ports> dot1x).", true)];
35046
36746
  }
35047
- if (global) return [passAt2(id, ports[0]?.node ?? global.node, "802.1X is enabled on the switch and on ports.")];
35048
- return [passAt2(id, anchor, "802.1X is not configured (judged by EXOS-NAC-001).")];
36747
+ if (global) return [passAt3(id, ports[0]?.node ?? global.node, "802.1X is enabled on the switch and on ports.")];
36748
+ return [passAt3(id, anchor, "802.1X is not configured (judged by EXOS-NAC-001).")];
35049
36749
  })
35050
36750
  };
35051
36751
  var allExosRules = [
@@ -35062,7 +36762,7 @@ var allExosRules = [
35062
36762
  ExosEapsControlVlan,
35063
36763
  ExosStackingPriority,
35064
36764
  ExosMlagIsc,
35065
- // Ported from the former commercial set (decision 0001 S3b)
36765
+ // Ported rules
35066
36766
  ExosIdleTimeout,
35067
36767
  ExosSnmpv3UserSecurity,
35068
36768
  ExosSnmpV1V2cDisabled,
@@ -35168,7 +36868,7 @@ var wholeConfig = (ruleId, okMessage, judge) => (node, context) => {
35168
36868
  if (failures.length > 0) return failures;
35169
36869
  return vossPass(ruleId, node, typeof okMessage === "string" ? okMessage : okMessage(index));
35170
36870
  };
35171
- var judgedOnce2 = (judge) => (node, context) => {
36871
+ var judgedOnce3 = (judge) => (node, context) => {
35172
36872
  const index = vossIndexOf(context);
35173
36873
  if (!index || index.first !== node) return [];
35174
36874
  return judge(index, node);
@@ -35212,7 +36912,7 @@ var VossSysNameRequired = {
35212
36912
  owner: "NetOps",
35213
36913
  remediation: 'Configure system name: snmp-server name "<name>"'
35214
36914
  },
35215
- check: judgedOnce2((index, anchor) => {
36915
+ check: judgedOnce3((index, anchor) => {
35216
36916
  const lines = index.global.filter((l) => {
35217
36917
  const { words: words2 } = negatedWords(l);
35218
36918
  return words2[0] === "snmp-server" && words2[1] === "name";
@@ -35247,7 +36947,7 @@ var VossNtpRequired = {
35247
36947
  owner: "SecOps",
35248
36948
  remediation: "Configure an NTP server and enable NTP: ntp server <ip-address> enable; ntp"
35249
36949
  },
35250
- check: judgedOnce2((index, anchor) => {
36950
+ check: judgedOnce3((index, anchor) => {
35251
36951
  const servers = /* @__PURE__ */ new Map();
35252
36952
  for (const line of index.global) {
35253
36953
  const { neg, words } = negatedWords(line);
@@ -35308,7 +37008,7 @@ var VossLoggingRequired = {
35308
37008
  { type: "general", label: "monitoring" }
35309
37009
  ]
35310
37010
  },
35311
- check: judgedOnce2((index, anchor) => {
37011
+ check: judgedOnce3((index, anchor) => {
35312
37012
  let sending;
35313
37013
  const hosts = /* @__PURE__ */ new Map();
35314
37014
  for (const line of index.global) {
@@ -35380,7 +37080,7 @@ var VossSshEnabled = {
35380
37080
  { type: "general", label: "management-plane" }
35381
37081
  ]
35382
37082
  },
35383
- check: judgedOnce2((index, anchor) => {
37083
+ check: judgedOnce3((index, anchor) => {
35384
37084
  const ssh = lastExactToggle(index.global, "ssh");
35385
37085
  if (ssh?.on) return [vossPass("VOSS-SEC-001", ssh.node, "SSH is enabled.")];
35386
37086
  if (ssh) return [vossFail("VOSS-SEC-001", "warning", "The SSH server is disabled (no ssh).", ssh.node)];
@@ -36463,7 +38163,7 @@ var allVossRules = [
36463
38163
  VossIsisEnabled,
36464
38164
  VossIsisSpbm,
36465
38165
  VossDvrDomainId,
36466
- // Ported from the former commercial set (decision 0001 S3b)
38166
+ // Ported rules
36467
38167
  VossTelnetDisabled,
36468
38168
  VossCliTimeout,
36469
38169
  VossWebServerSecure,
@@ -36675,8 +38375,8 @@ var InterfaceDescriptionRequired3 = {
36675
38375
  remediation: 'Add a description to the interface using "description <text>" command.'
36676
38376
  },
36677
38377
  check: (node) => {
36678
- const interfaceName = node.id.replace(/^interface\s+/i, "").trim();
36679
- if (!isPhysicalPort2(interfaceName)) {
38378
+ const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
38379
+ if (!isPhysicalPort2(interfaceName2)) {
36680
38380
  return {
36681
38381
  passed: true,
36682
38382
  message: "Non-physical interface, description optional.",
@@ -36699,7 +38399,7 @@ var InterfaceDescriptionRequired3 = {
36699
38399
  if (!hasDescription3(node)) {
36700
38400
  return {
36701
38401
  passed: false,
36702
- message: `Interface ${interfaceName} is enabled but has no description.`,
38402
+ message: `Interface ${interfaceName2} is enabled but has no description.`,
36703
38403
  ruleId: "HUAWEI-IF-001",
36704
38404
  nodeId: node.id,
36705
38405
  level: "warning",
@@ -36728,8 +38428,8 @@ var AccessPortStpEdgeRequired = {
36728
38428
  remediation: 'Enable STP edge-port on access ports using "stp edged-port enable".'
36729
38429
  },
36730
38430
  check: (node) => {
36731
- const interfaceName = node.id.replace(/^interface\s+/i, "").trim();
36732
- if (!isPhysicalPort2(interfaceName) || !isAccessPort3(node) || !isEnabled(node)) {
38431
+ const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
38432
+ if (!isPhysicalPort2(interfaceName2) || !isAccessPort3(node) || !isEnabled(node)) {
36733
38433
  return {
36734
38434
  passed: true,
36735
38435
  message: "Not an active access port.",
@@ -36742,7 +38442,7 @@ var AccessPortStpEdgeRequired = {
36742
38442
  if (!hasStpEdgedPort(node)) {
36743
38443
  return {
36744
38444
  passed: false,
36745
- message: `Access port ${interfaceName} should have "stp edged-port enable" for faster convergence.`,
38445
+ message: `Access port ${interfaceName2} should have "stp edged-port enable" for faster convergence.`,
36746
38446
  ruleId: "HUAWEI-IF-002",
36747
38447
  nodeId: node.id,
36748
38448
  level: "warning",
@@ -36771,7 +38471,7 @@ var TrunkVlanRestriction = {
36771
38471
  remediation: "Restrict allowed VLANs on trunk ports to only required VLANs."
36772
38472
  },
36773
38473
  check: (node) => {
36774
- const interfaceName = node.id.replace(/^interface\s+/i, "").trim();
38474
+ const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
36775
38475
  if (!isTrunkPort3(node) || !isEnabled(node)) {
36776
38476
  return {
36777
38477
  passed: true,
@@ -36786,7 +38486,7 @@ var TrunkVlanRestriction = {
36786
38486
  if (allowedVlans && (equalsIgnoreCase(allowedVlans, "all") || allowedVlans.includes("1 to 4094"))) {
36787
38487
  return {
36788
38488
  passed: false,
36789
- message: `Trunk port ${interfaceName} allows all VLANs. Restrict to only required VLANs.`,
38489
+ message: `Trunk port ${interfaceName2} allows all VLANs. Restrict to only required VLANs.`,
36790
38490
  ruleId: "HUAWEI-IF-003",
36791
38491
  nodeId: node.id,
36792
38492
  level: "warning",
@@ -36815,8 +38515,8 @@ var PortSecurityRequired = {
36815
38515
  remediation: 'Enable port security on user-facing ports using "port-security enable".'
36816
38516
  },
36817
38517
  check: (node) => {
36818
- const interfaceName = node.id.replace(/^interface\s+/i, "").trim();
36819
- if (!isPhysicalPort2(interfaceName) || !isAccessPort3(node) || !isEnabled(node)) {
38518
+ const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
38519
+ if (!isPhysicalPort2(interfaceName2) || !isAccessPort3(node) || !isEnabled(node)) {
36820
38520
  return {
36821
38521
  passed: true,
36822
38522
  message: "Not an active access port.",
@@ -36829,7 +38529,7 @@ var PortSecurityRequired = {
36829
38529
  if (!hasPortSecurity2(node)) {
36830
38530
  return {
36831
38531
  passed: false,
36832
- message: `Access port ${interfaceName} does not have port security enabled.`,
38532
+ message: `Access port ${interfaceName2} does not have port security enabled.`,
36833
38533
  ruleId: "HUAWEI-IF-004",
36834
38534
  nodeId: node.id,
36835
38535
  level: "info",
@@ -38337,7 +40037,7 @@ var allHuaweiRules = [
38337
40037
  SyslogServerRequired,
38338
40038
  SshServerEnabled,
38339
40039
  TelnetDisabled2,
38340
- // Ported from the former commercial set (decision 0001 S3b)
40040
+ // Ported rules
38341
40041
  BgpPeerAuthenticationRequired,
38342
40042
  BgpPeerGtsmRequired,
38343
40043
  BgpPeerMaxPrefixRequired,
@@ -38494,7 +40194,7 @@ var result = (ruleId, node, passed, message, level) => ({
38494
40194
  level: passed ? "info" : level,
38495
40195
  loc: node.loc
38496
40196
  });
38497
- var failAt3 = (ruleId, cmd, message, level) => ({
40197
+ var failAt4 = (ruleId, cmd, message, level) => ({
38498
40198
  passed: false,
38499
40199
  message,
38500
40200
  ruleId,
@@ -38668,7 +40368,7 @@ var MikrotikDisableUnusedServices = {
38668
40368
  result("MIK-SEC-001", node, false, `Service '${service}' is enabled (RouterOS default). Consider disabling it.`, "warning")
38669
40369
  );
38670
40370
  } else if (!is(lastSet(lines, "disabled"), "yes")) {
38671
- findings.push(failAt3("MIK-SEC-001", last, `Service '${service}' is enabled. Consider disabling it.`, "warning"));
40371
+ findings.push(failAt4("MIK-SEC-001", last, `Service '${service}' is enabled. Consider disabling it.`, "warning"));
38672
40372
  }
38673
40373
  }
38674
40374
  if (findings.length > 0) return findings;
@@ -38859,7 +40559,7 @@ var MikrotikSnmpV3Required = {
38859
40559
  } else if (is(security, "authorized")) {
38860
40560
  issues.push(`SNMP community "${label}" uses SNMPv3 without encryption (security=authorized).`);
38861
40561
  }
38862
- if (issues.length > 0) findings.push(failAt3("MIK-SEC-006", cmd, issues.join(" "), "error"));
40562
+ if (issues.length > 0) findings.push(failAt4("MIK-SEC-006", cmd, issues.join(" "), "error"));
38863
40563
  }
38864
40564
  const factoryTouched = cmds.some(
38865
40565
  (c) => isSet(c) && (targetsDefault(c) || is(setTarget(c), "public")) || is(prop(c, "name"), "public")
@@ -39252,7 +40952,7 @@ var MikrotikFirewallRuleActions = {
39252
40952
  cmds.filter(isAdd).forEach((cmd, i) => {
39253
40953
  if (prop(cmd, "action") === void 0) {
39254
40954
  const chain = prop(cmd, "chain") ?? "unknown";
39255
- findings.push(failAt3("MIK-FW-003", cmd, `Firewall rule ${i + 1} (chain=${chain}) has no explicit action (defaults to accept).`, "error"));
40955
+ findings.push(failAt4("MIK-FW-003", cmd, `Firewall rule ${i + 1} (chain=${chain}) has no explicit action (defaults to accept).`, "error"));
39256
40956
  }
39257
40957
  });
39258
40958
  if (findings.length > 0) return findings;
@@ -39287,7 +40987,7 @@ var MikrotikStatefulFirst = {
39287
40987
  const drop = inChain[firstDrop];
39288
40988
  if (!drop) continue;
39289
40989
  if (!inChain.slice(0, firstDrop).some(isStatefulAccept)) {
39290
- findings.push(failAt3("MIK-FW-004", drop, `The ${chain} chain default drop comes before any rule accepting established,related connections.`, "warning"));
40990
+ findings.push(failAt4("MIK-FW-004", drop, `The ${chain} chain default drop comes before any rule accepting established,related connections.`, "warning"));
39291
40991
  }
39292
40992
  }
39293
40993
  if (findings.length > 0) return findings;
@@ -39418,7 +41118,7 @@ var MikrotikFirewallLogging = {
39418
41118
  check: (node) => {
39419
41119
  const cmds = ownCommands(node, RULE_PATH.filter);
39420
41120
  if (!cmds) return notApplicable("MIK-FW-008", node);
39421
- const findings = activeRules(cmds).filter((c) => isDropAction(c) && !isInvalidOnlyDrop(c) && !is(prop(c, "log"), "yes")).map((c) => failAt3("MIK-FW-008", c, `Drop rule in ${prop(c, "chain") ?? "unknown"} chain has no logging enabled.`, "info"));
41121
+ const findings = activeRules(cmds).filter((c) => isDropAction(c) && !isInvalidOnlyDrop(c) && !is(prop(c, "log"), "yes")).map((c) => failAt4("MIK-FW-008", c, `Drop rule in ${prop(c, "chain") ?? "unknown"} chain has no logging enabled.`, "info"));
39422
41122
  if (findings.length > 0) return findings;
39423
41123
  return result("MIK-FW-008", node, true, "Firewall drop rules have logging enabled.", "info");
39424
41124
  }
@@ -39440,7 +41140,7 @@ var MikrotikNatOutInterface = {
39440
41140
  if (!cmds) return notApplicable("MIK-NAT-001", node);
39441
41141
  const findings = activeRules(cmds).filter(
39442
41142
  (c) => is(prop(c, "chain"), "srcnat") && is(prop(c, "action"), "masquerade") && prop(c, "out-interface") === void 0 && prop(c, "out-interface-list") === void 0
39443
- ).map((c) => failAt3("MIK-NAT-001", c, "Masquerade NAT rule without out-interface or out-interface-list may NAT traffic incorrectly.", "warning"));
41143
+ ).map((c) => failAt4("MIK-NAT-001", c, "Masquerade NAT rule without out-interface or out-interface-list may NAT traffic incorrectly.", "warning"));
39444
41144
  if (findings.length > 0) return findings;
39445
41145
  return result("MIK-NAT-001", node, true, "NAT rules have appropriate interface specifications.", "info");
39446
41146
  }
@@ -39463,7 +41163,7 @@ var MikrotikDstNatConfig = {
39463
41163
  const scope = ["dst-address", "dst-address-list", "dst-address-type", "dst-port", "in-interface", "in-interface-list"];
39464
41164
  const findings = activeRules(cmds).filter(
39465
41165
  (c) => is(prop(c, "chain"), "dstnat") && is(prop(c, "action"), "dst-nat") && scope.every((p) => prop(c, p) === void 0)
39466
- ).map((c) => failAt3("MIK-NAT-002", c, "DNAT rule without dst-address, dst-port, or in-interface is too broad.", "warning"));
41166
+ ).map((c) => failAt4("MIK-NAT-002", c, "DNAT rule without dst-address, dst-port, or in-interface is too broad.", "warning"));
39467
41167
  if (findings.length > 0) return findings;
39468
41168
  return result("MIK-NAT-002", node, true, "DNAT rules have appropriate match criteria.", "info");
39469
41169
  }
@@ -39488,7 +41188,7 @@ var MikrotikInterfaceComments = {
39488
41188
  if (!isSet(cmd) || isDisabledCmd(cmd)) continue;
39489
41189
  const name = itemName(cmd);
39490
41190
  if (name !== void 0 && !prop(cmd, "comment")) {
39491
- findings.push(failAt3("MIK-IF-001", cmd, `Interface "${name}" has no comment/description.`, "warning"));
41191
+ findings.push(failAt4("MIK-IF-001", cmd, `Interface "${name}" has no comment/description.`, "warning"));
39492
41192
  }
39493
41193
  }
39494
41194
  if (findings.length > 0) return findings;
@@ -39510,7 +41210,7 @@ var MikrotikBridgeStp = {
39510
41210
  check: (node) => {
39511
41211
  const cmds = ownCommands(node, "/interface bridge");
39512
41212
  if (!cmds) return notApplicable("MIK-IF-002", node);
39513
- const findings = cmds.filter((c) => !isDisabledCmd(c) && is(prop(c, "protocol-mode"), "none")).map((c) => failAt3("MIK-IF-002", c, `Bridge "${itemName(c) ?? "unnamed"}" has STP disabled. Consider enabling RSTP.`, "warning"));
41213
+ const findings = cmds.filter((c) => !isDisabledCmd(c) && is(prop(c, "protocol-mode"), "none")).map((c) => failAt4("MIK-IF-002", c, `Bridge "${itemName(c) ?? "unnamed"}" has STP disabled. Consider enabling RSTP.`, "warning"));
39514
41214
  if (findings.length > 0) return findings;
39515
41215
  return result("MIK-IF-002", node, true, "Bridge STP configuration is acceptable.", "info");
39516
41216
  }
@@ -39535,7 +41235,7 @@ var MikrotikStaticRouteComments = {
39535
41235
  if (!isAdd(cmd)) continue;
39536
41236
  const dst = prop(cmd, "dst-address");
39537
41237
  if (dst !== void 0 && !prop(cmd, "comment")) {
39538
- findings.push(failAt3("MIK-RTR-001", cmd, `Static route to "${dst}" has no comment.`, "info"));
41238
+ findings.push(failAt4("MIK-RTR-001", cmd, `Static route to "${dst}" has no comment.`, "info"));
39539
41239
  }
39540
41240
  }
39541
41241
  if (findings.length > 0) return findings;
@@ -39561,7 +41261,7 @@ var MikrotikBgpDescription = {
39561
41261
  check: (node) => {
39562
41262
  const cmds = ownCommands(node, "/routing bgp connection");
39563
41263
  if (!cmds) return notApplicable("MIK-RTR-002", node);
39564
- const findings = cmds.filter((c) => isAdd(c) && !prop(c, "comment")).map((c) => failAt3("MIK-RTR-002", c, `BGP connection "${bgpLabel(c)}" has no comment.`, "info"));
41264
+ const findings = cmds.filter((c) => isAdd(c) && !prop(c, "comment")).map((c) => failAt4("MIK-RTR-002", c, `BGP connection "${bgpLabel(c)}" has no comment.`, "info"));
39565
41265
  if (findings.length > 0) return findings;
39566
41266
  return result("MIK-RTR-002", node, true, "BGP connections have comments.", "info");
39567
41267
  }
@@ -39615,7 +41315,7 @@ var MikrotikAddressComments = {
39615
41315
  if (!isAdd(cmd)) continue;
39616
41316
  const address = prop(cmd, "address");
39617
41317
  if (address !== void 0 && !prop(cmd, "comment")) {
39618
- findings.push(failAt3("MIK-ADDR-001", cmd, `IP address "${address}" on "${prop(cmd, "interface") ?? "unknown"}" has no comment.`, "info"));
41318
+ findings.push(failAt4("MIK-ADDR-001", cmd, `IP address "${address}" on "${prop(cmd, "interface") ?? "unknown"}" has no comment.`, "info"));
39619
41319
  }
39620
41320
  }
39621
41321
  if (findings.length > 0) return findings;
@@ -39703,7 +41403,7 @@ var MikrotikBgpMd5Auth = {
39703
41403
  check: (node) => {
39704
41404
  const cmds = bgpConnections(node);
39705
41405
  if (!cmds) return notApplicable("MIK-BGP-001", node);
39706
- const findings = cmds.filter((c) => !prop(c, "tcp-md5-key")).map((c) => failAt3("MIK-BGP-001", c, `BGP connection "${bgpLabel(c)}" has no MD5 authentication.`, "error"));
41406
+ const findings = cmds.filter((c) => !prop(c, "tcp-md5-key")).map((c) => failAt4("MIK-BGP-001", c, `BGP connection "${bgpLabel(c)}" has no MD5 authentication.`, "error"));
39707
41407
  if (findings.length > 0) return findings;
39708
41408
  return result("MIK-BGP-001", node, true, "All BGP connections have MD5 authentication configured.", "info");
39709
41409
  }
@@ -39733,7 +41433,7 @@ var MikrotikBgpMaxPrefix = {
39733
41433
  const cmds = bgpConnections(node);
39734
41434
  if (!cmds) return notApplicable("MIK-BGP-002", node);
39735
41435
  const limits = ["input.limit-process-routes-ipv4", "input.limit-process-routes-ipv6", "max-prefix-limit"];
39736
- const findings = cmds.filter((c) => limits.every((p) => !prop(c, p))).map((c) => failAt3("MIK-BGP-002", c, `BGP connection "${bgpLabel(c)}" has no max-prefix limit.`, "warning"));
41436
+ const findings = cmds.filter((c) => limits.every((p) => !prop(c, p))).map((c) => failAt4("MIK-BGP-002", c, `BGP connection "${bgpLabel(c)}" has no max-prefix limit.`, "warning"));
39737
41437
  if (findings.length > 0) return findings;
39738
41438
  return result("MIK-BGP-002", node, true, "All BGP connections have max-prefix limits configured.", "info");
39739
41439
  }
@@ -39773,7 +41473,7 @@ var MikrotikBgpPrefixFiltering = {
39773
41473
  if (outputFilters.every((p) => !prop(cmd, p))) {
39774
41474
  issues.push(`BGP connection "${bgpLabel(cmd)}" has no output filter.`);
39775
41475
  }
39776
- if (issues.length > 0) findings.push(failAt3("MIK-BGP-003", cmd, issues.join(" "), "warning"));
41476
+ if (issues.length > 0) findings.push(failAt4("MIK-BGP-003", cmd, issues.join(" "), "warning"));
39777
41477
  }
39778
41478
  if (findings.length > 0) return findings;
39779
41479
  return result("MIK-BGP-003", node, true, "All BGP connections have input and output filters configured.", "info");
@@ -39820,7 +41520,7 @@ var MikrotikIpsecStrongEncryption = {
39820
41520
  for (const cmd of cmds) {
39821
41521
  if (isDisabledCmd(cmd)) continue;
39822
41522
  const weaknesses = ipsecWeaknesses(cmd, "profile");
39823
- if (weaknesses.length > 0) findings.push(failAt3("MIK-VPN-001", cmd, weaknesses.join(". "), "error"));
41523
+ if (weaknesses.length > 0) findings.push(failAt4("MIK-VPN-001", cmd, weaknesses.join(". "), "error"));
39824
41524
  }
39825
41525
  if (findings.length > 0) return findings;
39826
41526
  return result("MIK-VPN-001", node, true, "IPsec profiles use strong encryption.", "info");
@@ -39854,7 +41554,7 @@ var MikrotikIpsecProposalStrong = {
39854
41554
  for (const cmd of cmds) {
39855
41555
  if (isDisabledCmd(cmd)) continue;
39856
41556
  const weaknesses = ipsecWeaknesses(cmd, "proposal");
39857
- if (weaknesses.length > 0) findings.push(failAt3("MIK-VPN-002", cmd, weaknesses.join(". "), "error"));
41557
+ if (weaknesses.length > 0) findings.push(failAt4("MIK-VPN-002", cmd, weaknesses.join(". "), "error"));
39858
41558
  }
39859
41559
  if (findings.length > 0) return findings;
39860
41560
  return result("MIK-VPN-002", node, true, "IPsec proposals use strong encryption.", "info");
@@ -39909,7 +41609,7 @@ var MikrotikBridgeVlanFiltering = {
39909
41609
  if (name === void 0 || isDisabledCmd(cmd) || is(prop(cmd, "vlan-filtering"), "yes")) continue;
39910
41610
  if (isSet(cmd) && prop(cmd, "vlan-filtering") === void 0) continue;
39911
41611
  if (withVlans && !withVlans.has(name.toLowerCase())) continue;
39912
- findings.push(failAt3("MIK-VLAN-001", cmd, `Bridge "${name}" carries VLANs but does not have VLAN filtering enabled.`, "warning"));
41612
+ findings.push(failAt4("MIK-VLAN-001", cmd, `Bridge "${name}" carries VLANs but does not have VLAN filtering enabled.`, "warning"));
39913
41613
  }
39914
41614
  if (findings.length > 0) return findings;
39915
41615
  return result("MIK-VLAN-001", node, true, "Bridges that carry VLANs have VLAN filtering enabled.", "info");
@@ -39946,7 +41646,7 @@ var MikrotikVrrpAuthentication = {
39946
41646
  if (!isAdd(cmd) || isDisabledCmd(cmd) || !is(prop(cmd, "version"), "2")) continue;
39947
41647
  const auth = prop(cmd, "authentication");
39948
41648
  if (auth === void 0 || is(auth, "none") || !prop(cmd, "password")) {
39949
- findings.push(failAt3("MIK-HA-001", cmd, `VRRP instance "${prop(cmd, "name") ?? "unnamed"}" has no authentication configured.`, "warning"));
41649
+ findings.push(failAt4("MIK-HA-001", cmd, `VRRP instance "${prop(cmd, "name") ?? "unnamed"}" has no authentication configured.`, "warning"));
39950
41650
  }
39951
41651
  }
39952
41652
  if (findings.length > 0) return findings;
@@ -39989,7 +41689,7 @@ var MikrotikOspfAuthentication = {
39989
41689
  if (!isAdd(cmd) || isDisabledCmd(cmd) || isPassive(cmd)) continue;
39990
41690
  const auth = prop(cmd, "auth");
39991
41691
  if (auth === void 0 || is(auth, "none")) {
39992
- findings.push(failAt3("MIK-HA-002", cmd, `OSPF interface-template for "${prop(cmd, "interfaces") ?? prop(cmd, "networks") ?? "unnamed"}" has no authentication.`, "warning"));
41692
+ findings.push(failAt4("MIK-HA-002", cmd, `OSPF interface-template for "${prop(cmd, "interfaces") ?? prop(cmd, "networks") ?? "unnamed"}" has no authentication.`, "warning"));
39993
41693
  }
39994
41694
  }
39995
41695
  if (findings.length > 0) return findings;
@@ -40425,11 +42125,11 @@ var InterfaceDescriptionRequired4 = {
40425
42125
  remediation: 'Add description to interface: interface "<name>" > description "<description>"'
40426
42126
  },
40427
42127
  check: (node, context) => {
40428
- const interfaceName = getInterfaceName3(node);
42128
+ const interfaceName2 = getInterfaceName3(node);
40429
42129
  if (isProtocolInterfaceReference(context, node)) {
40430
42130
  return protocolReferencePass("NOKIA-IF-001", node);
40431
42131
  }
40432
- if (isSystemInterface(interfaceName)) {
42132
+ if (isSystemInterface(interfaceName2)) {
40433
42133
  return {
40434
42134
  passed: true,
40435
42135
  message: "System interface, description optional.",
@@ -40452,7 +42152,7 @@ var InterfaceDescriptionRequired4 = {
40452
42152
  if (!hasDescription4(node)) {
40453
42153
  return {
40454
42154
  passed: false,
40455
- message: `Interface "${interfaceName}" has no description.`,
42155
+ message: `Interface "${interfaceName2}" has no description.`,
40456
42156
  ruleId: "NOKIA-IF-001",
40457
42157
  nodeId: node.id,
40458
42158
  level: "warning",
@@ -40461,7 +42161,7 @@ var InterfaceDescriptionRequired4 = {
40461
42161
  }
40462
42162
  return {
40463
42163
  passed: true,
40464
- message: `Interface "${interfaceName}" has description.`,
42164
+ message: `Interface "${interfaceName2}" has description.`,
40465
42165
  ruleId: "NOKIA-IF-001",
40466
42166
  nodeId: node.id,
40467
42167
  level: "info",
@@ -40481,7 +42181,7 @@ var InterfaceAddressRequired = {
40481
42181
  remediation: 'Configure IP address: interface "<name>" > address <ip-prefix> (classic CLI) or > ipv4 > primary > address <ip> and prefix-length <n> (MD-CLI)'
40482
42182
  },
40483
42183
  check: (node, context) => {
40484
- const interfaceName = getInterfaceName3(node);
42184
+ const interfaceName2 = getInterfaceName3(node);
40485
42185
  if (isProtocolInterfaceReference(context, node)) {
40486
42186
  return protocolReferencePass("NOKIA-IF-002", node);
40487
42187
  }
@@ -40498,7 +42198,7 @@ var InterfaceAddressRequired = {
40498
42198
  if (!hasIpAddress2(node)) {
40499
42199
  return {
40500
42200
  passed: false,
40501
- message: `Interface "${interfaceName}" has no IP address configured.`,
42201
+ message: `Interface "${interfaceName2}" has no IP address configured.`,
40502
42202
  ruleId: "NOKIA-IF-002",
40503
42203
  nodeId: node.id,
40504
42204
  level: "warning",
@@ -40507,7 +42207,7 @@ var InterfaceAddressRequired = {
40507
42207
  }
40508
42208
  return {
40509
42209
  passed: true,
40510
- message: `Interface "${interfaceName}" has IP address: ${getIpAddress(node)}`,
42210
+ message: `Interface "${interfaceName2}" has IP address: ${getIpAddress(node)}`,
40511
42211
  ruleId: "NOKIA-IF-002",
40512
42212
  nodeId: node.id,
40513
42213
  level: "info",
@@ -42168,7 +43868,7 @@ var allNokiaRules = [
42168
43868
  LagDescriptionRequired,
42169
43869
  LagAdminStateRequired,
42170
43870
  LogConfigured,
42171
- // Ported from the former commercial set (decision 0001 S3b)
43871
+ // Ported rules
42172
43872
  AaaWithTacacsRequired,
42173
43873
  SshV2Required,
42174
43874
  SnmpV3Required,
@@ -43662,7 +45362,7 @@ var allCumulusRules = [
43662
45362
  CumulusNcluCommit,
43663
45363
  CumulusNvueApply,
43664
45364
  CumulusLoopbackAddress,
43665
- // Ported from the former commercial set (decision 0001 S3b)
45365
+ // Ported rules
43666
45366
  CumulusManagementVrf,
43667
45367
  CumulusUplinkMtu,
43668
45368
  CumulusRootGuard,
@@ -44069,6 +45769,7 @@ var allRules = [
44069
45769
  ...allCommonRules,
44070
45770
  // Cisco-specific rules
44071
45771
  ...allCiscoRules,
45772
+ ...allNxosRules,
44072
45773
  // Juniper-specific rules
44073
45774
  ...allJuniperRules,
44074
45775
  // Aruba HPE rules (all platforms)
@@ -44098,7 +45799,7 @@ var builtInRuleIds = new Set(allRules.map((rule) => rule.id));
44098
45799
  function builtInRuleDocsUrl(ruleId) {
44099
45800
  return builtInRuleIds.has(ruleId) ? ruleDocsUrl(ruleId) : void 0;
44100
45801
  }
44101
- var ciscoRulesFor = (vendorId) => allCiscoRules.filter((rule) => ruleAppliesToVendor(rule, vendorId));
45802
+ var ciscoRulesFor = (vendorId) => [...allCiscoRules, ...allNxosRules].filter((rule) => ruleAppliesToVendor(rule, vendorId));
44102
45803
  var vendorRulesRegistry = {
44103
45804
  // Cisco platforms share one rule array; each rule's `vendor` field says
44104
45805
  // whether it also applies to NX-OS (decision 0002 point 5).
@@ -44198,7 +45899,7 @@ function resolveVersion(injected) {
44198
45899
 
44199
45900
  // src/sarif.ts
44200
45901
  var TOOL_VERSION = resolveVersion(
44201
- true ? "0.11.0" : void 0
45902
+ true ? "0.13.0" : void 0
44202
45903
  );
44203
45904
  var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
44204
45905
  function cweNumber(cweId) {
@@ -44731,12 +46432,13 @@ function validateInputFilePath(filePath, maxSize = 10 * 1024 * 1024, baseDirs) {
44731
46432
  mustExist: true
44732
46433
  });
44733
46434
  }
46435
+ var MAX_PACK_FILE_SIZE = 5 * 1024 * 1024;
44734
46436
  function validatePackPath(packPath, baseDirs) {
44735
46437
  return validatePath(packPath, {
44736
46438
  allowedBaseDirs: baseDirs,
44737
46439
  allowedExtensions: [],
44738
- // Allow any extension - format detected via magic bytes
44739
- maxFileSize: MAX_ENCRYPTED_PACK_SIZE,
46440
+ // Any extension: the caller checks the format
46441
+ maxFileSize: MAX_PACK_FILE_SIZE,
44740
46442
  mustExist: true
44741
46443
  });
44742
46444
  }
@@ -44772,22 +46474,14 @@ function describeLoadError(error, fallback) {
44772
46474
  }
44773
46475
 
44774
46476
  // src/loaders/pack-detector.ts
44775
- var UNENCRYPTED_PACK_PRIORITY = 100;
44776
- var UNSUPPORTED_PACK_FORMAT_MESSAGE = "unsupported pack format (encrypted packs need the SentriFlow licensing plugin)";
46477
+ var PLAIN_PACK_PRIORITY = 100;
46478
+ var UNSUPPORTED_PACK_FORMAT_MESSAGE = "unsupported pack format";
44777
46479
  var UnsupportedPackFormatError = class extends SentriflowConfigError {
44778
46480
  constructor(filePath) {
44779
46481
  super(`${UNSUPPORTED_PACK_FORMAT_MESSAGE}: ${redactPath(filePath)}`, { filePath });
44780
46482
  this.name = "UnsupportedPackFormatError";
44781
46483
  }
44782
46484
  };
44783
- var MAGIC = [
44784
- ["GRX2", "grx2"],
44785
- ["GRPX", "grpx"]
44786
- ];
44787
- var EXTENSIONS = {
44788
- ".grx2": "grx2",
44789
- ".grpx": "grpx"
44790
- };
44791
46485
  async function readPackHeader(filePath, length) {
44792
46486
  let handle;
44793
46487
  try {
@@ -44804,15 +46498,8 @@ async function readPackHeader(filePath, length) {
44804
46498
  await handle?.close();
44805
46499
  }
44806
46500
  }
44807
- function detectPackFormat(filePath, header) {
44808
- const magic = Buffer.from(header.subarray(0, 4)).toString("latin1");
44809
- for (const [bytes, format2] of MAGIC) {
44810
- if (magic === bytes) return format2;
44811
- }
44812
- return EXTENSIONS[extname2(filePath).toLowerCase()] ?? "unencrypted";
44813
- }
44814
- function isEncryptedPackFormat(format2) {
44815
- return format2 !== "unencrypted";
46501
+ function isPlainPackFile(filePath) {
46502
+ return ALLOWED_CONFIG_EXTENSIONS.includes(extname2(filePath).toLowerCase());
44816
46503
  }
44817
46504
 
44818
46505
  // src/loaders/index.ts
@@ -44857,7 +46544,6 @@ import { resolve as resolve2, isAbsolute as isAbsolute2 } from "path";
44857
46544
  import { fileURLToPath, pathToFileURL } from "url";
44858
46545
  var PACK_HEADER_BYTES = 16;
44859
46546
  var DEFAULT_PLUGIN_PACK_PRIORITY = 300;
44860
- var DEFAULT_PLUGIN_MODULES = ["@sentriflow/licensing/cli"];
44861
46547
  var PLUGINS_ENV_VAR = "SENTRIFLOW_PLUGINS";
44862
46548
  function pluginRequestsFromEnv(env, cwd = process.cwd()) {
44863
46549
  const raw = env[PLUGINS_ENV_VAR];
@@ -44876,12 +46562,6 @@ function pluginLabel(request) {
44876
46562
  return redactPath(request);
44877
46563
  }
44878
46564
  }
44879
- function isModuleNotFound(error, specifier) {
44880
- if (!(error instanceof Error)) return false;
44881
- const code = error.code;
44882
- const notFound = code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || error.message.includes("Cannot find module") || error.message.includes("Cannot find package");
44883
- return notFound && error.message.includes(specifier.split("/").slice(0, 2).join("/"));
44884
- }
44885
46565
  function isPluginModule(value2) {
44886
46566
  if (typeof value2 !== "object" || value2 === null) return false;
44887
46567
  const register = value2.registerCommands;
@@ -44898,7 +46578,6 @@ var PluginLoadError = class extends Error {
44898
46578
  async function loadPlugins(program2, options) {
44899
46579
  const {
44900
46580
  cliVersion: cliVersion2,
44901
- optionalModules = DEFAULT_PLUGIN_MODULES,
44902
46581
  requestedModules = [],
44903
46582
  importer = (specifier) => import(
44904
46583
  /* @vite-ignore */
@@ -44915,19 +46594,11 @@ async function loadPlugins(program2, options) {
44915
46594
  loaders.push(loader);
44916
46595
  }
44917
46596
  };
44918
- const entries = [
44919
- ...optionalModules.map((specifier) => ({
44920
- specifier,
44921
- label: pluginLabel(specifier),
44922
- optional: true
44923
- })),
44924
- ...requestedModules.map((request) => ({
44925
- specifier: typeof request === "string" ? request : request.specifier,
44926
- label: pluginLabel(request),
44927
- optional: false
44928
- }))
44929
- ];
44930
- for (const { specifier, label, optional } of entries) {
46597
+ const entries = requestedModules.map((request) => ({
46598
+ specifier: typeof request === "string" ? request : request.specifier,
46599
+ label: pluginLabel(request)
46600
+ }));
46601
+ for (const { specifier, label } of entries) {
44931
46602
  try {
44932
46603
  const mod = await importer(specifier);
44933
46604
  if (!isPluginModule(mod)) {
@@ -44935,7 +46606,6 @@ async function loadPlugins(program2, options) {
44935
46606
  }
44936
46607
  await mod.registerCommands?.(program2, context);
44937
46608
  } catch (error) {
44938
- if (optional && isModuleNotFound(error, specifier)) continue;
44939
46609
  const message = describeLoadError(error, String(error));
44940
46610
  throw new PluginLoadError(specifier, message, label);
44941
46611
  }
@@ -45344,11 +47014,11 @@ async function resolveRules(options = {}) {
45344
47014
  }
45345
47015
  loadedPack = pack;
45346
47016
  loadedPack.priority = (pluginLoader.basePriority ?? DEFAULT_PLUGIN_PACK_PRIORITY) + i;
45347
- } else if (isEncryptedPackFormat(detectPackFormat(canonicalPath, header))) {
47017
+ } else if (!isPlainPackFile(canonicalPath)) {
45348
47018
  throw new UnsupportedPackFormatError(canonicalPath);
45349
47019
  } else {
45350
47020
  loadedPack = await loadRulePackFile(canonicalPath, allowedBaseDirs);
45351
- loadedPack.priority = UNENCRYPTED_PACK_PRIORITY + i;
47021
+ loadedPack.priority = PLAIN_PACK_PRIORITY + i;
45352
47022
  }
45353
47023
  allPacks.push(loadedPack);
45354
47024
  loadedCount++;
@@ -46736,7 +48406,7 @@ async function exitIfVendorUndetected() {
46736
48406
  }
46737
48407
  }
46738
48408
  var program = new Command2();
46739
- var cliVersion = resolveVersion(true ? "0.11.0" : void 0);
48409
+ var cliVersion = resolveVersion(true ? "0.13.0" : void 0);
46740
48410
  var pluginPackLoaders = [];
46741
48411
  var pluginRequests = pluginRequestsFromEnv(process.env);
46742
48412
  program.name("sentriflow").description("SentriFlow Network Configuration Validator").version(cliVersion).argument("[files...]", "Path(s) to configuration file(s) (supports multiple files)").option("--ast", "Output the AST instead of rule results").option(