@sentriflow/cli 0.12.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.
- package/dist/index.js +2153 -451
- 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
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
{ pattern: /^
|
|
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)\
|
|
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
|
-
|
|
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
|
|
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
|
],
|
|
@@ -3811,6 +3830,14 @@ function wholeLines(text, from, length) {
|
|
|
3811
3830
|
const lastBreak = text.lastIndexOf("\n", end - 1);
|
|
3812
3831
|
return lastBreak <= from || lastBreak < end - MAX_PARTIAL_LINE ? text.slice(from, end) : text.slice(from, lastBreak + 1);
|
|
3813
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
|
+
];
|
|
3814
3841
|
function matchVendorPatterns(configText, notes) {
|
|
3815
3842
|
const sampleText = detectionSample(configText);
|
|
3816
3843
|
const lines = sampleText.split("\n");
|
|
@@ -4062,7 +4089,7 @@ function matchVendorPatterns(configText, notes) {
|
|
|
4062
4089
|
if (/^vpc\s+domain\s+\d+/m.test(sampleText)) {
|
|
4063
4090
|
return CiscoNXOSSchema;
|
|
4064
4091
|
}
|
|
4065
|
-
if (
|
|
4092
|
+
if (NXOS_STATEMENT_MARKERS.some((marker) => marker.test(sampleText))) {
|
|
4066
4093
|
return CiscoNXOSSchema;
|
|
4067
4094
|
}
|
|
4068
4095
|
if (/^mlag\s+configuration/m.test(sampleText)) {
|
|
@@ -5187,7 +5214,13 @@ var SchemaAwareParser = class {
|
|
|
5187
5214
|
indentedKinds.add(this.blockStarterIndex(line.sanitized));
|
|
5188
5215
|
}
|
|
5189
5216
|
});
|
|
5190
|
-
const
|
|
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
|
+
};
|
|
5191
5224
|
for (const currentLine of lineContexts) {
|
|
5192
5225
|
let isBlockStarter = currentLine.isBlockStarter;
|
|
5193
5226
|
let blockStarterDepth = currentLine.blockStarterDepth;
|
|
@@ -5313,7 +5346,7 @@ var SchemaAwareParser = class {
|
|
|
5313
5346
|
} else {
|
|
5314
5347
|
rootNodes.push(newNode2);
|
|
5315
5348
|
}
|
|
5316
|
-
if (!currentLine.opaque) {
|
|
5349
|
+
if (!currentLine.opaque && !(isBlockStarter && this.blockBody(currentLine.sanitized) === false)) {
|
|
5317
5350
|
parentStack.push(newNode2);
|
|
5318
5351
|
}
|
|
5319
5352
|
}
|
|
@@ -5402,6 +5435,11 @@ var SchemaAwareParser = class {
|
|
|
5402
5435
|
blockStarterIndex(sanitizedLine) {
|
|
5403
5436
|
return this.vendor.blockStarters.findIndex((def) => def.pattern.test(sanitizedLine));
|
|
5404
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
|
+
}
|
|
5405
5443
|
/**
|
|
5406
5444
|
* Depths, in definition order, of the block starter definitions that match
|
|
5407
5445
|
* a line and open a block under `parent` (the section it is indented under;
|
|
@@ -5887,7 +5925,7 @@ var STORAGE_WORDS = /* @__PURE__ */ new Set([
|
|
|
5887
5925
|
...AUTH_ALGORITHMS,
|
|
5888
5926
|
...PRIV_ALGORITHMS
|
|
5889
5927
|
]);
|
|
5890
|
-
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"]);
|
|
5891
5929
|
var SNMP_HOST_FLAGS = /* @__PURE__ */ new Set(["informs", "inform", "traps", "trap", "auth", "noauth", "priv", "community"]);
|
|
5892
5930
|
var SNMP_HOST_OPTIONS = /* @__PURE__ */ new Set(["vrf", "version"]);
|
|
5893
5931
|
var SNMP_HOST_NO_SECRET = /* @__PURE__ */ new Set(["use-vrf", "filter-vrf", "source-interface"]);
|
|
@@ -5914,6 +5952,11 @@ var SKIP_IKE = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "local", "remote"]);
|
|
|
5914
5952
|
var SKIP_VRP_COMMUNITY = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "read", "write"]);
|
|
5915
5953
|
var SKIP_TEXT = /* @__PURE__ */ new Set([...SKIP_ALWAYS, "text"]);
|
|
5916
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
|
+
};
|
|
5917
5960
|
var valueAfter = (scan, i) => {
|
|
5918
5961
|
const { tokens, snmp } = scan;
|
|
5919
5962
|
const word = tokens[i]?.word ?? "";
|
|
@@ -5924,6 +5967,7 @@ var valueAfter = (scan, i) => {
|
|
|
5924
5967
|
let from;
|
|
5925
5968
|
let skip = SKIP_ALWAYS;
|
|
5926
5969
|
let storage = true;
|
|
5970
|
+
if (word === "password" && (i === 0 || i === 1 && first2 === "no") && isPasswordPolicy(tokens, i)) return -1;
|
|
5927
5971
|
if (word === "password" && i === 0) {
|
|
5928
5972
|
from = i + 1;
|
|
5929
5973
|
skip = SKIP_AOS_PASSWORD;
|
|
@@ -9121,7 +9165,7 @@ var isPolicySection = (parents) => {
|
|
|
9121
9165
|
for (const parent of parents) if (parent[0] === "policy-options") return true;
|
|
9122
9166
|
return false;
|
|
9123
9167
|
};
|
|
9124
|
-
var
|
|
9168
|
+
var isPasswordPolicy2 = (parents) => {
|
|
9125
9169
|
const nearest = parents[parents.length - 1];
|
|
9126
9170
|
return nearest !== void 0 && nearest.length === 1 && nearest[0] === "password" && parents[parents.length - 2]?.[0] === "login";
|
|
9127
9171
|
};
|
|
@@ -9138,7 +9182,7 @@ var notASecretSpans = (line, parents) => {
|
|
|
9138
9182
|
const last = part.all[part.all.length - 1];
|
|
9139
9183
|
if (!first2 || !last) continue;
|
|
9140
9184
|
const text = line.slice(first2.start, last.end);
|
|
9141
|
-
if (NOT_A_SECRET.some((re) => re.test(text)) || isPolicySection(part.parents) ||
|
|
9185
|
+
if (NOT_A_SECRET.some((re) => re.test(text)) || isPolicySection(part.parents) || isPasswordPolicy2(part.parents)) out.push({ start: first2.start, end: last.end });
|
|
9142
9186
|
}
|
|
9143
9187
|
return out;
|
|
9144
9188
|
};
|
|
@@ -12109,14 +12153,14 @@ var getInterfaceName = (node) => {
|
|
|
12109
12153
|
const ifName = match?.[1]?.trim();
|
|
12110
12154
|
return ifName && ifName.length > 0 ? ifName : void 0;
|
|
12111
12155
|
};
|
|
12112
|
-
var isAosCxPhysicalPort = (
|
|
12113
|
-
return /^\d+\/\d+\/\d+$/.test(
|
|
12156
|
+
var isAosCxPhysicalPort = (interfaceName2) => {
|
|
12157
|
+
return /^\d+\/\d+\/\d+$/.test(interfaceName2.trim());
|
|
12114
12158
|
};
|
|
12115
|
-
var isAosCxLag = (
|
|
12116
|
-
return /^lag\s*\d+$/i.test(
|
|
12159
|
+
var isAosCxLag = (interfaceName2) => {
|
|
12160
|
+
return /^lag\s*\d+$/i.test(interfaceName2.trim());
|
|
12117
12161
|
};
|
|
12118
|
-
var isAosCxVlanInterface = (
|
|
12119
|
-
return /^vlan\s*\d+$/i.test(
|
|
12162
|
+
var isAosCxVlanInterface = (interfaceName2) => {
|
|
12163
|
+
return /^vlan\s*\d+$/i.test(interfaceName2.trim());
|
|
12120
12164
|
};
|
|
12121
12165
|
var isAosCxTrunk = (node) => {
|
|
12122
12166
|
return hasChildCommand(node, "vlan trunk");
|
|
@@ -12428,6 +12472,7 @@ __export(cisco_exports, {
|
|
|
12428
12472
|
isLikelyTrunk: () => isLikelyTrunk,
|
|
12429
12473
|
isLineConfigPassword: () => isLineConfigPassword,
|
|
12430
12474
|
isLoopbackInterface: () => isLoopbackInterface,
|
|
12475
|
+
isNxosInterfaceEnabled: () => isNxosInterfaceEnabled,
|
|
12431
12476
|
isPhoneOrAP: () => isPhoneOrAP,
|
|
12432
12477
|
isPhysicalPort: () => isPhysicalPort,
|
|
12433
12478
|
isShutdown: () => isShutdown3,
|
|
@@ -12448,8 +12493,16 @@ var isShutdown3 = (node) => {
|
|
|
12448
12493
|
return child?.id && equalsIgnoreCase(child.id.trim(), "shutdown");
|
|
12449
12494
|
});
|
|
12450
12495
|
};
|
|
12451
|
-
var
|
|
12452
|
-
|
|
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");
|
|
12453
12506
|
};
|
|
12454
12507
|
var isLikelyTrunk = (node) => {
|
|
12455
12508
|
const desc = getChildCommand(node, "description");
|
|
@@ -12671,14 +12724,14 @@ var isWanInterface = (node) => {
|
|
|
12671
12724
|
if (!desc) return false;
|
|
12672
12725
|
return descriptionWords(desc.id).some((w) => WAN_DESCRIPTION_WORDS.has(w));
|
|
12673
12726
|
};
|
|
12674
|
-
var isLoopbackInterface = (
|
|
12675
|
-
return includesIgnoreCase(
|
|
12727
|
+
var isLoopbackInterface = (interfaceName2) => {
|
|
12728
|
+
return includesIgnoreCase(interfaceName2, "loopback");
|
|
12676
12729
|
};
|
|
12677
|
-
var isTunnelInterface = (
|
|
12678
|
-
return includesIgnoreCase(
|
|
12730
|
+
var isTunnelInterface = (interfaceName2) => {
|
|
12731
|
+
return includesIgnoreCase(interfaceName2, "tunnel");
|
|
12679
12732
|
};
|
|
12680
|
-
var isVlanInterface = (
|
|
12681
|
-
return startsWithIgnoreCase(
|
|
12733
|
+
var isVlanInterface = (interfaceName2) => {
|
|
12734
|
+
return startsWithIgnoreCase(interfaceName2, "interface vlan");
|
|
12682
12735
|
};
|
|
12683
12736
|
var hasPasswordEncryption = (node) => {
|
|
12684
12737
|
return equalsIgnoreCase(node.id.trim(), "service password-encryption");
|
|
@@ -12794,32 +12847,32 @@ var isIfaceStanza = (node) => {
|
|
|
12794
12847
|
var isAutoStanza = (node) => {
|
|
12795
12848
|
return node.id.toLowerCase().startsWith("auto ");
|
|
12796
12849
|
};
|
|
12797
|
-
var isSwitchPort = (
|
|
12798
|
-
const name =
|
|
12850
|
+
var isSwitchPort = (interfaceName2) => {
|
|
12851
|
+
const name = interfaceName2.toLowerCase();
|
|
12799
12852
|
return /swp\d+/.test(name);
|
|
12800
12853
|
};
|
|
12801
|
-
var isBondInterface = (
|
|
12802
|
-
const name =
|
|
12854
|
+
var isBondInterface = (interfaceName2) => {
|
|
12855
|
+
const name = interfaceName2.toLowerCase();
|
|
12803
12856
|
return /bond\d+/.test(name);
|
|
12804
12857
|
};
|
|
12805
|
-
var isBridgeInterface = (
|
|
12806
|
-
const name =
|
|
12858
|
+
var isBridgeInterface = (interfaceName2) => {
|
|
12859
|
+
const name = interfaceName2.toLowerCase();
|
|
12807
12860
|
return name.includes("bridge") || name === "br_default" || /^br\d+$/.test(name);
|
|
12808
12861
|
};
|
|
12809
|
-
var isVlanInterface2 = (
|
|
12810
|
-
const name =
|
|
12862
|
+
var isVlanInterface2 = (interfaceName2) => {
|
|
12863
|
+
const name = interfaceName2.toLowerCase();
|
|
12811
12864
|
return /vlan\d+/.test(name) || /_vlan\d+$/.test(name);
|
|
12812
12865
|
};
|
|
12813
|
-
var isManagementInterface2 = (
|
|
12814
|
-
const name =
|
|
12866
|
+
var isManagementInterface2 = (interfaceName2) => {
|
|
12867
|
+
const name = interfaceName2.toLowerCase();
|
|
12815
12868
|
return name === "eth0" || name === "mgmt";
|
|
12816
12869
|
};
|
|
12817
|
-
var isLoopback2 = (
|
|
12818
|
-
const name =
|
|
12870
|
+
var isLoopback2 = (interfaceName2) => {
|
|
12871
|
+
const name = interfaceName2.toLowerCase();
|
|
12819
12872
|
return name === "lo" || name.startsWith("loopback");
|
|
12820
12873
|
};
|
|
12821
|
-
var isPeerlink = (
|
|
12822
|
-
const name =
|
|
12874
|
+
var isPeerlink = (interfaceName2) => {
|
|
12875
|
+
const name = interfaceName2.toLowerCase();
|
|
12823
12876
|
return name.includes("peerlink");
|
|
12824
12877
|
};
|
|
12825
12878
|
var isVlanAwareBridge = (node) => {
|
|
@@ -12951,11 +13004,11 @@ var hasManagementVrf2 = (node) => {
|
|
|
12951
13004
|
(child) => child.id.toLowerCase().includes("vrf mgmt") || child.id.toLowerCase() === "vrf mgmt"
|
|
12952
13005
|
);
|
|
12953
13006
|
};
|
|
12954
|
-
var isManagementVrf = (
|
|
12955
|
-
return
|
|
13007
|
+
var isManagementVrf = (interfaceName2) => {
|
|
13008
|
+
return interfaceName2.toLowerCase() === "mgmt";
|
|
12956
13009
|
};
|
|
12957
|
-
var isPeerlinkSubinterface = (
|
|
12958
|
-
return
|
|
13010
|
+
var isPeerlinkSubinterface = (interfaceName2) => {
|
|
13011
|
+
return interfaceName2.toLowerCase().includes("peerlink.4094");
|
|
12959
13012
|
};
|
|
12960
13013
|
var hasClagdPeerIp = (node) => {
|
|
12961
13014
|
return node.children.some(
|
|
@@ -13019,8 +13072,8 @@ var getBridgePvid = (node) => {
|
|
|
13019
13072
|
if (!match?.[1]) return null;
|
|
13020
13073
|
return parseInt(match[1], 10);
|
|
13021
13074
|
};
|
|
13022
|
-
var isVniInterface = (
|
|
13023
|
-
return /^vni\d+$/i.test(
|
|
13075
|
+
var isVniInterface = (interfaceName2) => {
|
|
13076
|
+
return /^vni\d+$/i.test(interfaceName2) || /^vni[a-zA-Z]+$/i.test(interfaceName2);
|
|
13024
13077
|
};
|
|
13025
13078
|
var hasVxlanLocalTunnelip = (node) => {
|
|
13026
13079
|
return node.children.some(
|
|
@@ -13109,8 +13162,8 @@ var getMtu = (node) => {
|
|
|
13109
13162
|
if (!match?.[1]) return null;
|
|
13110
13163
|
return parseInt(match[1], 10);
|
|
13111
13164
|
};
|
|
13112
|
-
var isUplinkInterface = (
|
|
13113
|
-
const name =
|
|
13165
|
+
var isUplinkInterface = (interfaceName2) => {
|
|
13166
|
+
const name = interfaceName2.toLowerCase();
|
|
13114
13167
|
return /swp5[0-9]/.test(name);
|
|
13115
13168
|
};
|
|
13116
13169
|
var hasStormControl = (node) => {
|
|
@@ -14007,18 +14060,18 @@ var isEnabled = (node) => {
|
|
|
14007
14060
|
return rawText === "undo shutdown";
|
|
14008
14061
|
});
|
|
14009
14062
|
};
|
|
14010
|
-
var isPhysicalPort2 = (
|
|
14011
|
-
const name =
|
|
14063
|
+
var isPhysicalPort2 = (interfaceName2) => {
|
|
14064
|
+
const name = interfaceName2.toLowerCase();
|
|
14012
14065
|
return !name.includes("vlanif") && !name.includes("loopback") && !name.includes("null") && !name.includes("tunnel") && !name.includes("eth-trunk") && !name.includes("nve") && !name.includes("vbdif");
|
|
14013
14066
|
};
|
|
14014
|
-
var isVlanInterface3 = (
|
|
14015
|
-
return
|
|
14067
|
+
var isVlanInterface3 = (interfaceName2) => {
|
|
14068
|
+
return interfaceName2.toLowerCase().includes("vlanif");
|
|
14016
14069
|
};
|
|
14017
|
-
var isLoopbackInterface2 = (
|
|
14018
|
-
return
|
|
14070
|
+
var isLoopbackInterface2 = (interfaceName2) => {
|
|
14071
|
+
return interfaceName2.toLowerCase().includes("loopback");
|
|
14019
14072
|
};
|
|
14020
|
-
var isEthTrunk = (
|
|
14021
|
-
return
|
|
14073
|
+
var isEthTrunk = (interfaceName2) => {
|
|
14074
|
+
return interfaceName2.toLowerCase().includes("eth-trunk");
|
|
14022
14075
|
};
|
|
14023
14076
|
var isTrunkPort3 = (node) => {
|
|
14024
14077
|
if (!node?.children) return false;
|
|
@@ -14564,14 +14617,14 @@ var isDisabled = (node) => {
|
|
|
14564
14617
|
if (!node?.children) return false;
|
|
14565
14618
|
return node.children.some((child) => child?.id && equalsIgnoreCase(child.id.trim(), "disable"));
|
|
14566
14619
|
};
|
|
14567
|
-
var isPhysicalJunosPort = (
|
|
14568
|
-
return startsWithIgnoreCase(
|
|
14620
|
+
var isPhysicalJunosPort = (interfaceName2) => {
|
|
14621
|
+
return startsWithIgnoreCase(interfaceName2, "ge-") || startsWithIgnoreCase(interfaceName2, "xe-") || startsWithIgnoreCase(interfaceName2, "et-") || startsWithIgnoreCase(interfaceName2, "ae") || startsWithIgnoreCase(interfaceName2, "em") || startsWithIgnoreCase(interfaceName2, "fxp");
|
|
14569
14622
|
};
|
|
14570
|
-
var isLoopback3 = (
|
|
14571
|
-
return startsWithIgnoreCase(
|
|
14623
|
+
var isLoopback3 = (interfaceName2) => {
|
|
14624
|
+
return startsWithIgnoreCase(interfaceName2, "lo") || equalsIgnoreCase(interfaceName2, "lo0");
|
|
14572
14625
|
};
|
|
14573
|
-
var isIrbInterface = (
|
|
14574
|
-
return startsWithIgnoreCase(
|
|
14626
|
+
var isIrbInterface = (interfaceName2) => {
|
|
14627
|
+
return startsWithIgnoreCase(interfaceName2, "irb");
|
|
14575
14628
|
};
|
|
14576
14629
|
var parseJunosAddress = (address) => {
|
|
14577
14630
|
const parts = address.split("/");
|
|
@@ -15090,32 +15143,32 @@ var getCommandText = (nodeOrCommand) => {
|
|
|
15090
15143
|
};
|
|
15091
15144
|
var textOf = (nodeOrCommand) => getCommandText(nodeOrCommand);
|
|
15092
15145
|
var isDisabledResource = (nodeOrCommand) => parseProperty(textOf(nodeOrCommand), "disabled")?.toLowerCase() === "yes";
|
|
15093
|
-
var isPhysicalInterface = (
|
|
15094
|
-
const name =
|
|
15146
|
+
var isPhysicalInterface = (interfaceName2) => {
|
|
15147
|
+
const name = interfaceName2.toLowerCase();
|
|
15095
15148
|
return /^ether\d+$/.test(name) || /^sfp\d+$/.test(name) || /^sfp-sfpplus\d+$/.test(name) || /^combo\d+$/.test(name) || /^qsfp\d+$/.test(name);
|
|
15096
15149
|
};
|
|
15097
|
-
var isLoopback4 = (
|
|
15098
|
-
const name =
|
|
15150
|
+
var isLoopback4 = (interfaceName2) => {
|
|
15151
|
+
const name = interfaceName2.toLowerCase();
|
|
15099
15152
|
return name === "lo" || name.startsWith("loopback");
|
|
15100
15153
|
};
|
|
15101
|
-
var isBridgeInterface2 = (
|
|
15102
|
-
const name =
|
|
15154
|
+
var isBridgeInterface2 = (interfaceName2) => {
|
|
15155
|
+
const name = interfaceName2.toLowerCase();
|
|
15103
15156
|
return name.startsWith("bridge") || /^br\d+$/.test(name);
|
|
15104
15157
|
};
|
|
15105
|
-
var isVlanInterface4 = (
|
|
15106
|
-
const name =
|
|
15158
|
+
var isVlanInterface4 = (interfaceName2) => {
|
|
15159
|
+
const name = interfaceName2.toLowerCase();
|
|
15107
15160
|
return name.startsWith("vlan") || /^vlan\d+$/.test(name);
|
|
15108
15161
|
};
|
|
15109
|
-
var isBondingInterface = (
|
|
15110
|
-
const name =
|
|
15162
|
+
var isBondingInterface = (interfaceName2) => {
|
|
15163
|
+
const name = interfaceName2.toLowerCase();
|
|
15111
15164
|
return name.startsWith("bonding") || /^bond\d+$/.test(name);
|
|
15112
15165
|
};
|
|
15113
|
-
var isWireGuardInterface = (
|
|
15114
|
-
const name =
|
|
15166
|
+
var isWireGuardInterface = (interfaceName2) => {
|
|
15167
|
+
const name = interfaceName2.toLowerCase();
|
|
15115
15168
|
return name.startsWith("wireguard") || /^wg\d+$/.test(name);
|
|
15116
15169
|
};
|
|
15117
|
-
var isTunnelInterface2 = (
|
|
15118
|
-
const name =
|
|
15170
|
+
var isTunnelInterface2 = (interfaceName2) => {
|
|
15171
|
+
const name = interfaceName2.toLowerCase();
|
|
15119
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");
|
|
15120
15173
|
};
|
|
15121
15174
|
var QUOTED_STRING2 = /"(?:[^"\\]|\\.)*"/g;
|
|
@@ -15586,8 +15639,8 @@ var isLagPort = (portName) => {
|
|
|
15586
15639
|
const name = portName.toLowerCase();
|
|
15587
15640
|
return name.includes("lag");
|
|
15588
15641
|
};
|
|
15589
|
-
var isSystemInterface = (
|
|
15590
|
-
const name =
|
|
15642
|
+
var isSystemInterface = (interfaceName2) => {
|
|
15643
|
+
const name = interfaceName2.toLowerCase();
|
|
15591
15644
|
return name.includes("system") || name.includes("loopback") || name === '"system"';
|
|
15592
15645
|
};
|
|
15593
15646
|
var getPortMode = (node) => {
|
|
@@ -16307,17 +16360,17 @@ var isHAConfigured = (deviceconfigNode) => {
|
|
|
16307
16360
|
if (!ha?.children) return false;
|
|
16308
16361
|
return ha.children.length > 0;
|
|
16309
16362
|
};
|
|
16310
|
-
var isPhysicalEthernetPort = (
|
|
16311
|
-
return /^ethernet\d+\/\d+$/i.test(
|
|
16363
|
+
var isPhysicalEthernetPort = (interfaceName2) => {
|
|
16364
|
+
return /^ethernet\d+\/\d+$/i.test(interfaceName2);
|
|
16312
16365
|
};
|
|
16313
|
-
var isLoopbackInterface3 = (
|
|
16314
|
-
return /^loopback\.\d+$/i.test(
|
|
16366
|
+
var isLoopbackInterface3 = (interfaceName2) => {
|
|
16367
|
+
return /^loopback\.\d+$/i.test(interfaceName2);
|
|
16315
16368
|
};
|
|
16316
|
-
var isTunnelInterface3 = (
|
|
16317
|
-
return /^tunnel\.\d+$/i.test(
|
|
16369
|
+
var isTunnelInterface3 = (interfaceName2) => {
|
|
16370
|
+
return /^tunnel\.\d+$/i.test(interfaceName2);
|
|
16318
16371
|
};
|
|
16319
|
-
var isAggregateInterface = (
|
|
16320
|
-
return /^ae\d+$/i.test(
|
|
16372
|
+
var isAggregateInterface = (interfaceName2) => {
|
|
16373
|
+
return /^ae\d+$/i.test(interfaceName2);
|
|
16321
16374
|
};
|
|
16322
16375
|
var getZoneName2 = (zoneNode) => {
|
|
16323
16376
|
return zoneNode.id.split(/\s+/)[0] || zoneNode.id;
|
|
@@ -16705,31 +16758,31 @@ var isDisabled2 = (node) => {
|
|
|
16705
16758
|
if (!node?.children) return false;
|
|
16706
16759
|
return node.children.some((child) => child?.id?.toLowerCase().trim() === "disable");
|
|
16707
16760
|
};
|
|
16708
|
-
var isPhysicalVyosPort = (
|
|
16709
|
-
const name =
|
|
16761
|
+
var isPhysicalVyosPort = (interfaceName2) => {
|
|
16762
|
+
const name = interfaceName2.toLowerCase();
|
|
16710
16763
|
if (name.startsWith("ethernet eth")) {
|
|
16711
16764
|
return true;
|
|
16712
16765
|
}
|
|
16713
16766
|
return /^eth\d+$/.test(name);
|
|
16714
16767
|
};
|
|
16715
|
-
var isLoopback5 = (
|
|
16716
|
-
const name =
|
|
16768
|
+
var isLoopback5 = (interfaceName2) => {
|
|
16769
|
+
const name = interfaceName2.toLowerCase();
|
|
16717
16770
|
return name.includes("loopback") || name === "lo";
|
|
16718
16771
|
};
|
|
16719
|
-
var isBondingInterface2 = (
|
|
16720
|
-
const name =
|
|
16772
|
+
var isBondingInterface2 = (interfaceName2) => {
|
|
16773
|
+
const name = interfaceName2.toLowerCase();
|
|
16721
16774
|
return name.includes("bonding") || /^bond\d+$/.test(name);
|
|
16722
16775
|
};
|
|
16723
|
-
var isBridgeInterface3 = (
|
|
16724
|
-
const name =
|
|
16776
|
+
var isBridgeInterface3 = (interfaceName2) => {
|
|
16777
|
+
const name = interfaceName2.toLowerCase();
|
|
16725
16778
|
return name.includes("bridge") || /^br\d+$/.test(name);
|
|
16726
16779
|
};
|
|
16727
|
-
var isWireGuardInterface2 = (
|
|
16728
|
-
const name =
|
|
16780
|
+
var isWireGuardInterface2 = (interfaceName2) => {
|
|
16781
|
+
const name = interfaceName2.toLowerCase();
|
|
16729
16782
|
return name.includes("wireguard") || /^wg\d+$/.test(name);
|
|
16730
16783
|
};
|
|
16731
|
-
var isTunnelInterface4 = (
|
|
16732
|
-
const name =
|
|
16784
|
+
var isTunnelInterface4 = (interfaceName2) => {
|
|
16785
|
+
const name = interfaceName2.toLowerCase();
|
|
16733
16786
|
return name.includes("tunnel") || name.includes("vti") || name.includes("vxlan") || /^(tun|vti|vxlan)\d+$/.test(name);
|
|
16734
16787
|
};
|
|
16735
16788
|
var parseVyosAddress = (address) => {
|
|
@@ -18332,17 +18385,17 @@ var JsonRuleCompiler = class {
|
|
|
18332
18385
|
* Check if any matching child's id matches the pattern.
|
|
18333
18386
|
*/
|
|
18334
18387
|
childMatches(node, selector, pattern, flags) {
|
|
18335
|
-
const
|
|
18388
|
+
const matchingChildren2 = this.getMatchingChildren(node, selector);
|
|
18336
18389
|
const regex = this.getRegex(pattern, flags);
|
|
18337
|
-
return
|
|
18390
|
+
return matchingChildren2.some((child) => testRulePattern(regex, child.id));
|
|
18338
18391
|
}
|
|
18339
18392
|
/**
|
|
18340
18393
|
* Check if any matching child's id contains the text.
|
|
18341
18394
|
*/
|
|
18342
18395
|
childContains(node, selector, text) {
|
|
18343
18396
|
const textLower = text.toLowerCase();
|
|
18344
|
-
const
|
|
18345
|
-
return
|
|
18397
|
+
const matchingChildren2 = this.getMatchingChildren(node, selector);
|
|
18398
|
+
return matchingChildren2.some(
|
|
18346
18399
|
(child) => child.id.toLowerCase().includes(textLower)
|
|
18347
18400
|
);
|
|
18348
18401
|
}
|
|
@@ -19749,7 +19802,7 @@ var InterfaceDescriptionRequired = {
|
|
|
19749
19802
|
remediation: 'Add a description to the interface using the "description" command.'
|
|
19750
19803
|
},
|
|
19751
19804
|
check: (node, context) => {
|
|
19752
|
-
const
|
|
19805
|
+
const interfaceName2 = node.id;
|
|
19753
19806
|
const scope = interfaceScope(context, node);
|
|
19754
19807
|
if (scope === "nokia") {
|
|
19755
19808
|
return {
|
|
@@ -19781,7 +19834,7 @@ var InterfaceDescriptionRequired = {
|
|
|
19781
19834
|
loc: node.loc
|
|
19782
19835
|
};
|
|
19783
19836
|
}
|
|
19784
|
-
if (includesIgnoreCase(
|
|
19837
|
+
if (includesIgnoreCase(interfaceName2, "null") || includesIgnoreCase(interfaceName2, "loopback")) {
|
|
19785
19838
|
return {
|
|
19786
19839
|
passed: true,
|
|
19787
19840
|
message: "Loopback/Null interface - description optional.",
|
|
@@ -19791,7 +19844,7 @@ var InterfaceDescriptionRequired = {
|
|
|
19791
19844
|
loc: node.loc
|
|
19792
19845
|
};
|
|
19793
19846
|
}
|
|
19794
|
-
if (includesIgnoreCase(
|
|
19847
|
+
if (includesIgnoreCase(interfaceName2, "lo0")) {
|
|
19795
19848
|
return {
|
|
19796
19849
|
passed: true,
|
|
19797
19850
|
message: "Loopback interface - description optional.",
|
|
@@ -20600,16 +20653,26 @@ var SnmpNoDefaultCommunity = {
|
|
|
20600
20653
|
return { passed: true, message: "SNMP community is not default.", ruleId: "NET-SNMP-002", nodeId: node.id, level: "info", loc: node.loc };
|
|
20601
20654
|
}
|
|
20602
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
|
+
};
|
|
20603
20666
|
var SnmpNoRwAccess = {
|
|
20604
20667
|
id: "NET-SNMP-004",
|
|
20605
20668
|
selector: "snmp-server community",
|
|
20606
|
-
vendor: "cisco-ios",
|
|
20669
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
20607
20670
|
category: "Protocol-Security",
|
|
20608
20671
|
metadata: {
|
|
20609
20672
|
level: "warning",
|
|
20610
20673
|
obu: "Security",
|
|
20611
20674
|
owner: "SecOps",
|
|
20612
|
-
remediation:
|
|
20675
|
+
remediation: 'Remove SNMP RW access unless specifically required. Use RO for monitoring. On NX-OS, use "ro" or "group network-operator".',
|
|
20613
20676
|
security: {
|
|
20614
20677
|
cwe: ["CWE-284"],
|
|
20615
20678
|
cvssScore: 7.5
|
|
@@ -20620,8 +20683,7 @@ var SnmpNoRwAccess = {
|
|
|
20620
20683
|
]
|
|
20621
20684
|
},
|
|
20622
20685
|
check: (node) => {
|
|
20623
|
-
|
|
20624
|
-
if (rawText.includes(" RW")) {
|
|
20686
|
+
if (isSnmpReadWrite(node)) {
|
|
20625
20687
|
return {
|
|
20626
20688
|
passed: false,
|
|
20627
20689
|
message: "SNMP RW (write) access is configured. This is a security risk.",
|
|
@@ -20631,7 +20693,7 @@ var SnmpNoRwAccess = {
|
|
|
20631
20693
|
loc: node.loc
|
|
20632
20694
|
};
|
|
20633
20695
|
}
|
|
20634
|
-
return { passed: true, message:
|
|
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 };
|
|
20635
20697
|
}
|
|
20636
20698
|
};
|
|
20637
20699
|
var globalStatementsCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -20649,7 +20711,7 @@ var globalStatementsOf = (ast) => {
|
|
|
20649
20711
|
if (n.type === "comment") continue;
|
|
20650
20712
|
const id = n.id.trim().toLowerCase();
|
|
20651
20713
|
statements.add(id);
|
|
20652
|
-
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;
|
|
20653
20715
|
}
|
|
20654
20716
|
};
|
|
20655
20717
|
walk(ast);
|
|
@@ -20660,6 +20722,11 @@ var globalStatementsOf = (ast) => {
|
|
|
20660
20722
|
globalStatementsCache.set(ast, result2);
|
|
20661
20723
|
return result2;
|
|
20662
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
|
+
};
|
|
20663
20730
|
var isCdpDisabledGlobally = (ast) => {
|
|
20664
20731
|
if (!ast) return false;
|
|
20665
20732
|
const { statements, nxos } = globalStatementsOf(ast);
|
|
@@ -21021,6 +21088,7 @@ var bgpKeyNotJudged = (ast, node) => {
|
|
|
21021
21088
|
return head === "neighbor" && kind !== void 0 || head === "template" && kind === "peer" && name !== void 0;
|
|
21022
21089
|
});
|
|
21023
21090
|
};
|
|
21091
|
+
var NXOS_PASSWORD_POLICIES = /* @__PURE__ */ new Set(["strength-check", "secure-mode", "prompt username"]);
|
|
21024
21092
|
var CiscoNoPlaintextPasswords = {
|
|
21025
21093
|
id: "NET-SEC-001",
|
|
21026
21094
|
selector: "password",
|
|
@@ -21062,13 +21130,20 @@ var CiscoNoPlaintextPasswords = {
|
|
|
21062
21130
|
};
|
|
21063
21131
|
}
|
|
21064
21132
|
const onLine = ast ? isLineConfigPassword(ast, node) : false;
|
|
21065
|
-
|
|
21133
|
+
if (!onLine && NXOS_PASSWORD_POLICIES.has(params.slice(1).join(" ").toLowerCase())) {
|
|
21134
|
+
return notApplicable2;
|
|
21135
|
+
}
|
|
21136
|
+
const result2 = evaluatePasswordStorage({
|
|
21066
21137
|
ruleId: "NET-SEC-001",
|
|
21067
21138
|
node,
|
|
21068
21139
|
label: onLine ? "line password" : '"password" command',
|
|
21069
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.`,
|
|
21070
21141
|
args: params.slice(1)
|
|
21071
21142
|
});
|
|
21143
|
+
if (onLine && NXOS_PASSWORD_POLICIES.has(params.slice(1).join(" ").toLowerCase())) {
|
|
21144
|
+
return { ...result2, nodeId: "password ****" };
|
|
21145
|
+
}
|
|
21146
|
+
return result2;
|
|
21072
21147
|
}
|
|
21073
21148
|
};
|
|
21074
21149
|
var CiscoNoPlaintextUsernamePasswords = {
|
|
@@ -21422,16 +21497,17 @@ var CiscoBgpNeighborAuthentication = {
|
|
|
21422
21497
|
return passResult("CISCO-BGP-002", node, "All BGP neighbors have authentication.");
|
|
21423
21498
|
}
|
|
21424
21499
|
};
|
|
21500
|
+
var isDynamicAsPrefixPeer = (peer) => peer.id.includes("/") && peer.remoteAs.toLowerCase() === "route-map";
|
|
21425
21501
|
var CiscoBgpTtlSecurity = {
|
|
21426
21502
|
id: "CISCO-BGP-003",
|
|
21427
21503
|
selector: "router bgp",
|
|
21428
|
-
vendor: "cisco-ios",
|
|
21504
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21429
21505
|
category: "Routing",
|
|
21430
21506
|
metadata: {
|
|
21431
21507
|
level: "warning",
|
|
21432
21508
|
obu: "Security",
|
|
21433
21509
|
owner: "SecOps",
|
|
21434
|
-
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".',
|
|
21435
21511
|
security: {
|
|
21436
21512
|
cwe: ["CWE-290"]
|
|
21437
21513
|
},
|
|
@@ -21442,19 +21518,20 @@ var CiscoBgpTtlSecurity = {
|
|
|
21442
21518
|
},
|
|
21443
21519
|
check: (node) => {
|
|
21444
21520
|
const ebgp = bgpPeers(node).filter(
|
|
21445
|
-
(p) => bgpSessionKind(node, p) !== "ibgp" && !findBgpNeighborCommand(p.lines, "ebgp-multihop")
|
|
21521
|
+
(p) => bgpSessionKind(node, p) !== "ibgp" && (isDynamicAsPrefixPeer(p) || !findBgpNeighborCommand(p.lines, "ebgp-multihop"))
|
|
21446
21522
|
);
|
|
21447
21523
|
if (ebgp.length === 0) {
|
|
21448
21524
|
return passResult("CISCO-BGP-003", node, "No eBGP neighbors configured.");
|
|
21449
21525
|
}
|
|
21450
|
-
const findings = ebgp.filter((p) => !findBgpNeighborCommand(p.lines, "ttl-security")).map(
|
|
21451
|
-
(p)
|
|
21526
|
+
const findings = ebgp.filter((p) => !findBgpNeighborCommand(p.lines, "ttl-security")).map((p) => {
|
|
21527
|
+
const line = peerLine(p, node);
|
|
21528
|
+
return offenderResult(
|
|
21452
21529
|
"CISCO-BGP-003",
|
|
21453
|
-
|
|
21454
|
-
`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"`}.`,
|
|
21455
21532
|
"warning"
|
|
21456
|
-
)
|
|
21457
|
-
);
|
|
21533
|
+
);
|
|
21534
|
+
});
|
|
21458
21535
|
if (findings.length > 0) return findings;
|
|
21459
21536
|
return passResult("CISCO-BGP-003", node, "eBGP peers have TTL security configured.");
|
|
21460
21537
|
}
|
|
@@ -21462,44 +21539,62 @@ var CiscoBgpTtlSecurity = {
|
|
|
21462
21539
|
var CiscoBgpMaxPrefix = {
|
|
21463
21540
|
id: "CISCO-BGP-004",
|
|
21464
21541
|
selector: "router bgp",
|
|
21465
|
-
vendor: "cisco-ios",
|
|
21542
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21466
21543
|
category: "Routing",
|
|
21467
21544
|
metadata: {
|
|
21468
21545
|
level: "warning",
|
|
21469
21546
|
obu: "Network Engineering",
|
|
21470
21547
|
owner: "NetOps",
|
|
21471
|
-
remediation:
|
|
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".`
|
|
21472
21549
|
},
|
|
21473
21550
|
check: (node) => {
|
|
21474
21551
|
const peers = bgpPeers(node);
|
|
21475
21552
|
if (peers.length === 0) {
|
|
21476
21553
|
return passResult("CISCO-BGP-004", node, "No BGP neighbors configured.");
|
|
21477
21554
|
}
|
|
21478
|
-
const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "maximum-prefix")).map(
|
|
21479
|
-
(p)
|
|
21555
|
+
const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "maximum-prefix")).map((p) => {
|
|
21556
|
+
const line = peerLine(p, node);
|
|
21557
|
+
return offenderResult(
|
|
21480
21558
|
"CISCO-BGP-004",
|
|
21481
|
-
|
|
21482
|
-
`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"}.`,
|
|
21483
21561
|
"warning"
|
|
21484
|
-
)
|
|
21485
|
-
);
|
|
21562
|
+
);
|
|
21563
|
+
});
|
|
21486
21564
|
if (findings.length > 0) return findings;
|
|
21487
21565
|
return passResult("CISCO-BGP-004", node, "BGP peers have maximum-prefix configured.");
|
|
21488
21566
|
}
|
|
21489
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;
|
|
21490
21570
|
var CiscoBgpLogNeighborChanges = {
|
|
21491
21571
|
id: "CISCO-BGP-005",
|
|
21492
21572
|
selector: "router bgp",
|
|
21493
|
-
vendor: "cisco-ios",
|
|
21573
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21494
21574
|
category: "Routing",
|
|
21495
21575
|
metadata: {
|
|
21496
21576
|
level: "info",
|
|
21497
21577
|
obu: "Network Engineering",
|
|
21498
21578
|
owner: "NetOps",
|
|
21499
|
-
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".'
|
|
21500
21580
|
},
|
|
21501
|
-
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
|
+
}
|
|
21502
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
|
+
}
|
|
21503
21598
|
const explicitOff = hasChildCommand(node, "no bgp log-neighbor-changes");
|
|
21504
21599
|
return {
|
|
21505
21600
|
passed: false,
|
|
@@ -21513,10 +21608,19 @@ var CiscoBgpLogNeighborChanges = {
|
|
|
21513
21608
|
return passResult("CISCO-BGP-005", node, "BGP log-neighbor-changes is enabled.");
|
|
21514
21609
|
}
|
|
21515
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
|
+
};
|
|
21516
21620
|
var CiscoWanUrpf = {
|
|
21517
21621
|
id: "CISCO-DATA-001",
|
|
21518
21622
|
selector: "interface",
|
|
21519
|
-
vendor: "cisco-ios",
|
|
21623
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21520
21624
|
category: "Protocol-Security",
|
|
21521
21625
|
metadata: {
|
|
21522
21626
|
level: "warning",
|
|
@@ -21531,8 +21635,10 @@ var CiscoWanUrpf = {
|
|
|
21531
21635
|
{ type: "general", label: "urpf" }
|
|
21532
21636
|
]
|
|
21533
21637
|
},
|
|
21534
|
-
check: (node) => {
|
|
21535
|
-
|
|
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) {
|
|
21536
21642
|
return passResult("CISCO-DATA-001", node, "Not applicable.");
|
|
21537
21643
|
}
|
|
21538
21644
|
if (!isWanInterface(node)) {
|
|
@@ -21649,7 +21755,7 @@ var CiscoWanNoProxyArp = {
|
|
|
21649
21755
|
var CiscoNoDirectedBroadcast = {
|
|
21650
21756
|
id: "CISCO-DATA-005",
|
|
21651
21757
|
selector: "interface",
|
|
21652
|
-
vendor: "cisco-ios",
|
|
21758
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21653
21759
|
category: "Service-Hardening",
|
|
21654
21760
|
metadata: {
|
|
21655
21761
|
level: "error",
|
|
@@ -21665,8 +21771,8 @@ var CiscoNoDirectedBroadcast = {
|
|
|
21665
21771
|
{ type: "general", label: "smurf-attack" }
|
|
21666
21772
|
]
|
|
21667
21773
|
},
|
|
21668
|
-
check: (node) => {
|
|
21669
|
-
if (
|
|
21774
|
+
check: (node, context) => {
|
|
21775
|
+
if (isAdminDown(node, context) || isLoopbackInterface(node.id)) {
|
|
21670
21776
|
return passResult("CISCO-DATA-005", node, "Not applicable.");
|
|
21671
21777
|
}
|
|
21672
21778
|
if (hasChildCommand(node, "ip directed-broadcast") && !hasNoDirectedBroadcast(node)) {
|
|
@@ -21685,7 +21791,7 @@ var CiscoNoDirectedBroadcast = {
|
|
|
21685
21791
|
var CiscoSnmpNoDefaultCommunity = {
|
|
21686
21792
|
id: "CISCO-SNMP-001",
|
|
21687
21793
|
selector: "snmp-server community",
|
|
21688
|
-
vendor: "cisco-ios",
|
|
21794
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
21689
21795
|
category: "Protocol-Security",
|
|
21690
21796
|
metadata: {
|
|
21691
21797
|
level: "error",
|
|
@@ -21875,7 +21981,7 @@ var CiscoUndefinedFilterAcl = {
|
|
|
21875
21981
|
)
|
|
21876
21982
|
};
|
|
21877
21983
|
var ACL_USAGE_EFFECTS = {
|
|
21878
|
-
"management-filter": "
|
|
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.",
|
|
21879
21985
|
"route-map-match": "The route-map entry does not match what was intended.",
|
|
21880
21986
|
"class-map-match": "The class does not classify the intended traffic.",
|
|
21881
21987
|
"crypto-match": "The crypto map (or GETVPN group) protects no traffic, or not the intended traffic.",
|
|
@@ -22231,26 +22337,34 @@ var NxosSecretStorage = {
|
|
|
22231
22337
|
},
|
|
22232
22338
|
check: judgeWholeConfig("CISCO-SEC-002", "No RADIUS or TACACS+ key is stored in plain text or as type 7.", (ast, scope) => {
|
|
22233
22339
|
const findings = [];
|
|
22340
|
+
const radsec = /* @__PURE__ */ new Set();
|
|
22234
22341
|
let aes = false;
|
|
22342
|
+
let tls = false;
|
|
22235
22343
|
walkStatements(ast, (node) => {
|
|
22236
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;
|
|
22237
22346
|
const match = nxosAaaSecret(node);
|
|
22238
22347
|
const value2 = match?.value;
|
|
22239
22348
|
if (!match || !value2 || value2.storage === "ok") return;
|
|
22240
22349
|
if (value2.storage === "plain" && isPlaceholderSecret(node.params.slice(value2.from, value2.to).join(" "))) return;
|
|
22241
22350
|
const masked = maskSecretParams(node.params, value2.from);
|
|
22242
22351
|
const plain = value2.storage === "plain";
|
|
22243
|
-
|
|
22352
|
+
const finding = {
|
|
22244
22353
|
node,
|
|
22245
22354
|
level: plain ? "error" : "warning",
|
|
22246
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}`,
|
|
22247
22356
|
masked
|
|
22248
|
-
}
|
|
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
|
+
}
|
|
22249
22362
|
});
|
|
22363
|
+
const judged = tls ? findings.filter((f) => !radsec.has(f)) : findings;
|
|
22250
22364
|
if (!aes && !scope.snippet) {
|
|
22251
|
-
for (const f of
|
|
22365
|
+
for (const f of judged) f.message += ' This configuration has no "feature password encryption aes".';
|
|
22252
22366
|
}
|
|
22253
|
-
return
|
|
22367
|
+
return judged;
|
|
22254
22368
|
})
|
|
22255
22369
|
};
|
|
22256
22370
|
var allCiscoRules = [
|
|
@@ -22314,6 +22428,1593 @@ var isTopLevel = (node, context) => {
|
|
|
22314
22428
|
return !ast || ast.includes(node);
|
|
22315
22429
|
};
|
|
22316
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
|
+
|
|
22317
24018
|
// ../rules-default/src/juniper/junos-rules.ts
|
|
22318
24019
|
var idIs = (node, name) => node !== void 0 && equalsIgnoreCase(node.id.trim(), name);
|
|
22319
24020
|
var enclosingBlocks = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
|
|
@@ -24406,7 +26107,7 @@ var allJuniperRules = [
|
|
|
24406
26107
|
var generalTags2 = (...labels) => labels.map((label) => ({ type: "general", label }));
|
|
24407
26108
|
var textOf2 = (node) => node.id.trim().replace(/\s+/g, " ").toLowerCase();
|
|
24408
26109
|
var wordsOf2 = (node) => node.params.map((p) => p.toLowerCase());
|
|
24409
|
-
var
|
|
26110
|
+
var passAt2 = (ruleId, node, message) => ({
|
|
24410
26111
|
passed: true,
|
|
24411
26112
|
message,
|
|
24412
26113
|
ruleId,
|
|
@@ -24414,7 +26115,7 @@ var passAt = (ruleId, node, message) => ({
|
|
|
24414
26115
|
level: "info",
|
|
24415
26116
|
loc: locOf(node)
|
|
24416
26117
|
});
|
|
24417
|
-
var
|
|
26118
|
+
var failAt2 = (ruleId, at2, message, level) => ({
|
|
24418
26119
|
passed: false,
|
|
24419
26120
|
message,
|
|
24420
26121
|
ruleId,
|
|
@@ -24423,7 +26124,7 @@ var failAt = (ruleId, at2, message, level) => ({
|
|
|
24423
26124
|
loc: locOf(at2)
|
|
24424
26125
|
});
|
|
24425
26126
|
var failAbsent = (ruleId, anchor, message, level) => ({
|
|
24426
|
-
...
|
|
26127
|
+
...failAt2(ruleId, anchor, message, level),
|
|
24427
26128
|
nodeId: maskSecretLine(anchor),
|
|
24428
26129
|
absent: true
|
|
24429
26130
|
});
|
|
@@ -24496,7 +26197,7 @@ var SshEnabled = {
|
|
|
24496
26197
|
},
|
|
24497
26198
|
check: configWide("aoscx", (statements, anchor) => {
|
|
24498
26199
|
const enabled = statements.find((s) => /^ssh server vrf \S+$/.test(textOf2(s)));
|
|
24499
|
-
if (enabled) return
|
|
26200
|
+
if (enabled) return passAt2("ARU-SEC-001", enabled, "SSH server is enabled on a VRF.");
|
|
24500
26201
|
return failAbsent(
|
|
24501
26202
|
"ARU-SEC-001",
|
|
24502
26203
|
anchor,
|
|
@@ -24571,10 +26272,10 @@ var TelnetDisabled = {
|
|
|
24571
26272
|
check: (node, context) => {
|
|
24572
26273
|
const text = textOf2(node);
|
|
24573
26274
|
if (text.startsWith("telnet")) {
|
|
24574
|
-
return
|
|
26275
|
+
return failAt2("ARU-SEC-003", node, "Telnet is enabled. Consider disabling and using SSH instead.", "warning");
|
|
24575
26276
|
}
|
|
24576
26277
|
if (/^no telnet-server\b/.test(text)) {
|
|
24577
|
-
return
|
|
26278
|
+
return passAt2("ARU-SEC-003", node, "Telnet server is disabled.");
|
|
24578
26279
|
}
|
|
24579
26280
|
const index = indexOf(context);
|
|
24580
26281
|
if (!index || index.statements[0] !== node || index.platform !== "aosswitch") return [];
|
|
@@ -24607,7 +26308,7 @@ var NtpConfigured = {
|
|
|
24607
26308
|
},
|
|
24608
26309
|
check: configWideOn(["aoscx", "wlc"], (_platform, statements, anchor) => {
|
|
24609
26310
|
const server = statements.find((s) => NTP_SERVER.test(textOf2(s)));
|
|
24610
|
-
if (server) return
|
|
26311
|
+
if (server) return passAt2("ARU-NTP-001", server, "NTP server is configured.");
|
|
24611
26312
|
return failAbsent("ARU-NTP-001", anchor, 'No NTP server is configured ("ntp server <address>").', "warning");
|
|
24612
26313
|
})
|
|
24613
26314
|
};
|
|
@@ -24625,8 +26326,8 @@ var SntpConfigured = {
|
|
|
24625
26326
|
const server = statements.find((s) => SNTP_SERVER.test(textOf2(s)));
|
|
24626
26327
|
if (!server) return [];
|
|
24627
26328
|
const has = (text) => statements.some((s) => textOf2(s) === text);
|
|
24628
|
-
if (has("timesync sntp") && has("sntp unicast")) return
|
|
24629
|
-
return
|
|
26329
|
+
if (has("timesync sntp") && has("sntp unicast")) return passAt2("ARU-NTP-002", server, "SNTP servers are in use.");
|
|
26330
|
+
return failAt2(
|
|
24630
26331
|
"ARU-NTP-002",
|
|
24631
26332
|
server,
|
|
24632
26333
|
'SNTP servers are configured but not used: add "timesync sntp" and "sntp unicast".',
|
|
@@ -24653,7 +26354,7 @@ var LoggingConfigured = {
|
|
|
24653
26354
|
},
|
|
24654
26355
|
check: configWideOn(["aoscx", "aosswitch", "wlc"], (_platform, statements, anchor) => {
|
|
24655
26356
|
const server = statements.find((s) => /^logging \S*[.:]/.test(textOf2(s)));
|
|
24656
|
-
if (server) return
|
|
26357
|
+
if (server) return passAt2("ARU-LOG-001", server, "Remote syslog server is configured.");
|
|
24657
26358
|
return failAbsent("ARU-LOG-001", anchor, 'No remote syslog server is configured ("logging <address>").', "warning");
|
|
24658
26359
|
})
|
|
24659
26360
|
};
|
|
@@ -24682,7 +26383,7 @@ var AaaConfigured = {
|
|
|
24682
26383
|
},
|
|
24683
26384
|
check: configWideOn(["aoscx", "aosswitch", "wlc"], (platform, statements, anchor) => {
|
|
24684
26385
|
const remote = statements.find(platform === "wlc" ? isWlcManagementServerGroup : isRemoteAuthentication);
|
|
24685
|
-
if (remote) return
|
|
26386
|
+
if (remote) return passAt2("ARU-AAA-001", remote, "Management logins use a remote authentication server.");
|
|
24686
26387
|
return failAbsent(
|
|
24687
26388
|
"ARU-AAA-001",
|
|
24688
26389
|
anchor,
|
|
@@ -24721,7 +26422,7 @@ var RadiusKeyConfigured = {
|
|
|
24721
26422
|
check: (node, context) => {
|
|
24722
26423
|
const missing = serverKeyMissing(node, context, "radius");
|
|
24723
26424
|
if (missing === void 0) {
|
|
24724
|
-
return
|
|
26425
|
+
return passAt2("ARU-RAD-001", node, "Not a RADIUS server host statement.");
|
|
24725
26426
|
}
|
|
24726
26427
|
if (missing) {
|
|
24727
26428
|
return {
|
|
@@ -24764,7 +26465,7 @@ var TacacsKeyConfigured = {
|
|
|
24764
26465
|
check: (node, context) => {
|
|
24765
26466
|
const missing = serverKeyMissing(node, context, "tacacs");
|
|
24766
26467
|
if (missing === void 0) {
|
|
24767
|
-
return
|
|
26468
|
+
return passAt2("ARU-TAC-001", node, "Not a TACACS+ server host statement.");
|
|
24768
26469
|
}
|
|
24769
26470
|
if (missing) {
|
|
24770
26471
|
return {
|
|
@@ -24811,8 +26512,8 @@ var AaaAccountingEnabled = {
|
|
|
24811
26512
|
if (!index?.platform || !isRemoteAuthentication(node)) return [];
|
|
24812
26513
|
if (index.statements.find(isRemoteAuthentication) !== node) return [];
|
|
24813
26514
|
const accounting = index.statements.find(isRemoteAccounting);
|
|
24814
|
-
if (accounting) return
|
|
24815
|
-
return
|
|
26515
|
+
if (accounting) return passAt2("ARU-AAA-003", accounting, "AAA accounting is sent to a server.");
|
|
26516
|
+
return failAt2(
|
|
24816
26517
|
"ARU-AAA-003",
|
|
24817
26518
|
node,
|
|
24818
26519
|
'Login authentication uses a remote server, but no "aaa accounting" sends records to one; accounting stays on the switch (or is off).',
|
|
@@ -25316,10 +27017,10 @@ var AosCxUsbDisabled = {
|
|
|
25316
27017
|
},
|
|
25317
27018
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25318
27019
|
const disabled = statements.find((s) => textOf2(s) === "no usb");
|
|
25319
|
-
if (disabled) return
|
|
27020
|
+
if (disabled) return passAt2("ARU-HARD-001", disabled, "USB auxiliary port is disabled.");
|
|
25320
27021
|
const enabled = statements.find((s) => textOf2(s) === "usb");
|
|
25321
27022
|
if (enabled) {
|
|
25322
|
-
return
|
|
27023
|
+
return failAt2("ARU-HARD-001", enabled, 'USB auxiliary port is enabled. Disable with "no usb" when not in use.', "warning");
|
|
25323
27024
|
}
|
|
25324
27025
|
return failAbsent(
|
|
25325
27026
|
"ARU-HARD-001",
|
|
@@ -25356,7 +27057,7 @@ var AosCxPasswordComplexity = {
|
|
|
25356
27057
|
);
|
|
25357
27058
|
}
|
|
25358
27059
|
if (!block.children.some((c) => textOf2(c) === "enable")) {
|
|
25359
|
-
return
|
|
27060
|
+
return failAt2(
|
|
25360
27061
|
"ARU-HARD-002",
|
|
25361
27062
|
block,
|
|
25362
27063
|
'Password complexity is not enabled: add "enable" in the password complexity context.',
|
|
@@ -25370,7 +27071,7 @@ var AosCxPasswordComplexity = {
|
|
|
25370
27071
|
if (minLength === null || minLength < 12) {
|
|
25371
27072
|
const shown2 = lengthValue === void 0 ? "8 (the default)" : lengthValue;
|
|
25372
27073
|
results.push(
|
|
25373
|
-
|
|
27074
|
+
failAt2(
|
|
25374
27075
|
"ARU-HARD-002",
|
|
25375
27076
|
lengthCmd ?? block,
|
|
25376
27077
|
`Password minimum length is ${shown2}. Recommended minimum is 12 characters.`,
|
|
@@ -25381,7 +27082,7 @@ var AosCxPasswordComplexity = {
|
|
|
25381
27082
|
for (const child of block.children) {
|
|
25382
27083
|
if (COMPLEXITY_CLASS.test(textOf2(child))) {
|
|
25383
27084
|
results.push(
|
|
25384
|
-
|
|
27085
|
+
failAt2(
|
|
25385
27086
|
"ARU-HARD-002",
|
|
25386
27087
|
child,
|
|
25387
27088
|
`"${child.id.trim()}" removes a character-class requirement. Require uppercase, lowercase, numeric, and special characters.`,
|
|
@@ -25390,7 +27091,7 @@ var AosCxPasswordComplexity = {
|
|
|
25390
27091
|
);
|
|
25391
27092
|
}
|
|
25392
27093
|
}
|
|
25393
|
-
return results.length > 0 ? results :
|
|
27094
|
+
return results.length > 0 ? results : passAt2("ARU-HARD-002", block, "Password complexity is properly configured.");
|
|
25394
27095
|
})
|
|
25395
27096
|
};
|
|
25396
27097
|
var GENERIC_HOSTNAME = /^(?:switch|aruba|cx\d*)$/i;
|
|
@@ -25411,9 +27112,9 @@ var AosCxHostname = {
|
|
|
25411
27112
|
return failAbsent("ARU-HARD-003", anchor, 'Hostname is not configured; the switch uses the default name "switch".', "warning");
|
|
25412
27113
|
}
|
|
25413
27114
|
if (GENERIC_HOSTNAME.test(hostname)) {
|
|
25414
|
-
return
|
|
27115
|
+
return failAt2("ARU-HARD-003", statement2, `Generic hostname "${hostname}" detected. Use a descriptive hostname.`, "warning");
|
|
25415
27116
|
}
|
|
25416
|
-
return
|
|
27117
|
+
return passAt2("ARU-HARD-003", statement2, `Hostname "${hostname}" is configured.`);
|
|
25417
27118
|
})
|
|
25418
27119
|
};
|
|
25419
27120
|
var AosCxNtpAuthentication = {
|
|
@@ -25435,7 +27136,7 @@ var AosCxNtpAuthentication = {
|
|
|
25435
27136
|
const words = wordsOf2(node);
|
|
25436
27137
|
if (words[1] !== "server" || words[2] === void 0) return [];
|
|
25437
27138
|
if (!words.slice(3).includes("key")) {
|
|
25438
|
-
return
|
|
27139
|
+
return failAt2(
|
|
25439
27140
|
"ARU-HARD-004",
|
|
25440
27141
|
node,
|
|
25441
27142
|
`NTP server ${node.params[2] ?? ""} configured without authentication key. Use "ntp server <ip> key <id>".`,
|
|
@@ -25444,14 +27145,14 @@ var AosCxNtpAuthentication = {
|
|
|
25444
27145
|
}
|
|
25445
27146
|
const statements = indexOf(context)?.statements;
|
|
25446
27147
|
if (statements && !statements.some((s) => textOf2(s) === "ntp authentication")) {
|
|
25447
|
-
return
|
|
27148
|
+
return failAt2(
|
|
25448
27149
|
"ARU-HARD-004",
|
|
25449
27150
|
node,
|
|
25450
27151
|
'NTP server has a key, but "ntp authentication" is not in the configuration. Enable it so the key is checked.',
|
|
25451
27152
|
"info"
|
|
25452
27153
|
);
|
|
25453
27154
|
}
|
|
25454
|
-
return
|
|
27155
|
+
return passAt2("ARU-HARD-004", node, "NTP server uses an authentication key.");
|
|
25455
27156
|
}
|
|
25456
27157
|
};
|
|
25457
27158
|
var AosCxBanner = {
|
|
@@ -25467,7 +27168,7 @@ var AosCxBanner = {
|
|
|
25467
27168
|
},
|
|
25468
27169
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25469
27170
|
const banner = statements.find((s) => /^banner (motd|exec)\b/.test(textOf2(s)));
|
|
25470
|
-
if (banner) return
|
|
27171
|
+
if (banner) return passAt2("ARU-HARD-006", banner, "Login banner is configured.");
|
|
25471
27172
|
return failAbsent(
|
|
25472
27173
|
"ARU-HARD-006",
|
|
25473
27174
|
anchor,
|
|
@@ -25495,9 +27196,9 @@ var AosCxSshVrfMgmt = {
|
|
|
25495
27196
|
const vrf = wordsOf2(node)[3];
|
|
25496
27197
|
if (vrf === void 0) return [];
|
|
25497
27198
|
if (vrf === "default") {
|
|
25498
|
-
return
|
|
27199
|
+
return failAt2("ARU-MGMT-001", node, "SSH is enabled on default VRF. Restrict to management VRF for security.", "warning");
|
|
25499
27200
|
}
|
|
25500
|
-
return
|
|
27201
|
+
return passAt2("ARU-MGMT-001", node, `SSH is enabled on VRF ${node.params[3] ?? vrf}.`);
|
|
25501
27202
|
}
|
|
25502
27203
|
};
|
|
25503
27204
|
var AosCxLoginLockout = {
|
|
@@ -25526,14 +27227,14 @@ var AosCxLoginLockout = {
|
|
|
25526
27227
|
}
|
|
25527
27228
|
const attempts = parseInteger(statement2.params[3] ?? "");
|
|
25528
27229
|
if (attempts === null || attempts > 5) {
|
|
25529
|
-
return
|
|
27230
|
+
return failAt2(
|
|
25530
27231
|
"ARU-MGMT-004",
|
|
25531
27232
|
statement2,
|
|
25532
27233
|
`Max login attempts is ${statement2.params[3] ?? "unset"}. Recommended maximum is 3-5.`,
|
|
25533
27234
|
"warning"
|
|
25534
27235
|
);
|
|
25535
27236
|
}
|
|
25536
|
-
return
|
|
27237
|
+
return passAt2("ARU-MGMT-004", statement2, `Login attempt limit set to ${attempts}.`);
|
|
25537
27238
|
})
|
|
25538
27239
|
};
|
|
25539
27240
|
var AosCxSessionTimeout = {
|
|
@@ -25554,21 +27255,21 @@ var AosCxSessionTimeout = {
|
|
|
25554
27255
|
const cliSession = statements.find((s) => textOf2(s) === "cli-session");
|
|
25555
27256
|
const timeoutCmd = (cliSession && childStarting(cliSession, "timeout")) ?? statements.find((s) => wordsOf2(s)[0] === "session-timeout");
|
|
25556
27257
|
if (!timeoutCmd) {
|
|
25557
|
-
return
|
|
27258
|
+
return passAt2("ARU-MGMT-005", anchor, "CLI session idle timeout is the default of 30 minutes.");
|
|
25558
27259
|
}
|
|
25559
27260
|
const timeout = parseInteger(timeoutCmd.params[1] ?? "");
|
|
25560
27261
|
if (timeout === 0) {
|
|
25561
|
-
return
|
|
27262
|
+
return failAt2("ARU-MGMT-005", timeoutCmd, "Session timeout is disabled (0). Configure a reasonable timeout.", "warning");
|
|
25562
27263
|
}
|
|
25563
27264
|
if (timeout !== null && timeout > 30) {
|
|
25564
|
-
return
|
|
27265
|
+
return failAt2(
|
|
25565
27266
|
"ARU-MGMT-005",
|
|
25566
27267
|
timeoutCmd,
|
|
25567
27268
|
`Session timeout is ${timeout} minutes. Recommended is 10-15 minutes.`,
|
|
25568
27269
|
"warning"
|
|
25569
27270
|
);
|
|
25570
27271
|
}
|
|
25571
|
-
return
|
|
27272
|
+
return passAt2("ARU-MGMT-005", timeoutCmd, "Session timeout is configured.");
|
|
25572
27273
|
})
|
|
25573
27274
|
};
|
|
25574
27275
|
var isDhcpSnoopingOn = (text) => text === "dhcpv4-snooping" || text === "dhcp-snooping";
|
|
@@ -25588,7 +27289,7 @@ var AosCxDhcpSnooping = {
|
|
|
25588
27289
|
},
|
|
25589
27290
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25590
27291
|
const vlans = accessVlansOf(statements);
|
|
25591
|
-
if (vlans.size === 0) return
|
|
27292
|
+
if (vlans.size === 0) return passAt2("ARU-L2-001", anchor, "No active access ports.");
|
|
25592
27293
|
const global = statements.find((s) => isDhcpSnoopingOn(textOf2(s)));
|
|
25593
27294
|
if (!global) {
|
|
25594
27295
|
return failAbsent(
|
|
@@ -25603,10 +27304,10 @@ var AosCxDhcpSnooping = {
|
|
|
25603
27304
|
const block = vlanBlockOf(statements, vlan);
|
|
25604
27305
|
if (block?.children.some((c) => isDhcpSnoopingOn(textOf2(c)))) continue;
|
|
25605
27306
|
results.push(
|
|
25606
|
-
|
|
27307
|
+
failAt2("ARU-L2-001", block ?? port, `DHCP snooping is not enabled in access VLAN ${vlan}.`, "warning")
|
|
25607
27308
|
);
|
|
25608
27309
|
}
|
|
25609
|
-
return results.length > 0 ? results :
|
|
27310
|
+
return results.length > 0 ? results : passAt2("ARU-L2-001", global, "DHCP snooping is enabled on every access VLAN.");
|
|
25610
27311
|
})
|
|
25611
27312
|
};
|
|
25612
27313
|
var AosCxArpInspection = {
|
|
@@ -25625,16 +27326,16 @@ var AosCxArpInspection = {
|
|
|
25625
27326
|
},
|
|
25626
27327
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25627
27328
|
const vlans = accessVlansOf(statements);
|
|
25628
|
-
if (vlans.size === 0) return
|
|
27329
|
+
if (vlans.size === 0) return passAt2("ARU-L2-002", anchor, "No active access ports.");
|
|
25629
27330
|
const results = [];
|
|
25630
27331
|
for (const [vlan, port] of vlans) {
|
|
25631
27332
|
const block = vlanBlockOf(statements, vlan);
|
|
25632
27333
|
if (block?.children.some((c) => textOf2(c) === "arp inspection")) continue;
|
|
25633
27334
|
results.push(
|
|
25634
|
-
|
|
27335
|
+
failAt2("ARU-L2-002", block ?? port, `Dynamic ARP inspection is not enabled in access VLAN ${vlan} ("arp inspection").`, "info")
|
|
25635
27336
|
);
|
|
25636
27337
|
}
|
|
25637
|
-
return results.length > 0 ? results :
|
|
27338
|
+
return results.length > 0 ? results : passAt2("ARU-L2-002", anchor, "ARP inspection is enabled on every access VLAN.");
|
|
25638
27339
|
})
|
|
25639
27340
|
};
|
|
25640
27341
|
var AosCxPortSecurity = {
|
|
@@ -25653,11 +27354,11 @@ var AosCxPortSecurity = {
|
|
|
25653
27354
|
tags: generalTags2("layer2-security", "mac-flooding")
|
|
25654
27355
|
},
|
|
25655
27356
|
check: (node) => {
|
|
25656
|
-
if (!isActiveAccessPort(node)) return
|
|
27357
|
+
if (!isActiveAccessPort(node)) return passAt2("ARU-L2-003", node, "Not an active access port.");
|
|
25657
27358
|
if (hasAosCxPortSecurity(node) || hasAosCxDot1x(node) || hasAosCxMacAuth(node)) {
|
|
25658
|
-
return
|
|
27359
|
+
return passAt2("ARU-L2-003", node, "Port security or port-access authentication is enabled.");
|
|
25659
27360
|
}
|
|
25660
|
-
return
|
|
27361
|
+
return failAt2("ARU-L2-003", node, `Access port ${getInterfaceName(node) ?? ""} should have port security enabled.`, "warning");
|
|
25661
27362
|
}
|
|
25662
27363
|
};
|
|
25663
27364
|
var AosCxMstpRegion = {
|
|
@@ -25672,12 +27373,12 @@ var AosCxMstpRegion = {
|
|
|
25672
27373
|
},
|
|
25673
27374
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25674
27375
|
const enabled = statements.find((s) => textOf2(s) === "spanning-tree");
|
|
25675
|
-
if (!enabled) return
|
|
27376
|
+
if (!enabled) return passAt2("ARU-STP-001", anchor, "Spanning tree is not enabled.");
|
|
25676
27377
|
const mode = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "spanning-tree mode")?.params[2]?.toLowerCase();
|
|
25677
|
-
if (mode !== void 0 && mode !== "mstp") return
|
|
27378
|
+
if (mode !== void 0 && mode !== "mstp") return passAt2("ARU-STP-001", enabled, `Spanning tree runs in ${mode} mode.`);
|
|
25678
27379
|
const name = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "spanning-tree config-name");
|
|
25679
|
-
if (name) return
|
|
25680
|
-
return
|
|
27380
|
+
if (name) return passAt2("ARU-STP-001", name, "MSTP region name is configured.");
|
|
27381
|
+
return failAt2(
|
|
25681
27382
|
"ARU-STP-001",
|
|
25682
27383
|
enabled,
|
|
25683
27384
|
"MSTP region name is not configured; the default (the switch MAC address) puts each switch in its own region.",
|
|
@@ -25703,10 +27404,10 @@ var AosCxRootGuard = {
|
|
|
25703
27404
|
check: (node) => {
|
|
25704
27405
|
const ifName = getInterfaceName(node);
|
|
25705
27406
|
if (!ifName || !(isAosCxPhysicalPort(ifName) || isAosCxLag(ifName)) || !isAosCxTrunk(node) || !isActive(node)) {
|
|
25706
|
-
return
|
|
27407
|
+
return passAt2("ARU-STP-003", node, "Not an active trunk port.");
|
|
25707
27408
|
}
|
|
25708
|
-
if (hasAosCxRootGuard(node)) return
|
|
25709
|
-
return
|
|
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");
|
|
25710
27411
|
}
|
|
25711
27412
|
};
|
|
25712
27413
|
var AosCxLoopProtect = {
|
|
@@ -25725,9 +27426,9 @@ var AosCxLoopProtect = {
|
|
|
25725
27426
|
tags: generalTags2("layer2-security", "loop-prevention")
|
|
25726
27427
|
},
|
|
25727
27428
|
check: (node) => {
|
|
25728
|
-
if (!isActiveAccessPort(node)) return
|
|
25729
|
-
if (hasAosCxLoopProtect(node)) return
|
|
25730
|
-
return
|
|
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");
|
|
25731
27432
|
}
|
|
25732
27433
|
};
|
|
25733
27434
|
var AosCxStormControl = {
|
|
@@ -25748,10 +27449,10 @@ var AosCxStormControl = {
|
|
|
25748
27449
|
check: (node) => {
|
|
25749
27450
|
const ifName = getInterfaceName(node);
|
|
25750
27451
|
if (!ifName || !isAosCxPhysicalPort(ifName) || !(isAosCxAccess(node) || isAosCxTrunk(node)) || !isActive(node)) {
|
|
25751
|
-
return
|
|
27452
|
+
return passAt2("ARU-STP-005", node, "Not an active layer 2 port.");
|
|
25752
27453
|
}
|
|
25753
|
-
if (hasAosCxStormControl(node)) return
|
|
25754
|
-
return
|
|
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");
|
|
25755
27456
|
}
|
|
25756
27457
|
};
|
|
25757
27458
|
var AosCxDot1xOnAccess = {
|
|
@@ -25770,11 +27471,11 @@ var AosCxDot1xOnAccess = {
|
|
|
25770
27471
|
tags: generalTags2("authentication", "network-access-control")
|
|
25771
27472
|
},
|
|
25772
27473
|
check: (node) => {
|
|
25773
|
-
if (!isActiveAccessPort(node)) return
|
|
27474
|
+
if (!isActiveAccessPort(node)) return passAt2("ARU-DOT1X-001", node, "Not an active access port.");
|
|
25774
27475
|
if (hasAosCxDot1x(node) || hasAosCxMacAuth(node)) {
|
|
25775
|
-
return
|
|
27476
|
+
return passAt2("ARU-DOT1X-001", node, "Port access authentication is enabled.");
|
|
25776
27477
|
}
|
|
25777
|
-
return
|
|
27478
|
+
return failAt2(
|
|
25778
27479
|
"ARU-DOT1X-001",
|
|
25779
27480
|
node,
|
|
25780
27481
|
`Access port ${getInterfaceName(node) ?? ""} should have 802.1X or MAC authentication enabled.`,
|
|
@@ -25807,7 +27508,7 @@ var AosCxOspfAuth = {
|
|
|
25807
27508
|
const ifName = getInterfaceName(node) ?? "";
|
|
25808
27509
|
const ospf = node.children.map(wordsOf2).find((w) => w[0] === "ip" && w[1] === "ospf" && /^\d+$/.test(w[2] ?? "") && w[3] === "area");
|
|
25809
27510
|
if (!ospf || /^loopback/i.test(ifName) || node.children.some((c) => textOf2(c) === "ip ospf passive")) {
|
|
25810
|
-
return
|
|
27511
|
+
return passAt2("ARU-RTG-001", node, "No active OSPF adjacency on this interface.");
|
|
25811
27512
|
}
|
|
25812
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);
|
|
25813
27514
|
if (type === void 0) {
|
|
@@ -25816,7 +27517,7 @@ var AosCxOspfAuth = {
|
|
|
25816
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);
|
|
25817
27518
|
}
|
|
25818
27519
|
if (type === void 0 || type === "null") {
|
|
25819
|
-
return
|
|
27520
|
+
return failAt2(
|
|
25820
27521
|
"ARU-RTG-001",
|
|
25821
27522
|
node,
|
|
25822
27523
|
"OSPF interface has no authentication configured. Enable message-digest or keychain authentication.",
|
|
@@ -25824,9 +27525,9 @@ var AosCxOspfAuth = {
|
|
|
25824
27525
|
);
|
|
25825
27526
|
}
|
|
25826
27527
|
if (type === "simple-text") {
|
|
25827
|
-
return
|
|
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");
|
|
25828
27529
|
}
|
|
25829
|
-
return
|
|
27530
|
+
return passAt2("ARU-RTG-001", node, "OSPF authentication is configured.");
|
|
25830
27531
|
}
|
|
25831
27532
|
};
|
|
25832
27533
|
var AosCxBgpAuth = {
|
|
@@ -25874,9 +27575,9 @@ var AosCxBgpAuth = {
|
|
|
25874
27575
|
const group = entry.peerGroup ? neighbors.get(entry.peerGroup) : void 0;
|
|
25875
27576
|
if (entry.password || group?.password) continue;
|
|
25876
27577
|
const name = key.split(" ")[1] ?? key;
|
|
25877
|
-
results.push(
|
|
27578
|
+
results.push(failAt2("ARU-RTG-002", entry.peer, `BGP neighbor ${name} has no password configured.`, "warning"));
|
|
25878
27579
|
}
|
|
25879
|
-
return results.length > 0 ? results :
|
|
27580
|
+
return results.length > 0 ? results : passAt2("ARU-RTG-002", node, "BGP authentication is configured.");
|
|
25880
27581
|
}
|
|
25881
27582
|
};
|
|
25882
27583
|
var AosCxVsxKeepaliveVrf = {
|
|
@@ -25894,18 +27595,18 @@ var AosCxVsxKeepaliveVrf = {
|
|
|
25894
27595
|
check: (node) => {
|
|
25895
27596
|
if (textOf2(node) !== "vsx") return [];
|
|
25896
27597
|
const keepalive = node.children.find((c) => wordsOf2(c)[0] === "keepalive" && wordsOf2(c)[1] === "peer");
|
|
25897
|
-
if (!keepalive) return
|
|
27598
|
+
if (!keepalive) return failAt2("ARU-HA-001", node, "VSX keepalive is not configured.", "warning");
|
|
25898
27599
|
const words = wordsOf2(keepalive);
|
|
25899
27600
|
const vrf = words[words.indexOf("vrf") + 1];
|
|
25900
27601
|
if (!words.includes("vrf") || vrf === void 0 || vrf === "default") {
|
|
25901
|
-
return
|
|
27602
|
+
return failAt2(
|
|
25902
27603
|
"ARU-HA-001",
|
|
25903
27604
|
keepalive,
|
|
25904
27605
|
"VSX keepalive runs in the default VRF; use a dedicated VRF so it does not traverse VSX LAG paths.",
|
|
25905
27606
|
"warning"
|
|
25906
27607
|
);
|
|
25907
27608
|
}
|
|
25908
|
-
return
|
|
27609
|
+
return passAt2("ARU-HA-001", keepalive, `VSX keepalive is configured in VRF ${vrf}.`);
|
|
25909
27610
|
}
|
|
25910
27611
|
};
|
|
25911
27612
|
var AosCxMacsecCipher = {
|
|
@@ -25925,17 +27626,17 @@ var AosCxMacsecCipher = {
|
|
|
25925
27626
|
},
|
|
25926
27627
|
check: (node) => {
|
|
25927
27628
|
const cipher = childStarting(node, "cipher-suite");
|
|
25928
|
-
if (!cipher) return
|
|
27629
|
+
if (!cipher) return passAt2("ARU-MACSEC-001", node, "MACsec uses the default cipher suite gcm-aes-xpn-256.");
|
|
25929
27630
|
const weak = wordsOf2(cipher).slice(1).filter((suite) => suite.endsWith("-128"));
|
|
25930
27631
|
if (weak.length > 0) {
|
|
25931
|
-
return
|
|
27632
|
+
return failAt2(
|
|
25932
27633
|
"ARU-MACSEC-001",
|
|
25933
27634
|
cipher,
|
|
25934
27635
|
`MACsec policy allows ${weak.join(", ")}. Consider using gcm-aes-256 (or gcm-aes-xpn-256) for strongest MACsec encryption.`,
|
|
25935
27636
|
"warning"
|
|
25936
27637
|
);
|
|
25937
27638
|
}
|
|
25938
|
-
return
|
|
27639
|
+
return passAt2("ARU-MACSEC-001", cipher, "MACsec is using 256-bit encryption.");
|
|
25939
27640
|
}
|
|
25940
27641
|
};
|
|
25941
27642
|
var DEFAULT_COMMUNITIES = /* @__PURE__ */ new Set(["public", "private"]);
|
|
@@ -25956,7 +27657,7 @@ var AosCxSnmpv3Required = {
|
|
|
25956
27657
|
},
|
|
25957
27658
|
check: configWide("aoscx", (statements, anchor) => {
|
|
25958
27659
|
const agent = statements.find((s) => wordsOf2(s).slice(0, 2).join(" ") === "snmp-server vrf");
|
|
25959
|
-
if (!agent) return
|
|
27660
|
+
if (!agent) return passAt2("ARU-LOG-003", anchor, "SNMP is not enabled (no snmp-server vrf).");
|
|
25960
27661
|
const communities = statements.filter((s) => wordsOf2(s).slice(0, 2).join(" ") === "snmp-server community");
|
|
25961
27662
|
if (communities.length === 0) {
|
|
25962
27663
|
return failAbsent(
|
|
@@ -25967,14 +27668,14 @@ var AosCxSnmpv3Required = {
|
|
|
25967
27668
|
);
|
|
25968
27669
|
}
|
|
25969
27670
|
const results = communities.filter((c) => !DEFAULT_COMMUNITIES.has((c.params[2] ?? "").toLowerCase())).map(
|
|
25970
|
-
(c) =>
|
|
27671
|
+
(c) => failAt2(
|
|
25971
27672
|
"ARU-LOG-003",
|
|
25972
27673
|
c,
|
|
25973
27674
|
"SNMPv2c community string detected. Consider using SNMPv3 with authentication and privacy.",
|
|
25974
27675
|
"warning"
|
|
25975
27676
|
)
|
|
25976
27677
|
);
|
|
25977
|
-
return results.length > 0 ? results :
|
|
27678
|
+
return results.length > 0 ? results : passAt2("ARU-LOG-003", agent, "Only default-named communities, reported by ARU-SEC-002.");
|
|
25978
27679
|
})
|
|
25979
27680
|
};
|
|
25980
27681
|
var AosCxSnmpv3AuthPriv = {
|
|
@@ -25994,11 +27695,11 @@ var AosCxSnmpv3AuthPriv = {
|
|
|
25994
27695
|
},
|
|
25995
27696
|
check: (node) => {
|
|
25996
27697
|
const words = wordsOf2(node).slice(3);
|
|
25997
|
-
if (!words.includes("auth")) return
|
|
27698
|
+
if (!words.includes("auth")) return failAt2("ARU-LOG-002", node, "SNMPv3 user has no authentication configured.", "warning");
|
|
25998
27699
|
if (!words.includes("priv")) {
|
|
25999
|
-
return
|
|
27700
|
+
return failAt2("ARU-LOG-002", node, "SNMPv3 user has authentication but no privacy (encryption).", "warning");
|
|
26000
27701
|
}
|
|
26001
|
-
return
|
|
27702
|
+
return passAt2("ARU-LOG-002", node, "SNMPv3 user has authentication and privacy enabled.");
|
|
26002
27703
|
}
|
|
26003
27704
|
};
|
|
26004
27705
|
var allAosCxRules = [
|
|
@@ -26211,14 +27912,14 @@ var AosSwitchSshEnabled = {
|
|
|
26211
27912
|
check: configWide("aosswitch", (statements, anchor) => {
|
|
26212
27913
|
const disabled = statements.find((s) => textOf2(s) === "no ip ssh");
|
|
26213
27914
|
if (disabled) {
|
|
26214
|
-
return
|
|
27915
|
+
return failAt2(
|
|
26215
27916
|
"AOSSW-SEC-003",
|
|
26216
27917
|
disabled,
|
|
26217
27918
|
'SSH server is disabled ("no ip ssh"). Enable it with "ip ssh" and disable Telnet.',
|
|
26218
27919
|
"error"
|
|
26219
27920
|
);
|
|
26220
27921
|
}
|
|
26221
|
-
return
|
|
27922
|
+
return passAt2("AOSSW-SEC-003", anchor, "SSH server is on (the AOS-Switch default).");
|
|
26222
27923
|
})
|
|
26223
27924
|
};
|
|
26224
27925
|
var AosSwitchSpanningTree = {
|
|
@@ -26387,11 +28088,11 @@ var AosSwitchTimesync = {
|
|
|
26387
28088
|
check: configWide("aosswitch", (statements, anchor) => {
|
|
26388
28089
|
const lines = statements.flatMap((s) => [s, ...s.children]);
|
|
26389
28090
|
const server = lines.find((s) => NTP_SERVER.test(textOf2(s)) || SNTP_SERVER.test(textOf2(s)));
|
|
26390
|
-
if (server) return
|
|
28091
|
+
if (server) return passAt2("AOSSW-TIME-001", server, "Time server is configured.");
|
|
26391
28092
|
const sntpMode = statements.some((s) => textOf2(s) === "timesync sntp") ? statements.find((s) => SNTP_LEARNED_MODE.test(textOf2(s))) : void 0;
|
|
26392
|
-
if (sntpMode) return
|
|
28093
|
+
if (sntpMode) return passAt2("AOSSW-TIME-001", sntpMode, "SNTP learns its time server by DHCP or broadcast.");
|
|
26393
28094
|
const timep = lines.find((s) => TIMEP.test(textOf2(s)));
|
|
26394
|
-
if (timep) return
|
|
28095
|
+
if (timep) return passAt2("AOSSW-TIME-001", timep, "TimeP time synchronization is configured.");
|
|
26395
28096
|
return failAbsent(
|
|
26396
28097
|
"AOSSW-TIME-001",
|
|
26397
28098
|
anchor,
|
|
@@ -26416,10 +28117,10 @@ var HttpDisabled = {
|
|
|
26416
28117
|
},
|
|
26417
28118
|
check: configWide("aosswitch", (statements, anchor) => {
|
|
26418
28119
|
const disabled = statements.find((s) => ["no web-management", "no web-management plaintext"].includes(textOf2(s)));
|
|
26419
|
-
if (disabled) return
|
|
28120
|
+
if (disabled) return passAt2("ARU-HTTP-001", disabled, "Plaintext web management (HTTP) is disabled.");
|
|
26420
28121
|
const enabled = statements.find((s) => textOf2(s) === "web-management" || textOf2(s) === "web-management plaintext");
|
|
26421
28122
|
if (enabled) {
|
|
26422
|
-
return
|
|
28123
|
+
return failAt2("ARU-HTTP-001", enabled, "Plaintext web management (HTTP) is enabled. Disable it and use HTTPS only.", "warning");
|
|
26423
28124
|
}
|
|
26424
28125
|
return failAbsent(
|
|
26425
28126
|
"ARU-HTTP-001",
|
|
@@ -27024,9 +28725,9 @@ var WlcCpsecEnabled = {
|
|
|
27024
28725
|
if (textOf2(node) !== "control-plane-security") return [];
|
|
27025
28726
|
const disabled = node.children.find((c) => textOf2(c) === "no cpsec-enable");
|
|
27026
28727
|
if (disabled) {
|
|
27027
|
-
return
|
|
28728
|
+
return failAt2("ARU-WLC-001", disabled, "Control Plane Security (CPsec) is disabled. Enable for secure AP communication.", "warning");
|
|
27028
28729
|
}
|
|
27029
|
-
return
|
|
28730
|
+
return passAt2("ARU-WLC-001", node, "Control Plane Security (CPsec) is enabled.");
|
|
27030
28731
|
}
|
|
27031
28732
|
};
|
|
27032
28733
|
var WlcUserRoleFirewall = {
|
|
@@ -27052,9 +28753,9 @@ var WlcUserRoleFirewall = {
|
|
|
27052
28753
|
return words[0] === "access-list" && ["session", "eth", "mac"].includes(words[1] ?? "") && words[2] !== void 0;
|
|
27053
28754
|
});
|
|
27054
28755
|
if (!hasPolicy) {
|
|
27055
|
-
return
|
|
28756
|
+
return failAt2("ARU-WLC-004", node, `User role "${name}" has no firewall policy (access-list session) configured.`, "warning");
|
|
27056
28757
|
}
|
|
27057
|
-
return
|
|
28758
|
+
return passAt2("ARU-WLC-004", node, `User role "${name}" has firewall policy configured.`);
|
|
27058
28759
|
}
|
|
27059
28760
|
};
|
|
27060
28761
|
var WlcSsidLimit = {
|
|
@@ -27073,14 +28774,14 @@ var WlcSsidLimit = {
|
|
|
27073
28774
|
const name = profileNameOf(node);
|
|
27074
28775
|
const vaps = new Set(getApGroupVirtualAps(node).map((v) => v.trim().toLowerCase()));
|
|
27075
28776
|
if (vaps.size > 4) {
|
|
27076
|
-
return
|
|
28777
|
+
return failAt2(
|
|
27077
28778
|
"ARU-WLC-005",
|
|
27078
28779
|
node,
|
|
27079
28780
|
`AP group "${name}" has ${vaps.size} virtual-APs. Best practice is 4 or fewer.`,
|
|
27080
28781
|
"warning"
|
|
27081
28782
|
);
|
|
27082
28783
|
}
|
|
27083
|
-
return
|
|
28784
|
+
return passAt2("ARU-WLC-005", node, `AP group "${name}" has ${vaps.size} virtual-AP(s).`);
|
|
27084
28785
|
}
|
|
27085
28786
|
};
|
|
27086
28787
|
var opmodesOf = (node) => {
|
|
@@ -27108,12 +28809,12 @@ var WlcWpa3Enterprise = {
|
|
|
27108
28809
|
const name = profileNameOf(node);
|
|
27109
28810
|
const modes = opmodesOf(node);
|
|
27110
28811
|
if (modes.length === 0 || modes.every((m) => m === "opensystem" || m === "open")) {
|
|
27111
|
-
return
|
|
28812
|
+
return passAt2("ARU-WIFI-001", node, `SSID profile "${name}" is open; reported by ARUWLC-WLAN-001.`);
|
|
27112
28813
|
}
|
|
27113
28814
|
if (modes.some(isWpa3OrOwe)) {
|
|
27114
|
-
return
|
|
28815
|
+
return passAt2("ARU-WIFI-001", node, `SSID profile "${name}" offers WPA3 (${modes.join(", ")}).`);
|
|
27115
28816
|
}
|
|
27116
|
-
return
|
|
28817
|
+
return failAt2(
|
|
27117
28818
|
"ARU-WIFI-001",
|
|
27118
28819
|
node,
|
|
27119
28820
|
`SSID profile "${name}" uses ${modes.join(", ")} without WPA3. Consider WPA3-Enterprise for enhanced security.`,
|
|
@@ -27142,9 +28843,9 @@ var WlcWpa3SaePassphrase = {
|
|
|
27142
28843
|
const name = profileNameOf(node);
|
|
27143
28844
|
const hasPassphrase = node.children.some((c) => wordsOf2(c)[0] === "wpa-passphrase" && c.params.length > 1);
|
|
27144
28845
|
if (!hasPassphrase) {
|
|
27145
|
-
return
|
|
28846
|
+
return failAt2("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has no wpa-passphrase configured.`, "warning");
|
|
27146
28847
|
}
|
|
27147
|
-
return
|
|
28848
|
+
return passAt2("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has a passphrase configured.`);
|
|
27148
28849
|
}
|
|
27149
28850
|
};
|
|
27150
28851
|
var WlcSsidMaxClients = {
|
|
@@ -27162,14 +28863,14 @@ var WlcSsidMaxClients = {
|
|
|
27162
28863
|
const name = profileNameOf(node);
|
|
27163
28864
|
const maxClients = getMaxClients(node);
|
|
27164
28865
|
if (maxClients === null) {
|
|
27165
|
-
return
|
|
28866
|
+
return failAt2(
|
|
27166
28867
|
"ARUWLC-WLAN-004",
|
|
27167
28868
|
node,
|
|
27168
28869
|
`SSID profile "${name}" has no max-clients limit (the default is the AP maximum). Consider setting one.`,
|
|
27169
28870
|
"info"
|
|
27170
28871
|
);
|
|
27171
28872
|
}
|
|
27172
|
-
return
|
|
28873
|
+
return passAt2("ARUWLC-WLAN-004", node, `SSID profile "${name}" has max-clients ${maxClients}.`);
|
|
27173
28874
|
}
|
|
27174
28875
|
};
|
|
27175
28876
|
var allWlcRules = [
|
|
@@ -33819,7 +35520,7 @@ var exosIndexOf = (context) => {
|
|
|
33819
35520
|
}
|
|
33820
35521
|
return index;
|
|
33821
35522
|
};
|
|
33822
|
-
var
|
|
35523
|
+
var passAt3 = (ruleId, node, message) => ({
|
|
33823
35524
|
passed: true,
|
|
33824
35525
|
message,
|
|
33825
35526
|
ruleId,
|
|
@@ -33827,7 +35528,7 @@ var passAt2 = (ruleId, node, message) => ({
|
|
|
33827
35528
|
level: "info",
|
|
33828
35529
|
loc: locOf(node)
|
|
33829
35530
|
});
|
|
33830
|
-
var
|
|
35531
|
+
var failAt3 = (ruleId, at2, level, message, absent = false) => ({
|
|
33831
35532
|
passed: false,
|
|
33832
35533
|
message,
|
|
33833
35534
|
ruleId,
|
|
@@ -33836,7 +35537,7 @@ var failAt2 = (ruleId, at2, level, message, absent = false) => ({
|
|
|
33836
35537
|
loc: locOf(at2),
|
|
33837
35538
|
...absent ? { absent: true } : {}
|
|
33838
35539
|
});
|
|
33839
|
-
var
|
|
35540
|
+
var judgedOnce2 = (judge) => (node, context) => {
|
|
33840
35541
|
const index = exosIndexOf(context);
|
|
33841
35542
|
if (!index || index.anchor !== node) return [];
|
|
33842
35543
|
return judge(index, node);
|
|
@@ -33864,12 +35565,12 @@ var ExosSysnameRequired = {
|
|
|
33864
35565
|
owner: "NetOps",
|
|
33865
35566
|
remediation: 'Configure sysname using: configure snmp sysname "<name>"'
|
|
33866
35567
|
},
|
|
33867
|
-
check:
|
|
35568
|
+
check: judgedOnce2((index, anchor) => {
|
|
33868
35569
|
const id = "EXOS-SYS-001";
|
|
33869
35570
|
const sysname = lastMatching(index, /^configure\s+snmp\s+sysname\s+\S/i);
|
|
33870
35571
|
if (!sysname) {
|
|
33871
35572
|
return [
|
|
33872
|
-
|
|
35573
|
+
failAt3(
|
|
33873
35574
|
id,
|
|
33874
35575
|
anchor,
|
|
33875
35576
|
"warning",
|
|
@@ -33879,7 +35580,7 @@ var ExosSysnameRequired = {
|
|
|
33879
35580
|
];
|
|
33880
35581
|
}
|
|
33881
35582
|
const name = sysname.text.match(/sysname\s+["']?([^"'\s]+)["']?/i)?.[1] ?? "configured";
|
|
33882
|
-
return [
|
|
35583
|
+
return [passAt3(id, sysname.node, `SNMP sysname is configured: ${name}`)];
|
|
33883
35584
|
})
|
|
33884
35585
|
};
|
|
33885
35586
|
var SNTP_SERVER2 = /^configure\s+sntp-client\s+(?:primary|secondary)\s+(?:server\s+)?\S+/i;
|
|
@@ -33894,13 +35595,13 @@ var ExosSntpRequired = {
|
|
|
33894
35595
|
owner: "SecOps",
|
|
33895
35596
|
remediation: "Configure SNTP using: configure sntp-client primary <ip> vr VR-Mgmt (or NTP: configure ntp server add <ip> vr VR-Mgmt)"
|
|
33896
35597
|
},
|
|
33897
|
-
check:
|
|
35598
|
+
check: judgedOnce2((index, anchor) => {
|
|
33898
35599
|
const id = "EXOS-SYS-002";
|
|
33899
35600
|
const server = matching(index, SNTP_SERVER2)[0] ?? matching(index, NTP_SERVER2)[0];
|
|
33900
35601
|
if (!server) {
|
|
33901
|
-
return [
|
|
35602
|
+
return [failAt3(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
|
|
33902
35603
|
}
|
|
33903
|
-
return [
|
|
35604
|
+
return [passAt3(id, server.node, "A time server is configured.")];
|
|
33904
35605
|
})
|
|
33905
35606
|
};
|
|
33906
35607
|
var ExosSntpEnabled = {
|
|
@@ -33913,30 +35614,30 @@ var ExosSntpEnabled = {
|
|
|
33913
35614
|
owner: "SecOps",
|
|
33914
35615
|
remediation: "Enable SNTP client: enable sntp-client (for NTP servers: enable ntp)"
|
|
33915
35616
|
},
|
|
33916
|
-
check:
|
|
35617
|
+
check: judgedOnce2((index, anchor) => {
|
|
33917
35618
|
const id = "EXOS-SYS-003";
|
|
33918
35619
|
const sntpServer = matching(index, SNTP_SERVER2)[0];
|
|
33919
35620
|
const ntpServer = matching(index, NTP_SERVER2)[0];
|
|
33920
35621
|
const sntp = lastMatching(index, /^(?:enable|disable)\s+sntp-client\s*$/i);
|
|
33921
35622
|
const ntp = lastMatching(index, /^(?:enable|disable)\s+ntp\s*$/i);
|
|
33922
35623
|
const on = [sntp, ntp].find((l) => l !== void 0 && /^enable/i.test(l.text));
|
|
33923
|
-
if (on) return [
|
|
35624
|
+
if (on) return [passAt3(id, on.node, "A time synchronization client is enabled.")];
|
|
33924
35625
|
if (!sntpServer && !ntpServer && !sntp && !ntp) {
|
|
33925
|
-
return [
|
|
35626
|
+
return [passAt3(id, anchor, "SNTP and NTP are not configured (a missing time source is reported by EXOS-SYS-002).")];
|
|
33926
35627
|
}
|
|
33927
35628
|
const results = [];
|
|
33928
35629
|
if (sntp) {
|
|
33929
|
-
results.push(
|
|
35630
|
+
results.push(failAt3(id, sntp.node, "warning", "The SNTP client is disabled; the switch clock is not synchronized."));
|
|
33930
35631
|
} else if (sntpServer) {
|
|
33931
35632
|
results.push(
|
|
33932
|
-
|
|
35633
|
+
failAt3(id, sntpServer.node, "warning", "SNTP servers are configured, but the SNTP client is not enabled: enable sntp-client.", true)
|
|
33933
35634
|
);
|
|
33934
35635
|
}
|
|
33935
35636
|
if (ntp) {
|
|
33936
|
-
results.push(
|
|
35637
|
+
results.push(failAt3(id, ntp.node, "warning", "NTP is disabled; the switch clock is not synchronized."));
|
|
33937
35638
|
} else if (ntpServer) {
|
|
33938
35639
|
results.push(
|
|
33939
|
-
|
|
35640
|
+
failAt3(id, ntpServer.node, "warning", "NTP servers are configured, but NTP is not enabled (disabled by default): enable ntp.", true)
|
|
33940
35641
|
);
|
|
33941
35642
|
}
|
|
33942
35643
|
return results;
|
|
@@ -33959,16 +35660,16 @@ var ExosSyslogRequired = {
|
|
|
33959
35660
|
{ type: "general", label: "monitoring" }
|
|
33960
35661
|
]
|
|
33961
35662
|
},
|
|
33962
|
-
check:
|
|
35663
|
+
check: judgedOnce2((index, anchor) => {
|
|
33963
35664
|
const id = "EXOS-SYS-004";
|
|
33964
35665
|
const server = matching(index, /^configure\s+syslog\s+add\s+\S+/i)[0];
|
|
33965
35666
|
if (!server) {
|
|
33966
|
-
return [
|
|
35667
|
+
return [failAt3(id, anchor, "warning", "Remote syslog is not configured. Centralized logging is recommended.", true)];
|
|
33967
35668
|
}
|
|
33968
35669
|
const state = lastMatching(index, /^(?:enable|disable)\s+syslog\s*$/i);
|
|
33969
35670
|
if (!state) {
|
|
33970
35671
|
return [
|
|
33971
|
-
|
|
35672
|
+
failAt3(
|
|
33972
35673
|
id,
|
|
33973
35674
|
server.node,
|
|
33974
35675
|
"warning",
|
|
@@ -33978,9 +35679,9 @@ var ExosSyslogRequired = {
|
|
|
33978
35679
|
];
|
|
33979
35680
|
}
|
|
33980
35681
|
if (/^disable/i.test(state.text)) {
|
|
33981
|
-
return [
|
|
35682
|
+
return [failAt3(id, state.node, "warning", "Remote syslog is disabled; messages are not sent to the configured servers.")];
|
|
33982
35683
|
}
|
|
33983
|
-
return [
|
|
35684
|
+
return [passAt3(id, server.node, "Remote syslog is configured and enabled.")];
|
|
33984
35685
|
})
|
|
33985
35686
|
};
|
|
33986
35687
|
var ExosSsh2Enabled = {
|
|
@@ -34000,16 +35701,16 @@ var ExosSsh2Enabled = {
|
|
|
34000
35701
|
{ type: "general", label: "management-plane" }
|
|
34001
35702
|
]
|
|
34002
35703
|
},
|
|
34003
|
-
check:
|
|
35704
|
+
check: judgedOnce2((index, anchor) => {
|
|
34004
35705
|
const id = "EXOS-SEC-001";
|
|
34005
35706
|
const last = lastMatching(index, /^(?:enable|disable)\s+ssh2(?:\s|$)/i);
|
|
34006
35707
|
if (!last) {
|
|
34007
|
-
return [
|
|
35708
|
+
return [failAt3(id, anchor, "warning", "SSH2 is not enabled (disabled by default). Secure management access is recommended.", true)];
|
|
34008
35709
|
}
|
|
34009
35710
|
if (/^disable/i.test(last.text)) {
|
|
34010
|
-
return [
|
|
35711
|
+
return [failAt3(id, last.node, "warning", "SSH2 is disabled. Secure management access is recommended.")];
|
|
34011
35712
|
}
|
|
34012
|
-
return [
|
|
35713
|
+
return [passAt3(id, last.node, "SSH2 is enabled for secure management.")];
|
|
34013
35714
|
})
|
|
34014
35715
|
};
|
|
34015
35716
|
var ExosTelnetDisabled = {
|
|
@@ -34031,16 +35732,16 @@ var ExosTelnetDisabled = {
|
|
|
34031
35732
|
{ type: "general", label: "management-plane" }
|
|
34032
35733
|
]
|
|
34033
35734
|
},
|
|
34034
|
-
check:
|
|
35735
|
+
check: judgedOnce2((index, anchor) => {
|
|
34035
35736
|
const id = "EXOS-SEC-002";
|
|
34036
35737
|
const last = lastMatching(index, /^(?:enable|disable)\s+telnet\s*$/i);
|
|
34037
35738
|
if (!last) {
|
|
34038
|
-
return [
|
|
35739
|
+
return [failAt3(id, anchor, "warning", "Telnet is not disabled (enabled by default). Use SSH2 for secure management.", true)];
|
|
34039
35740
|
}
|
|
34040
35741
|
if (/^enable/i.test(last.text)) {
|
|
34041
|
-
return [
|
|
35742
|
+
return [failAt3(id, last.node, "warning", "Telnet is enabled. Use SSH2 for secure management.")];
|
|
34042
35743
|
}
|
|
34043
|
-
return [
|
|
35744
|
+
return [passAt3(id, last.node, "Telnet is disabled.")];
|
|
34044
35745
|
})
|
|
34045
35746
|
};
|
|
34046
35747
|
var RADIUS_MGMT_SERVER = /^configure\s+radius\s+(?:mgmt-access\s+)?(?:primary|secondary|\d+)\s+server\s+\S+/i;
|
|
@@ -34058,23 +35759,23 @@ var ExosAaaRequired = {
|
|
|
34058
35759
|
cwe: ["CWE-287"]
|
|
34059
35760
|
}
|
|
34060
35761
|
},
|
|
34061
|
-
check:
|
|
35762
|
+
check: judgedOnce2((index, anchor) => {
|
|
34062
35763
|
const id = "EXOS-SEC-003";
|
|
34063
35764
|
const radius = matching(index, RADIUS_MGMT_SERVER);
|
|
34064
35765
|
const tacacs = matching(index, TACACS_SERVER);
|
|
34065
35766
|
const radiusState = lastMatching(index, /^(?:enable|disable)\s+radius(?:\s+mgmt-access)?\s*$/i);
|
|
34066
35767
|
const tacacsState = lastMatching(index, /^(?:enable|disable)\s+tacacs\s*$/i);
|
|
34067
35768
|
const isOn3 = (l) => l !== void 0 && /^enable/i.test(l.text);
|
|
34068
|
-
if (radius[0] && isOn3(radiusState)) return [
|
|
34069
|
-
if (tacacs[0] && isOn3(tacacsState)) return [
|
|
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.")];
|
|
34070
35771
|
const off = (radius[0] ? radiusState : void 0) ?? (tacacs[0] ? tacacsState : void 0);
|
|
34071
35772
|
if (off) {
|
|
34072
|
-
return [
|
|
35773
|
+
return [failAt3(id, off.node, "info", "AAA (RADIUS/TACACS+) servers are configured, but management authentication is disabled.")];
|
|
34073
35774
|
}
|
|
34074
35775
|
const server = matching(index, new RegExp(`${RADIUS_MGMT_SERVER.source}|${TACACS_SERVER.source}`, "i"))[0];
|
|
34075
35776
|
if (server) {
|
|
34076
35777
|
return [
|
|
34077
|
-
|
|
35778
|
+
failAt3(
|
|
34078
35779
|
id,
|
|
34079
35780
|
server.node,
|
|
34080
35781
|
"info",
|
|
@@ -34084,7 +35785,7 @@ var ExosAaaRequired = {
|
|
|
34084
35785
|
];
|
|
34085
35786
|
}
|
|
34086
35787
|
return [
|
|
34087
|
-
|
|
35788
|
+
failAt3(id, anchor, "info", "AAA (RADIUS/TACACS) is not configured for management access. Centralized authentication is recommended.", true)
|
|
34088
35789
|
];
|
|
34089
35790
|
})
|
|
34090
35791
|
};
|
|
@@ -34243,13 +35944,13 @@ var ExosEapsControlVlan = {
|
|
|
34243
35944
|
owner: "NetOps",
|
|
34244
35945
|
remediation: "Configure EAPS control VLAN: configure eaps <name> add control vlan <vlan>"
|
|
34245
35946
|
},
|
|
34246
|
-
check:
|
|
35947
|
+
check: judgedOnce2((index, anchor) => {
|
|
34247
35948
|
const id = "EXOS-EAPS-001";
|
|
34248
35949
|
const domains = index.lines.flatMap((l) => {
|
|
34249
35950
|
const name = l.text.match(/^create\s+eaps\s+(\S+)\s*$/i)?.[1];
|
|
34250
35951
|
return name ? [{ line: l, name }] : [];
|
|
34251
35952
|
});
|
|
34252
|
-
if (domains.length === 0) return [
|
|
35953
|
+
if (domains.length === 0) return [passAt3(id, anchor, "EAPS is not configured.")];
|
|
34253
35954
|
const withControl = new Set(
|
|
34254
35955
|
index.lines.flatMap((l) => {
|
|
34255
35956
|
const name = l.text.match(/^configure\s+eaps\s+(\S+)\s+add\s+control\s+(?:vlan\s+)?\S+/i)?.[1];
|
|
@@ -34257,9 +35958,9 @@ var ExosEapsControlVlan = {
|
|
|
34257
35958
|
})
|
|
34258
35959
|
);
|
|
34259
35960
|
const results = domains.filter((d) => !withControl.has(exosName(d.name))).map(
|
|
34260
|
-
(d) =>
|
|
35961
|
+
(d) => failAt3(id, d.line.node, "error", `EAPS domain ${d.name} has no control VLAN; the domain does not run without one.`)
|
|
34261
35962
|
);
|
|
34262
|
-
return results.length > 0 ? results : [
|
|
35963
|
+
return results.length > 0 ? results : [passAt3(id, domains[0]?.line.node ?? anchor, "Every EAPS domain has a control VLAN.")];
|
|
34263
35964
|
})
|
|
34264
35965
|
};
|
|
34265
35966
|
var ExosStackingPriority = {
|
|
@@ -34272,12 +35973,12 @@ var ExosStackingPriority = {
|
|
|
34272
35973
|
owner: "NetOps",
|
|
34273
35974
|
remediation: 'Configure stacking priority: configure stacking [node-address <mac> | slot <slot>] priority <1-100>; check it with "show stacking configuration"'
|
|
34274
35975
|
},
|
|
34275
|
-
check:
|
|
35976
|
+
check: judgedOnce2((index, anchor) => {
|
|
34276
35977
|
const id = "EXOS-STACK-001";
|
|
34277
35978
|
const stacking = matching(index, /^(?:enable|configure)\s+stacking(?:\s|$)/i)[0];
|
|
34278
35979
|
if (!stacking) {
|
|
34279
35980
|
return [
|
|
34280
|
-
|
|
35981
|
+
passAt3(
|
|
34281
35982
|
id,
|
|
34282
35983
|
anchor,
|
|
34283
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".'
|
|
@@ -34286,15 +35987,15 @@ var ExosStackingPriority = {
|
|
|
34286
35987
|
}
|
|
34287
35988
|
const priorities = matching(index, /^configure\s+stacking\s+(?:(?:node-address|slot)\s+\S+\s+)?priority\s+\S+/i);
|
|
34288
35989
|
const numeric = priorities.find((l) => /\bpriority\s+\d+\s*$/i.test(l.text));
|
|
34289
|
-
if (numeric) return [
|
|
35990
|
+
if (numeric) return [passAt3(id, numeric.node, "Stacking node priority is configured.")];
|
|
34290
35991
|
const automatic = priorities[priorities.length - 1];
|
|
34291
35992
|
if (automatic) {
|
|
34292
35993
|
return [
|
|
34293
|
-
|
|
35994
|
+
failAt3(id, automatic.node, "info", "Stacking priority is automatic: the master-capable node with the lowest slot number becomes master.")
|
|
34294
35995
|
];
|
|
34295
35996
|
}
|
|
34296
35997
|
return [
|
|
34297
|
-
|
|
35998
|
+
failAt3(
|
|
34298
35999
|
id,
|
|
34299
36000
|
stacking.node,
|
|
34300
36001
|
"info",
|
|
@@ -34314,13 +36015,13 @@ var ExosMlagIsc = {
|
|
|
34314
36015
|
owner: "NetOps",
|
|
34315
36016
|
remediation: "Configure MLAG ISC: configure mlag peer <name> ipaddress <ip> vr VR-Default"
|
|
34316
36017
|
},
|
|
34317
|
-
check:
|
|
36018
|
+
check: judgedOnce2((index, anchor) => {
|
|
34318
36019
|
const id = "EXOS-MLAG-001";
|
|
34319
36020
|
const peers = index.lines.flatMap((l) => {
|
|
34320
36021
|
const name = l.text.match(/^create\s+mlag\s+peer\s+(\S+)/i)?.[1];
|
|
34321
36022
|
return name ? [{ line: l, name }] : [];
|
|
34322
36023
|
});
|
|
34323
|
-
if (peers.length === 0) return [
|
|
36024
|
+
if (peers.length === 0) return [passAt3(id, anchor, "MLAG is not configured.")];
|
|
34324
36025
|
const withAddress = new Set(
|
|
34325
36026
|
index.lines.flatMap((l) => {
|
|
34326
36027
|
const name = l.text.match(/^configure\s+mlag\s+peer\s+(\S+)\s+ipaddress\s+\S+/i)?.[1];
|
|
@@ -34328,14 +36029,14 @@ var ExosMlagIsc = {
|
|
|
34328
36029
|
})
|
|
34329
36030
|
);
|
|
34330
36031
|
const results = peers.filter((p) => !withAddress.has(exosName(p.name))).map(
|
|
34331
|
-
(p) =>
|
|
36032
|
+
(p) => failAt3(
|
|
34332
36033
|
id,
|
|
34333
36034
|
p.line.node,
|
|
34334
36035
|
"error",
|
|
34335
36036
|
`MLAG peer ${p.name} has no peer IP address; the Inter-Switch Connection cannot exchange keep-alives or checkpoint state.`
|
|
34336
36037
|
)
|
|
34337
36038
|
);
|
|
34338
|
-
return results.length > 0 ? results : [
|
|
36039
|
+
return results.length > 0 ? results : [passAt3(id, peers[0]?.line.node ?? anchor, "Every MLAG peer has a peer IP address.")];
|
|
34339
36040
|
})
|
|
34340
36041
|
};
|
|
34341
36042
|
var MAX_IDLE_MINUTES = 10;
|
|
@@ -34354,29 +36055,29 @@ var ExosIdleTimeout = {
|
|
|
34354
36055
|
},
|
|
34355
36056
|
tags: EXOS_TAGS("session-management", "management-plane")
|
|
34356
36057
|
},
|
|
34357
|
-
check:
|
|
36058
|
+
check: judgedOnce2((index, anchor) => {
|
|
34358
36059
|
const id = "EXOS-MGMT-004";
|
|
34359
36060
|
const results = [];
|
|
34360
36061
|
const timer = lastMatching(index, /^(?:enable|disable)\s+(?:cli\s+)?idle-?timeout\s*$/i);
|
|
34361
36062
|
if (timer && /^disable/i.test(timer.text)) {
|
|
34362
|
-
results.push(
|
|
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."));
|
|
34363
36064
|
}
|
|
34364
36065
|
const cli = lastMatching(index, /^configure\s+(?:cli\s+idle-timeout|idletimeout)\s+\d+/i);
|
|
34365
36066
|
const cliValue = cli?.text.match(/(?:idle-timeout|idletimeout)\s+(\d+)/i)?.[1];
|
|
34366
36067
|
const cliMinutes = cliValue === void 0 ? void 0 : Number(cliValue);
|
|
34367
36068
|
if (cli && cliMinutes !== void 0 && cliMinutes > MAX_IDLE_MINUTES) {
|
|
34368
|
-
results.push(
|
|
36069
|
+
results.push(failAt3(id, cli.node, "warning", `CLI idle timeout is ${cliMinutes} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
|
|
34369
36070
|
}
|
|
34370
36071
|
const ssh = lastMatching(index, /^configure\s+ssh2\s+idletimeout\s+\S+/i);
|
|
34371
36072
|
const sshValue = ssh?.text.match(/idletimeout\s+(\S+)/i)?.[1]?.toLowerCase();
|
|
34372
36073
|
if (ssh && sshValue === "none") {
|
|
34373
|
-
results.push(
|
|
36074
|
+
results.push(failAt3(id, ssh.node, "warning", "SSH2 idle timeout is disabled (none)."));
|
|
34374
36075
|
} else if (ssh && sshValue !== void 0 && Number(sshValue) > MAX_IDLE_MINUTES) {
|
|
34375
|
-
results.push(
|
|
36076
|
+
results.push(failAt3(id, ssh.node, "warning", `SSH2 idle timeout is ${sshValue} minutes; the recommended maximum is ${MAX_IDLE_MINUTES}.`));
|
|
34376
36077
|
}
|
|
34377
36078
|
if (!cli && results.length === 0) {
|
|
34378
36079
|
results.push(
|
|
34379
|
-
|
|
36080
|
+
failAt3(
|
|
34380
36081
|
id,
|
|
34381
36082
|
anchor,
|
|
34382
36083
|
"warning",
|
|
@@ -34385,7 +36086,7 @@ var ExosIdleTimeout = {
|
|
|
34385
36086
|
)
|
|
34386
36087
|
);
|
|
34387
36088
|
}
|
|
34388
|
-
return results.length > 0 ? results : [
|
|
36089
|
+
return results.length > 0 ? results : [passAt3(id, cli?.node ?? anchor, "Idle management sessions time out.")];
|
|
34389
36090
|
})
|
|
34390
36091
|
};
|
|
34391
36092
|
var ExosSnmpv3UserSecurity = {
|
|
@@ -34404,10 +36105,10 @@ var ExosSnmpv3UserSecurity = {
|
|
|
34404
36105
|
},
|
|
34405
36106
|
tags: EXOS_TAGS("snmp", "encryption", "management-plane")
|
|
34406
36107
|
},
|
|
34407
|
-
check:
|
|
36108
|
+
check: judgedOnce2((index, anchor) => {
|
|
34408
36109
|
const id = "EXOS-MGMT-007";
|
|
34409
36110
|
const users = matching(index, /^configure\s+snmpv3\s+add\s+user\s+/i).filter((l) => !/\bclone-from\b/i.test(l.text));
|
|
34410
|
-
if (users.length === 0) return [
|
|
36111
|
+
if (users.length === 0) return [passAt3(id, anchor, "No SNMPv3 users are configured.")];
|
|
34411
36112
|
const results = [];
|
|
34412
36113
|
for (const l of users) {
|
|
34413
36114
|
const tokens = l.text.split(/\s+/).map((t) => t.toLowerCase());
|
|
@@ -34415,15 +36116,15 @@ var ExosSnmpv3UserSecurity = {
|
|
|
34415
36116
|
const authAt = tokens.indexOf("authentication");
|
|
34416
36117
|
const privAt = tokens.indexOf("privacy");
|
|
34417
36118
|
if (authAt < 0 || privAt < 0) {
|
|
34418
|
-
results.push(
|
|
36119
|
+
results.push(failAt3(id, l.node, "error", `SNMPv3 user ${name} has no ${authAt < 0 ? "authentication or privacy" : "privacy (encryption)"}.`));
|
|
34419
36120
|
continue;
|
|
34420
36121
|
}
|
|
34421
36122
|
const algorithm = tokens.slice(privAt + 1).find((t) => !["encrypted", "hex", "localized-key"].includes(t));
|
|
34422
36123
|
if (algorithm !== "aes" && algorithm !== "3des") {
|
|
34423
|
-
results.push(
|
|
36124
|
+
results.push(failAt3(id, l.node, "warning", `SNMPv3 user ${name} uses DES privacy (the default); use AES.`));
|
|
34424
36125
|
}
|
|
34425
36126
|
}
|
|
34426
|
-
return results.length > 0 ? results : [
|
|
36127
|
+
return results.length > 0 ? results : [passAt3(id, anchor, "SNMPv3 users use authentication and privacy.")];
|
|
34427
36128
|
})
|
|
34428
36129
|
};
|
|
34429
36130
|
var ExosSnmpV1V2cDisabled = {
|
|
@@ -34442,13 +36143,13 @@ var ExosSnmpV1V2cDisabled = {
|
|
|
34442
36143
|
},
|
|
34443
36144
|
tags: EXOS_TAGS("snmp", "cleartext-transmission")
|
|
34444
36145
|
},
|
|
34445
|
-
check:
|
|
36146
|
+
check: judgedOnce2((index, anchor) => {
|
|
34446
36147
|
const id = "EXOS-MGMT-008";
|
|
34447
36148
|
const last = lastMatching(index, /^(?:enable|disable)\s+snmp\s+access(?:\s+snmp-v1v2c)?\s*$/i);
|
|
34448
36149
|
if (last && /^enable/i.test(last.text)) {
|
|
34449
|
-
return [
|
|
36150
|
+
return [failAt3(id, last.node, "error", "SNMPv1/v2c access is enabled; community strings travel in cleartext. Disable it and use SNMPv3.")];
|
|
34450
36151
|
}
|
|
34451
|
-
return [
|
|
36152
|
+
return [passAt3(id, last?.node ?? anchor, last ? "SNMPv1/v2c access is disabled." : "SNMP access is not enabled (disabled by default).")];
|
|
34452
36153
|
})
|
|
34453
36154
|
};
|
|
34454
36155
|
var ExosLoginLockout = {
|
|
@@ -34465,15 +36166,15 @@ var ExosLoginLockout = {
|
|
|
34465
36166
|
},
|
|
34466
36167
|
tags: EXOS_TAGS("authentication", "brute-force-protection")
|
|
34467
36168
|
},
|
|
34468
|
-
check:
|
|
36169
|
+
check: judgedOnce2((index, anchor) => {
|
|
34469
36170
|
const id = "EXOS-MGMT-009";
|
|
34470
36171
|
const lines = matching(index, /^configure\s+account\s+\S+\s+password-policy\s+lockout-on-login-failures\s+(?:on|off)\b/i);
|
|
34471
|
-
const results = lines.filter((l) => /\boff\b/i.test(l.text)).map((l) =>
|
|
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}`));
|
|
34472
36173
|
const on = lines.find((l) => /\bon\b/i.test(l.text));
|
|
34473
36174
|
if (!on && results.length === 0) {
|
|
34474
|
-
results.push(
|
|
36175
|
+
results.push(failAt3(id, anchor, "warning", "Account lockout after failed logins is not configured (by default accounts are never locked out).", true));
|
|
34475
36176
|
}
|
|
34476
|
-
return results.length > 0 ? results : [
|
|
36177
|
+
return results.length > 0 ? results : [passAt3(id, on?.node ?? anchor, "Accounts lock out after failed logins.")];
|
|
34477
36178
|
})
|
|
34478
36179
|
};
|
|
34479
36180
|
var ExosLoginBanner = {
|
|
@@ -34487,17 +36188,17 @@ var ExosLoginBanner = {
|
|
|
34487
36188
|
remediation: "Configure a pre-login legal banner and keep it in the configuration: configure banner before-login save-to-configuration",
|
|
34488
36189
|
tags: EXOS_TAGS("legal", "management-plane")
|
|
34489
36190
|
},
|
|
34490
|
-
check:
|
|
36191
|
+
check: judgedOnce2((index, anchor) => {
|
|
34491
36192
|
const id = "EXOS-MGMT-010";
|
|
34492
36193
|
const banners = matching(index, /^configure\s+banner\b/i);
|
|
34493
36194
|
const beforeLogin = banners.find((l) => !/\bafter-login\b/i.test(l.text));
|
|
34494
|
-
if (beforeLogin) return [
|
|
36195
|
+
if (beforeLogin) return [passAt3(id, beforeLogin.node, "A pre-login banner is configured.")];
|
|
34495
36196
|
const afterLogin = banners[0];
|
|
34496
36197
|
if (afterLogin) {
|
|
34497
|
-
return [
|
|
36198
|
+
return [failAt3(id, afterLogin.node, "warning", "Only an after-login banner is configured; the legal warning must be shown before login.")];
|
|
34498
36199
|
}
|
|
34499
36200
|
return [
|
|
34500
|
-
|
|
36201
|
+
failAt3(
|
|
34501
36202
|
id,
|
|
34502
36203
|
anchor,
|
|
34503
36204
|
"info",
|
|
@@ -34521,19 +36222,19 @@ var ExosDosProtection = {
|
|
|
34521
36222
|
},
|
|
34522
36223
|
tags: EXOS_TAGS("dos-protection", "control-plane")
|
|
34523
36224
|
},
|
|
34524
|
-
check:
|
|
36225
|
+
check: judgedOnce2((index, anchor) => {
|
|
34525
36226
|
const id = "EXOS-CTRL-001";
|
|
34526
36227
|
const last = lastMatching(index, /^(?:enable|disable)\s+dos-protect(?:\s+simulated)?\s*$/i);
|
|
34527
36228
|
if (!last) {
|
|
34528
|
-
return [
|
|
36229
|
+
return [failAt3(id, anchor, "warning", "DoS protection is not enabled (disabled by default).", true)];
|
|
34529
36230
|
}
|
|
34530
36231
|
if (/^disable/i.test(last.text)) {
|
|
34531
|
-
return [
|
|
36232
|
+
return [failAt3(id, last.node, "warning", "DoS protection is disabled.")];
|
|
34532
36233
|
}
|
|
34533
36234
|
if (/\bsimulated\b/i.test(last.text)) {
|
|
34534
|
-
return [
|
|
36235
|
+
return [failAt3(id, last.node, "warning", "DoS protection runs in simulated mode, which creates no ACLs.")];
|
|
34535
36236
|
}
|
|
34536
|
-
return [
|
|
36237
|
+
return [passAt3(id, last.node, "DoS protection is enabled.")];
|
|
34537
36238
|
})
|
|
34538
36239
|
};
|
|
34539
36240
|
var ExosMacLearningLimit = {
|
|
@@ -34550,15 +36251,15 @@ var ExosMacLearningLimit = {
|
|
|
34550
36251
|
},
|
|
34551
36252
|
tags: EXOS_TAGS("port-security", "mac-flooding")
|
|
34552
36253
|
},
|
|
34553
|
-
check:
|
|
36254
|
+
check: judgedOnce2((index, anchor) => {
|
|
34554
36255
|
const id = "EXOS-CTRL-003";
|
|
34555
36256
|
const access = firstAccessPort(index);
|
|
34556
|
-
if (!access) return [
|
|
36257
|
+
if (!access) return [passAt3(id, anchor, "No untagged access ports outside the Default VLAN.")];
|
|
34557
36258
|
const limit = index.lines.find(
|
|
34558
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)
|
|
34559
36260
|
);
|
|
34560
|
-
if (limit) return [
|
|
34561
|
-
return [
|
|
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)];
|
|
34562
36263
|
})
|
|
34563
36264
|
};
|
|
34564
36265
|
var ExosMacLocking = {
|
|
@@ -34575,19 +36276,19 @@ var ExosMacLocking = {
|
|
|
34575
36276
|
},
|
|
34576
36277
|
tags: EXOS_TAGS("mac-security", "port-security")
|
|
34577
36278
|
},
|
|
34578
|
-
check:
|
|
36279
|
+
check: judgedOnce2((index, anchor) => {
|
|
34579
36280
|
const id = "EXOS-CTRL-004";
|
|
34580
36281
|
const ports = matching(index, /^enable\s+mac-locking\s+ports\s+\S+/i);
|
|
34581
36282
|
const global = lastMatching(index, /^(?:enable|disable)\s+mac-locking\s*$/i);
|
|
34582
36283
|
const globalOn = global !== void 0 && /^enable/i.test(global.text);
|
|
34583
36284
|
if (ports.length > 0 && !globalOn) {
|
|
34584
|
-
return ports.map((l) =>
|
|
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."));
|
|
34585
36286
|
}
|
|
34586
36287
|
if (globalOn && global && ports.length === 0) {
|
|
34587
|
-
return [
|
|
36288
|
+
return [failAt3(id, global.node, "info", "MAC locking is enabled on the switch but on no port.")];
|
|
34588
36289
|
}
|
|
34589
|
-
if (globalOn) return [
|
|
34590
|
-
return [
|
|
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).")];
|
|
34591
36292
|
})
|
|
34592
36293
|
};
|
|
34593
36294
|
var ExosDhcpSnooping = {
|
|
@@ -34604,16 +36305,16 @@ var ExosDhcpSnooping = {
|
|
|
34604
36305
|
},
|
|
34605
36306
|
tags: EXOS_TAGS("dhcp-snooping", "data-plane", "spoofing-prevention")
|
|
34606
36307
|
},
|
|
34607
|
-
check:
|
|
36308
|
+
check: judgedOnce2((index, anchor) => {
|
|
34608
36309
|
const id = "EXOS-DATA-002";
|
|
34609
36310
|
const snooping = matching(index, /^enable\s+ip-security\s+dhcp-snooping\s+/i);
|
|
34610
|
-
const results = snooping.filter((l) => /\bviolation-action\s+none\b/i.test(l.text)).map((l) =>
|
|
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."));
|
|
34611
36312
|
if (results.length > 0) return results;
|
|
34612
36313
|
const first2 = snooping[0];
|
|
34613
|
-
if (first2) return [
|
|
36314
|
+
if (first2) return [passAt3(id, first2.node, "DHCP snooping is enabled.")];
|
|
34614
36315
|
const access = firstAccessPort(index);
|
|
34615
|
-
if (!access) return [
|
|
34616
|
-
return [
|
|
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)];
|
|
34617
36318
|
})
|
|
34618
36319
|
};
|
|
34619
36320
|
var ExosDhcpTrustedPorts = {
|
|
@@ -34630,15 +36331,15 @@ var ExosDhcpTrustedPorts = {
|
|
|
34630
36331
|
},
|
|
34631
36332
|
tags: EXOS_TAGS("dhcp-snooping", "data-plane")
|
|
34632
36333
|
},
|
|
34633
|
-
check:
|
|
36334
|
+
check: judgedOnce2((index, anchor) => {
|
|
34634
36335
|
const id = "EXOS-DATA-003";
|
|
34635
36336
|
const snooping = matching(index, /^enable\s+ip-security\s+dhcp-snooping\s+/i)[0];
|
|
34636
|
-
if (!snooping) return [
|
|
36337
|
+
if (!snooping) return [passAt3(id, anchor, "DHCP snooping is not enabled.")];
|
|
34637
36338
|
const trusted = index.lines.find(
|
|
34638
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)
|
|
34639
36340
|
);
|
|
34640
|
-
if (trusted) return [
|
|
34641
|
-
return [
|
|
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)];
|
|
34642
36343
|
})
|
|
34643
36344
|
};
|
|
34644
36345
|
var ExosArpValidation = {
|
|
@@ -34655,13 +36356,13 @@ var ExosArpValidation = {
|
|
|
34655
36356
|
},
|
|
34656
36357
|
tags: EXOS_TAGS("arp-inspection", "data-plane", "spoofing-prevention")
|
|
34657
36358
|
},
|
|
34658
|
-
check:
|
|
36359
|
+
check: judgedOnce2((index, anchor) => {
|
|
34659
36360
|
const id = "EXOS-DATA-004";
|
|
34660
36361
|
const validation = matching(index, /^enable\s+ip-security\s+arp\s+validation\b/i)[0];
|
|
34661
|
-
if (validation) return [
|
|
36362
|
+
if (validation) return [passAt3(id, validation.node, "ARP validation is enabled.")];
|
|
34662
36363
|
const access = firstAccessPort(index);
|
|
34663
|
-
if (!access) return [
|
|
34664
|
-
return [
|
|
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)];
|
|
34665
36366
|
})
|
|
34666
36367
|
};
|
|
34667
36368
|
var ExosSourceIpLockdown = {
|
|
@@ -34678,13 +36379,13 @@ var ExosSourceIpLockdown = {
|
|
|
34678
36379
|
},
|
|
34679
36380
|
tags: EXOS_TAGS("ip-source-guard", "data-plane", "spoofing-prevention")
|
|
34680
36381
|
},
|
|
34681
|
-
check:
|
|
36382
|
+
check: judgedOnce2((index, anchor) => {
|
|
34682
36383
|
const id = "EXOS-DATA-005";
|
|
34683
36384
|
const lockdown = matching(index, /^enable\s+ip-security\s+source-ip-lockdown\s+ports\s+\S+/i)[0];
|
|
34684
|
-
if (lockdown) return [
|
|
36385
|
+
if (lockdown) return [passAt3(id, lockdown.node, "Source IP lockdown is enabled.")];
|
|
34685
36386
|
const access = firstAccessPort(index);
|
|
34686
|
-
if (!access) return [
|
|
34687
|
-
return [
|
|
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)];
|
|
34688
36389
|
})
|
|
34689
36390
|
};
|
|
34690
36391
|
var BGP_LINE = /^(?:create\s+bgp\s+neighbor|configure\s+bgp\s+as-number|enable\s+bgp\s*$)/i;
|
|
@@ -34752,15 +36453,15 @@ var ExosBgpAuthentication = {
|
|
|
34752
36453
|
},
|
|
34753
36454
|
tags: EXOS_TAGS("bgp", "authentication", "routing-security")
|
|
34754
36455
|
},
|
|
34755
|
-
check:
|
|
36456
|
+
check: judgedOnce2((index, anchor) => {
|
|
34756
36457
|
const id = "EXOS-BGP-001";
|
|
34757
36458
|
const bgp = exosBgp(index);
|
|
34758
|
-
if (bgp.neighbors.length === 0) return [
|
|
36459
|
+
if (bgp.neighbors.length === 0) return [passAt3(id, anchor, "No BGP neighbors are configured.")];
|
|
34759
36460
|
const results = bgp.neighbors.filter((n) => {
|
|
34760
36461
|
const password = bgpSetting(index, n, "password");
|
|
34761
36462
|
return password === void 0 || password.toLowerCase() === "none";
|
|
34762
|
-
}).map((n) =>
|
|
34763
|
-
return results.length > 0 ? results : [
|
|
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.")];
|
|
34764
36465
|
})
|
|
34765
36466
|
};
|
|
34766
36467
|
var ExosBgpMaxPrefix = {
|
|
@@ -34777,16 +36478,16 @@ var ExosBgpMaxPrefix = {
|
|
|
34777
36478
|
},
|
|
34778
36479
|
tags: EXOS_TAGS("bgp", "resource-exhaustion", "routing-security")
|
|
34779
36480
|
},
|
|
34780
|
-
check:
|
|
36481
|
+
check: judgedOnce2((index, anchor) => {
|
|
34781
36482
|
const id = "EXOS-BGP-002";
|
|
34782
36483
|
const bgp = exosBgp(index);
|
|
34783
36484
|
const ebgp = bgp.neighbors.filter((n) => !isIbgp(bgp, n));
|
|
34784
|
-
if (ebgp.length === 0) return [
|
|
36485
|
+
if (ebgp.length === 0) return [passAt3(id, anchor, "No eBGP neighbors are configured.")];
|
|
34785
36486
|
const results = ebgp.filter((n) => {
|
|
34786
36487
|
const limit = bgpSetting(index, n, "maximum-prefix");
|
|
34787
36488
|
return limit === void 0 || Number(limit) === 0;
|
|
34788
|
-
}).map((n) =>
|
|
34789
|
-
return results.length > 0 ? results : [
|
|
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.")];
|
|
34790
36491
|
})
|
|
34791
36492
|
};
|
|
34792
36493
|
var ExosBgpRoutePolicy = {
|
|
@@ -34803,16 +36504,16 @@ var ExosBgpRoutePolicy = {
|
|
|
34803
36504
|
},
|
|
34804
36505
|
tags: EXOS_TAGS("bgp", "route-filtering", "routing-security")
|
|
34805
36506
|
},
|
|
34806
|
-
check:
|
|
36507
|
+
check: judgedOnce2((index, anchor) => {
|
|
34807
36508
|
const id = "EXOS-BGP-003";
|
|
34808
36509
|
const bgp = exosBgp(index);
|
|
34809
36510
|
const ebgp = bgp.neighbors.filter((n) => !isIbgp(bgp, n));
|
|
34810
|
-
if (ebgp.length === 0) return [
|
|
36511
|
+
if (ebgp.length === 0) return [passAt3(id, anchor, "No eBGP neighbors are configured.")];
|
|
34811
36512
|
const results = ebgp.filter((n) => {
|
|
34812
36513
|
const policy = bgpSetting(index, n, "route-policy\\s+in");
|
|
34813
36514
|
return policy === void 0 || policy.toLowerCase() === "none";
|
|
34814
|
-
}).map((n) =>
|
|
34815
|
-
return results.length > 0 ? results : [
|
|
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.")];
|
|
34816
36517
|
})
|
|
34817
36518
|
};
|
|
34818
36519
|
var ExosBgpRouterId = {
|
|
@@ -34826,16 +36527,16 @@ var ExosBgpRouterId = {
|
|
|
34826
36527
|
remediation: "Configure the BGP router ID: configure bgp routerid <ip>",
|
|
34827
36528
|
tags: EXOS_TAGS("bgp", "routing-stability")
|
|
34828
36529
|
},
|
|
34829
|
-
check:
|
|
36530
|
+
check: judgedOnce2((index, anchor) => {
|
|
34830
36531
|
const id = "EXOS-BGP-004";
|
|
34831
36532
|
const bgp = exosBgp(index);
|
|
34832
|
-
if (!bgp.first) return [
|
|
36533
|
+
if (!bgp.first) return [passAt3(id, anchor, "BGP is not configured.")];
|
|
34833
36534
|
const routerId = lastMatching(index, /^configure\s+bgp\s+routerid\s+\S+/i);
|
|
34834
|
-
if (!routerId) return [
|
|
36535
|
+
if (!routerId) return [failAt3(id, bgp.first, "warning", "BGP router ID is not configured.", true)];
|
|
34835
36536
|
if (/\s0\.0\.0\.0\s*$/.test(routerId.text)) {
|
|
34836
|
-
return [
|
|
36537
|
+
return [failAt3(id, routerId.node, "warning", "BGP router ID is 0.0.0.0 (removed).")];
|
|
34837
36538
|
}
|
|
34838
|
-
return [
|
|
36539
|
+
return [passAt3(id, routerId.node, "BGP router ID is configured.")];
|
|
34839
36540
|
})
|
|
34840
36541
|
};
|
|
34841
36542
|
var ExosBgpGracefulRestart = {
|
|
@@ -34849,14 +36550,14 @@ var ExosBgpGracefulRestart = {
|
|
|
34849
36550
|
remediation: "Enable graceful restart (with BGP disabled): configure bgp restart both",
|
|
34850
36551
|
tags: EXOS_TAGS("bgp", "high-availability")
|
|
34851
36552
|
},
|
|
34852
|
-
check:
|
|
36553
|
+
check: judgedOnce2((index, anchor) => {
|
|
34853
36554
|
const id = "EXOS-BGP-005";
|
|
34854
36555
|
const bgp = exosBgp(index);
|
|
34855
|
-
if (!bgp.first) return [
|
|
36556
|
+
if (!bgp.first) return [passAt3(id, anchor, "BGP is not configured.")];
|
|
34856
36557
|
const restart = lastMatching(index, /^configure\s+bgp\s+restart\s+(?:none|planned|unplanned|both|aware-only)\s*$/i);
|
|
34857
|
-
if (!restart) return [
|
|
34858
|
-
if (/\snone\s*$/i.test(restart.text)) return [
|
|
34859
|
-
return [
|
|
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.")];
|
|
34860
36561
|
})
|
|
34861
36562
|
};
|
|
34862
36563
|
var exosOspfInterfaces = (index) => index.lines.flatMap((l) => {
|
|
@@ -34899,20 +36600,20 @@ var ExosOspfAuthentication = {
|
|
|
34899
36600
|
},
|
|
34900
36601
|
tags: EXOS_TAGS("ospf", "authentication", "routing-security")
|
|
34901
36602
|
},
|
|
34902
|
-
check:
|
|
36603
|
+
check: judgedOnce2((index, anchor) => {
|
|
34903
36604
|
const id = "EXOS-OSPF-001";
|
|
34904
36605
|
const active = exosOspfInterfaces(index).filter((i) => !i.passive);
|
|
34905
|
-
if (active.length === 0) return [
|
|
36606
|
+
if (active.length === 0) return [passAt3(id, anchor, "No active OSPF interfaces are configured.")];
|
|
34906
36607
|
const results = [];
|
|
34907
36608
|
for (const intf of active) {
|
|
34908
36609
|
const auth = ospfAuthOf(index, intf);
|
|
34909
36610
|
if (auth === "simple") {
|
|
34910
|
-
results.push(
|
|
36611
|
+
results.push(failAt3(id, intf.node, "error", `OSPF VLAN ${intf.vlan} uses cleartext simple-password authentication; use MD5.`));
|
|
34911
36612
|
} else if (auth === "none") {
|
|
34912
|
-
results.push(
|
|
36613
|
+
results.push(failAt3(id, intf.node, "error", `OSPF VLAN ${intf.vlan} has no authentication.`));
|
|
34913
36614
|
}
|
|
34914
36615
|
}
|
|
34915
|
-
return results.length > 0 ? results : [
|
|
36616
|
+
return results.length > 0 ? results : [passAt3(id, active[0]?.node ?? anchor, "Active OSPF interfaces use MD5 authentication.")];
|
|
34916
36617
|
})
|
|
34917
36618
|
};
|
|
34918
36619
|
var ExosOspfRouterId = {
|
|
@@ -34926,16 +36627,16 @@ var ExosOspfRouterId = {
|
|
|
34926
36627
|
remediation: "Configure the OSPF router ID: configure ospf routerid <ip>",
|
|
34927
36628
|
tags: EXOS_TAGS("ospf", "routing-stability")
|
|
34928
36629
|
},
|
|
34929
|
-
check:
|
|
36630
|
+
check: judgedOnce2((index, anchor) => {
|
|
34930
36631
|
const id = "EXOS-OSPF-002";
|
|
34931
36632
|
const first2 = exosOspfInterfaces(index)[0]?.node ?? matching(index, /^enable\s+ospf\s*$/i)[0]?.node;
|
|
34932
|
-
if (!first2) return [
|
|
36633
|
+
if (!first2) return [passAt3(id, anchor, "OSPF is not configured.")];
|
|
34933
36634
|
const routerId = lastMatching(index, /^configure\s+ospf\s+routerid\s+\S+/i);
|
|
34934
|
-
if (!routerId) return [
|
|
36635
|
+
if (!routerId) return [failAt3(id, first2, "warning", "OSPF router ID is not configured (default automatic).", true)];
|
|
34935
36636
|
if (/\s(?:automatic|0\.0\.0\.0)\s*$/i.test(routerId.text)) {
|
|
34936
|
-
return [
|
|
36637
|
+
return [failAt3(id, routerId.node, "warning", "OSPF router ID is chosen automatically; set it explicitly.")];
|
|
34937
36638
|
}
|
|
34938
|
-
return [
|
|
36639
|
+
return [passAt3(id, routerId.node, "OSPF router ID is configured.")];
|
|
34939
36640
|
})
|
|
34940
36641
|
};
|
|
34941
36642
|
var ExosOspfPassive = {
|
|
@@ -34952,18 +36653,18 @@ var ExosOspfPassive = {
|
|
|
34952
36653
|
},
|
|
34953
36654
|
tags: EXOS_TAGS("ospf", "routing-security")
|
|
34954
36655
|
},
|
|
34955
|
-
check:
|
|
36656
|
+
check: judgedOnce2((index, anchor) => {
|
|
34956
36657
|
const id = "EXOS-OSPF-003";
|
|
34957
36658
|
const interfaces = exosOspfInterfaces(index);
|
|
34958
36659
|
const first2 = interfaces[0];
|
|
34959
|
-
if (!first2) return [
|
|
36660
|
+
if (!first2) return [passAt3(id, anchor, "No OSPF interfaces are configured.")];
|
|
34960
36661
|
const allActive = interfaces.filter((i) => i.vlan === "all" && !i.passive);
|
|
34961
36662
|
if (allActive.length > 0) {
|
|
34962
|
-
return allActive.map((i) =>
|
|
36663
|
+
return allActive.map((i) => failAt3(id, i.node, "info", "OSPF is enabled on all VLANs, including host-facing ones; add those as passive."));
|
|
34963
36664
|
}
|
|
34964
36665
|
const passive = interfaces.find((i) => i.passive);
|
|
34965
|
-
if (passive) return [
|
|
34966
|
-
return [
|
|
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)];
|
|
34967
36668
|
})
|
|
34968
36669
|
};
|
|
34969
36670
|
var ExosSflow = {
|
|
@@ -34977,16 +36678,16 @@ var ExosSflow = {
|
|
|
34977
36678
|
remediation: "Enable sFlow: configure sflow collector <ip> port <port> vr VR-Default; enable sflow; enable sflow ports <ports>",
|
|
34978
36679
|
tags: EXOS_TAGS("monitoring", "traffic-analysis")
|
|
34979
36680
|
},
|
|
34980
|
-
check:
|
|
36681
|
+
check: judgedOnce2((index, anchor) => {
|
|
34981
36682
|
const id = "EXOS-SYS-005";
|
|
34982
36683
|
const enabled = lastMatching(index, /^(?:enable|disable)\s+sflow\s*$/i);
|
|
34983
36684
|
if (!enabled || /^disable/i.test(enabled.text)) {
|
|
34984
|
-
return [
|
|
36685
|
+
return [failAt3(id, enabled?.node ?? anchor, "info", "sFlow is not enabled (disabled by default).", !enabled)];
|
|
34985
36686
|
}
|
|
34986
36687
|
if (!matching(index, /^configure\s+sflow\s+collector\s+/i)[0]) {
|
|
34987
|
-
return [
|
|
36688
|
+
return [failAt3(id, enabled.node, "info", "sFlow is enabled but no collector is configured.", true)];
|
|
34988
36689
|
}
|
|
34989
|
-
return [
|
|
36690
|
+
return [passAt3(id, enabled.node, "sFlow is enabled with a collector.")];
|
|
34990
36691
|
})
|
|
34991
36692
|
};
|
|
34992
36693
|
var isGlobalDot1x = (text) => {
|
|
@@ -35010,13 +36711,13 @@ var ExosDot1xEnabled = {
|
|
|
35010
36711
|
},
|
|
35011
36712
|
tags: EXOS_TAGS("802.1x", "network-access-control")
|
|
35012
36713
|
},
|
|
35013
|
-
check:
|
|
36714
|
+
check: judgedOnce2((index, anchor) => {
|
|
35014
36715
|
const id = "EXOS-NAC-001";
|
|
35015
36716
|
const dot1x = index.lines.find((l) => isGlobalDot1x(l.text));
|
|
35016
|
-
if (dot1x) return [
|
|
36717
|
+
if (dot1x) return [passAt3(id, dot1x.node, "802.1X network login is enabled.")];
|
|
35017
36718
|
const access = firstAccessPort(index);
|
|
35018
|
-
if (!access) return [
|
|
35019
|
-
return [
|
|
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)];
|
|
35020
36721
|
})
|
|
35021
36722
|
};
|
|
35022
36723
|
var ExosNetloginPorts = {
|
|
@@ -35033,18 +36734,18 @@ var ExosNetloginPorts = {
|
|
|
35033
36734
|
},
|
|
35034
36735
|
tags: EXOS_TAGS("802.1x", "network-access-control")
|
|
35035
36736
|
},
|
|
35036
|
-
check:
|
|
36737
|
+
check: judgedOnce2((index, anchor) => {
|
|
35037
36738
|
const id = "EXOS-NAC-002";
|
|
35038
36739
|
const global = index.lines.find((l) => isGlobalDot1x(l.text));
|
|
35039
36740
|
const ports = index.lines.filter((l) => isPortDot1x(l.text));
|
|
35040
36741
|
if (ports.length > 0 && !global) {
|
|
35041
|
-
return ports.map((l) =>
|
|
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."));
|
|
35042
36743
|
}
|
|
35043
36744
|
if (global && ports.length === 0) {
|
|
35044
|
-
return [
|
|
36745
|
+
return [failAt3(id, global.node, "info", "802.1X is enabled on the switch but on no port (enable netlogin ports <ports> dot1x).", true)];
|
|
35045
36746
|
}
|
|
35046
|
-
if (global) return [
|
|
35047
|
-
return [
|
|
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).")];
|
|
35048
36749
|
})
|
|
35049
36750
|
};
|
|
35050
36751
|
var allExosRules = [
|
|
@@ -35167,7 +36868,7 @@ var wholeConfig = (ruleId, okMessage, judge) => (node, context) => {
|
|
|
35167
36868
|
if (failures.length > 0) return failures;
|
|
35168
36869
|
return vossPass(ruleId, node, typeof okMessage === "string" ? okMessage : okMessage(index));
|
|
35169
36870
|
};
|
|
35170
|
-
var
|
|
36871
|
+
var judgedOnce3 = (judge) => (node, context) => {
|
|
35171
36872
|
const index = vossIndexOf(context);
|
|
35172
36873
|
if (!index || index.first !== node) return [];
|
|
35173
36874
|
return judge(index, node);
|
|
@@ -35211,7 +36912,7 @@ var VossSysNameRequired = {
|
|
|
35211
36912
|
owner: "NetOps",
|
|
35212
36913
|
remediation: 'Configure system name: snmp-server name "<name>"'
|
|
35213
36914
|
},
|
|
35214
|
-
check:
|
|
36915
|
+
check: judgedOnce3((index, anchor) => {
|
|
35215
36916
|
const lines = index.global.filter((l) => {
|
|
35216
36917
|
const { words: words2 } = negatedWords(l);
|
|
35217
36918
|
return words2[0] === "snmp-server" && words2[1] === "name";
|
|
@@ -35246,7 +36947,7 @@ var VossNtpRequired = {
|
|
|
35246
36947
|
owner: "SecOps",
|
|
35247
36948
|
remediation: "Configure an NTP server and enable NTP: ntp server <ip-address> enable; ntp"
|
|
35248
36949
|
},
|
|
35249
|
-
check:
|
|
36950
|
+
check: judgedOnce3((index, anchor) => {
|
|
35250
36951
|
const servers = /* @__PURE__ */ new Map();
|
|
35251
36952
|
for (const line of index.global) {
|
|
35252
36953
|
const { neg, words } = negatedWords(line);
|
|
@@ -35307,7 +37008,7 @@ var VossLoggingRequired = {
|
|
|
35307
37008
|
{ type: "general", label: "monitoring" }
|
|
35308
37009
|
]
|
|
35309
37010
|
},
|
|
35310
|
-
check:
|
|
37011
|
+
check: judgedOnce3((index, anchor) => {
|
|
35311
37012
|
let sending;
|
|
35312
37013
|
const hosts = /* @__PURE__ */ new Map();
|
|
35313
37014
|
for (const line of index.global) {
|
|
@@ -35379,7 +37080,7 @@ var VossSshEnabled = {
|
|
|
35379
37080
|
{ type: "general", label: "management-plane" }
|
|
35380
37081
|
]
|
|
35381
37082
|
},
|
|
35382
|
-
check:
|
|
37083
|
+
check: judgedOnce3((index, anchor) => {
|
|
35383
37084
|
const ssh = lastExactToggle(index.global, "ssh");
|
|
35384
37085
|
if (ssh?.on) return [vossPass("VOSS-SEC-001", ssh.node, "SSH is enabled.")];
|
|
35385
37086
|
if (ssh) return [vossFail("VOSS-SEC-001", "warning", "The SSH server is disabled (no ssh).", ssh.node)];
|
|
@@ -36674,8 +38375,8 @@ var InterfaceDescriptionRequired3 = {
|
|
|
36674
38375
|
remediation: 'Add a description to the interface using "description <text>" command.'
|
|
36675
38376
|
},
|
|
36676
38377
|
check: (node) => {
|
|
36677
|
-
const
|
|
36678
|
-
if (!isPhysicalPort2(
|
|
38378
|
+
const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
|
|
38379
|
+
if (!isPhysicalPort2(interfaceName2)) {
|
|
36679
38380
|
return {
|
|
36680
38381
|
passed: true,
|
|
36681
38382
|
message: "Non-physical interface, description optional.",
|
|
@@ -36698,7 +38399,7 @@ var InterfaceDescriptionRequired3 = {
|
|
|
36698
38399
|
if (!hasDescription3(node)) {
|
|
36699
38400
|
return {
|
|
36700
38401
|
passed: false,
|
|
36701
|
-
message: `Interface ${
|
|
38402
|
+
message: `Interface ${interfaceName2} is enabled but has no description.`,
|
|
36702
38403
|
ruleId: "HUAWEI-IF-001",
|
|
36703
38404
|
nodeId: node.id,
|
|
36704
38405
|
level: "warning",
|
|
@@ -36727,8 +38428,8 @@ var AccessPortStpEdgeRequired = {
|
|
|
36727
38428
|
remediation: 'Enable STP edge-port on access ports using "stp edged-port enable".'
|
|
36728
38429
|
},
|
|
36729
38430
|
check: (node) => {
|
|
36730
|
-
const
|
|
36731
|
-
if (!isPhysicalPort2(
|
|
38431
|
+
const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
|
|
38432
|
+
if (!isPhysicalPort2(interfaceName2) || !isAccessPort3(node) || !isEnabled(node)) {
|
|
36732
38433
|
return {
|
|
36733
38434
|
passed: true,
|
|
36734
38435
|
message: "Not an active access port.",
|
|
@@ -36741,7 +38442,7 @@ var AccessPortStpEdgeRequired = {
|
|
|
36741
38442
|
if (!hasStpEdgedPort(node)) {
|
|
36742
38443
|
return {
|
|
36743
38444
|
passed: false,
|
|
36744
|
-
message: `Access port ${
|
|
38445
|
+
message: `Access port ${interfaceName2} should have "stp edged-port enable" for faster convergence.`,
|
|
36745
38446
|
ruleId: "HUAWEI-IF-002",
|
|
36746
38447
|
nodeId: node.id,
|
|
36747
38448
|
level: "warning",
|
|
@@ -36770,7 +38471,7 @@ var TrunkVlanRestriction = {
|
|
|
36770
38471
|
remediation: "Restrict allowed VLANs on trunk ports to only required VLANs."
|
|
36771
38472
|
},
|
|
36772
38473
|
check: (node) => {
|
|
36773
|
-
const
|
|
38474
|
+
const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
|
|
36774
38475
|
if (!isTrunkPort3(node) || !isEnabled(node)) {
|
|
36775
38476
|
return {
|
|
36776
38477
|
passed: true,
|
|
@@ -36785,7 +38486,7 @@ var TrunkVlanRestriction = {
|
|
|
36785
38486
|
if (allowedVlans && (equalsIgnoreCase(allowedVlans, "all") || allowedVlans.includes("1 to 4094"))) {
|
|
36786
38487
|
return {
|
|
36787
38488
|
passed: false,
|
|
36788
|
-
message: `Trunk port ${
|
|
38489
|
+
message: `Trunk port ${interfaceName2} allows all VLANs. Restrict to only required VLANs.`,
|
|
36789
38490
|
ruleId: "HUAWEI-IF-003",
|
|
36790
38491
|
nodeId: node.id,
|
|
36791
38492
|
level: "warning",
|
|
@@ -36814,8 +38515,8 @@ var PortSecurityRequired = {
|
|
|
36814
38515
|
remediation: 'Enable port security on user-facing ports using "port-security enable".'
|
|
36815
38516
|
},
|
|
36816
38517
|
check: (node) => {
|
|
36817
|
-
const
|
|
36818
|
-
if (!isPhysicalPort2(
|
|
38518
|
+
const interfaceName2 = node.id.replace(/^interface\s+/i, "").trim();
|
|
38519
|
+
if (!isPhysicalPort2(interfaceName2) || !isAccessPort3(node) || !isEnabled(node)) {
|
|
36819
38520
|
return {
|
|
36820
38521
|
passed: true,
|
|
36821
38522
|
message: "Not an active access port.",
|
|
@@ -36828,7 +38529,7 @@ var PortSecurityRequired = {
|
|
|
36828
38529
|
if (!hasPortSecurity2(node)) {
|
|
36829
38530
|
return {
|
|
36830
38531
|
passed: false,
|
|
36831
|
-
message: `Access port ${
|
|
38532
|
+
message: `Access port ${interfaceName2} does not have port security enabled.`,
|
|
36832
38533
|
ruleId: "HUAWEI-IF-004",
|
|
36833
38534
|
nodeId: node.id,
|
|
36834
38535
|
level: "info",
|
|
@@ -38493,7 +40194,7 @@ var result = (ruleId, node, passed, message, level) => ({
|
|
|
38493
40194
|
level: passed ? "info" : level,
|
|
38494
40195
|
loc: node.loc
|
|
38495
40196
|
});
|
|
38496
|
-
var
|
|
40197
|
+
var failAt4 = (ruleId, cmd, message, level) => ({
|
|
38497
40198
|
passed: false,
|
|
38498
40199
|
message,
|
|
38499
40200
|
ruleId,
|
|
@@ -38667,7 +40368,7 @@ var MikrotikDisableUnusedServices = {
|
|
|
38667
40368
|
result("MIK-SEC-001", node, false, `Service '${service}' is enabled (RouterOS default). Consider disabling it.`, "warning")
|
|
38668
40369
|
);
|
|
38669
40370
|
} else if (!is(lastSet(lines, "disabled"), "yes")) {
|
|
38670
|
-
findings.push(
|
|
40371
|
+
findings.push(failAt4("MIK-SEC-001", last, `Service '${service}' is enabled. Consider disabling it.`, "warning"));
|
|
38671
40372
|
}
|
|
38672
40373
|
}
|
|
38673
40374
|
if (findings.length > 0) return findings;
|
|
@@ -38858,7 +40559,7 @@ var MikrotikSnmpV3Required = {
|
|
|
38858
40559
|
} else if (is(security, "authorized")) {
|
|
38859
40560
|
issues.push(`SNMP community "${label}" uses SNMPv3 without encryption (security=authorized).`);
|
|
38860
40561
|
}
|
|
38861
|
-
if (issues.length > 0) findings.push(
|
|
40562
|
+
if (issues.length > 0) findings.push(failAt4("MIK-SEC-006", cmd, issues.join(" "), "error"));
|
|
38862
40563
|
}
|
|
38863
40564
|
const factoryTouched = cmds.some(
|
|
38864
40565
|
(c) => isSet(c) && (targetsDefault(c) || is(setTarget(c), "public")) || is(prop(c, "name"), "public")
|
|
@@ -39251,7 +40952,7 @@ var MikrotikFirewallRuleActions = {
|
|
|
39251
40952
|
cmds.filter(isAdd).forEach((cmd, i) => {
|
|
39252
40953
|
if (prop(cmd, "action") === void 0) {
|
|
39253
40954
|
const chain = prop(cmd, "chain") ?? "unknown";
|
|
39254
|
-
findings.push(
|
|
40955
|
+
findings.push(failAt4("MIK-FW-003", cmd, `Firewall rule ${i + 1} (chain=${chain}) has no explicit action (defaults to accept).`, "error"));
|
|
39255
40956
|
}
|
|
39256
40957
|
});
|
|
39257
40958
|
if (findings.length > 0) return findings;
|
|
@@ -39286,7 +40987,7 @@ var MikrotikStatefulFirst = {
|
|
|
39286
40987
|
const drop = inChain[firstDrop];
|
|
39287
40988
|
if (!drop) continue;
|
|
39288
40989
|
if (!inChain.slice(0, firstDrop).some(isStatefulAccept)) {
|
|
39289
|
-
findings.push(
|
|
40990
|
+
findings.push(failAt4("MIK-FW-004", drop, `The ${chain} chain default drop comes before any rule accepting established,related connections.`, "warning"));
|
|
39290
40991
|
}
|
|
39291
40992
|
}
|
|
39292
40993
|
if (findings.length > 0) return findings;
|
|
@@ -39417,7 +41118,7 @@ var MikrotikFirewallLogging = {
|
|
|
39417
41118
|
check: (node) => {
|
|
39418
41119
|
const cmds = ownCommands(node, RULE_PATH.filter);
|
|
39419
41120
|
if (!cmds) return notApplicable("MIK-FW-008", node);
|
|
39420
|
-
const findings = activeRules(cmds).filter((c) => isDropAction(c) && !isInvalidOnlyDrop(c) && !is(prop(c, "log"), "yes")).map((c) =>
|
|
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"));
|
|
39421
41122
|
if (findings.length > 0) return findings;
|
|
39422
41123
|
return result("MIK-FW-008", node, true, "Firewall drop rules have logging enabled.", "info");
|
|
39423
41124
|
}
|
|
@@ -39439,7 +41140,7 @@ var MikrotikNatOutInterface = {
|
|
|
39439
41140
|
if (!cmds) return notApplicable("MIK-NAT-001", node);
|
|
39440
41141
|
const findings = activeRules(cmds).filter(
|
|
39441
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
|
|
39442
|
-
).map((c) =>
|
|
41143
|
+
).map((c) => failAt4("MIK-NAT-001", c, "Masquerade NAT rule without out-interface or out-interface-list may NAT traffic incorrectly.", "warning"));
|
|
39443
41144
|
if (findings.length > 0) return findings;
|
|
39444
41145
|
return result("MIK-NAT-001", node, true, "NAT rules have appropriate interface specifications.", "info");
|
|
39445
41146
|
}
|
|
@@ -39462,7 +41163,7 @@ var MikrotikDstNatConfig = {
|
|
|
39462
41163
|
const scope = ["dst-address", "dst-address-list", "dst-address-type", "dst-port", "in-interface", "in-interface-list"];
|
|
39463
41164
|
const findings = activeRules(cmds).filter(
|
|
39464
41165
|
(c) => is(prop(c, "chain"), "dstnat") && is(prop(c, "action"), "dst-nat") && scope.every((p) => prop(c, p) === void 0)
|
|
39465
|
-
).map((c) =>
|
|
41166
|
+
).map((c) => failAt4("MIK-NAT-002", c, "DNAT rule without dst-address, dst-port, or in-interface is too broad.", "warning"));
|
|
39466
41167
|
if (findings.length > 0) return findings;
|
|
39467
41168
|
return result("MIK-NAT-002", node, true, "DNAT rules have appropriate match criteria.", "info");
|
|
39468
41169
|
}
|
|
@@ -39487,7 +41188,7 @@ var MikrotikInterfaceComments = {
|
|
|
39487
41188
|
if (!isSet(cmd) || isDisabledCmd(cmd)) continue;
|
|
39488
41189
|
const name = itemName(cmd);
|
|
39489
41190
|
if (name !== void 0 && !prop(cmd, "comment")) {
|
|
39490
|
-
findings.push(
|
|
41191
|
+
findings.push(failAt4("MIK-IF-001", cmd, `Interface "${name}" has no comment/description.`, "warning"));
|
|
39491
41192
|
}
|
|
39492
41193
|
}
|
|
39493
41194
|
if (findings.length > 0) return findings;
|
|
@@ -39509,7 +41210,7 @@ var MikrotikBridgeStp = {
|
|
|
39509
41210
|
check: (node) => {
|
|
39510
41211
|
const cmds = ownCommands(node, "/interface bridge");
|
|
39511
41212
|
if (!cmds) return notApplicable("MIK-IF-002", node);
|
|
39512
|
-
const findings = cmds.filter((c) => !isDisabledCmd(c) && is(prop(c, "protocol-mode"), "none")).map((c) =>
|
|
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"));
|
|
39513
41214
|
if (findings.length > 0) return findings;
|
|
39514
41215
|
return result("MIK-IF-002", node, true, "Bridge STP configuration is acceptable.", "info");
|
|
39515
41216
|
}
|
|
@@ -39534,7 +41235,7 @@ var MikrotikStaticRouteComments = {
|
|
|
39534
41235
|
if (!isAdd(cmd)) continue;
|
|
39535
41236
|
const dst = prop(cmd, "dst-address");
|
|
39536
41237
|
if (dst !== void 0 && !prop(cmd, "comment")) {
|
|
39537
|
-
findings.push(
|
|
41238
|
+
findings.push(failAt4("MIK-RTR-001", cmd, `Static route to "${dst}" has no comment.`, "info"));
|
|
39538
41239
|
}
|
|
39539
41240
|
}
|
|
39540
41241
|
if (findings.length > 0) return findings;
|
|
@@ -39560,7 +41261,7 @@ var MikrotikBgpDescription = {
|
|
|
39560
41261
|
check: (node) => {
|
|
39561
41262
|
const cmds = ownCommands(node, "/routing bgp connection");
|
|
39562
41263
|
if (!cmds) return notApplicable("MIK-RTR-002", node);
|
|
39563
|
-
const findings = cmds.filter((c) => isAdd(c) && !prop(c, "comment")).map((c) =>
|
|
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"));
|
|
39564
41265
|
if (findings.length > 0) return findings;
|
|
39565
41266
|
return result("MIK-RTR-002", node, true, "BGP connections have comments.", "info");
|
|
39566
41267
|
}
|
|
@@ -39614,7 +41315,7 @@ var MikrotikAddressComments = {
|
|
|
39614
41315
|
if (!isAdd(cmd)) continue;
|
|
39615
41316
|
const address = prop(cmd, "address");
|
|
39616
41317
|
if (address !== void 0 && !prop(cmd, "comment")) {
|
|
39617
|
-
findings.push(
|
|
41318
|
+
findings.push(failAt4("MIK-ADDR-001", cmd, `IP address "${address}" on "${prop(cmd, "interface") ?? "unknown"}" has no comment.`, "info"));
|
|
39618
41319
|
}
|
|
39619
41320
|
}
|
|
39620
41321
|
if (findings.length > 0) return findings;
|
|
@@ -39702,7 +41403,7 @@ var MikrotikBgpMd5Auth = {
|
|
|
39702
41403
|
check: (node) => {
|
|
39703
41404
|
const cmds = bgpConnections(node);
|
|
39704
41405
|
if (!cmds) return notApplicable("MIK-BGP-001", node);
|
|
39705
|
-
const findings = cmds.filter((c) => !prop(c, "tcp-md5-key")).map((c) =>
|
|
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"));
|
|
39706
41407
|
if (findings.length > 0) return findings;
|
|
39707
41408
|
return result("MIK-BGP-001", node, true, "All BGP connections have MD5 authentication configured.", "info");
|
|
39708
41409
|
}
|
|
@@ -39732,7 +41433,7 @@ var MikrotikBgpMaxPrefix = {
|
|
|
39732
41433
|
const cmds = bgpConnections(node);
|
|
39733
41434
|
if (!cmds) return notApplicable("MIK-BGP-002", node);
|
|
39734
41435
|
const limits = ["input.limit-process-routes-ipv4", "input.limit-process-routes-ipv6", "max-prefix-limit"];
|
|
39735
|
-
const findings = cmds.filter((c) => limits.every((p) => !prop(c, p))).map((c) =>
|
|
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"));
|
|
39736
41437
|
if (findings.length > 0) return findings;
|
|
39737
41438
|
return result("MIK-BGP-002", node, true, "All BGP connections have max-prefix limits configured.", "info");
|
|
39738
41439
|
}
|
|
@@ -39772,7 +41473,7 @@ var MikrotikBgpPrefixFiltering = {
|
|
|
39772
41473
|
if (outputFilters.every((p) => !prop(cmd, p))) {
|
|
39773
41474
|
issues.push(`BGP connection "${bgpLabel(cmd)}" has no output filter.`);
|
|
39774
41475
|
}
|
|
39775
|
-
if (issues.length > 0) findings.push(
|
|
41476
|
+
if (issues.length > 0) findings.push(failAt4("MIK-BGP-003", cmd, issues.join(" "), "warning"));
|
|
39776
41477
|
}
|
|
39777
41478
|
if (findings.length > 0) return findings;
|
|
39778
41479
|
return result("MIK-BGP-003", node, true, "All BGP connections have input and output filters configured.", "info");
|
|
@@ -39819,7 +41520,7 @@ var MikrotikIpsecStrongEncryption = {
|
|
|
39819
41520
|
for (const cmd of cmds) {
|
|
39820
41521
|
if (isDisabledCmd(cmd)) continue;
|
|
39821
41522
|
const weaknesses = ipsecWeaknesses(cmd, "profile");
|
|
39822
|
-
if (weaknesses.length > 0) findings.push(
|
|
41523
|
+
if (weaknesses.length > 0) findings.push(failAt4("MIK-VPN-001", cmd, weaknesses.join(". "), "error"));
|
|
39823
41524
|
}
|
|
39824
41525
|
if (findings.length > 0) return findings;
|
|
39825
41526
|
return result("MIK-VPN-001", node, true, "IPsec profiles use strong encryption.", "info");
|
|
@@ -39853,7 +41554,7 @@ var MikrotikIpsecProposalStrong = {
|
|
|
39853
41554
|
for (const cmd of cmds) {
|
|
39854
41555
|
if (isDisabledCmd(cmd)) continue;
|
|
39855
41556
|
const weaknesses = ipsecWeaknesses(cmd, "proposal");
|
|
39856
|
-
if (weaknesses.length > 0) findings.push(
|
|
41557
|
+
if (weaknesses.length > 0) findings.push(failAt4("MIK-VPN-002", cmd, weaknesses.join(". "), "error"));
|
|
39857
41558
|
}
|
|
39858
41559
|
if (findings.length > 0) return findings;
|
|
39859
41560
|
return result("MIK-VPN-002", node, true, "IPsec proposals use strong encryption.", "info");
|
|
@@ -39908,7 +41609,7 @@ var MikrotikBridgeVlanFiltering = {
|
|
|
39908
41609
|
if (name === void 0 || isDisabledCmd(cmd) || is(prop(cmd, "vlan-filtering"), "yes")) continue;
|
|
39909
41610
|
if (isSet(cmd) && prop(cmd, "vlan-filtering") === void 0) continue;
|
|
39910
41611
|
if (withVlans && !withVlans.has(name.toLowerCase())) continue;
|
|
39911
|
-
findings.push(
|
|
41612
|
+
findings.push(failAt4("MIK-VLAN-001", cmd, `Bridge "${name}" carries VLANs but does not have VLAN filtering enabled.`, "warning"));
|
|
39912
41613
|
}
|
|
39913
41614
|
if (findings.length > 0) return findings;
|
|
39914
41615
|
return result("MIK-VLAN-001", node, true, "Bridges that carry VLANs have VLAN filtering enabled.", "info");
|
|
@@ -39945,7 +41646,7 @@ var MikrotikVrrpAuthentication = {
|
|
|
39945
41646
|
if (!isAdd(cmd) || isDisabledCmd(cmd) || !is(prop(cmd, "version"), "2")) continue;
|
|
39946
41647
|
const auth = prop(cmd, "authentication");
|
|
39947
41648
|
if (auth === void 0 || is(auth, "none") || !prop(cmd, "password")) {
|
|
39948
|
-
findings.push(
|
|
41649
|
+
findings.push(failAt4("MIK-HA-001", cmd, `VRRP instance "${prop(cmd, "name") ?? "unnamed"}" has no authentication configured.`, "warning"));
|
|
39949
41650
|
}
|
|
39950
41651
|
}
|
|
39951
41652
|
if (findings.length > 0) return findings;
|
|
@@ -39988,7 +41689,7 @@ var MikrotikOspfAuthentication = {
|
|
|
39988
41689
|
if (!isAdd(cmd) || isDisabledCmd(cmd) || isPassive(cmd)) continue;
|
|
39989
41690
|
const auth = prop(cmd, "auth");
|
|
39990
41691
|
if (auth === void 0 || is(auth, "none")) {
|
|
39991
|
-
findings.push(
|
|
41692
|
+
findings.push(failAt4("MIK-HA-002", cmd, `OSPF interface-template for "${prop(cmd, "interfaces") ?? prop(cmd, "networks") ?? "unnamed"}" has no authentication.`, "warning"));
|
|
39992
41693
|
}
|
|
39993
41694
|
}
|
|
39994
41695
|
if (findings.length > 0) return findings;
|
|
@@ -40424,11 +42125,11 @@ var InterfaceDescriptionRequired4 = {
|
|
|
40424
42125
|
remediation: 'Add description to interface: interface "<name>" > description "<description>"'
|
|
40425
42126
|
},
|
|
40426
42127
|
check: (node, context) => {
|
|
40427
|
-
const
|
|
42128
|
+
const interfaceName2 = getInterfaceName3(node);
|
|
40428
42129
|
if (isProtocolInterfaceReference(context, node)) {
|
|
40429
42130
|
return protocolReferencePass("NOKIA-IF-001", node);
|
|
40430
42131
|
}
|
|
40431
|
-
if (isSystemInterface(
|
|
42132
|
+
if (isSystemInterface(interfaceName2)) {
|
|
40432
42133
|
return {
|
|
40433
42134
|
passed: true,
|
|
40434
42135
|
message: "System interface, description optional.",
|
|
@@ -40451,7 +42152,7 @@ var InterfaceDescriptionRequired4 = {
|
|
|
40451
42152
|
if (!hasDescription4(node)) {
|
|
40452
42153
|
return {
|
|
40453
42154
|
passed: false,
|
|
40454
|
-
message: `Interface "${
|
|
42155
|
+
message: `Interface "${interfaceName2}" has no description.`,
|
|
40455
42156
|
ruleId: "NOKIA-IF-001",
|
|
40456
42157
|
nodeId: node.id,
|
|
40457
42158
|
level: "warning",
|
|
@@ -40460,7 +42161,7 @@ var InterfaceDescriptionRequired4 = {
|
|
|
40460
42161
|
}
|
|
40461
42162
|
return {
|
|
40462
42163
|
passed: true,
|
|
40463
|
-
message: `Interface "${
|
|
42164
|
+
message: `Interface "${interfaceName2}" has description.`,
|
|
40464
42165
|
ruleId: "NOKIA-IF-001",
|
|
40465
42166
|
nodeId: node.id,
|
|
40466
42167
|
level: "info",
|
|
@@ -40480,7 +42181,7 @@ var InterfaceAddressRequired = {
|
|
|
40480
42181
|
remediation: 'Configure IP address: interface "<name>" > address <ip-prefix> (classic CLI) or > ipv4 > primary > address <ip> and prefix-length <n> (MD-CLI)'
|
|
40481
42182
|
},
|
|
40482
42183
|
check: (node, context) => {
|
|
40483
|
-
const
|
|
42184
|
+
const interfaceName2 = getInterfaceName3(node);
|
|
40484
42185
|
if (isProtocolInterfaceReference(context, node)) {
|
|
40485
42186
|
return protocolReferencePass("NOKIA-IF-002", node);
|
|
40486
42187
|
}
|
|
@@ -40497,7 +42198,7 @@ var InterfaceAddressRequired = {
|
|
|
40497
42198
|
if (!hasIpAddress2(node)) {
|
|
40498
42199
|
return {
|
|
40499
42200
|
passed: false,
|
|
40500
|
-
message: `Interface "${
|
|
42201
|
+
message: `Interface "${interfaceName2}" has no IP address configured.`,
|
|
40501
42202
|
ruleId: "NOKIA-IF-002",
|
|
40502
42203
|
nodeId: node.id,
|
|
40503
42204
|
level: "warning",
|
|
@@ -40506,7 +42207,7 @@ var InterfaceAddressRequired = {
|
|
|
40506
42207
|
}
|
|
40507
42208
|
return {
|
|
40508
42209
|
passed: true,
|
|
40509
|
-
message: `Interface "${
|
|
42210
|
+
message: `Interface "${interfaceName2}" has IP address: ${getIpAddress(node)}`,
|
|
40510
42211
|
ruleId: "NOKIA-IF-002",
|
|
40511
42212
|
nodeId: node.id,
|
|
40512
42213
|
level: "info",
|
|
@@ -44068,6 +45769,7 @@ var allRules = [
|
|
|
44068
45769
|
...allCommonRules,
|
|
44069
45770
|
// Cisco-specific rules
|
|
44070
45771
|
...allCiscoRules,
|
|
45772
|
+
...allNxosRules,
|
|
44071
45773
|
// Juniper-specific rules
|
|
44072
45774
|
...allJuniperRules,
|
|
44073
45775
|
// Aruba HPE rules (all platforms)
|
|
@@ -44097,7 +45799,7 @@ var builtInRuleIds = new Set(allRules.map((rule) => rule.id));
|
|
|
44097
45799
|
function builtInRuleDocsUrl(ruleId) {
|
|
44098
45800
|
return builtInRuleIds.has(ruleId) ? ruleDocsUrl(ruleId) : void 0;
|
|
44099
45801
|
}
|
|
44100
|
-
var ciscoRulesFor = (vendorId) => allCiscoRules.filter((rule) => ruleAppliesToVendor(rule, vendorId));
|
|
45802
|
+
var ciscoRulesFor = (vendorId) => [...allCiscoRules, ...allNxosRules].filter((rule) => ruleAppliesToVendor(rule, vendorId));
|
|
44101
45803
|
var vendorRulesRegistry = {
|
|
44102
45804
|
// Cisco platforms share one rule array; each rule's `vendor` field says
|
|
44103
45805
|
// whether it also applies to NX-OS (decision 0002 point 5).
|
|
@@ -44197,7 +45899,7 @@ function resolveVersion(injected) {
|
|
|
44197
45899
|
|
|
44198
45900
|
// src/sarif.ts
|
|
44199
45901
|
var TOOL_VERSION = resolveVersion(
|
|
44200
|
-
true ? "0.
|
|
45902
|
+
true ? "0.13.0" : void 0
|
|
44201
45903
|
);
|
|
44202
45904
|
var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
|
|
44203
45905
|
function cweNumber(cweId) {
|
|
@@ -46704,7 +48406,7 @@ async function exitIfVendorUndetected() {
|
|
|
46704
48406
|
}
|
|
46705
48407
|
}
|
|
46706
48408
|
var program = new Command2();
|
|
46707
|
-
var cliVersion = resolveVersion(true ? "0.
|
|
48409
|
+
var cliVersion = resolveVersion(true ? "0.13.0" : void 0);
|
|
46708
48410
|
var pluginPackLoaders = [];
|
|
46709
48411
|
var pluginRequests = pluginRequestsFromEnv(process.env);
|
|
46710
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(
|