@sentriflow/cli 0.11.0-rc.1 → 0.11.0-rc.3
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 +924 -447
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ var CiscoIOSSchema = {
|
|
|
44
44
|
{ pattern: /^class-map\s+\S+/i, depth: 0 },
|
|
45
45
|
{ pattern: /^policy-map\s+\S+/i, depth: 0 },
|
|
46
46
|
// Line and management
|
|
47
|
-
{ pattern: /^line\s+(vty|
|
|
47
|
+
{ pattern: /^line\s+(vty|con(?:sole)?|aux|tty)\s+\S+/i, depth: 0 },
|
|
48
48
|
{ pattern: /^line\s+\d+/i, depth: 0 },
|
|
49
49
|
// Object groups (ASA/IOS)
|
|
50
50
|
{ pattern: /^object-group\s+\S+/i, depth: 0 },
|
|
@@ -2317,6 +2317,7 @@ var NokiaSROSSchema = {
|
|
|
2317
2317
|
};
|
|
2318
2318
|
|
|
2319
2319
|
// ../core/src/parser/vendors/cumulus-linux.ts
|
|
2320
|
+
var NVUE_STARTUP_YAML = /^-[ \t]+(set|header):[ \t]*$/m;
|
|
2320
2321
|
var CumulusLinuxSchema = {
|
|
2321
2322
|
id: "cumulus-linux",
|
|
2322
2323
|
name: "NVIDIA Cumulus Linux",
|
|
@@ -2411,6 +2412,12 @@ var CumulusLinuxSchema = {
|
|
|
2411
2412
|
/^exit-address-family$/i,
|
|
2412
2413
|
/^exit-vrf$/i,
|
|
2413
2414
|
/^exit$/i
|
|
2415
|
+
],
|
|
2416
|
+
unsupportedFormats: [
|
|
2417
|
+
{
|
|
2418
|
+
pattern: NVUE_STARTUP_YAML,
|
|
2419
|
+
message: 'this file looks like NVUE startup.yaml, which is not supported: export the configuration with "nv config show -o commands" and scan that output'
|
|
2420
|
+
}
|
|
2414
2421
|
]
|
|
2415
2422
|
};
|
|
2416
2423
|
|
|
@@ -3743,6 +3750,37 @@ var PANOS_XML_MARKERS = [
|
|
|
3743
3750
|
var VYOS_VERSION_FOOTER = /^(\/\/|\/\*)\s*(===\s*)?(vyos|vyatta)-config-version:/m;
|
|
3744
3751
|
var VYOS_FOOTER_SAMPLE = 4e3;
|
|
3745
3752
|
var DETECTION_SAMPLE = 2e3;
|
|
3753
|
+
var VYOS_SET_MARKERS = [
|
|
3754
|
+
/^set\s+(interfaces\s+ethernet|service\s+ssh(?!\s+(protocol|description|tag)\s)|nat\s+(source|destination|static)|nat66\s+(source|destination)|firewall\s+name|high-availability|vpn\s+ipsec|traffic-policy|container\s+name|port-forward)\s+/m,
|
|
3755
|
+
/^set\s+firewall\s+(all-ping|broadcast-ping|global-options|group|ip-src-route|ipv6-name|ipv6-receive-redirects|ipv6-src-route|log-martians|modify|receive-redirects|send-redirects|source-validation|syn-cookies|twa-hazards-protection|zone|options\s+mss-clamp|(ipv4|ipv6)\s+(forward|input|output|prerouting|name))\s/m,
|
|
3756
|
+
/^set\s+service\s+((gui|ubnt-discover|unms|snmp|dhcp-server|dhcpv6-server|dhcp-relay|dhcpv6-relay|dns|lldp|ntp|https|mdns|upnp|router-advert|console-server|conntrack-sync|webproxy|tftp-server|pppoe-server|broadcast-relay|telnet)\s+(?!(protocol|description|tag)\s)|nat\s+rule\s)/m,
|
|
3757
|
+
/^set\s+interfaces\s+(switch\s+switch\d|(loopback|dummy|tunnel|vti|openvpn|pppoe|pseudo-ethernet|vxlan|l2tpv3|wirelessmodem|macsec|geneve|sstpc|virtual-ethernet|ipv6-tunnel)\s)/m,
|
|
3758
|
+
/^set\s+system\s+(offload|analytics-handler|crash-handler|traffic-analysis|config-management|syslog\s+global|login\s+user\s+\S+\s+authentication\s+plaintext-password)\s/m,
|
|
3759
|
+
// Routing (JunOS uses routing-options and policy-options)
|
|
3760
|
+
/^set\s+(protocols\s+static\s+route6?|protocols\s+bgp\s+system-as|policy\s+(route-map|prefix-list6?|access-list6?|as-path-list|community-list|large-community-list))\s+/m,
|
|
3761
|
+
/^set\s+interfaces\s+(bonding\s+bond\d+|bridge\s+br\d+|wireguard\s+wg\d+)/m
|
|
3762
|
+
];
|
|
3763
|
+
var JUNOS_SET_MARKER = /^set\s+(version\s|(access|access-profile|accounting-options|applications|apply-groups|bridge-domains|chassis|class-of-service|dynamic-profiles|ethernet-switching-options|event-options|forwarding-options|groups|logical-systems|multi-chassis|multicast-snooping-options|poe|policy-options|routing-instances|routing-options|security|services|switch-options|virtual-chassis|virtual-network-functions|vlans|vmhost)\s|system\s+(root-authentication|services|extensions|management-instance)\s|firewall\s+(family|filter|policer|interface-set|three-color-policer|hierarchical-policer|load-balance-group|atm-policer)\s|interfaces\s+((ge|xe|et|fe|mge|sxe|xt|lt|gr|ip|ae)-\d|(ae|lo|fxp|em|me|reth|st|eth|re|fti|demux|pp|vme|bme|jsrv)\d|(irb|vlan|dsc|interface-range)[\s.])|protocols\s+(bgp\s+group|ospf3|evpn|igmp-snooping|lldp|lldp-med|rstp|vstp|mstp|dot1x|rsvp|ldp|l2circuit|router-advertisement|layer2-control|oam)\s)/m;
|
|
3764
|
+
var SHARED_SET_STATEMENT = /^set\s+(system|chassis|interfaces|protocols|policy-options|routing-options|routing-instances|security|firewall)/m;
|
|
3765
|
+
var SET_FORM_SCAN = 1024 * 1024;
|
|
3766
|
+
var SET_FORM_LINE = 256;
|
|
3767
|
+
function setFormVendor(configText) {
|
|
3768
|
+
const text = configText.length > SET_FORM_SCAN ? configText.slice(0, SET_FORM_SCAN) : configText;
|
|
3769
|
+
const end = text.length;
|
|
3770
|
+
let offset = 0;
|
|
3771
|
+
while (offset < end) {
|
|
3772
|
+
const newline = text.indexOf("\n", offset);
|
|
3773
|
+
const lineEnd = newline === -1 || newline > end ? end : newline;
|
|
3774
|
+
if (text.startsWith("set", offset)) {
|
|
3775
|
+
const line = text.slice(offset, Math.min(lineEnd, offset + SET_FORM_LINE));
|
|
3776
|
+
if (VYOS_SET_MARKERS.some((re) => re.test(line))) return VyOSSchema;
|
|
3777
|
+
if (JUNOS_SET_MARKER.test(line)) return JuniperJunOSSchema;
|
|
3778
|
+
}
|
|
3779
|
+
if (newline === -1) break;
|
|
3780
|
+
offset = newline + 1;
|
|
3781
|
+
}
|
|
3782
|
+
return null;
|
|
3783
|
+
}
|
|
3746
3784
|
var MAX_COMMENT_PREAMBLE = 256 * 1024;
|
|
3747
3785
|
var PREAMBLE_LINE = /^[ \t]*(?:!|#|;|\/\/|\r?$)/;
|
|
3748
3786
|
function configurationStart(configText) {
|
|
@@ -3763,7 +3801,7 @@ function detectionSample(configText) {
|
|
|
3763
3801
|
return `${configText.slice(0, DETECTION_SAMPLE)}
|
|
3764
3802
|
${configText.slice(start, start + DETECTION_SAMPLE)}`;
|
|
3765
3803
|
}
|
|
3766
|
-
function matchVendorPatterns(configText) {
|
|
3804
|
+
function matchVendorPatterns(configText, notes) {
|
|
3767
3805
|
const sampleText = detectionSample(configText);
|
|
3768
3806
|
const lines = sampleText.split("\n");
|
|
3769
3807
|
if (looksLikeXml(sampleText)) {
|
|
@@ -3904,7 +3942,7 @@ function matchVendorPatterns(configText) {
|
|
|
3904
3942
|
if (/^\s*(device-group|template|template-stack|shared)\s*\{/m.test(sampleText)) {
|
|
3905
3943
|
return PaloAltoPANOSSchema;
|
|
3906
3944
|
}
|
|
3907
|
-
if (
|
|
3945
|
+
if (VYOS_SET_MARKERS.some((re) => re.test(sampleText))) {
|
|
3908
3946
|
return VyOSSchema;
|
|
3909
3947
|
}
|
|
3910
3948
|
if (hasVyOSServiceBlock(lines)) {
|
|
@@ -3916,21 +3954,9 @@ function matchVendorPatterns(configText) {
|
|
|
3916
3954
|
if (hasVyOSEthernetBlock(lines)) {
|
|
3917
3955
|
return VyOSSchema;
|
|
3918
3956
|
}
|
|
3919
|
-
if (/^set\s+interfaces\s+ethernet\s+eth\d+/m.test(sampleText)) {
|
|
3920
|
-
return VyOSSchema;
|
|
3921
|
-
}
|
|
3922
3957
|
if (hasVyOSFirewallRuleBlock(lines)) {
|
|
3923
3958
|
return VyOSSchema;
|
|
3924
3959
|
}
|
|
3925
|
-
if (/^set\s+firewall\s+zone\s+/m.test(sampleText)) {
|
|
3926
|
-
return VyOSSchema;
|
|
3927
|
-
}
|
|
3928
|
-
if (/^set\s+(protocols\s+static\s+route6?|protocols\s+bgp\s+system-as|policy\s+(route-map|prefix-list6?|access-list6?|as-path-list|community-list|large-community-list))\s+/m.test(sampleText)) {
|
|
3929
|
-
return VyOSSchema;
|
|
3930
|
-
}
|
|
3931
|
-
if (/^set\s+interfaces\s+(bonding\s+bond\d+|bridge\s+br\d+|wireguard\s+wg\d+)/m.test(sampleText)) {
|
|
3932
|
-
return VyOSSchema;
|
|
3933
|
-
}
|
|
3934
3960
|
if (hasVyOSHighAvailabilityBlock(lines)) {
|
|
3935
3961
|
return VyOSSchema;
|
|
3936
3962
|
}
|
|
@@ -3946,9 +3972,14 @@ function matchVendorPatterns(configText) {
|
|
|
3946
3972
|
if (/^\s*(system|chassis|interfaces|protocols|policy-options|routing-options|routing-instances|security|firewall|class-of-service|vlans|bridge-domains)\s*\{/m.test(sampleText)) {
|
|
3947
3973
|
return JuniperJunOSSchema;
|
|
3948
3974
|
}
|
|
3949
|
-
if (
|
|
3975
|
+
if (JUNOS_SET_MARKER.test(sampleText)) {
|
|
3950
3976
|
return JuniperJunOSSchema;
|
|
3951
3977
|
}
|
|
3978
|
+
if (SHARED_SET_STATEMENT.test(sampleText)) {
|
|
3979
|
+
const marked = setFormVendor(configText);
|
|
3980
|
+
if (!marked && notes) notes.sharedSetOnly = true;
|
|
3981
|
+
return marked ?? JuniperJunOSSchema;
|
|
3982
|
+
}
|
|
3952
3983
|
if (/^\s*(ge|xe|et|ae|lo|irb|vlan|em|fxp)-[\d\/:.]+\s*\{/m.test(sampleText)) {
|
|
3953
3984
|
return JuniperJunOSSchema;
|
|
3954
3985
|
}
|
|
@@ -4267,7 +4298,7 @@ function matchVendorPatterns(configText) {
|
|
|
4267
4298
|
if (/^return\s*$/m.test(sampleText)) {
|
|
4268
4299
|
return HuaweiVRPSchema;
|
|
4269
4300
|
}
|
|
4270
|
-
return null;
|
|
4301
|
+
return /^set\s/m.test(sampleText) ? setFormVendor(configText) : null;
|
|
4271
4302
|
}
|
|
4272
4303
|
var UNSUPPORTED_PLATFORMS = [
|
|
4273
4304
|
{
|
|
@@ -4310,6 +4341,10 @@ var UNSUPPORTED_PLATFORMS = [
|
|
|
4310
4341
|
// `import route-target` with the values on the following lines (IOS: `route-target import 1:1`)
|
|
4311
4342
|
/^\s+(import|export)\s+route-target\s*$/m
|
|
4312
4343
|
]
|
|
4344
|
+
},
|
|
4345
|
+
{
|
|
4346
|
+
name: 'Cumulus Linux NVUE startup.yaml (export it with "nv config show -o commands")',
|
|
4347
|
+
patterns: [NVUE_STARTUP_YAML]
|
|
4313
4348
|
}
|
|
4314
4349
|
];
|
|
4315
4350
|
var IOS_STRONG_PATTERNS = [
|
|
@@ -4341,7 +4376,15 @@ function detectVendorWithConfidence(configText) {
|
|
|
4341
4376
|
};
|
|
4342
4377
|
}
|
|
4343
4378
|
}
|
|
4344
|
-
const
|
|
4379
|
+
const notes = { sharedSetOnly: false };
|
|
4380
|
+
const matched = matchVendorPatterns(configText, notes);
|
|
4381
|
+
if (matched && notes.sharedSetOnly) {
|
|
4382
|
+
return {
|
|
4383
|
+
vendor: matched,
|
|
4384
|
+
confidence: "low",
|
|
4385
|
+
reason: "Set-form statements that both JunOS and VyOS/EdgeOS write, with no marker for either; assuming JunOS, but it may be VyOS"
|
|
4386
|
+
};
|
|
4387
|
+
}
|
|
4345
4388
|
if (matched) {
|
|
4346
4389
|
return {
|
|
4347
4390
|
vendor: matched,
|
|
@@ -4643,6 +4686,7 @@ var SchemaAwareParser = class {
|
|
|
4643
4686
|
}
|
|
4644
4687
|
this.warnings = [];
|
|
4645
4688
|
this.longLines = [];
|
|
4689
|
+
this.reportUnsupportedFormat(configText);
|
|
4646
4690
|
const shortened = /* @__PURE__ */ new Set();
|
|
4647
4691
|
const lines = rawLines.map((line, i) => {
|
|
4648
4692
|
const bounded = boundLine(line);
|
|
@@ -4729,6 +4773,23 @@ var SchemaAwareParser = class {
|
|
|
4729
4773
|
}
|
|
4730
4774
|
return false;
|
|
4731
4775
|
}
|
|
4776
|
+
/**
|
|
4777
|
+
* Reports the first of the vendor's unsupported formats the text matches
|
|
4778
|
+
* (see VendorSchema.unsupportedFormats), once, at its first matching line.
|
|
4779
|
+
*/
|
|
4780
|
+
reportUnsupportedFormat(text) {
|
|
4781
|
+
for (const format2 of this.vendor.unsupportedFormats ?? []) {
|
|
4782
|
+
const match = format2.pattern.exec(text);
|
|
4783
|
+
if (!match) continue;
|
|
4784
|
+
const lineIndex = text.slice(0, match.index).split("\n").length - 1;
|
|
4785
|
+
this.warnings.push({
|
|
4786
|
+
code: "UNSUPPORTED_FORMAT",
|
|
4787
|
+
message: format2.message,
|
|
4788
|
+
lines: [this.options.startLine + lineIndex]
|
|
4789
|
+
});
|
|
4790
|
+
return;
|
|
4791
|
+
}
|
|
4792
|
+
}
|
|
4732
4793
|
/**
|
|
4733
4794
|
* Reports lines in a flat, full-path form that were not rebuilt into a
|
|
4734
4795
|
* hierarchy (see VendorSchema.flatFormatLine).
|
|
@@ -7246,6 +7307,46 @@ var RuleEngine = class {
|
|
|
7246
7307
|
}
|
|
7247
7308
|
};
|
|
7248
7309
|
|
|
7310
|
+
// ../core/src/engine/ancestors.ts
|
|
7311
|
+
var parentsByAst = /* @__PURE__ */ new WeakMap();
|
|
7312
|
+
function readParents(ast) {
|
|
7313
|
+
const parents = /* @__PURE__ */ new Map();
|
|
7314
|
+
const stack = [];
|
|
7315
|
+
for (const root of ast) {
|
|
7316
|
+
parents.set(root, null);
|
|
7317
|
+
stack.push(root);
|
|
7318
|
+
}
|
|
7319
|
+
let node = stack.pop();
|
|
7320
|
+
while (node) {
|
|
7321
|
+
for (const child of node.children) {
|
|
7322
|
+
parents.set(child, node);
|
|
7323
|
+
stack.push(child);
|
|
7324
|
+
}
|
|
7325
|
+
node = stack.pop();
|
|
7326
|
+
}
|
|
7327
|
+
return parents;
|
|
7328
|
+
}
|
|
7329
|
+
function pathTo(ast, parents, node) {
|
|
7330
|
+
const path = [];
|
|
7331
|
+
let current = node;
|
|
7332
|
+
for (; ; ) {
|
|
7333
|
+
const parent = parents.get(current);
|
|
7334
|
+
if (parent === void 0) return void 0;
|
|
7335
|
+
if (parent === null) return ast.includes(current) ? path.reverse() : void 0;
|
|
7336
|
+
if (!parent.children.includes(current)) return void 0;
|
|
7337
|
+
path.push(parent);
|
|
7338
|
+
current = parent;
|
|
7339
|
+
}
|
|
7340
|
+
}
|
|
7341
|
+
function ancestorsOf(ast, node) {
|
|
7342
|
+
const known = parentsByAst.get(ast);
|
|
7343
|
+
const path = known ? pathTo(ast, known, node) : void 0;
|
|
7344
|
+
if (path) return path;
|
|
7345
|
+
const parents = readParents(ast);
|
|
7346
|
+
parentsByAst.set(ast, parents);
|
|
7347
|
+
return pathTo(ast, parents, node);
|
|
7348
|
+
}
|
|
7349
|
+
|
|
7249
7350
|
// ../core/src/helpers/index.ts
|
|
7250
7351
|
var helpers_exports = {};
|
|
7251
7352
|
__export(helpers_exports, {
|
|
@@ -7557,7 +7658,14 @@ var canonicalIpv6 = (text) => {
|
|
|
7557
7658
|
return `${words.slice(0, best).join(":")}::${words.slice(best + bestLen).join(":")}`;
|
|
7558
7659
|
};
|
|
7559
7660
|
var bgpNeighborKey = (id) => canonicalIpv6(id) ?? id;
|
|
7560
|
-
var isBgpTemplateKind = (word) => word === "peer-session" || word === "peer-policy";
|
|
7661
|
+
var isBgpTemplateKind = (word) => word === "peer" || word === "peer-session" || word === "peer-policy";
|
|
7662
|
+
var descendantsOf = (node) => (node.children ?? []).flatMap((child) => [child, ...descendantsOf(child)]);
|
|
7663
|
+
var asNeighborLine = (id, line) => ({
|
|
7664
|
+
...line,
|
|
7665
|
+
id: `neighbor ${id} ${line.id}`,
|
|
7666
|
+
params: ["neighbor", id, ...line.params],
|
|
7667
|
+
children: []
|
|
7668
|
+
});
|
|
7561
7669
|
var resolveBgpNeighbors = (routerBgp) => {
|
|
7562
7670
|
const own = /* @__PURE__ */ new Map();
|
|
7563
7671
|
const groupNames = /* @__PURE__ */ new Set();
|
|
@@ -7570,7 +7678,8 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7570
7678
|
const raw = params[1];
|
|
7571
7679
|
if (head === "neighbor" && raw) {
|
|
7572
7680
|
const id = bgpNeighborKey(raw);
|
|
7573
|
-
|
|
7681
|
+
const section = child.children?.length ? descendantsOf(child).map((line) => asNeighborLine(id, line)) : [];
|
|
7682
|
+
own.set(id, [...own.get(id) ?? [], child, ...section]);
|
|
7574
7683
|
const k2 = params[2]?.toLowerCase();
|
|
7575
7684
|
const k3 = params[3]?.toLowerCase();
|
|
7576
7685
|
if (k2 === "peer-group") {
|
|
@@ -7585,7 +7694,7 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7585
7694
|
} else if (head === "template") {
|
|
7586
7695
|
const kind = params[1]?.toLowerCase();
|
|
7587
7696
|
const name = params[2];
|
|
7588
|
-
if (isBgpTemplateKind(kind) && name) templates.set(`${kind} ${name}`, child
|
|
7697
|
+
if (isBgpTemplateKind(kind) && name) templates.set(`${kind} ${name}`, descendantsOf(child));
|
|
7589
7698
|
}
|
|
7590
7699
|
if (child.children?.length) visit(child);
|
|
7591
7700
|
}
|
|
@@ -7615,9 +7724,7 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7615
7724
|
const kind = line.params[3]?.toLowerCase();
|
|
7616
7725
|
const name = line.params[4];
|
|
7617
7726
|
if (!isBgpTemplateKind(kind) || !name) continue;
|
|
7618
|
-
for (const t of expandTemplate(kind, name, /* @__PURE__ */ new Set()))
|
|
7619
|
-
inherited.push({ ...t, id: `neighbor ${id} ${t.id}`, params: ["neighbor", id, ...t.params], children: [] });
|
|
7620
|
-
}
|
|
7727
|
+
for (const t of expandTemplate(kind, name, /* @__PURE__ */ new Set())) inherited.push(asNeighborLine(id, t));
|
|
7621
7728
|
}
|
|
7622
7729
|
return inherited.length > 0 ? [...lines, ...inherited] : lines;
|
|
7623
7730
|
};
|
|
@@ -8903,11 +9010,11 @@ var hasWeakUsernamePassword = (node) => {
|
|
|
8903
9010
|
}
|
|
8904
9011
|
return false;
|
|
8905
9012
|
};
|
|
9013
|
+
var IOS_LINE_SECTION = /^line\s+(?:con(?:s(?:o(?:l(?:e)?)?)?)?|aux|tty|vty|\d+)(?:\s|$)/i;
|
|
8906
9014
|
var isLineConfigPassword = (ast, node) => {
|
|
8907
9015
|
const parent = findParentSection(ast, node);
|
|
8908
9016
|
if (!parent) return false;
|
|
8909
|
-
|
|
8910
|
-
return parentId.startsWith("line vty") || parentId.startsWith("line console") || parentId.startsWith("line aux");
|
|
9017
|
+
return IOS_LINE_SECTION.test(parent.id.trim());
|
|
8911
9018
|
};
|
|
8912
9019
|
var getSshVersion = (node) => {
|
|
8913
9020
|
if (includesIgnoreCase(node.rawText, "ip ssh version")) {
|
|
@@ -12585,6 +12692,11 @@ var getDestinationZones = (ruleNode) => {
|
|
|
12585
12692
|
if (!to?.children) return [];
|
|
12586
12693
|
return to.children.map((child) => child?.id?.trim() ?? "").filter(Boolean);
|
|
12587
12694
|
};
|
|
12695
|
+
var memberValues = (cmd) => {
|
|
12696
|
+
const rest = (cmd.id ?? "").trim().replace(/;\s*$/, "").split(/\s+/).slice(1).join(" ");
|
|
12697
|
+
const tokens = rest.replace(/[[\]]/g, " ").match(/"[^"]*"|\S+/g) ?? [];
|
|
12698
|
+
return tokens.map((token) => token.replace(/^"(.*)"$/, "$1").trim()).filter(Boolean);
|
|
12699
|
+
};
|
|
12588
12700
|
var getApplications = (ruleNode) => {
|
|
12589
12701
|
if (!ruleNode?.children) return [];
|
|
12590
12702
|
const application = findStanza6(ruleNode, "application");
|
|
@@ -12595,10 +12707,7 @@ var getApplications = (ruleNode) => {
|
|
|
12595
12707
|
(child) => child?.id?.toLowerCase().startsWith("application ")
|
|
12596
12708
|
);
|
|
12597
12709
|
if (appCommands.length > 0) {
|
|
12598
|
-
return appCommands.
|
|
12599
|
-
const parts = cmd?.id?.split(/\s+/) ?? [];
|
|
12600
|
-
return parts.slice(1).join(" ").replace(/;$/, "").trim();
|
|
12601
|
-
}).filter(Boolean);
|
|
12710
|
+
return appCommands.flatMap((cmd) => memberValues(cmd));
|
|
12602
12711
|
}
|
|
12603
12712
|
return [];
|
|
12604
12713
|
};
|
|
@@ -12619,10 +12728,9 @@ var hasAnySource = (ruleNode) => {
|
|
|
12619
12728
|
(child) => child?.id?.toLowerCase().startsWith("source ")
|
|
12620
12729
|
);
|
|
12621
12730
|
if (sourceCommands.length > 0) {
|
|
12622
|
-
return sourceCommands.some(
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
});
|
|
12731
|
+
return sourceCommands.some(
|
|
12732
|
+
(cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
|
|
12733
|
+
);
|
|
12626
12734
|
}
|
|
12627
12735
|
return false;
|
|
12628
12736
|
};
|
|
@@ -12639,10 +12747,9 @@ var hasAnyDestination = (ruleNode) => {
|
|
|
12639
12747
|
(child) => child?.id?.toLowerCase().startsWith("destination ")
|
|
12640
12748
|
);
|
|
12641
12749
|
if (destCommands.length > 0) {
|
|
12642
|
-
return destCommands.some(
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
});
|
|
12750
|
+
return destCommands.some(
|
|
12751
|
+
(cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
|
|
12752
|
+
);
|
|
12646
12753
|
}
|
|
12647
12754
|
return false;
|
|
12648
12755
|
};
|
|
@@ -12659,10 +12766,7 @@ var hasAnyService2 = (ruleNode) => {
|
|
|
12659
12766
|
(child) => child?.id?.toLowerCase().startsWith("service ")
|
|
12660
12767
|
);
|
|
12661
12768
|
if (serviceCommands2.length > 0) {
|
|
12662
|
-
return serviceCommands2.some((cmd) =>
|
|
12663
|
-
const value = cmd?.id?.split(/\s+/).slice(1).join(" ").toLowerCase().replace(/;$/, "").trim();
|
|
12664
|
-
return value === "any";
|
|
12665
|
-
});
|
|
12769
|
+
return serviceCommands2.some((cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any"));
|
|
12666
12770
|
}
|
|
12667
12771
|
return false;
|
|
12668
12772
|
};
|
|
@@ -14347,6 +14451,9 @@ function isJsonLocate(obj) {
|
|
|
14347
14451
|
if (!isSelector(locate.selector)) return false;
|
|
14348
14452
|
return locate.where === void 0 || isJsonCheck(locate.where);
|
|
14349
14453
|
}
|
|
14454
|
+
function isJsonNotUnder(obj) {
|
|
14455
|
+
return Array.isArray(obj) && obj.length > 0 && obj.every((name) => typeof name === "string" && name.length > 0 && name.trim() === name && !/[\r\n]/.test(name));
|
|
14456
|
+
}
|
|
14350
14457
|
function isJsonRule(obj) {
|
|
14351
14458
|
if (typeof obj !== "object" || obj === null) {
|
|
14352
14459
|
return false;
|
|
@@ -14387,6 +14494,12 @@ function isJsonRule(obj) {
|
|
|
14387
14494
|
if (rule.locate !== void 0 && !isJsonLocate(rule.locate)) {
|
|
14388
14495
|
return false;
|
|
14389
14496
|
}
|
|
14497
|
+
if (rule.topLevelOnly !== void 0 && typeof rule.topLevelOnly !== "boolean") {
|
|
14498
|
+
return false;
|
|
14499
|
+
}
|
|
14500
|
+
if (rule.notUnder !== void 0 && !isJsonNotUnder(rule.notUnder)) {
|
|
14501
|
+
return false;
|
|
14502
|
+
}
|
|
14390
14503
|
if (rule.failureMessage !== void 0 && typeof rule.failureMessage !== "string") {
|
|
14391
14504
|
return false;
|
|
14392
14505
|
}
|
|
@@ -14420,6 +14533,12 @@ function isJsonRuleFile(obj) {
|
|
|
14420
14533
|
}
|
|
14421
14534
|
|
|
14422
14535
|
// ../core/src/json-rules/JsonRuleCompiler.ts
|
|
14536
|
+
function nameMatchesBlock(names, id) {
|
|
14537
|
+
for (const name of names) {
|
|
14538
|
+
if (id === name || id.startsWith(name) && /\s/.test(id.charAt(name.length))) return true;
|
|
14539
|
+
}
|
|
14540
|
+
return false;
|
|
14541
|
+
}
|
|
14423
14542
|
var JsonRuleCompiler = class {
|
|
14424
14543
|
registry;
|
|
14425
14544
|
evaluator;
|
|
@@ -14477,13 +14596,15 @@ var JsonRuleCompiler = class {
|
|
|
14477
14596
|
compile(jsonRule) {
|
|
14478
14597
|
this.prepareCheck(jsonRule.check, jsonRule.id, "/check");
|
|
14479
14598
|
const locate = this.prepareLocate(jsonRule);
|
|
14599
|
+
const scope = this.prepareScope(jsonRule);
|
|
14480
14600
|
return {
|
|
14481
14601
|
id: jsonRule.id,
|
|
14482
14602
|
selector: jsonRule.selector,
|
|
14483
14603
|
vendor: jsonRule.vendor,
|
|
14484
14604
|
category: jsonRule.category,
|
|
14485
14605
|
metadata: jsonRule.metadata,
|
|
14486
|
-
check: (node,
|
|
14606
|
+
check: (node, ctx) => {
|
|
14607
|
+
if (scope && !this.inScope(node, scope, ctx)) return [];
|
|
14487
14608
|
let passed;
|
|
14488
14609
|
let reported = node;
|
|
14489
14610
|
try {
|
|
@@ -14539,6 +14660,42 @@ var JsonRuleCompiler = class {
|
|
|
14539
14660
|
}
|
|
14540
14661
|
return { selector: locate.selector.toLowerCase(), where: locate.where };
|
|
14541
14662
|
}
|
|
14663
|
+
/**
|
|
14664
|
+
* Validate and normalise a rule's `topLevelOnly` and `notUnder` fields.
|
|
14665
|
+
* @returns undefined when the rule runs on every matching node
|
|
14666
|
+
* @throws RuleCompileError for a malformed field
|
|
14667
|
+
*/
|
|
14668
|
+
prepareScope(jsonRule) {
|
|
14669
|
+
const topLevelOnly = jsonRule.topLevelOnly;
|
|
14670
|
+
const notUnder = jsonRule.notUnder;
|
|
14671
|
+
if (topLevelOnly !== void 0 && typeof topLevelOnly !== "boolean") {
|
|
14672
|
+
throw new RuleCompileError(jsonRule.id, "/topLevelOnly", "expected true or false");
|
|
14673
|
+
}
|
|
14674
|
+
if (notUnder !== void 0 && !isJsonNotUnder(notUnder)) {
|
|
14675
|
+
throw new RuleCompileError(
|
|
14676
|
+
jsonRule.id,
|
|
14677
|
+
"/notUnder",
|
|
14678
|
+
"expected a non-empty list of block ids, each a non-empty string without leading or trailing whitespace"
|
|
14679
|
+
);
|
|
14680
|
+
}
|
|
14681
|
+
if (!topLevelOnly && notUnder === void 0) return void 0;
|
|
14682
|
+
return {
|
|
14683
|
+
topLevelOnly: topLevelOnly === true,
|
|
14684
|
+
notUnder: new Set((notUnder ?? []).map((name) => name.toLowerCase()))
|
|
14685
|
+
};
|
|
14686
|
+
}
|
|
14687
|
+
/**
|
|
14688
|
+
* Whether a scoped rule judges `node`. Without the AST there is no way to
|
|
14689
|
+
* tell where the node lies, so a check called outside the engine judges
|
|
14690
|
+
* the node it is given.
|
|
14691
|
+
*/
|
|
14692
|
+
inScope(node, scope, ctx) {
|
|
14693
|
+
const ast = ctx?.getAst?.();
|
|
14694
|
+
if (!ast) return true;
|
|
14695
|
+
if (scope.topLevelOnly) return ast.includes(node);
|
|
14696
|
+
const enclosing = ancestorsOf(ast, node) ?? [];
|
|
14697
|
+
return !enclosing.some((block) => nameMatchesBlock(scope.notUnder, block.id.trim().toLowerCase()));
|
|
14698
|
+
}
|
|
14542
14699
|
/**
|
|
14543
14700
|
* Find the first descendant of `node` (depth-first, document order) whose
|
|
14544
14701
|
* id starts with the locate selector and, with `where`, satisfies it.
|
|
@@ -14765,6 +14922,7 @@ function validateJsonRuleFile(data, options = {}) {
|
|
|
14765
14922
|
} else {
|
|
14766
14923
|
obj.rules.forEach((rule, i) => {
|
|
14767
14924
|
pushLocateError(rule, `/rules/${i}`, errors);
|
|
14925
|
+
pushScopeErrors(rule, `/rules/${i}`, errors);
|
|
14768
14926
|
});
|
|
14769
14927
|
}
|
|
14770
14928
|
}
|
|
@@ -14813,6 +14971,24 @@ function pushLocateError(rule, path, errors) {
|
|
|
14813
14971
|
severity: "error"
|
|
14814
14972
|
});
|
|
14815
14973
|
}
|
|
14974
|
+
function pushScopeErrors(rule, path, errors) {
|
|
14975
|
+
if (typeof rule !== "object" || rule === null) return;
|
|
14976
|
+
const { topLevelOnly, notUnder } = rule;
|
|
14977
|
+
if (topLevelOnly !== void 0 && typeof topLevelOnly !== "boolean") {
|
|
14978
|
+
errors.push({
|
|
14979
|
+
path: `${path}/topLevelOnly`,
|
|
14980
|
+
message: 'Invalid "topLevelOnly": expected true or false',
|
|
14981
|
+
severity: "error"
|
|
14982
|
+
});
|
|
14983
|
+
}
|
|
14984
|
+
if (notUnder !== void 0 && !isJsonNotUnder(notUnder)) {
|
|
14985
|
+
errors.push({
|
|
14986
|
+
path: `${path}/notUnder`,
|
|
14987
|
+
message: 'Invalid "notUnder": expected a non-empty list of block ids, each a non-empty string without leading or trailing whitespace',
|
|
14988
|
+
severity: "error"
|
|
14989
|
+
});
|
|
14990
|
+
}
|
|
14991
|
+
}
|
|
14816
14992
|
function validateRule(rule, path, ctx) {
|
|
14817
14993
|
if (!RULE_ID_PATTERN.test(rule.id)) {
|
|
14818
14994
|
ctx.errors.push({
|
|
@@ -17011,33 +17187,32 @@ var VtyExecTimeout = {
|
|
|
17011
17187
|
}
|
|
17012
17188
|
return { passed: true, message: "Exec-timeout at the IOS default (10 minutes).", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
17013
17189
|
}
|
|
17014
|
-
const
|
|
17015
|
-
const minutesStr = timeoutMatch?.[1];
|
|
17016
|
-
if (!minutesStr) {
|
|
17017
|
-
return { passed: true, message: "Exec-timeout configured.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
17018
|
-
}
|
|
17019
|
-
const minutes = parseInteger(minutesStr);
|
|
17190
|
+
const minutes = parseInteger(timeoutCmd.params[1] ?? "");
|
|
17020
17191
|
if (minutes === null) {
|
|
17021
17192
|
return { passed: true, message: "Exec-timeout configured.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
17022
17193
|
}
|
|
17023
|
-
|
|
17194
|
+
const seconds = parseInteger(timeoutCmd.params[2] ?? "0") ?? 0;
|
|
17195
|
+
const total = minutes * 60 + seconds;
|
|
17196
|
+
if (total === 0) {
|
|
17024
17197
|
return {
|
|
17025
17198
|
passed: false,
|
|
17026
17199
|
message: "VTY exec-timeout is disabled (0). Configure a timeout (max 15 minutes).",
|
|
17027
17200
|
ruleId: "NET-MGMT-003",
|
|
17028
|
-
nodeId:
|
|
17201
|
+
nodeId: timeoutCmd.id,
|
|
17029
17202
|
level: "warning",
|
|
17030
|
-
loc:
|
|
17203
|
+
loc: timeoutCmd.loc
|
|
17031
17204
|
};
|
|
17032
17205
|
}
|
|
17033
|
-
if (
|
|
17206
|
+
if (total > 15 * 60) {
|
|
17207
|
+
const unit = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
17208
|
+
const value = seconds > 0 ? `${unit(minutes, "minute")} ${unit(seconds, "second")}` : unit(minutes, "minute");
|
|
17034
17209
|
return {
|
|
17035
17210
|
passed: false,
|
|
17036
|
-
message: `VTY exec-timeout of ${
|
|
17211
|
+
message: `VTY exec-timeout of ${value} exceeds maximum 15 minutes.`,
|
|
17037
17212
|
ruleId: "NET-MGMT-003",
|
|
17038
|
-
nodeId:
|
|
17213
|
+
nodeId: timeoutCmd.id,
|
|
17039
17214
|
level: "warning",
|
|
17040
|
-
loc:
|
|
17215
|
+
loc: timeoutCmd.loc
|
|
17041
17216
|
};
|
|
17042
17217
|
}
|
|
17043
17218
|
return { passed: true, message: "Exec-timeout configured within limits.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -17364,6 +17539,45 @@ var SnmpNoRwAccess = {
|
|
|
17364
17539
|
return { passed: true, message: "SNMP is read-only.", ruleId: "NET-SNMP-004", nodeId: node.id, level: "info", loc: node.loc };
|
|
17365
17540
|
}
|
|
17366
17541
|
};
|
|
17542
|
+
var globalStatementsCache = /* @__PURE__ */ new WeakMap();
|
|
17543
|
+
var globalStatementsOf = (ast) => {
|
|
17544
|
+
const cached = globalStatementsCache.get(ast);
|
|
17545
|
+
if (cached) return cached;
|
|
17546
|
+
const statements = /* @__PURE__ */ new Set();
|
|
17547
|
+
let nxos = false;
|
|
17548
|
+
const walk = (nodes) => {
|
|
17549
|
+
for (const n of nodes) {
|
|
17550
|
+
if (n.type === "virtual_root") {
|
|
17551
|
+
walk(n.children);
|
|
17552
|
+
continue;
|
|
17553
|
+
}
|
|
17554
|
+
if (n.type === "comment") continue;
|
|
17555
|
+
const id = n.id.trim().toLowerCase();
|
|
17556
|
+
statements.add(id);
|
|
17557
|
+
if (/^(feature\s|vrf context\s|vdc\s)/.test(id)) nxos = true;
|
|
17558
|
+
}
|
|
17559
|
+
};
|
|
17560
|
+
walk(ast);
|
|
17561
|
+
if (statements.has("lldp run") || statements.has("no lldp run") || statements.has("cdp run") || statements.has("no cdp run")) {
|
|
17562
|
+
nxos = false;
|
|
17563
|
+
}
|
|
17564
|
+
const result2 = { statements, nxos };
|
|
17565
|
+
globalStatementsCache.set(ast, result2);
|
|
17566
|
+
return result2;
|
|
17567
|
+
};
|
|
17568
|
+
var isCdpDisabledGlobally = (ast) => {
|
|
17569
|
+
if (!ast) return false;
|
|
17570
|
+
const { statements, nxos } = globalStatementsOf(ast);
|
|
17571
|
+
return statements.has(nxos ? "no cdp enable" : "no cdp run");
|
|
17572
|
+
};
|
|
17573
|
+
var lldpGlobalState = (ast) => {
|
|
17574
|
+
if (!ast) return "unknown";
|
|
17575
|
+
const { statements, nxos } = globalStatementsOf(ast);
|
|
17576
|
+
if (nxos) return statements.has("feature lldp") ? "on" : "off";
|
|
17577
|
+
if (statements.has("no lldp run")) return "off";
|
|
17578
|
+
return statements.has("lldp run") ? "on" : "unknown";
|
|
17579
|
+
};
|
|
17580
|
+
var LLDP_UNKNOWN_NOTE = ' LLDP is not configured globally ("lldp run" or "no lldp run" is absent), and whether it is on by default depends on the platform (off on the Catalyst 9500, on on the Cisco IE3500): check your platform.';
|
|
17367
17581
|
var CdpDisabledOnExternal = {
|
|
17368
17582
|
id: "NET-SVC-005",
|
|
17369
17583
|
selector: "interface",
|
|
@@ -17382,10 +17596,13 @@ var CdpDisabledOnExternal = {
|
|
|
17382
17596
|
{ type: "general", label: "cdp" }
|
|
17383
17597
|
]
|
|
17384
17598
|
},
|
|
17385
|
-
check: (node) => {
|
|
17599
|
+
check: (node, context) => {
|
|
17386
17600
|
if (!isPhysicalPort(node.id) || isShutdown3(node)) {
|
|
17387
17601
|
return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-005", nodeId: node.id, level: "info", loc: node.loc };
|
|
17388
17602
|
}
|
|
17603
|
+
if (isCdpDisabledGlobally(context.getAst?.())) {
|
|
17604
|
+
return { passed: true, message: "CDP is disabled globally.", ruleId: "NET-SVC-005", nodeId: node.id, level: "info", loc: node.loc };
|
|
17605
|
+
}
|
|
17389
17606
|
if (isPhoneOrAP(node)) {
|
|
17390
17607
|
const desc = getChildCommand(node, "description");
|
|
17391
17608
|
const descText = desc?.rawText.toLowerCase() || "";
|
|
@@ -17448,10 +17665,17 @@ var LldpDisabledOnExternal = {
|
|
|
17448
17665
|
{ type: "general", label: "lldp" }
|
|
17449
17666
|
]
|
|
17450
17667
|
},
|
|
17451
|
-
check: (node) => {
|
|
17668
|
+
check: (node, context) => {
|
|
17452
17669
|
if (!isPhysicalPort(node.id) || isShutdown3(node)) {
|
|
17453
17670
|
return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-006", nodeId: node.id, level: "info", loc: node.loc };
|
|
17454
17671
|
}
|
|
17672
|
+
const globalState = lldpGlobalState(context.getAst?.());
|
|
17673
|
+
if (globalState === "off") {
|
|
17674
|
+
return { passed: true, message: "LLDP is disabled globally.", ruleId: "NET-SVC-006", nodeId: node.id, level: "info", loc: node.loc };
|
|
17675
|
+
}
|
|
17676
|
+
const unknown = globalState === "unknown";
|
|
17677
|
+
const level = unknown ? "info" : "warning";
|
|
17678
|
+
const note = unknown ? LLDP_UNKNOWN_NOTE : "";
|
|
17455
17679
|
if (isPhoneOrAP(node)) {
|
|
17456
17680
|
const desc = getChildCommand(node, "description");
|
|
17457
17681
|
const descText = desc?.rawText.toLowerCase() || "";
|
|
@@ -17461,10 +17685,10 @@ var LldpDisabledOnExternal = {
|
|
|
17461
17685
|
if (!noLldpTx || !noLldpRx) {
|
|
17462
17686
|
return {
|
|
17463
17687
|
passed: false,
|
|
17464
|
-
message: `Cisco AP port "${node.params.slice(1).join(" ")}" should have LLDP disabled. Add "no lldp transmit" and "no lldp receive"
|
|
17688
|
+
message: `Cisco AP port "${node.params.slice(1).join(" ")}" should have LLDP disabled. Add "no lldp transmit" and "no lldp receive".${note}`,
|
|
17465
17689
|
ruleId: "NET-SVC-006",
|
|
17466
17690
|
nodeId: node.id,
|
|
17467
|
-
level
|
|
17691
|
+
level,
|
|
17468
17692
|
loc: node.loc
|
|
17469
17693
|
};
|
|
17470
17694
|
}
|
|
@@ -17477,10 +17701,10 @@ var LldpDisabledOnExternal = {
|
|
|
17477
17701
|
if (!noLldpTx || !noLldpRx) {
|
|
17478
17702
|
return {
|
|
17479
17703
|
passed: false,
|
|
17480
|
-
message: `External interface "${node.params.slice(1).join(" ")}" should have LLDP disabled
|
|
17704
|
+
message: `External interface "${node.params.slice(1).join(" ")}" should have LLDP disabled.${note}`,
|
|
17481
17705
|
ruleId: "NET-SVC-006",
|
|
17482
17706
|
nodeId: node.id,
|
|
17483
|
-
level
|
|
17707
|
+
level,
|
|
17484
17708
|
loc: node.loc
|
|
17485
17709
|
};
|
|
17486
17710
|
}
|
|
@@ -17491,10 +17715,10 @@ var LldpDisabledOnExternal = {
|
|
|
17491
17715
|
if (!noLldpTx || !noLldpRx) {
|
|
17492
17716
|
return {
|
|
17493
17717
|
passed: false,
|
|
17494
|
-
message: `Endpoint port "${node.params.slice(1).join(" ")}" should have LLDP disabled
|
|
17718
|
+
message: `Endpoint port "${node.params.slice(1).join(" ")}" should have LLDP disabled.${note}`,
|
|
17495
17719
|
ruleId: "NET-SVC-006",
|
|
17496
17720
|
nodeId: node.id,
|
|
17497
|
-
level
|
|
17721
|
+
level,
|
|
17498
17722
|
loc: node.loc
|
|
17499
17723
|
};
|
|
17500
17724
|
}
|
|
@@ -17687,6 +17911,21 @@ var evaluatePasswordStorage = ({ ruleId, node, label, fix, args }) => {
|
|
|
17687
17911
|
loc: node.loc
|
|
17688
17912
|
};
|
|
17689
17913
|
};
|
|
17914
|
+
var bgpKeyNotJudged = (ast, node) => {
|
|
17915
|
+
const type = node.params[1];
|
|
17916
|
+
if (type !== "3" && type !== "7") return false;
|
|
17917
|
+
let ancestors = [];
|
|
17918
|
+
walkStatements(ast, (statement2, path) => {
|
|
17919
|
+
if (statement2 === node) ancestors = [...path];
|
|
17920
|
+
});
|
|
17921
|
+
const words = (n) => n.params.map((w) => w.toLowerCase());
|
|
17922
|
+
if (!ancestors.some((a) => words(a)[0] === "router" && words(a)[1] === "bgp")) return false;
|
|
17923
|
+
if (type === "3") return true;
|
|
17924
|
+
return ancestors.some((a) => {
|
|
17925
|
+
const [head, kind, name] = words(a);
|
|
17926
|
+
return head === "neighbor" && kind !== void 0 || head === "template" && kind === "peer" && name !== void 0;
|
|
17927
|
+
});
|
|
17928
|
+
};
|
|
17690
17929
|
var CiscoNoPlaintextPasswords = {
|
|
17691
17930
|
id: "NET-SEC-001",
|
|
17692
17931
|
selector: "password",
|
|
@@ -17721,6 +17960,12 @@ var CiscoNoPlaintextPasswords = {
|
|
|
17721
17960
|
return notApplicable2;
|
|
17722
17961
|
}
|
|
17723
17962
|
const ast = context.getAst?.();
|
|
17963
|
+
if (ast && bgpKeyNotJudged(ast, node)) {
|
|
17964
|
+
return {
|
|
17965
|
+
...notApplicable2,
|
|
17966
|
+
message: "BGP neighbor key stored as type 3 or 7 is not judged: NX-OS has no stronger form for BGP keys."
|
|
17967
|
+
};
|
|
17968
|
+
}
|
|
17724
17969
|
const onLine = ast ? isLineConfigPassword(ast, node) : false;
|
|
17725
17970
|
return evaluatePasswordStorage({
|
|
17726
17971
|
ruleId: "NET-SEC-001",
|
|
@@ -17869,6 +18114,39 @@ var CiscoSshVersion2 = {
|
|
|
17869
18114
|
return passResult("CISCO-MGMT-004", node, "SSH version 2 is configured.");
|
|
17870
18115
|
}
|
|
17871
18116
|
};
|
|
18117
|
+
var NxosTelnetFeature = {
|
|
18118
|
+
id: "CISCO-MGMT-009",
|
|
18119
|
+
selector: "feature",
|
|
18120
|
+
vendor: "cisco-nxos",
|
|
18121
|
+
category: "Service-Hardening",
|
|
18122
|
+
metadata: {
|
|
18123
|
+
level: "error",
|
|
18124
|
+
obu: "Security",
|
|
18125
|
+
owner: "SecOps",
|
|
18126
|
+
remediation: 'Run "no feature telnet" and manage the switch over SSH ("feature ssh").',
|
|
18127
|
+
security: {
|
|
18128
|
+
cwe: ["CWE-319"]
|
|
18129
|
+
},
|
|
18130
|
+
tags: [
|
|
18131
|
+
{ type: "general", label: "telnet" },
|
|
18132
|
+
{ type: "general", label: "management" },
|
|
18133
|
+
{ type: "general", label: "cleartext" }
|
|
18134
|
+
]
|
|
18135
|
+
},
|
|
18136
|
+
check: (node) => {
|
|
18137
|
+
if (node.params.length === 2 && node.params[1]?.toLowerCase() === "telnet") {
|
|
18138
|
+
return {
|
|
18139
|
+
passed: false,
|
|
18140
|
+
message: 'The Telnet server is enabled ("feature telnet"). Telnet sends credentials in clear text: run "no feature telnet" and use SSH ("feature ssh").',
|
|
18141
|
+
ruleId: "CISCO-MGMT-009",
|
|
18142
|
+
nodeId: node.id,
|
|
18143
|
+
level: "error",
|
|
18144
|
+
loc: node.loc
|
|
18145
|
+
};
|
|
18146
|
+
}
|
|
18147
|
+
return passResult("CISCO-MGMT-009", node, "Not the Telnet feature.");
|
|
18148
|
+
}
|
|
18149
|
+
};
|
|
17872
18150
|
var BANNER_DISCLOSURE = /\b(cisco|ios|ios-xe)\b|\bversion\s+\d+\.\d+/i;
|
|
17873
18151
|
var CiscoLoginBannerNoDisclosure = {
|
|
17874
18152
|
id: "CISCO-MGMT-008",
|
|
@@ -18011,13 +18289,13 @@ var CiscoOspfInterfaceAuthentication = {
|
|
|
18011
18289
|
var CiscoBgpNeighborAuthentication = {
|
|
18012
18290
|
id: "CISCO-BGP-002",
|
|
18013
18291
|
selector: "router bgp",
|
|
18014
|
-
vendor: "cisco-ios",
|
|
18292
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
18015
18293
|
category: "Routing",
|
|
18016
18294
|
metadata: {
|
|
18017
18295
|
level: "warning",
|
|
18018
18296
|
obu: "Security",
|
|
18019
18297
|
owner: "SecOps",
|
|
18020
|
-
remediation: 'Authenticate every eBGP session with TCP-AO ("neighbor <ip> ao <key-chain>", IOS XE) or TCP MD5 ("neighbor <ip> password <key>"), on the neighbor, its peer-group or peer-session template. iBGP neighbors without authentication are reported as info.',
|
|
18298
|
+
remediation: 'Authenticate every eBGP session with TCP-AO ("neighbor <ip> ao <key-chain>", IOS XE) or TCP MD5 ("neighbor <ip> password <key>"), on the neighbor, its peer-group or peer-session template. On NX-OS, configure "password <key>" under "neighbor <ip>", its "template peer" or "template peer-session". iBGP neighbors without authentication are reported as info.',
|
|
18021
18299
|
security: {
|
|
18022
18300
|
cwe: ["CWE-306"],
|
|
18023
18301
|
cvssScore: 8.1
|
|
@@ -18034,14 +18312,16 @@ var CiscoBgpNeighborAuthentication = {
|
|
|
18034
18312
|
return passResult("CISCO-BGP-002", node, "No BGP neighbors configured.");
|
|
18035
18313
|
}
|
|
18036
18314
|
const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "password") && !findBgpNeighborCommand(p.lines, "ao")).map((p) => {
|
|
18315
|
+
const line = peerLine(p, node);
|
|
18316
|
+
const section = line.children.length > 0;
|
|
18037
18317
|
const { level, message } = bgpAuthFinding(
|
|
18038
18318
|
bgpSessionKind(node, p),
|
|
18039
18319
|
p.id,
|
|
18040
18320
|
p.remoteAs,
|
|
18041
|
-
`TCP-AO ("neighbor ${p.id} ao <key-chain>") or TCP MD5 ("neighbor ${p.id} password <key>")`,
|
|
18042
|
-
"on the neighbor, its peer-group or peer-session template"
|
|
18321
|
+
section ? 'TCP MD5 ("password <key>")' : `TCP-AO ("neighbor ${p.id} ao <key-chain>") or TCP MD5 ("neighbor ${p.id} password <key>")`,
|
|
18322
|
+
section ? `under "neighbor ${p.id}", its "template peer" or "template peer-session"` : "on the neighbor, its peer-group or peer-session template"
|
|
18043
18323
|
);
|
|
18044
|
-
return offenderResult("CISCO-BGP-002",
|
|
18324
|
+
return offenderResult("CISCO-BGP-002", line, message, level);
|
|
18045
18325
|
});
|
|
18046
18326
|
if (findings.length > 0) return findings;
|
|
18047
18327
|
return passResult("CISCO-BGP-002", node, "All BGP neighbors have authentication.");
|
|
@@ -18125,9 +18405,10 @@ var CiscoBgpLogNeighborChanges = {
|
|
|
18125
18405
|
},
|
|
18126
18406
|
check: (node) => {
|
|
18127
18407
|
if (!hasBgpLogNeighborChanges2(node)) {
|
|
18408
|
+
const explicitOff = hasChildCommand(node, "no bgp log-neighbor-changes");
|
|
18128
18409
|
return {
|
|
18129
18410
|
passed: false,
|
|
18130
|
-
message: 'BGP neighbor changes are not logged. Configure "bgp log-neighbor-changes" for visibility.',
|
|
18411
|
+
message: explicitOff ? 'BGP neighbor changes are not logged. Configure "bgp log-neighbor-changes" for visibility.' : 'BGP neighbor-change logging is not configured. Cisco documentation is not consistent on whether this is logged by default, so set "bgp log-neighbor-changes" explicitly.',
|
|
18131
18412
|
ruleId: "CISCO-BGP-005",
|
|
18132
18413
|
nodeId: node.id,
|
|
18133
18414
|
level: "info",
|
|
@@ -18363,22 +18644,28 @@ var CiscoHsrpMd5Authentication = {
|
|
|
18363
18644
|
if (!hasHsrp) {
|
|
18364
18645
|
return passResult("CISCO-CTRL-003", node, "No HSRP configured.");
|
|
18365
18646
|
}
|
|
18366
|
-
const
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18647
|
+
const authByGroup = /* @__PURE__ */ new Map();
|
|
18648
|
+
for (const child of node.children) {
|
|
18649
|
+
const match = /^standby(?:\s+(\d+))?\s+authentication(?:\s+(\S+))?/i.exec(child.id.trim());
|
|
18650
|
+
if (!match) continue;
|
|
18651
|
+
authByGroup.set(Number(match[1] ?? 0), { line: child, md5: match[2]?.toLowerCase() === "md5" });
|
|
18652
|
+
}
|
|
18653
|
+
if (authByGroup.size === 0) {
|
|
18370
18654
|
return passResult("CISCO-CTRL-003", node, "No HSRP authentication (reported by NET-FHRP-002).");
|
|
18371
18655
|
}
|
|
18372
|
-
|
|
18373
|
-
|
|
18656
|
+
const findings = [];
|
|
18657
|
+
for (const [group, { line, md5 }] of authByGroup) {
|
|
18658
|
+
if (md5) continue;
|
|
18659
|
+
findings.push({
|
|
18374
18660
|
passed: false,
|
|
18375
|
-
message: `
|
|
18661
|
+
message: `HSRP group ${group} on interface "${node.params.slice(1).join(" ")}" has authentication that is not MD5. Configure "standby ${group} authentication md5 key-string <key>".`,
|
|
18376
18662
|
ruleId: "CISCO-CTRL-003",
|
|
18377
|
-
nodeId:
|
|
18663
|
+
nodeId: line.id,
|
|
18378
18664
|
level: "warning",
|
|
18379
|
-
loc:
|
|
18380
|
-
};
|
|
18665
|
+
loc: line.loc
|
|
18666
|
+
});
|
|
18381
18667
|
}
|
|
18668
|
+
if (findings.length > 0) return findings;
|
|
18382
18669
|
return passResult("CISCO-CTRL-003", node, "HSRP has MD5 authentication configured.");
|
|
18383
18670
|
}
|
|
18384
18671
|
};
|
|
@@ -18898,6 +19185,7 @@ var allCiscoRules = [
|
|
|
18898
19185
|
CiscoNoPlaintextUsernamePasswords,
|
|
18899
19186
|
// Ported from the former commercial set (decision 0001 S3a)
|
|
18900
19187
|
CiscoSshVersion2,
|
|
19188
|
+
NxosTelnetFeature,
|
|
18901
19189
|
CiscoLoginBannerNoDisclosure,
|
|
18902
19190
|
CiscoSnmpv3AuthPriv,
|
|
18903
19191
|
CiscoNoDangerousServices,
|
|
@@ -18925,7 +19213,25 @@ var allCiscoRules = [
|
|
|
18925
19213
|
NxosSecretStorage
|
|
18926
19214
|
];
|
|
18927
19215
|
|
|
19216
|
+
// ../rules-default/src/common/top-level.ts
|
|
19217
|
+
var isTopLevel = (node, context) => {
|
|
19218
|
+
const ast = context?.getAst?.();
|
|
19219
|
+
return !ast || ast.includes(node);
|
|
19220
|
+
};
|
|
19221
|
+
|
|
18928
19222
|
// ../rules-default/src/juniper/junos-rules.ts
|
|
19223
|
+
var idIs = (node, name) => node !== void 0 && equalsIgnoreCase(node.id.trim(), name);
|
|
19224
|
+
var enclosingBlocks = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
|
|
19225
|
+
var inGroup = (node, context) => idIs(enclosingBlocks(node, context)[0], "groups");
|
|
19226
|
+
var isRoutingProtocolsStanza = (node, context) => {
|
|
19227
|
+
if (isTopLevel(node, context)) return true;
|
|
19228
|
+
let path = enclosingBlocks(node, context);
|
|
19229
|
+
if ((idIs(path[0], "logical-systems") || idIs(path[0], "tenants")) && path.length >= 2) path = path.slice(2);
|
|
19230
|
+
return path.length === 0 || path.length === 2 && idIs(path[0], "routing-instances");
|
|
19231
|
+
};
|
|
19232
|
+
var NOT_TOP_LEVEL_SYSTEM = "Not the top-level system stanza.";
|
|
19233
|
+
var NOT_ROUTING_PROTOCOLS = "Not the protocols stanza of the device, a logical system, a tenant system or a routing instance.";
|
|
19234
|
+
var GROUP_CONTENT = "Configuration group content is not judged.";
|
|
18929
19235
|
var offenderResult2 = (ruleId, offender, message, level) => ({
|
|
18930
19236
|
passed: false,
|
|
18931
19237
|
message,
|
|
@@ -18954,7 +19260,10 @@ var RootAuthRequired = {
|
|
|
18954
19260
|
{ type: "general", label: "hardening" }
|
|
18955
19261
|
]
|
|
18956
19262
|
},
|
|
18957
|
-
check: (node) => {
|
|
19263
|
+
check: (node, context) => {
|
|
19264
|
+
if (!isTopLevel(node, context)) {
|
|
19265
|
+
return passResult2("JUN-SYS-001", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19266
|
+
}
|
|
18958
19267
|
const rootAuth = findStanza4(node, "root-authentication");
|
|
18959
19268
|
if (!rootAuth) {
|
|
18960
19269
|
return {
|
|
@@ -19002,7 +19311,10 @@ var SshServiceRequired = {
|
|
|
19002
19311
|
cwe: ["CWE-319"]
|
|
19003
19312
|
}
|
|
19004
19313
|
},
|
|
19005
|
-
check: (node) => {
|
|
19314
|
+
check: (node, context) => {
|
|
19315
|
+
if (!isTopLevel(node, context)) {
|
|
19316
|
+
return passResult2("JUN-SYS-002", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19317
|
+
}
|
|
19006
19318
|
const services = findStanza4(node, "services");
|
|
19007
19319
|
if (!services) {
|
|
19008
19320
|
return {
|
|
@@ -19046,7 +19358,10 @@ var SyslogRequired = {
|
|
|
19046
19358
|
owner: "NetOps",
|
|
19047
19359
|
remediation: 'Configure "syslog" under system stanza with appropriate log destinations.'
|
|
19048
19360
|
},
|
|
19049
|
-
check: (node) => {
|
|
19361
|
+
check: (node, context) => {
|
|
19362
|
+
if (!isTopLevel(node, context)) {
|
|
19363
|
+
return passResult2("JUN-SYS-003", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19364
|
+
}
|
|
19050
19365
|
const syslog = findStanza4(node, "syslog");
|
|
19051
19366
|
if (!syslog) {
|
|
19052
19367
|
return {
|
|
@@ -19091,7 +19406,10 @@ var NtpRequired = {
|
|
|
19091
19406
|
owner: "NetOps",
|
|
19092
19407
|
remediation: 'Configure "ntp" under system stanza with at least one NTP server.'
|
|
19093
19408
|
},
|
|
19094
|
-
check: (node) => {
|
|
19409
|
+
check: (node, context) => {
|
|
19410
|
+
if (!isTopLevel(node, context)) {
|
|
19411
|
+
return passResult2("JUN-SYS-004", node, NOT_TOP_LEVEL_SYSTEM);
|
|
19412
|
+
}
|
|
19095
19413
|
const ntp = findStanza4(node, "ntp");
|
|
19096
19414
|
if (!ntp) {
|
|
19097
19415
|
return {
|
|
@@ -19176,7 +19494,10 @@ var JunosBgpRouterId = {
|
|
|
19176
19494
|
owner: "NetOps",
|
|
19177
19495
|
remediation: 'Configure "router-id" under routing-options stanza.'
|
|
19178
19496
|
},
|
|
19179
|
-
check: (node) => {
|
|
19497
|
+
check: (node, context) => {
|
|
19498
|
+
if (inGroup(node, context)) {
|
|
19499
|
+
return passResult2("JUN-BGP-001", node, GROUP_CONTENT);
|
|
19500
|
+
}
|
|
19180
19501
|
const hasRouterId = hasChildCommand(node, "router-id");
|
|
19181
19502
|
if (!hasRouterId) {
|
|
19182
19503
|
return {
|
|
@@ -19210,6 +19531,9 @@ var JunosBgpAsNumber = {
|
|
|
19210
19531
|
remediation: 'Configure "autonomous-system" under routing-options stanza.'
|
|
19211
19532
|
},
|
|
19212
19533
|
check: (node, context) => {
|
|
19534
|
+
if (inGroup(node, context)) {
|
|
19535
|
+
return passResult2("JUN-BGP-002", node, GROUP_CONTENT);
|
|
19536
|
+
}
|
|
19213
19537
|
const ast = context.getAst?.();
|
|
19214
19538
|
if (!ast) {
|
|
19215
19539
|
return { passed: true, message: "Cannot check without AST context.", ruleId: "JUN-BGP-002", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19264,7 +19588,10 @@ var JunosOspfAreaInterfaces = {
|
|
|
19264
19588
|
owner: "NetOps",
|
|
19265
19589
|
remediation: "Configure interfaces under each OSPF area."
|
|
19266
19590
|
},
|
|
19267
|
-
check: (node) => {
|
|
19591
|
+
check: (node, context) => {
|
|
19592
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
19593
|
+
return passResult2("JUN-OSPF-001", node, NOT_ROUTING_PROTOCOLS);
|
|
19594
|
+
}
|
|
19268
19595
|
const ospf = findStanza4(node, "ospf");
|
|
19269
19596
|
if (!ospf) {
|
|
19270
19597
|
return { passed: true, message: "OSPF not configured.", ruleId: "JUN-OSPF-001", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19309,7 +19636,10 @@ var JunosPolicyAction = {
|
|
|
19309
19636
|
owner: "NetOps",
|
|
19310
19637
|
remediation: 'Ensure all policy-statement terms have explicit "then accept" or "then reject" actions.'
|
|
19311
19638
|
},
|
|
19312
|
-
check: (node) => {
|
|
19639
|
+
check: (node, context) => {
|
|
19640
|
+
if (inGroup(node, context)) {
|
|
19641
|
+
return passResult2("JUN-POL-001", node, GROUP_CONTENT);
|
|
19642
|
+
}
|
|
19313
19643
|
const policyStatements = findStanzas3(node, /^policy-statement/i);
|
|
19314
19644
|
if (policyStatements.length === 0) {
|
|
19315
19645
|
return { passed: true, message: "No policy statements configured.", ruleId: "JUN-POL-001", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -19372,7 +19702,10 @@ var JunosFirewallDefaultDeny = {
|
|
|
19372
19702
|
{ type: "general", label: "deny-by-default" }
|
|
19373
19703
|
]
|
|
19374
19704
|
},
|
|
19375
|
-
check: (node) => {
|
|
19705
|
+
check: (node, context) => {
|
|
19706
|
+
if (inGroup(node, context)) {
|
|
19707
|
+
return passResult2("JUN-FW-001", node, GROUP_CONTENT);
|
|
19708
|
+
}
|
|
19376
19709
|
const findFilters = (n) => {
|
|
19377
19710
|
const filters2 = [];
|
|
19378
19711
|
for (const child of n.children) {
|
|
@@ -19524,10 +19857,6 @@ var failResult = (ruleId, node, message, level) => ({
|
|
|
19524
19857
|
level,
|
|
19525
19858
|
loc: node.loc
|
|
19526
19859
|
});
|
|
19527
|
-
var isTopLevel = (node, context) => {
|
|
19528
|
-
const ast = context.getAst?.();
|
|
19529
|
-
return !ast || ast.includes(node);
|
|
19530
|
-
};
|
|
19531
19860
|
var topLevelStanza = (context, name) => context.getAst?.()?.find((n) => equalsIgnoreCase(n.id.trim(), name));
|
|
19532
19861
|
var isPublicAsn = (asn) => {
|
|
19533
19862
|
const dot = asn.match(/^(\d+)\.(\d+)$/);
|
|
@@ -19850,7 +20179,10 @@ var JunosIsisAuthentication = {
|
|
|
19850
20179
|
},
|
|
19851
20180
|
tags: generalTags("routing", "authentication", "isis")
|
|
19852
20181
|
},
|
|
19853
|
-
check: (node) => {
|
|
20182
|
+
check: (node, context) => {
|
|
20183
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20184
|
+
return passResult2("JUN-CTRL-002", node, NOT_ROUTING_PROTOCOLS);
|
|
20185
|
+
}
|
|
19854
20186
|
const isis = findStanza4(node, "isis");
|
|
19855
20187
|
if (!isis) {
|
|
19856
20188
|
return passResult2("JUN-CTRL-002", node, "IS-IS not configured.");
|
|
@@ -19881,7 +20213,10 @@ var JunosBfdRecommended = {
|
|
|
19881
20213
|
owner: "NetOps",
|
|
19882
20214
|
remediation: "Configure BFD (bfd-liveness-detection) for routing protocol adjacencies."
|
|
19883
20215
|
},
|
|
19884
|
-
check: (node) => {
|
|
20216
|
+
check: (node, context) => {
|
|
20217
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20218
|
+
return passResult2("JUN-CTRL-003", node, NOT_ROUTING_PROTOCOLS);
|
|
20219
|
+
}
|
|
19885
20220
|
const bgp = findStanza4(node, "bgp");
|
|
19886
20221
|
const ospf = findStanza4(node, "ospf");
|
|
19887
20222
|
const isis = findStanza4(node, "isis");
|
|
@@ -20011,7 +20346,10 @@ var JunosBgpAuthentication = {
|
|
|
20011
20346
|
},
|
|
20012
20347
|
tags: generalTags("bgp", "authentication", "routing")
|
|
20013
20348
|
},
|
|
20014
|
-
check: (node) => {
|
|
20349
|
+
check: (node, context) => {
|
|
20350
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20351
|
+
return passResult2("JUN-BGP-003", node, NOT_ROUTING_PROTOCOLS);
|
|
20352
|
+
}
|
|
20015
20353
|
const bgp = findStanza4(node, "bgp");
|
|
20016
20354
|
if (!bgp) {
|
|
20017
20355
|
return passResult2("JUN-BGP-003", node, "BGP not configured.");
|
|
@@ -20043,7 +20381,10 @@ var JunosBgpPrefixLimit = {
|
|
|
20043
20381
|
},
|
|
20044
20382
|
tags: generalTags("bgp", "dos", "routing")
|
|
20045
20383
|
},
|
|
20046
|
-
check: (node) => {
|
|
20384
|
+
check: (node, context) => {
|
|
20385
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20386
|
+
return passResult2("JUN-BGP-005", node, NOT_ROUTING_PROTOCOLS);
|
|
20387
|
+
}
|
|
20047
20388
|
const bgp = findStanza4(node, "bgp");
|
|
20048
20389
|
if (!bgp) {
|
|
20049
20390
|
return passResult2("JUN-BGP-005", node, "BGP not configured.");
|
|
@@ -20085,7 +20426,10 @@ var JunosBgpPolicies = {
|
|
|
20085
20426
|
},
|
|
20086
20427
|
tags: generalTags("bgp", "filtering", "routing")
|
|
20087
20428
|
},
|
|
20088
|
-
check: (node) => {
|
|
20429
|
+
check: (node, context) => {
|
|
20430
|
+
if (!isRoutingProtocolsStanza(node, context)) {
|
|
20431
|
+
return passResult2("JUN-BGP-006", node, NOT_ROUTING_PROTOCOLS);
|
|
20432
|
+
}
|
|
20089
20433
|
const bgp = findStanza4(node, "bgp");
|
|
20090
20434
|
if (!bgp) {
|
|
20091
20435
|
return passResult2("JUN-BGP-006", node, "BGP not configured.");
|
|
@@ -20233,6 +20577,7 @@ var JunosProtectRe = {
|
|
|
20233
20577
|
return passResult2("JUN-RE-001", node, "Protect-RE filter is applied to loopback interface.");
|
|
20234
20578
|
}
|
|
20235
20579
|
};
|
|
20580
|
+
var UNTRUSTED_ZONE = /untrust|external|internet/i;
|
|
20236
20581
|
var JunosZoneScreens = {
|
|
20237
20582
|
id: "JUN-ZONE-003",
|
|
20238
20583
|
selector: "security",
|
|
@@ -20248,7 +20593,10 @@ var JunosZoneScreens = {
|
|
|
20248
20593
|
},
|
|
20249
20594
|
tags: generalTags("ids", "ddos", "screen")
|
|
20250
20595
|
},
|
|
20251
|
-
check: (node) => {
|
|
20596
|
+
check: (node, context) => {
|
|
20597
|
+
if (inGroup(node, context)) {
|
|
20598
|
+
return passResult2("JUN-ZONE-003", node, GROUP_CONTENT);
|
|
20599
|
+
}
|
|
20252
20600
|
const zones = findStanza4(node, "zones");
|
|
20253
20601
|
if (!zones) {
|
|
20254
20602
|
return passResult2("JUN-ZONE-003", node, "Security zones not configured.");
|
|
@@ -20256,7 +20604,7 @@ var JunosZoneScreens = {
|
|
|
20256
20604
|
const findings = [];
|
|
20257
20605
|
for (const zone of findStanzas3(zones, /^security-zone\s/i)) {
|
|
20258
20606
|
const zoneName = zone.id.replace(/^security-zone\s+/i, "").trim();
|
|
20259
|
-
const untrusted =
|
|
20607
|
+
const untrusted = UNTRUSTED_ZONE.test(zoneName);
|
|
20260
20608
|
if (untrusted && !hasZoneScreen(zone)) {
|
|
20261
20609
|
findings.push(offenderResult2("JUN-ZONE-003", zone, `Zone "${zoneName}" should have a security screen configured.`, "warning"));
|
|
20262
20610
|
}
|
|
@@ -20265,6 +20613,83 @@ var JunosZoneScreens = {
|
|
|
20265
20613
|
return passResult2("JUN-ZONE-003", node, "Security screens configured on appropriate zones.");
|
|
20266
20614
|
}
|
|
20267
20615
|
};
|
|
20616
|
+
var HOST_INBOUND_KINDS = ["system-services", "protocols"];
|
|
20617
|
+
var hostInboundMessage = (scope, kind, exceptions) => {
|
|
20618
|
+
const x = exceptions ? ' except those marked "except"' : "";
|
|
20619
|
+
return kind === "system-services" ? `${scope} accepts every host-inbound system service${x} ("system-services all"). List only the services it needs, such as ssh and ping.` : `${scope} accepts every host-inbound routing protocol${x} ("protocols all"). List only the protocols that run on it, such as bgp and ospf.`;
|
|
20620
|
+
};
|
|
20621
|
+
var paramIs = (node, index, word) => {
|
|
20622
|
+
const param = node.params[index];
|
|
20623
|
+
return param !== void 0 && equalsIgnoreCase(param, word);
|
|
20624
|
+
};
|
|
20625
|
+
var isExcepted = (node) => node.params.slice(1).some((p) => equalsIgnoreCase(p, "except")) || node.children.some((child) => paramIs(child, 0, "except"));
|
|
20626
|
+
var hostInboundAlls = (hostInbound) => {
|
|
20627
|
+
const found = [];
|
|
20628
|
+
for (const child of hostInbound.children) {
|
|
20629
|
+
const kind = HOST_INBOUND_KINDS.find((k) => paramIs(child, 0, k));
|
|
20630
|
+
if (!kind) continue;
|
|
20631
|
+
if (child.params.length === 2 && paramIs(child, 1, "all")) {
|
|
20632
|
+
found.push({ kind, entry: child, exceptions: false });
|
|
20633
|
+
continue;
|
|
20634
|
+
}
|
|
20635
|
+
const all = child.children.find((c) => paramIs(c, 0, "all"));
|
|
20636
|
+
if (!all) continue;
|
|
20637
|
+
const exceptions = child.children.some((c) => c !== all && isExcepted(c));
|
|
20638
|
+
found.push({ kind, entry: all, exceptions });
|
|
20639
|
+
}
|
|
20640
|
+
return found;
|
|
20641
|
+
};
|
|
20642
|
+
var hostInboundScopes = (zones) => {
|
|
20643
|
+
const scopes = [];
|
|
20644
|
+
for (const zone of findStanzas3(zones, /^(security-zone\s+\S|functional-zone\s+management\s*$)/i)) {
|
|
20645
|
+
const functional = /^functional-zone\s/i.test(zone.id);
|
|
20646
|
+
const name = functional ? "management" : zone.id.replace(/^security-zone\s+/i, "").trim();
|
|
20647
|
+
const zoneScope = functional ? `Functional zone "${name}"` : `Zone "${name}"`;
|
|
20648
|
+
const inZone = functional ? `in functional zone "${name}"` : `in zone "${name}"`;
|
|
20649
|
+
const own = findStanza4(zone, "host-inbound-traffic");
|
|
20650
|
+
if (own) scopes.push({ scope: zoneScope, zoneName: name, hostInbound: own });
|
|
20651
|
+
for (const ifl of findStanza4(zone, "interfaces")?.children ?? []) {
|
|
20652
|
+
const hostInbound = findStanza4(ifl, "host-inbound-traffic");
|
|
20653
|
+
if (hostInbound) scopes.push({ scope: `Interface ${ifl.id.trim()} ${inZone}`, zoneName: name, hostInbound });
|
|
20654
|
+
}
|
|
20655
|
+
}
|
|
20656
|
+
return scopes;
|
|
20657
|
+
};
|
|
20658
|
+
var JunosHostInboundAll = {
|
|
20659
|
+
id: "JUN-ZONE-004",
|
|
20660
|
+
selector: "security",
|
|
20661
|
+
vendor: "juniper-junos",
|
|
20662
|
+
category: "Service-Hardening",
|
|
20663
|
+
metadata: {
|
|
20664
|
+
level: "warning",
|
|
20665
|
+
obu: "Security",
|
|
20666
|
+
owner: "SecOps",
|
|
20667
|
+
remediation: 'Replace "host-inbound-traffic system-services all" and "protocols all" with the services and protocols each zone or interface needs (for example "system-services ssh", "protocols bgp").',
|
|
20668
|
+
security: {
|
|
20669
|
+
cwe: ["CWE-284"]
|
|
20670
|
+
},
|
|
20671
|
+
tags: generalTags("host-inbound", "hardening")
|
|
20672
|
+
},
|
|
20673
|
+
check: (node) => {
|
|
20674
|
+
const zones = findStanza4(node, "zones");
|
|
20675
|
+
if (!zones) {
|
|
20676
|
+
return passResult2("JUN-ZONE-004", node, "Security zones not configured.");
|
|
20677
|
+
}
|
|
20678
|
+
const findings = [];
|
|
20679
|
+
for (const { scope, zoneName, hostInbound } of hostInboundScopes(zones)) {
|
|
20680
|
+
const level = UNTRUSTED_ZONE.test(zoneName) ? "warning" : "info";
|
|
20681
|
+
for (const { kind, entry, exceptions } of hostInboundAlls(hostInbound)) {
|
|
20682
|
+
findings.push({
|
|
20683
|
+
...offenderResult2("JUN-ZONE-004", entry, hostInboundMessage(scope, kind, exceptions), level),
|
|
20684
|
+
// One id in both forms: brace "all" and set "system-services all" (C1).
|
|
20685
|
+
nodeId: `${kind} all`
|
|
20686
|
+
});
|
|
20687
|
+
}
|
|
20688
|
+
}
|
|
20689
|
+
if (findings.length > 0) return findings;
|
|
20690
|
+
return passResult2("JUN-ZONE-004", node, "No zone accepts all host-inbound services or protocols.");
|
|
20691
|
+
}
|
|
20692
|
+
};
|
|
20268
20693
|
var WEAK_PROPOSAL_SET = /^proposal-set\s+(basic|compatible|standard)\b/i;
|
|
20269
20694
|
var JunosIkeDhGroup = {
|
|
20270
20695
|
id: "JUN-VPN-001",
|
|
@@ -20361,7 +20786,10 @@ var JunosIkeDpd = {
|
|
|
20361
20786
|
owner: "NetOps",
|
|
20362
20787
|
remediation: "Enable dead-peer-detection on IKE gateways for tunnel health monitoring."
|
|
20363
20788
|
},
|
|
20364
|
-
check: (node) => {
|
|
20789
|
+
check: (node, context) => {
|
|
20790
|
+
if (inGroup(node, context)) {
|
|
20791
|
+
return passResult2("JUN-VPN-003", node, GROUP_CONTENT);
|
|
20792
|
+
}
|
|
20365
20793
|
const ike = findStanza4(node, "ike");
|
|
20366
20794
|
if (!ike) {
|
|
20367
20795
|
return passResult2("JUN-VPN-003", node, "IKE not configured.");
|
|
@@ -20581,7 +21009,11 @@ var JunosSecretStorage = {
|
|
|
20581
21009
|
})
|
|
20582
21010
|
};
|
|
20583
21011
|
var SRX_SECURITY_STATEMENT = /^(zones|policies|screen|nat|flow|address-book|utm|alg|idp|application-firewall|log)\b/i;
|
|
20584
|
-
var
|
|
21012
|
+
var isLogicalSystemSecurity = (node, context) => {
|
|
21013
|
+
const logicalSystems = topLevelStanza(context, "logical-systems");
|
|
21014
|
+
return logicalSystems?.children.some((system) => system.children.some((child) => child === node)) ?? false;
|
|
21015
|
+
};
|
|
21016
|
+
var isSrxSecurityStanza = (node, context) => (isTopLevel(node, context) || isLogicalSystemSecurity(node, context)) && node.children.some((child) => SRX_SECURITY_STATEMENT.test(child.id.trim()));
|
|
20585
21017
|
var JunosOspfInterfaceAuth = {
|
|
20586
21018
|
id: "JUN-CTRL-001",
|
|
20587
21019
|
selector: "protocols",
|
|
@@ -20808,7 +21240,7 @@ var JunosSecurityLogging = {
|
|
|
20808
21240
|
level: "warning",
|
|
20809
21241
|
obu: "Security",
|
|
20810
21242
|
owner: "SecOps",
|
|
20811
|
-
remediation:
|
|
21243
|
+
remediation: 'Configure "security log mode stream" with a "stream" host. Event-mode security logs stay on the device unless forwarded.',
|
|
20812
21244
|
tags: generalTags("logging", "monitoring")
|
|
20813
21245
|
},
|
|
20814
21246
|
check: (node, context) => {
|
|
@@ -20819,7 +21251,7 @@ var JunosSecurityLogging = {
|
|
|
20819
21251
|
return failResult(
|
|
20820
21252
|
"JUN-LOG-002",
|
|
20821
21253
|
node,
|
|
20822
|
-
"
|
|
21254
|
+
"No security log stanza: no security log stream to a log host is configured.",
|
|
20823
21255
|
"warning"
|
|
20824
21256
|
);
|
|
20825
21257
|
}
|
|
@@ -20858,6 +21290,7 @@ var allJuniperRules = [
|
|
|
20858
21290
|
JunosGracefulRestart,
|
|
20859
21291
|
JunosProtectRe,
|
|
20860
21292
|
JunosZoneScreens,
|
|
21293
|
+
JunosHostInboundAll,
|
|
20861
21294
|
JunosIkeDhGroup,
|
|
20862
21295
|
JunosIpsecEncryption,
|
|
20863
21296
|
JunosIkeDpd,
|
|
@@ -20909,11 +21342,19 @@ var AOSSWITCH_MARKERS = [
|
|
|
20909
21342
|
/^(no )?web-management\b/,
|
|
20910
21343
|
/^(no )?telnet-server$/
|
|
20911
21344
|
];
|
|
21345
|
+
var WLC_MARKERS = [
|
|
21346
|
+
/^wlan (ssid-profile|virtual-ap) /,
|
|
21347
|
+
/^ap-group /,
|
|
21348
|
+
/^rf (arm-profile|dot11[ag]-radio-profile) /,
|
|
21349
|
+
/^aaa (authentication-server radius|profile) "/,
|
|
21350
|
+
/^netservice \S+ (tcp|udp|\d+)\b/
|
|
21351
|
+
];
|
|
20912
21352
|
var platformOf = (statements) => {
|
|
20913
21353
|
for (const statement2 of statements) {
|
|
20914
21354
|
const text = textOf2(statement2);
|
|
20915
21355
|
if (AOSCX_MARKERS.some((m) => m.test(text))) return "aoscx";
|
|
20916
21356
|
if (AOSSWITCH_MARKERS.some((m) => m.test(text))) return "aosswitch";
|
|
21357
|
+
if (WLC_MARKERS.some((m) => m.test(text))) return "wlc";
|
|
20917
21358
|
if (/^vlan \d+$/.test(text) && statement2.children.some((c) => /^(no )?(un)?tagged /.test(textOf2(c)))) {
|
|
20918
21359
|
return "aosswitch";
|
|
20919
21360
|
}
|
|
@@ -20930,24 +21371,26 @@ var indexOf = (context) => {
|
|
|
20930
21371
|
indexCache.set(ast, index);
|
|
20931
21372
|
return index;
|
|
20932
21373
|
};
|
|
20933
|
-
var
|
|
21374
|
+
var NTP_SERVER = /^ntp server \S+/;
|
|
21375
|
+
var SNTP_SERVER = /^sntp server (?:priority \d+ \S+|(?!priority\b)\S+)/;
|
|
21376
|
+
var configWideOn = (platforms, judge) => (node, context) => {
|
|
20934
21377
|
const index = indexOf(context);
|
|
20935
21378
|
const anchor = index?.statements[0];
|
|
20936
|
-
if (!index || anchor !== node || index.platform
|
|
20937
|
-
return judge(index.statements, anchor);
|
|
21379
|
+
if (!index?.platform || anchor !== node || !platforms.includes(index.platform)) return [];
|
|
21380
|
+
return judge(index.platform, index.statements, anchor);
|
|
20938
21381
|
};
|
|
21382
|
+
var configWide = (platform, judge) => configWideOn([platform], (_platform, statements, anchor) => judge(statements, anchor));
|
|
20939
21383
|
|
|
20940
21384
|
// ../rules-default/src/aruba/common-rules.ts
|
|
20941
21385
|
var SshEnabled = {
|
|
20942
21386
|
id: "ARU-SEC-001",
|
|
20943
|
-
|
|
20944
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21387
|
+
vendor: "aruba-aoscx",
|
|
20945
21388
|
category: "Session-Management",
|
|
20946
21389
|
metadata: {
|
|
20947
|
-
level: "
|
|
21390
|
+
level: "warning",
|
|
20948
21391
|
obu: "Security",
|
|
20949
21392
|
owner: "SecOps",
|
|
20950
|
-
remediation:
|
|
21393
|
+
remediation: 'Enable the SSH server on the management VRF ("ssh server vrf mgmt") and disable Telnet if it is enabled.',
|
|
20951
21394
|
security: {
|
|
20952
21395
|
cwe: ["CWE-319"]
|
|
20953
21396
|
},
|
|
@@ -20956,27 +21399,16 @@ var SshEnabled = {
|
|
|
20956
21399
|
{ type: "general", label: "encryption" }
|
|
20957
21400
|
]
|
|
20958
21401
|
},
|
|
20959
|
-
check: (
|
|
20960
|
-
const
|
|
20961
|
-
if (
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
|
|
20966
|
-
|
|
20967
|
-
|
|
20968
|
-
|
|
20969
|
-
};
|
|
20970
|
-
}
|
|
20971
|
-
return {
|
|
20972
|
-
passed: true,
|
|
20973
|
-
message: "SSH configuration found.",
|
|
20974
|
-
ruleId: "ARU-SEC-001",
|
|
20975
|
-
nodeId: node.id,
|
|
20976
|
-
level: "info",
|
|
20977
|
-
loc: node.loc
|
|
20978
|
-
};
|
|
20979
|
-
}
|
|
21402
|
+
check: configWide("aoscx", (statements, anchor) => {
|
|
21403
|
+
const enabled = statements.find((s) => /^ssh server vrf \S+$/.test(textOf2(s)));
|
|
21404
|
+
if (enabled) return passAt("ARU-SEC-001", enabled, "SSH server is enabled on a VRF.");
|
|
21405
|
+
return failAbsent(
|
|
21406
|
+
"ARU-SEC-001",
|
|
21407
|
+
anchor,
|
|
21408
|
+
'SSH server is not enabled on any VRF (no "ssh server vrf <vrf>"). Enable it on the management VRF.',
|
|
21409
|
+
"warning"
|
|
21410
|
+
);
|
|
21411
|
+
})
|
|
20980
21412
|
};
|
|
20981
21413
|
var SnmpNotDefault = {
|
|
20982
21414
|
id: "ARU-SEC-002",
|
|
@@ -21063,8 +21495,7 @@ var TelnetDisabled = {
|
|
|
21063
21495
|
};
|
|
21064
21496
|
var NtpConfigured = {
|
|
21065
21497
|
id: "ARU-NTP-001",
|
|
21066
|
-
|
|
21067
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21498
|
+
vendor: ["aruba-aoscx", "aruba-wlc"],
|
|
21068
21499
|
category: "Time-Synchronization",
|
|
21069
21500
|
metadata: {
|
|
21070
21501
|
level: "warning",
|
|
@@ -21079,64 +21510,37 @@ var NtpConfigured = {
|
|
|
21079
21510
|
{ type: "general", label: "logging" }
|
|
21080
21511
|
]
|
|
21081
21512
|
},
|
|
21082
|
-
check: (
|
|
21083
|
-
const
|
|
21084
|
-
if (
|
|
21085
|
-
|
|
21086
|
-
|
|
21087
|
-
message: "NTP is configured.",
|
|
21088
|
-
ruleId: "ARU-NTP-001",
|
|
21089
|
-
nodeId: node.id,
|
|
21090
|
-
level: "info",
|
|
21091
|
-
loc: node.loc
|
|
21092
|
-
};
|
|
21093
|
-
}
|
|
21094
|
-
return {
|
|
21095
|
-
passed: true,
|
|
21096
|
-
message: "NTP configuration found.",
|
|
21097
|
-
ruleId: "ARU-NTP-001",
|
|
21098
|
-
nodeId: node.id,
|
|
21099
|
-
level: "info",
|
|
21100
|
-
loc: node.loc
|
|
21101
|
-
};
|
|
21102
|
-
}
|
|
21513
|
+
check: configWideOn(["aoscx", "wlc"], (_platform, statements, anchor) => {
|
|
21514
|
+
const server = statements.find((s) => NTP_SERVER.test(textOf2(s)));
|
|
21515
|
+
if (server) return passAt("ARU-NTP-001", server, "NTP server is configured.");
|
|
21516
|
+
return failAbsent("ARU-NTP-001", anchor, 'No NTP server is configured ("ntp server <address>").', "warning");
|
|
21517
|
+
})
|
|
21103
21518
|
};
|
|
21104
21519
|
var SntpConfigured = {
|
|
21105
21520
|
id: "ARU-NTP-002",
|
|
21106
|
-
|
|
21107
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21521
|
+
vendor: "aruba-aosswitch",
|
|
21108
21522
|
category: "Time-Synchronization",
|
|
21109
21523
|
metadata: {
|
|
21110
21524
|
level: "warning",
|
|
21111
21525
|
obu: "Network Engineering",
|
|
21112
21526
|
owner: "NetOps",
|
|
21113
|
-
remediation: "
|
|
21527
|
+
remediation: 'Add "timesync sntp" and "sntp unicast" so the configured SNTP servers are used.'
|
|
21114
21528
|
},
|
|
21115
|
-
check: (
|
|
21116
|
-
const
|
|
21117
|
-
if (
|
|
21118
|
-
|
|
21119
|
-
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
|
|
21125
|
-
|
|
21126
|
-
|
|
21127
|
-
return {
|
|
21128
|
-
passed: true,
|
|
21129
|
-
message: "SNTP configuration found.",
|
|
21130
|
-
ruleId: "ARU-NTP-002",
|
|
21131
|
-
nodeId: maskSecretLine(node),
|
|
21132
|
-
level: "info",
|
|
21133
|
-
loc: node.loc
|
|
21134
|
-
};
|
|
21135
|
-
}
|
|
21529
|
+
check: configWide("aosswitch", (statements) => {
|
|
21530
|
+
const server = statements.find((s) => SNTP_SERVER.test(textOf2(s)));
|
|
21531
|
+
if (!server) return [];
|
|
21532
|
+
const has = (text) => statements.some((s) => textOf2(s) === text);
|
|
21533
|
+
if (has("timesync sntp") && has("sntp unicast")) return passAt("ARU-NTP-002", server, "SNTP servers are in use.");
|
|
21534
|
+
return failAt(
|
|
21535
|
+
"ARU-NTP-002",
|
|
21536
|
+
server,
|
|
21537
|
+
'SNTP servers are configured but not used: add "timesync sntp" and "sntp unicast".',
|
|
21538
|
+
"warning"
|
|
21539
|
+
);
|
|
21540
|
+
})
|
|
21136
21541
|
};
|
|
21137
21542
|
var LoggingConfigured = {
|
|
21138
21543
|
id: "ARU-LOG-001",
|
|
21139
|
-
selector: "logging",
|
|
21140
21544
|
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21141
21545
|
category: "Logging",
|
|
21142
21546
|
metadata: {
|
|
@@ -21152,31 +21556,20 @@ var LoggingConfigured = {
|
|
|
21152
21556
|
{ type: "general", label: "audit" }
|
|
21153
21557
|
]
|
|
21154
21558
|
},
|
|
21155
|
-
check: (
|
|
21156
|
-
const
|
|
21157
|
-
if (
|
|
21158
|
-
|
|
21159
|
-
|
|
21160
|
-
message: "Logging server is configured.",
|
|
21161
|
-
ruleId: "ARU-LOG-001",
|
|
21162
|
-
nodeId: node.id,
|
|
21163
|
-
level: "info",
|
|
21164
|
-
loc: node.loc
|
|
21165
|
-
};
|
|
21166
|
-
}
|
|
21167
|
-
return {
|
|
21168
|
-
passed: true,
|
|
21169
|
-
message: "Logging configuration found.",
|
|
21170
|
-
ruleId: "ARU-LOG-001",
|
|
21171
|
-
nodeId: node.id,
|
|
21172
|
-
level: "info",
|
|
21173
|
-
loc: node.loc
|
|
21174
|
-
};
|
|
21175
|
-
}
|
|
21559
|
+
check: configWideOn(["aoscx", "aosswitch", "wlc"], (_platform, statements, anchor) => {
|
|
21560
|
+
const server = statements.find((s) => /^logging \S*[.:]/.test(textOf2(s)));
|
|
21561
|
+
if (server) return passAt("ARU-LOG-001", server, "Remote syslog server is configured.");
|
|
21562
|
+
return failAbsent("ARU-LOG-001", anchor, 'No remote syslog server is configured ("logging <address>").', "warning");
|
|
21563
|
+
})
|
|
21176
21564
|
};
|
|
21565
|
+
var isRemoteAuthentication = (node) => {
|
|
21566
|
+
const words = wordsOf(node);
|
|
21567
|
+
if (words[0] !== "aaa" || words[1] !== "authentication") return false;
|
|
21568
|
+
return words[2] === "login" ? words.includes("group") : words.slice(3).some((w) => w === "tacacs" || w === "radius");
|
|
21569
|
+
};
|
|
21570
|
+
var isWlcManagementServerGroup = (node) => textOf2(node) === "aaa authentication mgmt" && node.children.some((c) => textOf2(c).startsWith("server-group "));
|
|
21177
21571
|
var AaaConfigured = {
|
|
21178
21572
|
id: "ARU-AAA-001",
|
|
21179
|
-
selector: "aaa",
|
|
21180
21573
|
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21181
21574
|
category: "Authentication",
|
|
21182
21575
|
metadata: {
|
|
@@ -21192,27 +21585,16 @@ var AaaConfigured = {
|
|
|
21192
21585
|
{ type: "general", label: "aaa" }
|
|
21193
21586
|
]
|
|
21194
21587
|
},
|
|
21195
|
-
check: (
|
|
21196
|
-
const
|
|
21197
|
-
if (
|
|
21198
|
-
|
|
21199
|
-
|
|
21200
|
-
|
|
21201
|
-
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
};
|
|
21206
|
-
}
|
|
21207
|
-
return {
|
|
21208
|
-
passed: true,
|
|
21209
|
-
message: "AAA configuration found.",
|
|
21210
|
-
ruleId: "ARU-AAA-001",
|
|
21211
|
-
nodeId: maskSecretLine(node),
|
|
21212
|
-
level: "info",
|
|
21213
|
-
loc: node.loc
|
|
21214
|
-
};
|
|
21215
|
-
}
|
|
21588
|
+
check: configWideOn(["aoscx", "aosswitch", "wlc"], (platform, statements, anchor) => {
|
|
21589
|
+
const remote = statements.find(platform === "wlc" ? isWlcManagementServerGroup : isRemoteAuthentication);
|
|
21590
|
+
if (remote) return passAt("ARU-AAA-001", remote, "Management logins use a remote authentication server.");
|
|
21591
|
+
return failAbsent(
|
|
21592
|
+
"ARU-AAA-001",
|
|
21593
|
+
anchor,
|
|
21594
|
+
"Management logins use local accounts only; configure RADIUS or TACACS+ authentication.",
|
|
21595
|
+
"warning"
|
|
21596
|
+
);
|
|
21597
|
+
})
|
|
21216
21598
|
};
|
|
21217
21599
|
var serverKeyMissing = (node, context, kind) => {
|
|
21218
21600
|
const words = wordsOf(node);
|
|
@@ -21309,11 +21691,6 @@ var TacacsKeyConfigured = {
|
|
|
21309
21691
|
};
|
|
21310
21692
|
}
|
|
21311
21693
|
};
|
|
21312
|
-
var isRemoteAuthentication = (node) => {
|
|
21313
|
-
const words = wordsOf(node);
|
|
21314
|
-
if (words[0] !== "aaa" || words[1] !== "authentication") return false;
|
|
21315
|
-
return words[2] === "login" ? words.includes("group") : words.slice(3).some((w) => w === "tacacs" || w === "radius");
|
|
21316
|
-
};
|
|
21317
21694
|
var isRemoteAccounting = (node) => {
|
|
21318
21695
|
const words = wordsOf(node);
|
|
21319
21696
|
if (words[0] !== "aaa" || words[1] !== "accounting") return false;
|
|
@@ -22725,28 +23102,29 @@ var AosSwitchOperatorPassword = {
|
|
|
22725
23102
|
};
|
|
22726
23103
|
var AosSwitchSshEnabled = {
|
|
22727
23104
|
id: "AOSSW-SEC-003",
|
|
22728
|
-
selector: "ip ssh",
|
|
22729
23105
|
vendor: "aruba-aosswitch",
|
|
22730
23106
|
category: "Session-Management",
|
|
22731
23107
|
metadata: {
|
|
22732
23108
|
level: "error",
|
|
22733
23109
|
obu: "Security",
|
|
22734
23110
|
owner: "SecOps",
|
|
22735
|
-
remediation: '
|
|
23111
|
+
remediation: 'Remove "no ip ssh" (or enter "ip ssh") so the SSH server runs, and disable Telnet ("no telnet-server").',
|
|
22736
23112
|
security: {
|
|
22737
23113
|
cwe: ["CWE-319"]
|
|
22738
23114
|
}
|
|
22739
23115
|
},
|
|
22740
|
-
check: (
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
23116
|
+
check: configWide("aosswitch", (statements, anchor) => {
|
|
23117
|
+
const disabled = statements.find((s) => textOf2(s) === "no ip ssh");
|
|
23118
|
+
if (disabled) {
|
|
23119
|
+
return failAt(
|
|
23120
|
+
"AOSSW-SEC-003",
|
|
23121
|
+
disabled,
|
|
23122
|
+
'SSH server is disabled ("no ip ssh"). Enable it with "ip ssh" and disable Telnet.',
|
|
23123
|
+
"error"
|
|
23124
|
+
);
|
|
23125
|
+
}
|
|
23126
|
+
return passAt("AOSSW-SEC-003", anchor, "SSH server is on (the AOS-Switch default).");
|
|
23127
|
+
})
|
|
22750
23128
|
};
|
|
22751
23129
|
var AosSwitchSpanningTree = {
|
|
22752
23130
|
id: "AOSSW-STP-001",
|
|
@@ -22899,38 +23277,33 @@ var AosSwitchConsoleTimeout = {
|
|
|
22899
23277
|
};
|
|
22900
23278
|
}
|
|
22901
23279
|
};
|
|
23280
|
+
var SNTP_LEARNED_MODE = /^sntp (dhcp|broadcast)$/;
|
|
23281
|
+
var TIMEP = /^ip timep (dhcp|manual \S+)/;
|
|
22902
23282
|
var AosSwitchTimesync = {
|
|
22903
23283
|
id: "AOSSW-TIME-001",
|
|
22904
|
-
selector: "timesync",
|
|
22905
23284
|
vendor: "aruba-aosswitch",
|
|
22906
23285
|
category: "Time-Synchronization",
|
|
22907
23286
|
metadata: {
|
|
22908
23287
|
level: "warning",
|
|
22909
23288
|
obu: "Network Engineering",
|
|
22910
23289
|
owner: "NetOps",
|
|
22911
|
-
remediation:
|
|
23290
|
+
remediation: 'Configure a time server: "sntp server priority 1 <address>" with "timesync sntp" and "sntp unicast", or "ntp server <address>".'
|
|
22912
23291
|
},
|
|
22913
|
-
check: (
|
|
22914
|
-
const
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
|
|
22919
|
-
|
|
22920
|
-
|
|
22921
|
-
|
|
22922
|
-
|
|
22923
|
-
|
|
22924
|
-
|
|
22925
|
-
|
|
22926
|
-
|
|
22927
|
-
|
|
22928
|
-
ruleId: "AOSSW-TIME-001",
|
|
22929
|
-
nodeId: node.id,
|
|
22930
|
-
level: "info",
|
|
22931
|
-
loc: node.loc
|
|
22932
|
-
};
|
|
22933
|
-
}
|
|
23292
|
+
check: configWide("aosswitch", (statements, anchor) => {
|
|
23293
|
+
const lines = statements.flatMap((s) => [s, ...s.children]);
|
|
23294
|
+
const server = lines.find((s) => NTP_SERVER.test(textOf2(s)) || SNTP_SERVER.test(textOf2(s)));
|
|
23295
|
+
if (server) return passAt("AOSSW-TIME-001", server, "Time server is configured.");
|
|
23296
|
+
const sntpMode = statements.some((s) => textOf2(s) === "timesync sntp") ? statements.find((s) => SNTP_LEARNED_MODE.test(textOf2(s))) : void 0;
|
|
23297
|
+
if (sntpMode) return passAt("AOSSW-TIME-001", sntpMode, "SNTP learns its time server by DHCP or broadcast.");
|
|
23298
|
+
const timep = lines.find((s) => TIMEP.test(textOf2(s)));
|
|
23299
|
+
if (timep) return passAt("AOSSW-TIME-001", timep, "TimeP time synchronization is configured.");
|
|
23300
|
+
return failAbsent(
|
|
23301
|
+
"AOSSW-TIME-001",
|
|
23302
|
+
anchor,
|
|
23303
|
+
'No time server is configured ("ntp server <address>" or "sntp server priority <n> <address>").',
|
|
23304
|
+
"warning"
|
|
23305
|
+
);
|
|
23306
|
+
})
|
|
22934
23307
|
};
|
|
22935
23308
|
var HttpDisabled = {
|
|
22936
23309
|
id: "ARU-HTTP-001",
|
|
@@ -23773,7 +24146,7 @@ var valueOf = (node, name) => {
|
|
|
23773
24146
|
const statement2 = childNamed(node, name);
|
|
23774
24147
|
return statement2 ? valuesOf(statement2)[0] : void 0;
|
|
23775
24148
|
};
|
|
23776
|
-
var
|
|
24149
|
+
var descendantsOf2 = (nodes) => {
|
|
23777
24150
|
const out = [];
|
|
23778
24151
|
const visit = (list) => {
|
|
23779
24152
|
for (const child of list) {
|
|
@@ -23784,16 +24157,9 @@ var descendantsOf = (nodes) => {
|
|
|
23784
24157
|
visit(nodes);
|
|
23785
24158
|
return out;
|
|
23786
24159
|
};
|
|
23787
|
-
var
|
|
23788
|
-
|
|
23789
|
-
|
|
23790
|
-
if (node.children.includes(target)) return [node];
|
|
23791
|
-
const path = ancestorsOf(node.children, target);
|
|
23792
|
-
if (path.length > 0) return [node, ...path];
|
|
23793
|
-
}
|
|
23794
|
-
return [];
|
|
23795
|
-
};
|
|
23796
|
-
var inTemplate = (node, context) => ancestorsOf(context.getAst?.() ?? [], node).some((a) => ["template", "template-stack"].includes(keywordOf(a)));
|
|
24160
|
+
var enclosingBlocks2 = (node, context) => ancestorsOf(context?.getAst?.() ?? [], node) ?? [];
|
|
24161
|
+
var inTemplate = (node, context) => enclosingBlocks2(node, context).some((a) => ["template", "template-stack"].includes(keywordOf(a)));
|
|
24162
|
+
var TEMPLATE_CONTENT = "Panorama template content is not judged as the device configuration.";
|
|
23797
24163
|
var HostnameRequired = {
|
|
23798
24164
|
id: "PAN-SYS-001",
|
|
23799
24165
|
selector: "deviceconfig",
|
|
@@ -23805,7 +24171,10 @@ var HostnameRequired = {
|
|
|
23805
24171
|
owner: "NetOps",
|
|
23806
24172
|
remediation: "Configure hostname under deviceconfig > system."
|
|
23807
24173
|
},
|
|
23808
|
-
check: (node) => {
|
|
24174
|
+
check: (node, context) => {
|
|
24175
|
+
if (inTemplate(node, context)) {
|
|
24176
|
+
return passResult3("PAN-SYS-001", node, TEMPLATE_CONTENT);
|
|
24177
|
+
}
|
|
23809
24178
|
const system = findStanza6(node, "system");
|
|
23810
24179
|
if (!system) {
|
|
23811
24180
|
return {
|
|
@@ -23849,7 +24218,10 @@ var NtpRequired2 = {
|
|
|
23849
24218
|
owner: "SecOps",
|
|
23850
24219
|
remediation: "Configure NTP servers under deviceconfig > system > ntp-servers."
|
|
23851
24220
|
},
|
|
23852
|
-
check: (node) => {
|
|
24221
|
+
check: (node, context) => {
|
|
24222
|
+
if (inTemplate(node, context)) {
|
|
24223
|
+
return passResult3("PAN-SYS-002", node, TEMPLATE_CONTENT);
|
|
24224
|
+
}
|
|
23853
24225
|
const system = findStanza6(node, "system");
|
|
23854
24226
|
if (!system) {
|
|
23855
24227
|
return {
|
|
@@ -23893,7 +24265,10 @@ var DnsRequired = {
|
|
|
23893
24265
|
owner: "NetOps",
|
|
23894
24266
|
remediation: "Configure DNS servers under deviceconfig > system > dns-setting."
|
|
23895
24267
|
},
|
|
23896
|
-
check: (node) => {
|
|
24268
|
+
check: (node, context) => {
|
|
24269
|
+
if (inTemplate(node, context)) {
|
|
24270
|
+
return passResult3("PAN-SYS-003", node, TEMPLATE_CONTENT);
|
|
24271
|
+
}
|
|
23897
24272
|
const system = findStanza6(node, "system");
|
|
23898
24273
|
if (!system) {
|
|
23899
24274
|
return {
|
|
@@ -23951,7 +24326,10 @@ var ManagementAccessRestricted = {
|
|
|
23951
24326
|
cwe: ["CWE-284"]
|
|
23952
24327
|
}
|
|
23953
24328
|
},
|
|
23954
|
-
check: (node) => {
|
|
24329
|
+
check: (node, context) => {
|
|
24330
|
+
if (inTemplate(node, context)) {
|
|
24331
|
+
return passResult3("PAN-SYS-004", node, TEMPLATE_CONTENT);
|
|
24332
|
+
}
|
|
23955
24333
|
const system = findStanza6(node, "system");
|
|
23956
24334
|
if (!system) {
|
|
23957
24335
|
return {
|
|
@@ -23995,7 +24373,10 @@ var LoginBannerRequired = {
|
|
|
23995
24373
|
owner: "SecOps",
|
|
23996
24374
|
remediation: "Configure login-banner under deviceconfig > system."
|
|
23997
24375
|
},
|
|
23998
|
-
check: (node) => {
|
|
24376
|
+
check: (node, context) => {
|
|
24377
|
+
if (inTemplate(node, context)) {
|
|
24378
|
+
return passResult3("PAN-SYS-005", node, TEMPLATE_CONTENT);
|
|
24379
|
+
}
|
|
23999
24380
|
const system = findStanza6(node, "system");
|
|
24000
24381
|
if (!system) {
|
|
24001
24382
|
return {
|
|
@@ -24292,11 +24673,11 @@ var ZoneProtectionRequired = {
|
|
|
24292
24673
|
};
|
|
24293
24674
|
var NON_SECURITY_PROFILE_PARENTS = /* @__PURE__ */ new Set(["network", "log-settings", "profile-setting"]);
|
|
24294
24675
|
var isSecurityProfilesBlock = (ast, node) => {
|
|
24295
|
-
const parent = ancestorsOf(ast, node)
|
|
24676
|
+
const parent = ancestorsOf(ast, node)?.at(-1);
|
|
24296
24677
|
return !parent || !NON_SECURITY_PROFILE_PARENTS.has(keywordOf(parent));
|
|
24297
24678
|
};
|
|
24298
24679
|
var namesProfile = (node) => node !== void 0 && (node.children.length > 0 || valuesOf(node).length > 0);
|
|
24299
|
-
var securityProfileAvailable = (ast, type) =>
|
|
24680
|
+
var securityProfileAvailable = (ast, type) => descendantsOf2(ast).some((n) => {
|
|
24300
24681
|
const keyword = keywordOf(n);
|
|
24301
24682
|
if (keyword === "profiles" && n.children.length > 0 && isSecurityProfilesBlock(ast, n)) {
|
|
24302
24683
|
return namesProfile(childNamed(n, type));
|
|
@@ -24492,7 +24873,10 @@ var HARecommended = {
|
|
|
24492
24873
|
owner: "NetOps",
|
|
24493
24874
|
remediation: "Consider configuring High Availability (Active/Passive or Active/Active) for production environments."
|
|
24494
24875
|
},
|
|
24495
|
-
check: (node) => {
|
|
24876
|
+
check: (node, context) => {
|
|
24877
|
+
if (inTemplate(node, context)) {
|
|
24878
|
+
return passResult3("PAN-HA-001", node, TEMPLATE_CONTENT);
|
|
24879
|
+
}
|
|
24496
24880
|
const ha = findStanza6(node, "high-availability");
|
|
24497
24881
|
if (!ha || ha.children.length === 0) {
|
|
24498
24882
|
return {
|
|
@@ -24711,6 +25095,50 @@ var InterfaceManagementSecure = {
|
|
|
24711
25095
|
return passResult3("PAN-MGMT-003", node, "Interface management profiles use secure protocols only.");
|
|
24712
25096
|
}
|
|
24713
25097
|
};
|
|
25098
|
+
var PanMgmtServiceCleartext = {
|
|
25099
|
+
id: "PAN-MGMT-004",
|
|
25100
|
+
selector: "deviceconfig",
|
|
25101
|
+
vendor: "paloalto-panos",
|
|
25102
|
+
category: "Service-Hardening",
|
|
25103
|
+
metadata: {
|
|
25104
|
+
level: "error",
|
|
25105
|
+
obu: "Security",
|
|
25106
|
+
owner: "SecOps",
|
|
25107
|
+
remediation: 'Set "deviceconfig system service disable-telnet yes" and "disable-http yes" (Device > Setup > Interfaces > Management: clear Telnet and HTTP). Manage the firewall over SSH and HTTPS.',
|
|
25108
|
+
security: {
|
|
25109
|
+
cwe: ["CWE-319"]
|
|
25110
|
+
},
|
|
25111
|
+
tags: generalTags3("cleartext", "hardening")
|
|
25112
|
+
},
|
|
25113
|
+
check: (node) => {
|
|
25114
|
+
const service = childNamed(childNamed(node, "system"), "service");
|
|
25115
|
+
const findings = [];
|
|
25116
|
+
const telnet = childNamed(service, "disable-telnet");
|
|
25117
|
+
if (telnet && valuesOf(telnet)[0] === "no") {
|
|
25118
|
+
findings.push(
|
|
25119
|
+
offenderResult3(
|
|
25120
|
+
"PAN-MGMT-004",
|
|
25121
|
+
telnet,
|
|
25122
|
+
'The management interface accepts Telnet ("disable-telnet no"). Telnet sends credentials in clear text: set "disable-telnet yes" and use SSH.',
|
|
25123
|
+
"error"
|
|
25124
|
+
)
|
|
25125
|
+
);
|
|
25126
|
+
}
|
|
25127
|
+
const http = childNamed(service, "disable-http");
|
|
25128
|
+
if (http && valuesOf(http)[0] === "no") {
|
|
25129
|
+
findings.push(
|
|
25130
|
+
offenderResult3(
|
|
25131
|
+
"PAN-MGMT-004",
|
|
25132
|
+
http,
|
|
25133
|
+
'The management interface accepts HTTP ("disable-http no"). HTTP sends credentials in clear text: set "disable-http yes" and use HTTPS.',
|
|
25134
|
+
"error"
|
|
25135
|
+
)
|
|
25136
|
+
);
|
|
25137
|
+
}
|
|
25138
|
+
if (findings.length > 0) return findings;
|
|
25139
|
+
return passResult3("PAN-MGMT-004", node, "The management interface does not accept Telnet or HTTP.");
|
|
25140
|
+
}
|
|
25141
|
+
};
|
|
24714
25142
|
var WEAK_TLS_VERSIONS = /* @__PURE__ */ new Set(["sslv3", "tls1-0", "tls1-1"]);
|
|
24715
25143
|
var DecryptionTlsMinVersion = {
|
|
24716
25144
|
id: "PAN-DEC-001",
|
|
@@ -24783,7 +25211,7 @@ var DecryptionRuleDescription = {
|
|
|
24783
25211
|
var nameOf = (node) => keywordOf(node);
|
|
24784
25212
|
var usedProfileNames = (ast, refKeyword, implicitDefault) => {
|
|
24785
25213
|
const used = /* @__PURE__ */ new Set();
|
|
24786
|
-
for (const node of
|
|
25214
|
+
for (const node of descendantsOf2(ast)) {
|
|
24787
25215
|
if (node.children.length === 0 && keywordOf(node) === refKeyword) {
|
|
24788
25216
|
const name = valuesOf(node)[0];
|
|
24789
25217
|
if (name) used.add(name);
|
|
@@ -25113,10 +25541,13 @@ var LogForwardingRequired = {
|
|
|
25113
25541
|
remediation: "Configure log forwarding to syslog server, Panorama, or SIEM for centralized logging."
|
|
25114
25542
|
},
|
|
25115
25543
|
check: (node, context) => {
|
|
25116
|
-
|
|
25544
|
+
if (inTemplate(node, context)) {
|
|
25545
|
+
return passResult3("PAN-LOG-001", node, TEMPLATE_CONTENT);
|
|
25546
|
+
}
|
|
25547
|
+
const logSettings = descendantsOf2(context.getAst?.() ?? [node]).filter(
|
|
25117
25548
|
(n) => n.children.length > 0 && keywordOf(n) === "log-settings"
|
|
25118
25549
|
);
|
|
25119
|
-
if (logSettings.some((settings) =>
|
|
25550
|
+
if (logSettings.some((settings) => descendantsOf2(settings.children).some(forwardsLogs))) {
|
|
25120
25551
|
return passResult3("PAN-LOG-001", node, "Log forwarding is configured.");
|
|
25121
25552
|
}
|
|
25122
25553
|
return {
|
|
@@ -25235,6 +25666,7 @@ var allPaloAltoRules = [
|
|
|
25235
25666
|
PasswordComplexityRequired,
|
|
25236
25667
|
SnmpSecurityRequired,
|
|
25237
25668
|
InterfaceManagementSecure,
|
|
25669
|
+
PanMgmtServiceCleartext,
|
|
25238
25670
|
DecryptionTlsMinVersion,
|
|
25239
25671
|
DecryptionRuleDescription,
|
|
25240
25672
|
IkeCryptoStrong,
|
|
@@ -27361,6 +27793,15 @@ var offenderResult4 = (ruleId, offender, message, level) => ({
|
|
|
27361
27793
|
level,
|
|
27362
27794
|
loc: locOf(offender)
|
|
27363
27795
|
});
|
|
27796
|
+
var absentResult = (ruleId, anchor, message, level) => ({ ...offenderResult4(ruleId, anchor, message, level), absent: true });
|
|
27797
|
+
var unquote = (text) => text.replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
27798
|
+
var valueChild = (stanza, keyword) => stanza.children.find(
|
|
27799
|
+
(child) => startsWithIgnoreCase(child.id, keyword) && unquote(child.params.slice(1).join(" ")) !== ""
|
|
27800
|
+
);
|
|
27801
|
+
var hasValue = (stanza, keyword) => valueChild(stanza, keyword) !== void 0;
|
|
27802
|
+
var isProtocolsStanza = (node, context) => isTopLevel(node, context) || (context.getAst?.() ?? []).some(
|
|
27803
|
+
(top) => equalsIgnoreCase(top.id.trim(), "vrf") && top.children.some((vrf) => startsWithIgnoreCase(vrf.id, "name ") && vrf.children.includes(node))
|
|
27804
|
+
);
|
|
27364
27805
|
var VyosHostnameRequired = {
|
|
27365
27806
|
id: "VYOS-SYS-001",
|
|
27366
27807
|
selector: "system",
|
|
@@ -27372,17 +27813,11 @@ var VyosHostnameRequired = {
|
|
|
27372
27813
|
owner: "NetOps",
|
|
27373
27814
|
remediation: 'Configure "host-name" under system stanza.'
|
|
27374
27815
|
},
|
|
27375
|
-
check: (node) => {
|
|
27816
|
+
check: (node, context) => {
|
|
27817
|
+
if (!isTopLevel(node, context)) return [];
|
|
27376
27818
|
const hasHostname = hasChildCommand(node, "host-name");
|
|
27377
27819
|
if (!hasHostname) {
|
|
27378
|
-
return
|
|
27379
|
-
passed: false,
|
|
27380
|
-
message: "System missing host-name configuration.",
|
|
27381
|
-
ruleId: "VYOS-SYS-001",
|
|
27382
|
-
nodeId: node.id,
|
|
27383
|
-
level: "warning",
|
|
27384
|
-
loc: node.loc
|
|
27385
|
-
};
|
|
27820
|
+
return absentResult("VYOS-SYS-001", node, "System missing host-name configuration.", "warning");
|
|
27386
27821
|
}
|
|
27387
27822
|
return {
|
|
27388
27823
|
passed: true,
|
|
@@ -27406,30 +27841,17 @@ var VyosNtpRequired = {
|
|
|
27406
27841
|
remediation: 'Configure NTP servers under "service ntp server <address>" (VyOS 1.4+) or "system ntp server <address>" (1.3 and earlier).'
|
|
27407
27842
|
},
|
|
27408
27843
|
check: (node, context) => {
|
|
27844
|
+
if (!isTopLevel(node, context)) return [];
|
|
27409
27845
|
const service = (context.getAst?.() ?? []).find((n) => n.id.toLowerCase() === "service");
|
|
27410
27846
|
const serviceNtp = service ? findStanza7(service, "ntp") : void 0;
|
|
27411
27847
|
if (!hasNtpConfig(node) && !serviceNtp) {
|
|
27412
|
-
return
|
|
27413
|
-
passed: false,
|
|
27414
|
-
message: "System missing NTP configuration.",
|
|
27415
|
-
ruleId: "VYOS-SYS-002",
|
|
27416
|
-
nodeId: node.id,
|
|
27417
|
-
level: "warning",
|
|
27418
|
-
loc: node.loc
|
|
27419
|
-
};
|
|
27848
|
+
return absentResult("VYOS-SYS-002", node, "System missing NTP configuration.", "warning");
|
|
27420
27849
|
}
|
|
27421
27850
|
const ntp = findStanza7(node, "ntp") ?? serviceNtp;
|
|
27422
27851
|
if (ntp) {
|
|
27423
27852
|
const hasServer = hasChildCommand(ntp, "server");
|
|
27424
27853
|
if (!hasServer) {
|
|
27425
|
-
return
|
|
27426
|
-
passed: false,
|
|
27427
|
-
message: "NTP configured but no servers defined.",
|
|
27428
|
-
ruleId: "VYOS-SYS-002",
|
|
27429
|
-
nodeId: node.id,
|
|
27430
|
-
level: "warning",
|
|
27431
|
-
loc: node.loc
|
|
27432
|
-
};
|
|
27854
|
+
return offenderResult4("VYOS-SYS-002", ntp, "NTP configured but no servers defined.", "warning");
|
|
27433
27855
|
}
|
|
27434
27856
|
}
|
|
27435
27857
|
return {
|
|
@@ -27453,16 +27875,10 @@ var VyosSyslogRequired = {
|
|
|
27453
27875
|
owner: "NetOps",
|
|
27454
27876
|
remediation: 'Configure "syslog" under system stanza with remote host or local file.'
|
|
27455
27877
|
},
|
|
27456
|
-
check: (node) => {
|
|
27878
|
+
check: (node, context) => {
|
|
27879
|
+
if (!isTopLevel(node, context)) return [];
|
|
27457
27880
|
if (!hasSyslogConfig(node)) {
|
|
27458
|
-
return
|
|
27459
|
-
passed: false,
|
|
27460
|
-
message: "System missing syslog configuration.",
|
|
27461
|
-
ruleId: "VYOS-SYS-003",
|
|
27462
|
-
nodeId: node.id,
|
|
27463
|
-
level: "warning",
|
|
27464
|
-
loc: node.loc
|
|
27465
|
-
};
|
|
27881
|
+
return absentResult("VYOS-SYS-003", node, "System missing syslog configuration.", "warning");
|
|
27466
27882
|
}
|
|
27467
27883
|
return {
|
|
27468
27884
|
passed: true,
|
|
@@ -27488,7 +27904,8 @@ var VyosUserAuthRequired = {
|
|
|
27488
27904
|
cwe: ["CWE-306"]
|
|
27489
27905
|
}
|
|
27490
27906
|
},
|
|
27491
|
-
check: (node) => {
|
|
27907
|
+
check: (node, context) => {
|
|
27908
|
+
if (!isTopLevel(node, context)) return [];
|
|
27492
27909
|
const login = getLoginConfig(node);
|
|
27493
27910
|
if (!login) {
|
|
27494
27911
|
return {
|
|
@@ -27519,11 +27936,12 @@ var VyosUserAuthRequired = {
|
|
|
27519
27936
|
findings.push(offenderResult4("VYOS-SYS-004", user, `User "${username}" has no authentication configured.`, "error"));
|
|
27520
27937
|
continue;
|
|
27521
27938
|
}
|
|
27522
|
-
const hasPassword =
|
|
27939
|
+
const hasPassword = hasValue(auth, "encrypted-password");
|
|
27523
27940
|
const hasPublicKeys = hasChildCommand(auth, "public-keys");
|
|
27524
27941
|
if (!hasPassword && !hasPublicKeys) {
|
|
27525
27942
|
const username = user.id.split(/\s+/)[1] || user.id;
|
|
27526
|
-
|
|
27943
|
+
const message = hasValue(auth, "plaintext-password") ? `User "${username}" has only a plaintext-password, which VyOS replaces with encrypted-password on commit; store the hashed encrypted-password (or SSH public-keys) in the configuration.` : `User "${username}" has no password or SSH keys configured.`;
|
|
27944
|
+
findings.push(offenderResult4("VYOS-SYS-004", user, message, "error"));
|
|
27527
27945
|
}
|
|
27528
27946
|
}
|
|
27529
27947
|
if (findings.length > 0) return findings;
|
|
@@ -27552,19 +27970,16 @@ var VyosNoPlaintextPassword = {
|
|
|
27552
27970
|
}
|
|
27553
27971
|
},
|
|
27554
27972
|
check: (node) => {
|
|
27555
|
-
const
|
|
27556
|
-
|
|
27557
|
-
const value = child.params.slice(1).join(" ").replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
27558
|
-
return value !== "";
|
|
27559
|
-
});
|
|
27560
|
-
if (hasPlaintext) {
|
|
27973
|
+
const plaintext = valueChild(node, "plaintext-password");
|
|
27974
|
+
if (plaintext) {
|
|
27561
27975
|
return {
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
|
|
27566
|
-
|
|
27567
|
-
|
|
27976
|
+
...offenderResult4(
|
|
27977
|
+
"VYOS-SEC-001",
|
|
27978
|
+
plaintext,
|
|
27979
|
+
"Plaintext password found in configuration. VyOS should store hashed passwords only.",
|
|
27980
|
+
"error"
|
|
27981
|
+
),
|
|
27982
|
+
nodeId: maskSecretLine(plaintext)
|
|
27568
27983
|
};
|
|
27569
27984
|
}
|
|
27570
27985
|
return {
|
|
@@ -27588,17 +28003,11 @@ var VyosNameServersRequired = {
|
|
|
27588
28003
|
owner: "NetOps",
|
|
27589
28004
|
remediation: 'Configure "name-server" under system stanza.'
|
|
27590
28005
|
},
|
|
27591
|
-
check: (node) => {
|
|
28006
|
+
check: (node, context) => {
|
|
28007
|
+
if (!isTopLevel(node, context)) return [];
|
|
27592
28008
|
const hasNameServer = hasChildCommand(node, "name-server");
|
|
27593
28009
|
if (!hasNameServer) {
|
|
27594
|
-
return
|
|
27595
|
-
passed: false,
|
|
27596
|
-
message: "System has no name servers configured.",
|
|
27597
|
-
ruleId: "VYOS-SYS-005",
|
|
27598
|
-
nodeId: node.id,
|
|
27599
|
-
level: "info",
|
|
27600
|
-
loc: node.loc
|
|
27601
|
-
};
|
|
28010
|
+
return absentResult("VYOS-SYS-005", node, "System has no name servers configured.", "info");
|
|
27602
28011
|
}
|
|
27603
28012
|
return {
|
|
27604
28013
|
passed: true,
|
|
@@ -27624,16 +28033,10 @@ var VyosSshRequired = {
|
|
|
27624
28033
|
cwe: ["CWE-319"]
|
|
27625
28034
|
}
|
|
27626
28035
|
},
|
|
27627
|
-
check: (node) => {
|
|
28036
|
+
check: (node, context) => {
|
|
28037
|
+
if (!isTopLevel(node, context)) return [];
|
|
27628
28038
|
if (!hasSshService(node)) {
|
|
27629
|
-
return
|
|
27630
|
-
passed: false,
|
|
27631
|
-
message: "SSH service is not configured.",
|
|
27632
|
-
ruleId: "VYOS-SVC-001",
|
|
27633
|
-
nodeId: node.id,
|
|
27634
|
-
level: "warning",
|
|
27635
|
-
loc: node.loc
|
|
27636
|
-
};
|
|
28039
|
+
return absentResult("VYOS-SVC-001", node, "SSH service is not configured.", "warning");
|
|
27637
28040
|
}
|
|
27638
28041
|
return {
|
|
27639
28042
|
passed: true,
|
|
@@ -27659,7 +28062,8 @@ var VyosSshKeyAuth = {
|
|
|
27659
28062
|
cwe: ["CWE-309"]
|
|
27660
28063
|
}
|
|
27661
28064
|
},
|
|
27662
|
-
check: (node) => {
|
|
28065
|
+
check: (node, context) => {
|
|
28066
|
+
if (!isTopLevel(node, context)) return [];
|
|
27663
28067
|
const ssh = getSshConfig(node);
|
|
27664
28068
|
if (!ssh) {
|
|
27665
28069
|
return {
|
|
@@ -27673,14 +28077,7 @@ var VyosSshKeyAuth = {
|
|
|
27673
28077
|
}
|
|
27674
28078
|
const disablePassword = hasChildCommand(ssh, "disable-password-authentication");
|
|
27675
28079
|
if (!disablePassword) {
|
|
27676
|
-
return
|
|
27677
|
-
passed: false,
|
|
27678
|
-
message: "SSH password authentication is enabled. Consider using SSH keys only.",
|
|
27679
|
-
ruleId: "VYOS-SVC-002",
|
|
27680
|
-
nodeId: node.id,
|
|
27681
|
-
level: "info",
|
|
27682
|
-
loc: node.loc
|
|
27683
|
-
};
|
|
28080
|
+
return offenderResult4("VYOS-SVC-002", ssh, "SSH password authentication is enabled. Consider using SSH keys only.", "info");
|
|
27684
28081
|
}
|
|
27685
28082
|
return {
|
|
27686
28083
|
passed: true,
|
|
@@ -27703,7 +28100,8 @@ var VyosSshNonDefaultPort = {
|
|
|
27703
28100
|
owner: "SecOps",
|
|
27704
28101
|
remediation: 'Consider using a non-standard SSH port: "set service ssh port <port>".'
|
|
27705
28102
|
},
|
|
27706
|
-
check: (node) => {
|
|
28103
|
+
check: (node, context) => {
|
|
28104
|
+
if (!isTopLevel(node, context)) return [];
|
|
27707
28105
|
const ssh = getSshConfig(node);
|
|
27708
28106
|
if (!ssh) {
|
|
27709
28107
|
return {
|
|
@@ -27719,25 +28117,11 @@ var VyosSshNonDefaultPort = {
|
|
|
27719
28117
|
(child) => startsWithIgnoreCase(child.id, "port")
|
|
27720
28118
|
);
|
|
27721
28119
|
if (!portCmd) {
|
|
27722
|
-
return
|
|
27723
|
-
passed: false,
|
|
27724
|
-
message: "SSH using default port 22. Consider using a non-standard port.",
|
|
27725
|
-
ruleId: "VYOS-SVC-003",
|
|
27726
|
-
nodeId: node.id,
|
|
27727
|
-
level: "info",
|
|
27728
|
-
loc: node.loc
|
|
27729
|
-
};
|
|
28120
|
+
return offenderResult4("VYOS-SVC-003", ssh, "SSH using default port 22. Consider using a non-standard port.", "info");
|
|
27730
28121
|
}
|
|
27731
28122
|
const portMatch = portCmd.id.match(/port\s+['"]?(\d+)['"]?/i);
|
|
27732
28123
|
if (portMatch && portMatch[1] === "22") {
|
|
27733
|
-
return
|
|
27734
|
-
passed: false,
|
|
27735
|
-
message: "SSH configured on standard port 22. Consider using a non-standard port.",
|
|
27736
|
-
ruleId: "VYOS-SVC-003",
|
|
27737
|
-
nodeId: node.id,
|
|
27738
|
-
level: "info",
|
|
27739
|
-
loc: node.loc
|
|
27740
|
-
};
|
|
28124
|
+
return offenderResult4("VYOS-SVC-003", portCmd, "SSH configured on standard port 22. Consider using a non-standard port.", "info");
|
|
27741
28125
|
}
|
|
27742
28126
|
return {
|
|
27743
28127
|
passed: true,
|
|
@@ -27760,7 +28144,8 @@ var VyosInterfaceDescription = {
|
|
|
27760
28144
|
owner: "NetOps",
|
|
27761
28145
|
remediation: 'Add "description" to each physical interface.'
|
|
27762
28146
|
},
|
|
27763
|
-
check: (node) => {
|
|
28147
|
+
check: (node, context) => {
|
|
28148
|
+
if (!isTopLevel(node, context)) return [];
|
|
27764
28149
|
const findings = [];
|
|
27765
28150
|
const ethernetInterfaces = getEthernetInterfaces(node);
|
|
27766
28151
|
for (const iface of ethernetInterfaces) {
|
|
@@ -27784,6 +28169,22 @@ var VyosInterfaceDescription = {
|
|
|
27784
28169
|
};
|
|
27785
28170
|
}
|
|
27786
28171
|
};
|
|
28172
|
+
var memberPortNames = (interfaces) => {
|
|
28173
|
+
const names = /* @__PURE__ */ new Set();
|
|
28174
|
+
const visit = (parent) => {
|
|
28175
|
+
const owner = parent.id.toLowerCase();
|
|
28176
|
+
const holdsMembers = owner === "member" || owner === "switch-port";
|
|
28177
|
+
for (const child of parent.children) {
|
|
28178
|
+
if (holdsMembers) {
|
|
28179
|
+
const name = /^interface\s+(\S+)/i.exec(child.id)?.[1];
|
|
28180
|
+
if (name) names.add(name.toLowerCase());
|
|
28181
|
+
}
|
|
28182
|
+
visit(child);
|
|
28183
|
+
}
|
|
28184
|
+
};
|
|
28185
|
+
visit(interfaces);
|
|
28186
|
+
return names;
|
|
28187
|
+
};
|
|
27787
28188
|
var VyosInterfaceAddress = {
|
|
27788
28189
|
id: "VYOS-IF-002",
|
|
27789
28190
|
selector: "interfaces",
|
|
@@ -27795,23 +28196,17 @@ var VyosInterfaceAddress = {
|
|
|
27795
28196
|
owner: "NetOps",
|
|
27796
28197
|
remediation: 'Configure "address" (static IP or dhcp) for each active interface.'
|
|
27797
28198
|
},
|
|
27798
|
-
check: (node) => {
|
|
28199
|
+
check: (node, context) => {
|
|
28200
|
+
if (!isTopLevel(node, context)) return [];
|
|
27799
28201
|
const findings = [];
|
|
27800
28202
|
const ethernetInterfaces = getEthernetInterfaces(node);
|
|
27801
|
-
const members =
|
|
27802
|
-
for (const group of node.children) {
|
|
27803
|
-
const member = findStanza7(group, "member");
|
|
27804
|
-
for (const m of member?.children ?? []) {
|
|
27805
|
-
const name = /^interface\s+(\S+)/i.exec(m.id)?.[1];
|
|
27806
|
-
if (name) members.add(name.toLowerCase());
|
|
27807
|
-
}
|
|
27808
|
-
}
|
|
28203
|
+
const members = memberPortNames(node);
|
|
27809
28204
|
for (const iface of ethernetInterfaces) {
|
|
27810
28205
|
if (isDisabled2(iface)) {
|
|
27811
28206
|
continue;
|
|
27812
28207
|
}
|
|
27813
28208
|
const name = (iface.id.split(/\s+/).pop() ?? iface.id).toLowerCase();
|
|
27814
|
-
if (members.has(name) || hasChildCommand(iface, "bond-group") || iface.children.some((c) => /^vif(-s)?\s/i.test(c.id))) {
|
|
28209
|
+
if (members.has(name) || hasChildCommand(iface, "bond-group") || hasChildCommand(iface, "bridge-group") || iface.children.some((c) => /^vif(-s)?\s/i.test(c.id))) {
|
|
27815
28210
|
continue;
|
|
27816
28211
|
}
|
|
27817
28212
|
const hasAddress2 = hasChildCommand(iface, "address");
|
|
@@ -27842,7 +28237,8 @@ var VyosFirewallDefaultAction = {
|
|
|
27842
28237
|
owner: "SecOps",
|
|
27843
28238
|
remediation: 'Set "default-action drop" or "default-action reject" for each firewall ruleset.'
|
|
27844
28239
|
},
|
|
27845
|
-
check: (node) => {
|
|
28240
|
+
check: (node, context) => {
|
|
28241
|
+
if (!isTopLevel(node, context)) return [];
|
|
27846
28242
|
const rulesets = findStanzasByPrefix2(node, "name");
|
|
27847
28243
|
if (rulesets.length === 0) {
|
|
27848
28244
|
return {
|
|
@@ -27884,7 +28280,8 @@ var VyosFirewallRuleAction = {
|
|
|
27884
28280
|
owner: "SecOps",
|
|
27885
28281
|
remediation: 'Set "action accept", "action drop", or "action reject" for each firewall rule.'
|
|
27886
28282
|
},
|
|
27887
|
-
check: (node) => {
|
|
28283
|
+
check: (node, context) => {
|
|
28284
|
+
if (!isTopLevel(node, context)) return [];
|
|
27888
28285
|
const rulesets = findStanzasByPrefix2(node, "name");
|
|
27889
28286
|
if (rulesets.length === 0) {
|
|
27890
28287
|
return {
|
|
@@ -27930,7 +28327,8 @@ var VyosFirewallStateful = {
|
|
|
27930
28327
|
owner: "SecOps",
|
|
27931
28328
|
remediation: "Configure state-policy or add rules to accept established and related connections."
|
|
27932
28329
|
},
|
|
27933
|
-
check: (node) => {
|
|
28330
|
+
check: (node, context) => {
|
|
28331
|
+
if (!isTopLevel(node, context)) return [];
|
|
27934
28332
|
const statePolicy = findStanza7(node, "state-policy");
|
|
27935
28333
|
if (statePolicy) {
|
|
27936
28334
|
return {
|
|
@@ -27968,14 +28366,7 @@ var VyosFirewallStateful = {
|
|
|
27968
28366
|
if (hasStatefulRules) break;
|
|
27969
28367
|
}
|
|
27970
28368
|
if (!hasStatefulRules) {
|
|
27971
|
-
return
|
|
27972
|
-
passed: false,
|
|
27973
|
-
message: "No stateful firewall rules (established/related) found. Consider adding state-policy.",
|
|
27974
|
-
ruleId: "VYOS-FW-003",
|
|
27975
|
-
nodeId: node.id,
|
|
27976
|
-
level: "info",
|
|
27977
|
-
loc: node.loc
|
|
27978
|
-
};
|
|
28369
|
+
return absentResult("VYOS-FW-003", node, "No stateful firewall rules (established/related) found. Consider adding state-policy.", "info");
|
|
27979
28370
|
}
|
|
27980
28371
|
return {
|
|
27981
28372
|
passed: true,
|
|
@@ -27998,7 +28389,8 @@ var VyosNatOutboundInterface = {
|
|
|
27998
28389
|
owner: "NetOps",
|
|
27999
28390
|
remediation: 'Configure "outbound-interface" for source NAT rules.'
|
|
28000
28391
|
},
|
|
28001
|
-
check: (node) => {
|
|
28392
|
+
check: (node, context) => {
|
|
28393
|
+
if (!isTopLevel(node, context)) return [];
|
|
28002
28394
|
const source = findStanza7(node, "source");
|
|
28003
28395
|
if (!source) {
|
|
28004
28396
|
return {
|
|
@@ -28040,6 +28432,11 @@ var VyosNatOutboundInterface = {
|
|
|
28040
28432
|
};
|
|
28041
28433
|
}
|
|
28042
28434
|
};
|
|
28435
|
+
var translationNotRequired = (rule) => {
|
|
28436
|
+
if (hasChildCommand(rule, "exclude")) return true;
|
|
28437
|
+
const loadBalance = findStanza7(rule, "load-balance");
|
|
28438
|
+
return loadBalance !== void 0 && hasChildCommand(loadBalance, "backend");
|
|
28439
|
+
};
|
|
28043
28440
|
var VyosNatTranslation = {
|
|
28044
28441
|
id: "VYOS-NAT-002",
|
|
28045
28442
|
selector: "nat",
|
|
@@ -28051,12 +28448,14 @@ var VyosNatTranslation = {
|
|
|
28051
28448
|
owner: "NetOps",
|
|
28052
28449
|
remediation: 'Configure "translation address" for NAT rules (e.g., masquerade or static IP).'
|
|
28053
28450
|
},
|
|
28054
|
-
check: (node) => {
|
|
28451
|
+
check: (node, context) => {
|
|
28452
|
+
if (!isTopLevel(node, context)) return [];
|
|
28055
28453
|
const findings = [];
|
|
28056
28454
|
const source = findStanza7(node, "source");
|
|
28057
28455
|
if (source) {
|
|
28058
28456
|
const rules = findStanzasByPrefix2(source, "rule");
|
|
28059
28457
|
for (const rule of rules) {
|
|
28458
|
+
if (translationNotRequired(rule)) continue;
|
|
28060
28459
|
const hasTranslation = hasChildCommand(rule, "translation");
|
|
28061
28460
|
if (!hasTranslation) {
|
|
28062
28461
|
const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
|
|
@@ -28068,6 +28467,7 @@ var VyosNatTranslation = {
|
|
|
28068
28467
|
if (destination) {
|
|
28069
28468
|
const rules = findStanzasByPrefix2(destination, "rule");
|
|
28070
28469
|
for (const rule of rules) {
|
|
28470
|
+
if (translationNotRequired(rule)) continue;
|
|
28071
28471
|
const hasTranslation = hasChildCommand(rule, "translation");
|
|
28072
28472
|
if (!hasTranslation) {
|
|
28073
28473
|
const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
|
|
@@ -28100,7 +28500,8 @@ var VyosIpsecStrongEncryption = {
|
|
|
28100
28500
|
cwe: ["CWE-327"]
|
|
28101
28501
|
}
|
|
28102
28502
|
},
|
|
28103
|
-
check: (node) => {
|
|
28503
|
+
check: (node, context) => {
|
|
28504
|
+
if (!isTopLevel(node, context)) return [];
|
|
28104
28505
|
const ipsec = findStanza7(node, "ipsec");
|
|
28105
28506
|
if (!ipsec) {
|
|
28106
28507
|
return {
|
|
@@ -28161,7 +28562,8 @@ var VyosWireGuardAllowedIps = {
|
|
|
28161
28562
|
owner: "SecOps",
|
|
28162
28563
|
remediation: 'Configure "allowed-ips" for each WireGuard peer.'
|
|
28163
28564
|
},
|
|
28164
|
-
check: (node) => {
|
|
28565
|
+
check: (node, context) => {
|
|
28566
|
+
if (!isTopLevel(node, context)) return [];
|
|
28165
28567
|
const wgInterfaces = findStanzasByPrefix2(node, "wireguard");
|
|
28166
28568
|
if (wgInterfaces.length === 0) {
|
|
28167
28569
|
return {
|
|
@@ -28207,7 +28609,8 @@ var VyosBgpRouterId = {
|
|
|
28207
28609
|
owner: "NetOps",
|
|
28208
28610
|
remediation: 'Configure "parameters router-id" under BGP stanza.'
|
|
28209
28611
|
},
|
|
28210
|
-
check: (node) => {
|
|
28612
|
+
check: (node, context) => {
|
|
28613
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28211
28614
|
const bgp = findStanza7(node, "bgp");
|
|
28212
28615
|
if (!bgp) {
|
|
28213
28616
|
return {
|
|
@@ -28222,14 +28625,7 @@ var VyosBgpRouterId = {
|
|
|
28222
28625
|
const params = findStanza7(bgp, "parameters");
|
|
28223
28626
|
const hasRouterId = params ? hasChildCommand(params, "router-id") : hasChildCommand(bgp, "router-id");
|
|
28224
28627
|
if (!hasRouterId) {
|
|
28225
|
-
return
|
|
28226
|
-
passed: false,
|
|
28227
|
-
message: "BGP missing explicit router-id.",
|
|
28228
|
-
ruleId: "VYOS-BGP-001",
|
|
28229
|
-
nodeId: node.id,
|
|
28230
|
-
level: "warning",
|
|
28231
|
-
loc: node.loc
|
|
28232
|
-
};
|
|
28628
|
+
return offenderResult4("VYOS-BGP-001", params ?? bgp, "BGP missing explicit router-id.", "warning");
|
|
28233
28629
|
}
|
|
28234
28630
|
return {
|
|
28235
28631
|
passed: true,
|
|
@@ -28252,7 +28648,8 @@ var VyosBgpNeighborDescription = {
|
|
|
28252
28648
|
owner: "NetOps",
|
|
28253
28649
|
remediation: 'Add "description" to each BGP neighbor.'
|
|
28254
28650
|
},
|
|
28255
|
-
check: (node) => {
|
|
28651
|
+
check: (node, context) => {
|
|
28652
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28256
28653
|
const bgp = findStanza7(node, "bgp");
|
|
28257
28654
|
if (!bgp) {
|
|
28258
28655
|
return {
|
|
@@ -28305,7 +28702,8 @@ var VyosOspfAreaInterfaces = {
|
|
|
28305
28702
|
owner: "NetOps",
|
|
28306
28703
|
remediation: 'Configure interfaces under each OSPF area or use "interface" directly under OSPF.'
|
|
28307
28704
|
},
|
|
28308
|
-
check: (node) => {
|
|
28705
|
+
check: (node, context) => {
|
|
28706
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28309
28707
|
const ospf = findStanza7(node, "ospf");
|
|
28310
28708
|
if (!ospf) {
|
|
28311
28709
|
return {
|
|
@@ -28320,14 +28718,7 @@ var VyosOspfAreaInterfaces = {
|
|
|
28320
28718
|
const hasDirectInterfaces = hasChildCommand(ospf, "interface");
|
|
28321
28719
|
const areas = findStanzasByPrefix2(ospf, "area");
|
|
28322
28720
|
if (!hasDirectInterfaces && areas.length === 0) {
|
|
28323
|
-
return
|
|
28324
|
-
passed: false,
|
|
28325
|
-
message: "OSPF configured but no interfaces or areas defined.",
|
|
28326
|
-
ruleId: "VYOS-OSPF-001",
|
|
28327
|
-
nodeId: node.id,
|
|
28328
|
-
level: "warning",
|
|
28329
|
-
loc: node.loc
|
|
28330
|
-
};
|
|
28721
|
+
return offenderResult4("VYOS-OSPF-001", ospf, "OSPF configured but no interfaces or areas defined.", "warning");
|
|
28331
28722
|
}
|
|
28332
28723
|
const findings = [];
|
|
28333
28724
|
for (const area of areas) {
|
|
@@ -28360,7 +28751,8 @@ var VyosVrrpPreemptDelay = {
|
|
|
28360
28751
|
owner: "NetOps",
|
|
28361
28752
|
remediation: 'Configure "preempt-delay" in VRRP groups to prevent flapping.'
|
|
28362
28753
|
},
|
|
28363
|
-
check: (node) => {
|
|
28754
|
+
check: (node, context) => {
|
|
28755
|
+
if (!isTopLevel(node, context)) return [];
|
|
28364
28756
|
const vrrp = findStanza7(node, "vrrp");
|
|
28365
28757
|
if (!vrrp) {
|
|
28366
28758
|
return {
|
|
@@ -28402,6 +28794,49 @@ var VyosVrrpPreemptDelay = {
|
|
|
28402
28794
|
};
|
|
28403
28795
|
}
|
|
28404
28796
|
};
|
|
28797
|
+
var VyosSnmpDefaultCommunity = {
|
|
28798
|
+
id: "VYOS-SNMP-001",
|
|
28799
|
+
selector: "service",
|
|
28800
|
+
vendor: "vyos",
|
|
28801
|
+
category: "Protocol-Security",
|
|
28802
|
+
metadata: {
|
|
28803
|
+
level: "error",
|
|
28804
|
+
obu: "Security",
|
|
28805
|
+
owner: "SecOps",
|
|
28806
|
+
remediation: 'Delete the community ("delete service snmp community <name>"), use a unique string restricted with "network <prefix>" or "client <address>", or move to SNMPv3 ("service snmp v3").',
|
|
28807
|
+
security: {
|
|
28808
|
+
cwe: ["CWE-798"]
|
|
28809
|
+
}
|
|
28810
|
+
},
|
|
28811
|
+
check: (node, context) => {
|
|
28812
|
+
if (!isTopLevel(node, context)) return [];
|
|
28813
|
+
const snmp = findStanza7(node, "snmp");
|
|
28814
|
+
const findings = [];
|
|
28815
|
+
for (const child of snmp?.children ?? []) {
|
|
28816
|
+
if (child.params[0]?.toLowerCase() !== "community") continue;
|
|
28817
|
+
const name = unquote(child.params[1] ?? "");
|
|
28818
|
+
const lower = name.toLowerCase();
|
|
28819
|
+
if (lower !== "public" && lower !== "private") continue;
|
|
28820
|
+
findings.push(
|
|
28821
|
+
offenderResult4(
|
|
28822
|
+
"VYOS-SNMP-001",
|
|
28823
|
+
child,
|
|
28824
|
+
`SNMP community "${name}" is a well-known default. Use a unique community, or SNMPv3, and restrict which hosts may use it.`,
|
|
28825
|
+
"error"
|
|
28826
|
+
)
|
|
28827
|
+
);
|
|
28828
|
+
}
|
|
28829
|
+
if (findings.length > 0) return findings;
|
|
28830
|
+
return {
|
|
28831
|
+
passed: true,
|
|
28832
|
+
message: "No SNMP community uses a well-known name.",
|
|
28833
|
+
ruleId: "VYOS-SNMP-001",
|
|
28834
|
+
nodeId: node.id,
|
|
28835
|
+
level: "info",
|
|
28836
|
+
loc: node.loc
|
|
28837
|
+
};
|
|
28838
|
+
}
|
|
28839
|
+
};
|
|
28405
28840
|
var allVyosRules = [
|
|
28406
28841
|
VyosHostnameRequired,
|
|
28407
28842
|
VyosNtpRequired,
|
|
@@ -28424,7 +28859,8 @@ var allVyosRules = [
|
|
|
28424
28859
|
VyosBgpRouterId,
|
|
28425
28860
|
VyosBgpNeighborDescription,
|
|
28426
28861
|
VyosOspfAreaInterfaces,
|
|
28427
|
-
VyosVrrpPreemptDelay
|
|
28862
|
+
VyosVrrpPreemptDelay,
|
|
28863
|
+
VyosSnmpDefaultCommunity
|
|
28428
28864
|
];
|
|
28429
28865
|
|
|
28430
28866
|
// ../rules-default/src/vyos/index.ts
|
|
@@ -30351,8 +30787,8 @@ var ExosSysnameRequired = {
|
|
|
30351
30787
|
return [passAt2(id, sysname.node, `SNMP sysname is configured: ${name}`)];
|
|
30352
30788
|
})
|
|
30353
30789
|
};
|
|
30354
|
-
var
|
|
30355
|
-
var
|
|
30790
|
+
var SNTP_SERVER2 = /^configure\s+sntp-client\s+(?:primary|secondary)\s+(?:server\s+)?\S+/i;
|
|
30791
|
+
var NTP_SERVER2 = /^configure\s+ntp\s+server\s+add\s+\S+/i;
|
|
30356
30792
|
var ExosSntpRequired = {
|
|
30357
30793
|
id: "EXOS-SYS-002",
|
|
30358
30794
|
vendor: "extreme-exos",
|
|
@@ -30365,7 +30801,7 @@ var ExosSntpRequired = {
|
|
|
30365
30801
|
},
|
|
30366
30802
|
check: judgedOnce((index, anchor) => {
|
|
30367
30803
|
const id = "EXOS-SYS-002";
|
|
30368
|
-
const server = matching(index,
|
|
30804
|
+
const server = matching(index, SNTP_SERVER2)[0] ?? matching(index, NTP_SERVER2)[0];
|
|
30369
30805
|
if (!server) {
|
|
30370
30806
|
return [failAt2(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
|
|
30371
30807
|
}
|
|
@@ -30384,8 +30820,8 @@ var ExosSntpEnabled = {
|
|
|
30384
30820
|
},
|
|
30385
30821
|
check: judgedOnce((index, anchor) => {
|
|
30386
30822
|
const id = "EXOS-SYS-003";
|
|
30387
|
-
const sntpServer = matching(index,
|
|
30388
|
-
const ntpServer = matching(index,
|
|
30823
|
+
const sntpServer = matching(index, SNTP_SERVER2)[0];
|
|
30824
|
+
const ntpServer = matching(index, NTP_SERVER2)[0];
|
|
30389
30825
|
const sntp = lastMatching(index, /^(?:enable|disable)\s+sntp-client\s*$/i);
|
|
30390
30826
|
const ntp = lastMatching(index, /^(?:enable|disable)\s+ntp\s*$/i);
|
|
30391
30827
|
const on = [sntp, ntp].find((l) => l !== void 0 && /^enable/i.test(l.text));
|
|
@@ -37631,7 +38067,7 @@ var treeOf = (context, node) => {
|
|
|
37631
38067
|
return tree;
|
|
37632
38068
|
};
|
|
37633
38069
|
var kidsOf = (tree, node) => tree.children.get(node) ?? [];
|
|
37634
|
-
var
|
|
38070
|
+
var descendantsOf3 = (tree, node) => kidsOf(tree, node).flatMap((child) => [child, ...descendantsOf3(tree, child)]);
|
|
37635
38071
|
var parentWord = (tree, node) => {
|
|
37636
38072
|
const up = tree.parent.get(node);
|
|
37637
38073
|
return up ? wordOf(up) : "";
|
|
@@ -37694,7 +38130,7 @@ var AaaWithTacacsRequired = {
|
|
|
37694
38130
|
check: (node, context) => {
|
|
37695
38131
|
const tree = treeOf(context, node);
|
|
37696
38132
|
if (!isSystemSecurity(tree, node)) return [];
|
|
37697
|
-
const words = new Set(
|
|
38133
|
+
const words = new Set(descendantsOf3(tree, node).map(wordOf));
|
|
37698
38134
|
if (words.has("tacplus")) return npass("NOKIA-MGMT-001", node, "TACACS+ authentication is configured.");
|
|
37699
38135
|
if (words.has("radius") || words.has("ldap")) {
|
|
37700
38136
|
return npass("NOKIA-MGMT-001", node, "RADIUS or LDAP is configured. Consider TACACS+ for command-level authorization.");
|
|
@@ -37839,7 +38275,7 @@ var NtpAuthenticationRequired2 = {
|
|
|
37839
38275
|
return findings.length > 0 ? findings : npass("NOKIA-MGMT-004", node, "NTP authentication is configured.");
|
|
37840
38276
|
}
|
|
37841
38277
|
};
|
|
37842
|
-
var filterEffective = (tree, filter, defaultEnabled) => adminEnabled(tree, filter, defaultEnabled) &&
|
|
38278
|
+
var filterEffective = (tree, filter, defaultEnabled) => adminEnabled(tree, filter, defaultEnabled) && descendantsOf3(tree, filter).some((n) => wordOf(n) === "entry" || /^default-action\s+(drop|deny|reject)\b/i.test(keyOf2(n)));
|
|
37843
38279
|
var FILTER_WORDS = /* @__PURE__ */ new Set(["ip-filter", "ipv6-filter", "mac-filter"]);
|
|
37844
38280
|
var ManagementAccessFilterRequired = {
|
|
37845
38281
|
id: "NOKIA-MGMT-005",
|
|
@@ -37909,7 +38345,7 @@ var instanceAuthCheck = (ruleId, pattern, protocol, defaultEnabled, extraWords,
|
|
|
37909
38345
|
if (!adminEnabled(tree, node, defaultEnabled)) return npass(ruleId, node, `${protocol} is not enabled.`);
|
|
37910
38346
|
if (applies && !applies(tree, node)) return npass(ruleId, node, `${protocol} has no sessions configured.`);
|
|
37911
38347
|
const words = /* @__PURE__ */ new Set([...AUTH_WORDS, ...extraWords]);
|
|
37912
|
-
if (!
|
|
38348
|
+
if (!descendantsOf3(tree, node).some((n) => words.has(wordOf(n)))) {
|
|
37913
38349
|
return nfail(ruleId, node, "warning", `${protocol} is enabled without authentication. Configure an authentication key or keychain.`);
|
|
37914
38350
|
}
|
|
37915
38351
|
return npass(ruleId, node, `${protocol} authentication is configured.`);
|
|
@@ -38041,7 +38477,7 @@ var BgpGracefulRestartRecommended = {
|
|
|
38041
38477
|
const tree = treeOf(context, node);
|
|
38042
38478
|
if (!isBgpInstance(tree, node)) return [];
|
|
38043
38479
|
if (!adminEnabled(tree, node, true)) return npass("NOKIA-BGP-005", node, "BGP is not enabled.");
|
|
38044
|
-
if (!
|
|
38480
|
+
if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "graceful-restart")) {
|
|
38045
38481
|
return nfail("NOKIA-BGP-005", node, "info", "BGP graceful restart is not configured. Consider enabling for high availability.", true);
|
|
38046
38482
|
}
|
|
38047
38483
|
return npass("NOKIA-BGP-005", node, "BGP graceful restart is configured.");
|
|
@@ -38281,7 +38717,7 @@ var IpFilterRequired = {
|
|
|
38281
38717
|
const tree = treeOf(context, node);
|
|
38282
38718
|
if (!isTransitInterface(tree, node)) return [];
|
|
38283
38719
|
const ingress = childWithWord(tree, node, "ingress");
|
|
38284
|
-
const filtered = ingress !== void 0 &&
|
|
38720
|
+
const filtered = ingress !== void 0 && descendantsOf3(tree, ingress).some((n) => /^filter\s+ipv?6?\s+\S/i.test(keyOf2(n)) || /^ipv?6?\s+\S/i.test(keyOf2(n)) && parentWord(tree, n) === "filter");
|
|
38285
38721
|
if (!filtered) {
|
|
38286
38722
|
return nfail("NOKIA-DATA-001", node, "info", `Interface "${nameOf2(node)}" does not have an ingress IP filter. Consider adding ACLs for traffic filtering.`);
|
|
38287
38723
|
}
|
|
@@ -38309,7 +38745,7 @@ var UrpfRequired = {
|
|
|
38309
38745
|
check: (node, context) => {
|
|
38310
38746
|
const tree = treeOf(context, node);
|
|
38311
38747
|
if (!isTransitInterface(tree, node)) return [];
|
|
38312
|
-
if (!
|
|
38748
|
+
if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "urpf-check")) {
|
|
38313
38749
|
return nfail("NOKIA-URPF-001", node, "info", `Interface "${nameOf2(node)}" does not have uRPF configured. Consider enabling for anti-spoofing.`);
|
|
38314
38750
|
}
|
|
38315
38751
|
return npass("NOKIA-URPF-001", node, `Interface "${nameOf2(node)}" has uRPF enabled.`);
|
|
@@ -38330,7 +38766,7 @@ var VprnIsolationRequired = {
|
|
|
38330
38766
|
check: (node, context) => {
|
|
38331
38767
|
const tree = treeOf(context, node);
|
|
38332
38768
|
if (!isVprnService(tree, node)) return [];
|
|
38333
|
-
const words = new Set(
|
|
38769
|
+
const words = new Set(descendantsOf3(tree, node).map(wordOf));
|
|
38334
38770
|
const missing = [
|
|
38335
38771
|
words.has("route-distinguisher") ? "" : "route-distinguisher",
|
|
38336
38772
|
["vrf-target", "vrf-import", "vrf-export"].some((w) => words.has(w)) ? "" : "vrf-target"
|
|
@@ -38355,8 +38791,8 @@ var VprnGrtLeakingWarning = {
|
|
|
38355
38791
|
check: (node, context) => {
|
|
38356
38792
|
const tree = treeOf(context, node);
|
|
38357
38793
|
if (!isVprnService(tree, node)) return [];
|
|
38358
|
-
const leaking =
|
|
38359
|
-
if (leaking && !
|
|
38794
|
+
const leaking = descendantsOf3(tree, node).find((n) => wordOf(n) === "grt-leaking");
|
|
38795
|
+
if (leaking && !descendantsOf3(tree, leaking).some((n) => wordOf(n) === "export-grt")) {
|
|
38360
38796
|
return nfail("NOKIA-VPRN-002", leaking, "info", `VPRN ${nameOf2(node)} leaks routes to/from the GRT without an export-grt policy. Ensure policy controls are in place.`);
|
|
38361
38797
|
}
|
|
38362
38798
|
return npass("NOKIA-VPRN-002", node, `VPRN ${nameOf2(node)} has no uncontrolled GRT leaking.`);
|
|
@@ -38405,7 +38841,7 @@ var BfdRecommended = {
|
|
|
38405
38841
|
const tree = treeOf(context, node);
|
|
38406
38842
|
if (!isBgpInstance(tree, node)) return [];
|
|
38407
38843
|
if (!adminEnabled(tree, node, true)) return npass("NOKIA-HA-002", node, "BGP is not enabled.");
|
|
38408
|
-
const bfd =
|
|
38844
|
+
const bfd = descendantsOf3(tree, node).some(
|
|
38409
38845
|
(n) => wordOf(n) === "bfd-enable" || wordOf(n) === "bfd-liveness" && !/\sfalse$/i.test(keyOf2(n))
|
|
38410
38846
|
);
|
|
38411
38847
|
if (!bfd) {
|
|
@@ -38673,6 +39109,7 @@ function getRulesByNokiaVendor() {
|
|
|
38673
39109
|
}
|
|
38674
39110
|
|
|
38675
39111
|
// ../rules-default/src/cumulus/cumulus-rules.ts
|
|
39112
|
+
var isVlanDevice = (node, name) => /\.\d+$/.test(name) || hasChildCommand(node, "vlan-raw-device") || hasChildCommand(node, "vlan-id");
|
|
38676
39113
|
var CumulusInterfaceDescription = {
|
|
38677
39114
|
id: "CUM-IF-001",
|
|
38678
39115
|
selector: "iface",
|
|
@@ -38841,7 +39278,7 @@ var CumulusBridgeVlans = {
|
|
|
38841
39278
|
},
|
|
38842
39279
|
check: (node) => {
|
|
38843
39280
|
const ifaceName = getInterfaceName2(node);
|
|
38844
|
-
if (!isBridgeInterface(ifaceName)) {
|
|
39281
|
+
if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38845
39282
|
return {
|
|
38846
39283
|
passed: true,
|
|
38847
39284
|
message: "Not a bridge interface.",
|
|
@@ -38894,7 +39331,7 @@ var CumulusBridgePorts = {
|
|
|
38894
39331
|
},
|
|
38895
39332
|
check: (node) => {
|
|
38896
39333
|
const ifaceName = getInterfaceName2(node);
|
|
38897
|
-
if (!isBridgeInterface(ifaceName)) {
|
|
39334
|
+
if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38898
39335
|
return {
|
|
38899
39336
|
passed: true,
|
|
38900
39337
|
message: "Not a bridge interface.",
|
|
@@ -38937,7 +39374,7 @@ var CumulusBondSlaves = {
|
|
|
38937
39374
|
},
|
|
38938
39375
|
check: (node) => {
|
|
38939
39376
|
const ifaceName = getInterfaceName2(node);
|
|
38940
|
-
if (!isBondInterface(ifaceName)) {
|
|
39377
|
+
if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38941
39378
|
return {
|
|
38942
39379
|
passed: true,
|
|
38943
39380
|
message: "Not a bond interface.",
|
|
@@ -38980,7 +39417,7 @@ var CumulusBondClagId = {
|
|
|
38980
39417
|
},
|
|
38981
39418
|
check: (node) => {
|
|
38982
39419
|
const ifaceName = getInterfaceName2(node);
|
|
38983
|
-
if (!isBondInterface(ifaceName)) {
|
|
39420
|
+
if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38984
39421
|
return {
|
|
38985
39422
|
passed: true,
|
|
38986
39423
|
message: "Not a bond interface.",
|
|
@@ -40076,6 +40513,42 @@ var CumulusSecretEncryption = {
|
|
|
40076
40513
|
return findings;
|
|
40077
40514
|
})
|
|
40078
40515
|
};
|
|
40516
|
+
var NVUE_READONLY_COMMUNITY = /^nv\s+set\s+(?:system|service)\s+snmp-server\s+readonly-community(?:-v6)?\s+(\S+)/i;
|
|
40517
|
+
var CumulusSnmpDefaultCommunity = {
|
|
40518
|
+
id: "CUM-SNMP-001",
|
|
40519
|
+
vendor: "cumulus-linux",
|
|
40520
|
+
category: "Protocol-Security",
|
|
40521
|
+
metadata: {
|
|
40522
|
+
level: "error",
|
|
40523
|
+
obu: "Security",
|
|
40524
|
+
owner: "SecOps",
|
|
40525
|
+
remediation: 'Remove the community ("nv unset system snmp-server readonly-community <name>"), set a unique one restricted with "access <prefix>" (not "any"), or use SNMPv3 users ("nv set system snmp-server username ...").',
|
|
40526
|
+
security: {
|
|
40527
|
+
cwe: ["CWE-798"]
|
|
40528
|
+
},
|
|
40529
|
+
tags: [
|
|
40530
|
+
{ type: "general", label: "cleartext" },
|
|
40531
|
+
{ type: "general", label: "snmp" }
|
|
40532
|
+
]
|
|
40533
|
+
},
|
|
40534
|
+
check: judgeWholeConfig("CUM-SNMP-001", "No SNMP community uses a well-known name.", (ast) => {
|
|
40535
|
+
const findings = [];
|
|
40536
|
+
walkStatements(ast, (node) => {
|
|
40537
|
+
const value = NVUE_READONLY_COMMUNITY.exec(node.id)?.[1];
|
|
40538
|
+
if (!value) return;
|
|
40539
|
+
const name = value.replace(/^(['"])(.*)\1$/, "$2");
|
|
40540
|
+
const lower = name.toLowerCase();
|
|
40541
|
+
if (lower !== "public" && lower !== "private") return;
|
|
40542
|
+
findings.push({
|
|
40543
|
+
node,
|
|
40544
|
+
level: "error",
|
|
40545
|
+
message: `SNMP community "${name}" is a well-known default (NVUE "readonly-community"). Use a unique string restricted with "access <prefix>", or SNMPv3.`,
|
|
40546
|
+
masked: maskSecretLine(node)
|
|
40547
|
+
});
|
|
40548
|
+
});
|
|
40549
|
+
return findings;
|
|
40550
|
+
})
|
|
40551
|
+
};
|
|
40079
40552
|
var allCumulusRules = [
|
|
40080
40553
|
CumulusInterfaceDescription,
|
|
40081
40554
|
CumulusBpduGuard,
|
|
@@ -40110,7 +40583,8 @@ var allCumulusRules = [
|
|
|
40110
40583
|
CumulusVniVxlanId,
|
|
40111
40584
|
CumulusEvpnAnycastIp,
|
|
40112
40585
|
CumulusStormControl,
|
|
40113
|
-
CumulusSecretEncryption
|
|
40586
|
+
CumulusSecretEncryption,
|
|
40587
|
+
CumulusSnmpDefaultCommunity
|
|
40114
40588
|
];
|
|
40115
40589
|
|
|
40116
40590
|
// ../rules-default/src/cumulus/index.ts
|
|
@@ -40360,6 +40834,7 @@ var juniper_json_rules_default = {
|
|
|
40360
40834
|
{
|
|
40361
40835
|
id: "JSON-JUNOS-003",
|
|
40362
40836
|
selector: "system",
|
|
40837
|
+
topLevelOnly: true,
|
|
40363
40838
|
vendor: "juniper-junos",
|
|
40364
40839
|
category: "Documentation",
|
|
40365
40840
|
metadata: {
|
|
@@ -40380,6 +40855,7 @@ var juniper_json_rules_default = {
|
|
|
40380
40855
|
{
|
|
40381
40856
|
id: "JSON-JUNOS-004",
|
|
40382
40857
|
selector: "ospf",
|
|
40858
|
+
notUnder: ["groups"],
|
|
40383
40859
|
vendor: "juniper-junos",
|
|
40384
40860
|
category: "Routing",
|
|
40385
40861
|
metadata: {
|
|
@@ -40425,6 +40901,7 @@ var juniper_json_rules_default = {
|
|
|
40425
40901
|
{
|
|
40426
40902
|
id: "JSON-JUNOS-005",
|
|
40427
40903
|
selector: "system",
|
|
40904
|
+
topLevelOnly: true,
|
|
40428
40905
|
vendor: "juniper-junos",
|
|
40429
40906
|
category: "Logging",
|
|
40430
40907
|
metadata: {
|
|
@@ -40625,7 +41102,7 @@ function resolveVersion(injected) {
|
|
|
40625
41102
|
|
|
40626
41103
|
// src/sarif.ts
|
|
40627
41104
|
var TOOL_VERSION = resolveVersion(
|
|
40628
|
-
true ? "0.11.0-rc.
|
|
41105
|
+
true ? "0.11.0-rc.3" : void 0
|
|
40629
41106
|
);
|
|
40630
41107
|
var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
|
|
40631
41108
|
function cweNumber(cweId) {
|
|
@@ -43079,7 +43556,7 @@ async function exitIfVendorUndetected() {
|
|
|
43079
43556
|
}
|
|
43080
43557
|
}
|
|
43081
43558
|
var program = new Command2();
|
|
43082
|
-
var cliVersion = resolveVersion(true ? "0.11.0-rc.
|
|
43559
|
+
var cliVersion = resolveVersion(true ? "0.11.0-rc.3" : void 0);
|
|
43083
43560
|
var pluginPackLoaders = [];
|
|
43084
43561
|
var pluginRequests = pluginRequestsFromEnv(process.env);
|
|
43085
43562
|
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(
|