@sentriflow/cli 0.11.0-rc.1 → 0.11.0-rc.2
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 +672 -403
- 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) {
|
|
@@ -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,12 @@ 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
|
+
return setFormVendor(configText) ?? JuniperJunOSSchema;
|
|
3980
|
+
}
|
|
3952
3981
|
if (/^\s*(ge|xe|et|ae|lo|irb|vlan|em|fxp)-[\d\/:.]+\s*\{/m.test(sampleText)) {
|
|
3953
3982
|
return JuniperJunOSSchema;
|
|
3954
3983
|
}
|
|
@@ -4267,7 +4296,7 @@ function matchVendorPatterns(configText) {
|
|
|
4267
4296
|
if (/^return\s*$/m.test(sampleText)) {
|
|
4268
4297
|
return HuaweiVRPSchema;
|
|
4269
4298
|
}
|
|
4270
|
-
return null;
|
|
4299
|
+
return /^set\s/m.test(sampleText) ? setFormVendor(configText) : null;
|
|
4271
4300
|
}
|
|
4272
4301
|
var UNSUPPORTED_PLATFORMS = [
|
|
4273
4302
|
{
|
|
@@ -4310,6 +4339,10 @@ var UNSUPPORTED_PLATFORMS = [
|
|
|
4310
4339
|
// `import route-target` with the values on the following lines (IOS: `route-target import 1:1`)
|
|
4311
4340
|
/^\s+(import|export)\s+route-target\s*$/m
|
|
4312
4341
|
]
|
|
4342
|
+
},
|
|
4343
|
+
{
|
|
4344
|
+
name: 'Cumulus Linux NVUE startup.yaml (export it with "nv config show -o commands")',
|
|
4345
|
+
patterns: [NVUE_STARTUP_YAML]
|
|
4313
4346
|
}
|
|
4314
4347
|
];
|
|
4315
4348
|
var IOS_STRONG_PATTERNS = [
|
|
@@ -4643,6 +4676,7 @@ var SchemaAwareParser = class {
|
|
|
4643
4676
|
}
|
|
4644
4677
|
this.warnings = [];
|
|
4645
4678
|
this.longLines = [];
|
|
4679
|
+
this.reportUnsupportedFormat(configText);
|
|
4646
4680
|
const shortened = /* @__PURE__ */ new Set();
|
|
4647
4681
|
const lines = rawLines.map((line, i) => {
|
|
4648
4682
|
const bounded = boundLine(line);
|
|
@@ -4729,6 +4763,23 @@ var SchemaAwareParser = class {
|
|
|
4729
4763
|
}
|
|
4730
4764
|
return false;
|
|
4731
4765
|
}
|
|
4766
|
+
/**
|
|
4767
|
+
* Reports the first of the vendor's unsupported formats the text matches
|
|
4768
|
+
* (see VendorSchema.unsupportedFormats), once, at its first matching line.
|
|
4769
|
+
*/
|
|
4770
|
+
reportUnsupportedFormat(text) {
|
|
4771
|
+
for (const format2 of this.vendor.unsupportedFormats ?? []) {
|
|
4772
|
+
const match = format2.pattern.exec(text);
|
|
4773
|
+
if (!match) continue;
|
|
4774
|
+
const lineIndex = text.slice(0, match.index).split("\n").length - 1;
|
|
4775
|
+
this.warnings.push({
|
|
4776
|
+
code: "UNSUPPORTED_FORMAT",
|
|
4777
|
+
message: format2.message,
|
|
4778
|
+
lines: [this.options.startLine + lineIndex]
|
|
4779
|
+
});
|
|
4780
|
+
return;
|
|
4781
|
+
}
|
|
4782
|
+
}
|
|
4732
4783
|
/**
|
|
4733
4784
|
* Reports lines in a flat, full-path form that were not rebuilt into a
|
|
4734
4785
|
* hierarchy (see VendorSchema.flatFormatLine).
|
|
@@ -7557,7 +7608,14 @@ var canonicalIpv6 = (text) => {
|
|
|
7557
7608
|
return `${words.slice(0, best).join(":")}::${words.slice(best + bestLen).join(":")}`;
|
|
7558
7609
|
};
|
|
7559
7610
|
var bgpNeighborKey = (id) => canonicalIpv6(id) ?? id;
|
|
7560
|
-
var isBgpTemplateKind = (word) => word === "peer-session" || word === "peer-policy";
|
|
7611
|
+
var isBgpTemplateKind = (word) => word === "peer" || word === "peer-session" || word === "peer-policy";
|
|
7612
|
+
var descendantsOf = (node) => (node.children ?? []).flatMap((child) => [child, ...descendantsOf(child)]);
|
|
7613
|
+
var asNeighborLine = (id, line) => ({
|
|
7614
|
+
...line,
|
|
7615
|
+
id: `neighbor ${id} ${line.id}`,
|
|
7616
|
+
params: ["neighbor", id, ...line.params],
|
|
7617
|
+
children: []
|
|
7618
|
+
});
|
|
7561
7619
|
var resolveBgpNeighbors = (routerBgp) => {
|
|
7562
7620
|
const own = /* @__PURE__ */ new Map();
|
|
7563
7621
|
const groupNames = /* @__PURE__ */ new Set();
|
|
@@ -7570,7 +7628,8 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7570
7628
|
const raw = params[1];
|
|
7571
7629
|
if (head === "neighbor" && raw) {
|
|
7572
7630
|
const id = bgpNeighborKey(raw);
|
|
7573
|
-
|
|
7631
|
+
const section = child.children?.length ? descendantsOf(child).map((line) => asNeighborLine(id, line)) : [];
|
|
7632
|
+
own.set(id, [...own.get(id) ?? [], child, ...section]);
|
|
7574
7633
|
const k2 = params[2]?.toLowerCase();
|
|
7575
7634
|
const k3 = params[3]?.toLowerCase();
|
|
7576
7635
|
if (k2 === "peer-group") {
|
|
@@ -7585,7 +7644,7 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7585
7644
|
} else if (head === "template") {
|
|
7586
7645
|
const kind = params[1]?.toLowerCase();
|
|
7587
7646
|
const name = params[2];
|
|
7588
|
-
if (isBgpTemplateKind(kind) && name) templates.set(`${kind} ${name}`, child
|
|
7647
|
+
if (isBgpTemplateKind(kind) && name) templates.set(`${kind} ${name}`, descendantsOf(child));
|
|
7589
7648
|
}
|
|
7590
7649
|
if (child.children?.length) visit(child);
|
|
7591
7650
|
}
|
|
@@ -7615,9 +7674,7 @@ var resolveBgpNeighbors = (routerBgp) => {
|
|
|
7615
7674
|
const kind = line.params[3]?.toLowerCase();
|
|
7616
7675
|
const name = line.params[4];
|
|
7617
7676
|
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
|
-
}
|
|
7677
|
+
for (const t of expandTemplate(kind, name, /* @__PURE__ */ new Set())) inherited.push(asNeighborLine(id, t));
|
|
7621
7678
|
}
|
|
7622
7679
|
return inherited.length > 0 ? [...lines, ...inherited] : lines;
|
|
7623
7680
|
};
|
|
@@ -8903,11 +8960,11 @@ var hasWeakUsernamePassword = (node) => {
|
|
|
8903
8960
|
}
|
|
8904
8961
|
return false;
|
|
8905
8962
|
};
|
|
8963
|
+
var IOS_LINE_SECTION = /^line\s+(?:con(?:s(?:o(?:l(?:e)?)?)?)?|aux|tty|vty|\d+)(?:\s|$)/i;
|
|
8906
8964
|
var isLineConfigPassword = (ast, node) => {
|
|
8907
8965
|
const parent = findParentSection(ast, node);
|
|
8908
8966
|
if (!parent) return false;
|
|
8909
|
-
|
|
8910
|
-
return parentId.startsWith("line vty") || parentId.startsWith("line console") || parentId.startsWith("line aux");
|
|
8967
|
+
return IOS_LINE_SECTION.test(parent.id.trim());
|
|
8911
8968
|
};
|
|
8912
8969
|
var getSshVersion = (node) => {
|
|
8913
8970
|
if (includesIgnoreCase(node.rawText, "ip ssh version")) {
|
|
@@ -12585,6 +12642,11 @@ var getDestinationZones = (ruleNode) => {
|
|
|
12585
12642
|
if (!to?.children) return [];
|
|
12586
12643
|
return to.children.map((child) => child?.id?.trim() ?? "").filter(Boolean);
|
|
12587
12644
|
};
|
|
12645
|
+
var memberValues = (cmd) => {
|
|
12646
|
+
const rest = (cmd.id ?? "").trim().replace(/;\s*$/, "").split(/\s+/).slice(1).join(" ");
|
|
12647
|
+
const tokens = rest.replace(/[[\]]/g, " ").match(/"[^"]*"|\S+/g) ?? [];
|
|
12648
|
+
return tokens.map((token) => token.replace(/^"(.*)"$/, "$1").trim()).filter(Boolean);
|
|
12649
|
+
};
|
|
12588
12650
|
var getApplications = (ruleNode) => {
|
|
12589
12651
|
if (!ruleNode?.children) return [];
|
|
12590
12652
|
const application = findStanza6(ruleNode, "application");
|
|
@@ -12595,10 +12657,7 @@ var getApplications = (ruleNode) => {
|
|
|
12595
12657
|
(child) => child?.id?.toLowerCase().startsWith("application ")
|
|
12596
12658
|
);
|
|
12597
12659
|
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);
|
|
12660
|
+
return appCommands.flatMap((cmd) => memberValues(cmd));
|
|
12602
12661
|
}
|
|
12603
12662
|
return [];
|
|
12604
12663
|
};
|
|
@@ -12619,10 +12678,9 @@ var hasAnySource = (ruleNode) => {
|
|
|
12619
12678
|
(child) => child?.id?.toLowerCase().startsWith("source ")
|
|
12620
12679
|
);
|
|
12621
12680
|
if (sourceCommands.length > 0) {
|
|
12622
|
-
return sourceCommands.some(
|
|
12623
|
-
|
|
12624
|
-
|
|
12625
|
-
});
|
|
12681
|
+
return sourceCommands.some(
|
|
12682
|
+
(cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
|
|
12683
|
+
);
|
|
12626
12684
|
}
|
|
12627
12685
|
return false;
|
|
12628
12686
|
};
|
|
@@ -12639,10 +12697,9 @@ var hasAnyDestination = (ruleNode) => {
|
|
|
12639
12697
|
(child) => child?.id?.toLowerCase().startsWith("destination ")
|
|
12640
12698
|
);
|
|
12641
12699
|
if (destCommands.length > 0) {
|
|
12642
|
-
return destCommands.some(
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
});
|
|
12700
|
+
return destCommands.some(
|
|
12701
|
+
(cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
|
|
12702
|
+
);
|
|
12646
12703
|
}
|
|
12647
12704
|
return false;
|
|
12648
12705
|
};
|
|
@@ -12659,10 +12716,7 @@ var hasAnyService2 = (ruleNode) => {
|
|
|
12659
12716
|
(child) => child?.id?.toLowerCase().startsWith("service ")
|
|
12660
12717
|
);
|
|
12661
12718
|
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
|
-
});
|
|
12719
|
+
return serviceCommands2.some((cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any"));
|
|
12666
12720
|
}
|
|
12667
12721
|
return false;
|
|
12668
12722
|
};
|
|
@@ -17011,33 +17065,32 @@ var VtyExecTimeout = {
|
|
|
17011
17065
|
}
|
|
17012
17066
|
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
17067
|
}
|
|
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);
|
|
17068
|
+
const minutes = parseInteger(timeoutCmd.params[1] ?? "");
|
|
17020
17069
|
if (minutes === null) {
|
|
17021
17070
|
return { passed: true, message: "Exec-timeout configured.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
17022
17071
|
}
|
|
17023
|
-
|
|
17072
|
+
const seconds = parseInteger(timeoutCmd.params[2] ?? "0") ?? 0;
|
|
17073
|
+
const total = minutes * 60 + seconds;
|
|
17074
|
+
if (total === 0) {
|
|
17024
17075
|
return {
|
|
17025
17076
|
passed: false,
|
|
17026
17077
|
message: "VTY exec-timeout is disabled (0). Configure a timeout (max 15 minutes).",
|
|
17027
17078
|
ruleId: "NET-MGMT-003",
|
|
17028
|
-
nodeId:
|
|
17079
|
+
nodeId: timeoutCmd.id,
|
|
17029
17080
|
level: "warning",
|
|
17030
|
-
loc:
|
|
17081
|
+
loc: timeoutCmd.loc
|
|
17031
17082
|
};
|
|
17032
17083
|
}
|
|
17033
|
-
if (
|
|
17084
|
+
if (total > 15 * 60) {
|
|
17085
|
+
const unit = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
17086
|
+
const value = seconds > 0 ? `${unit(minutes, "minute")} ${unit(seconds, "second")}` : unit(minutes, "minute");
|
|
17034
17087
|
return {
|
|
17035
17088
|
passed: false,
|
|
17036
|
-
message: `VTY exec-timeout of ${
|
|
17089
|
+
message: `VTY exec-timeout of ${value} exceeds maximum 15 minutes.`,
|
|
17037
17090
|
ruleId: "NET-MGMT-003",
|
|
17038
|
-
nodeId:
|
|
17091
|
+
nodeId: timeoutCmd.id,
|
|
17039
17092
|
level: "warning",
|
|
17040
|
-
loc:
|
|
17093
|
+
loc: timeoutCmd.loc
|
|
17041
17094
|
};
|
|
17042
17095
|
}
|
|
17043
17096
|
return { passed: true, message: "Exec-timeout configured within limits.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
|
|
@@ -17364,6 +17417,45 @@ var SnmpNoRwAccess = {
|
|
|
17364
17417
|
return { passed: true, message: "SNMP is read-only.", ruleId: "NET-SNMP-004", nodeId: node.id, level: "info", loc: node.loc };
|
|
17365
17418
|
}
|
|
17366
17419
|
};
|
|
17420
|
+
var globalStatementsCache = /* @__PURE__ */ new WeakMap();
|
|
17421
|
+
var globalStatementsOf = (ast) => {
|
|
17422
|
+
const cached = globalStatementsCache.get(ast);
|
|
17423
|
+
if (cached) return cached;
|
|
17424
|
+
const statements = /* @__PURE__ */ new Set();
|
|
17425
|
+
let nxos = false;
|
|
17426
|
+
const walk = (nodes) => {
|
|
17427
|
+
for (const n of nodes) {
|
|
17428
|
+
if (n.type === "virtual_root") {
|
|
17429
|
+
walk(n.children);
|
|
17430
|
+
continue;
|
|
17431
|
+
}
|
|
17432
|
+
if (n.type === "comment") continue;
|
|
17433
|
+
const id = n.id.trim().toLowerCase();
|
|
17434
|
+
statements.add(id);
|
|
17435
|
+
if (/^(feature\s|vrf context\s|vdc\s)/.test(id)) nxos = true;
|
|
17436
|
+
}
|
|
17437
|
+
};
|
|
17438
|
+
walk(ast);
|
|
17439
|
+
if (statements.has("lldp run") || statements.has("no lldp run") || statements.has("cdp run") || statements.has("no cdp run")) {
|
|
17440
|
+
nxos = false;
|
|
17441
|
+
}
|
|
17442
|
+
const result2 = { statements, nxos };
|
|
17443
|
+
globalStatementsCache.set(ast, result2);
|
|
17444
|
+
return result2;
|
|
17445
|
+
};
|
|
17446
|
+
var isCdpDisabledGlobally = (ast) => {
|
|
17447
|
+
if (!ast) return false;
|
|
17448
|
+
const { statements, nxos } = globalStatementsOf(ast);
|
|
17449
|
+
return statements.has(nxos ? "no cdp enable" : "no cdp run");
|
|
17450
|
+
};
|
|
17451
|
+
var lldpGlobalState = (ast) => {
|
|
17452
|
+
if (!ast) return "unknown";
|
|
17453
|
+
const { statements, nxos } = globalStatementsOf(ast);
|
|
17454
|
+
if (nxos) return statements.has("feature lldp") ? "on" : "off";
|
|
17455
|
+
if (statements.has("no lldp run")) return "off";
|
|
17456
|
+
return statements.has("lldp run") ? "on" : "unknown";
|
|
17457
|
+
};
|
|
17458
|
+
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
17459
|
var CdpDisabledOnExternal = {
|
|
17368
17460
|
id: "NET-SVC-005",
|
|
17369
17461
|
selector: "interface",
|
|
@@ -17382,10 +17474,13 @@ var CdpDisabledOnExternal = {
|
|
|
17382
17474
|
{ type: "general", label: "cdp" }
|
|
17383
17475
|
]
|
|
17384
17476
|
},
|
|
17385
|
-
check: (node) => {
|
|
17477
|
+
check: (node, context) => {
|
|
17386
17478
|
if (!isPhysicalPort(node.id) || isShutdown3(node)) {
|
|
17387
17479
|
return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-005", nodeId: node.id, level: "info", loc: node.loc };
|
|
17388
17480
|
}
|
|
17481
|
+
if (isCdpDisabledGlobally(context.getAst?.())) {
|
|
17482
|
+
return { passed: true, message: "CDP is disabled globally.", ruleId: "NET-SVC-005", nodeId: node.id, level: "info", loc: node.loc };
|
|
17483
|
+
}
|
|
17389
17484
|
if (isPhoneOrAP(node)) {
|
|
17390
17485
|
const desc = getChildCommand(node, "description");
|
|
17391
17486
|
const descText = desc?.rawText.toLowerCase() || "";
|
|
@@ -17448,10 +17543,17 @@ var LldpDisabledOnExternal = {
|
|
|
17448
17543
|
{ type: "general", label: "lldp" }
|
|
17449
17544
|
]
|
|
17450
17545
|
},
|
|
17451
|
-
check: (node) => {
|
|
17546
|
+
check: (node, context) => {
|
|
17452
17547
|
if (!isPhysicalPort(node.id) || isShutdown3(node)) {
|
|
17453
17548
|
return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-006", nodeId: node.id, level: "info", loc: node.loc };
|
|
17454
17549
|
}
|
|
17550
|
+
const globalState = lldpGlobalState(context.getAst?.());
|
|
17551
|
+
if (globalState === "off") {
|
|
17552
|
+
return { passed: true, message: "LLDP is disabled globally.", ruleId: "NET-SVC-006", nodeId: node.id, level: "info", loc: node.loc };
|
|
17553
|
+
}
|
|
17554
|
+
const unknown = globalState === "unknown";
|
|
17555
|
+
const level = unknown ? "info" : "warning";
|
|
17556
|
+
const note = unknown ? LLDP_UNKNOWN_NOTE : "";
|
|
17455
17557
|
if (isPhoneOrAP(node)) {
|
|
17456
17558
|
const desc = getChildCommand(node, "description");
|
|
17457
17559
|
const descText = desc?.rawText.toLowerCase() || "";
|
|
@@ -17461,10 +17563,10 @@ var LldpDisabledOnExternal = {
|
|
|
17461
17563
|
if (!noLldpTx || !noLldpRx) {
|
|
17462
17564
|
return {
|
|
17463
17565
|
passed: false,
|
|
17464
|
-
message: `Cisco AP port "${node.params.slice(1).join(" ")}" should have LLDP disabled. Add "no lldp transmit" and "no lldp receive"
|
|
17566
|
+
message: `Cisco AP port "${node.params.slice(1).join(" ")}" should have LLDP disabled. Add "no lldp transmit" and "no lldp receive".${note}`,
|
|
17465
17567
|
ruleId: "NET-SVC-006",
|
|
17466
17568
|
nodeId: node.id,
|
|
17467
|
-
level
|
|
17569
|
+
level,
|
|
17468
17570
|
loc: node.loc
|
|
17469
17571
|
};
|
|
17470
17572
|
}
|
|
@@ -17477,10 +17579,10 @@ var LldpDisabledOnExternal = {
|
|
|
17477
17579
|
if (!noLldpTx || !noLldpRx) {
|
|
17478
17580
|
return {
|
|
17479
17581
|
passed: false,
|
|
17480
|
-
message: `External interface "${node.params.slice(1).join(" ")}" should have LLDP disabled
|
|
17582
|
+
message: `External interface "${node.params.slice(1).join(" ")}" should have LLDP disabled.${note}`,
|
|
17481
17583
|
ruleId: "NET-SVC-006",
|
|
17482
17584
|
nodeId: node.id,
|
|
17483
|
-
level
|
|
17585
|
+
level,
|
|
17484
17586
|
loc: node.loc
|
|
17485
17587
|
};
|
|
17486
17588
|
}
|
|
@@ -17491,10 +17593,10 @@ var LldpDisabledOnExternal = {
|
|
|
17491
17593
|
if (!noLldpTx || !noLldpRx) {
|
|
17492
17594
|
return {
|
|
17493
17595
|
passed: false,
|
|
17494
|
-
message: `Endpoint port "${node.params.slice(1).join(" ")}" should have LLDP disabled
|
|
17596
|
+
message: `Endpoint port "${node.params.slice(1).join(" ")}" should have LLDP disabled.${note}`,
|
|
17495
17597
|
ruleId: "NET-SVC-006",
|
|
17496
17598
|
nodeId: node.id,
|
|
17497
|
-
level
|
|
17599
|
+
level,
|
|
17498
17600
|
loc: node.loc
|
|
17499
17601
|
};
|
|
17500
17602
|
}
|
|
@@ -17687,6 +17789,21 @@ var evaluatePasswordStorage = ({ ruleId, node, label, fix, args }) => {
|
|
|
17687
17789
|
loc: node.loc
|
|
17688
17790
|
};
|
|
17689
17791
|
};
|
|
17792
|
+
var bgpKeyNotJudged = (ast, node) => {
|
|
17793
|
+
const type = node.params[1];
|
|
17794
|
+
if (type !== "3" && type !== "7") return false;
|
|
17795
|
+
let ancestors = [];
|
|
17796
|
+
walkStatements(ast, (statement2, path) => {
|
|
17797
|
+
if (statement2 === node) ancestors = [...path];
|
|
17798
|
+
});
|
|
17799
|
+
const words = (n) => n.params.map((w) => w.toLowerCase());
|
|
17800
|
+
if (!ancestors.some((a) => words(a)[0] === "router" && words(a)[1] === "bgp")) return false;
|
|
17801
|
+
if (type === "3") return true;
|
|
17802
|
+
return ancestors.some((a) => {
|
|
17803
|
+
const [head, kind, name] = words(a);
|
|
17804
|
+
return head === "neighbor" && kind !== void 0 || head === "template" && kind === "peer" && name !== void 0;
|
|
17805
|
+
});
|
|
17806
|
+
};
|
|
17690
17807
|
var CiscoNoPlaintextPasswords = {
|
|
17691
17808
|
id: "NET-SEC-001",
|
|
17692
17809
|
selector: "password",
|
|
@@ -17721,6 +17838,12 @@ var CiscoNoPlaintextPasswords = {
|
|
|
17721
17838
|
return notApplicable2;
|
|
17722
17839
|
}
|
|
17723
17840
|
const ast = context.getAst?.();
|
|
17841
|
+
if (ast && bgpKeyNotJudged(ast, node)) {
|
|
17842
|
+
return {
|
|
17843
|
+
...notApplicable2,
|
|
17844
|
+
message: "BGP neighbor key stored as type 3 or 7 is not judged: NX-OS has no stronger form for BGP keys."
|
|
17845
|
+
};
|
|
17846
|
+
}
|
|
17724
17847
|
const onLine = ast ? isLineConfigPassword(ast, node) : false;
|
|
17725
17848
|
return evaluatePasswordStorage({
|
|
17726
17849
|
ruleId: "NET-SEC-001",
|
|
@@ -17869,6 +17992,39 @@ var CiscoSshVersion2 = {
|
|
|
17869
17992
|
return passResult("CISCO-MGMT-004", node, "SSH version 2 is configured.");
|
|
17870
17993
|
}
|
|
17871
17994
|
};
|
|
17995
|
+
var NxosTelnetFeature = {
|
|
17996
|
+
id: "CISCO-MGMT-009",
|
|
17997
|
+
selector: "feature",
|
|
17998
|
+
vendor: "cisco-nxos",
|
|
17999
|
+
category: "Service-Hardening",
|
|
18000
|
+
metadata: {
|
|
18001
|
+
level: "error",
|
|
18002
|
+
obu: "Security",
|
|
18003
|
+
owner: "SecOps",
|
|
18004
|
+
remediation: 'Run "no feature telnet" and manage the switch over SSH ("feature ssh").',
|
|
18005
|
+
security: {
|
|
18006
|
+
cwe: ["CWE-319"]
|
|
18007
|
+
},
|
|
18008
|
+
tags: [
|
|
18009
|
+
{ type: "general", label: "telnet" },
|
|
18010
|
+
{ type: "general", label: "management" },
|
|
18011
|
+
{ type: "general", label: "cleartext" }
|
|
18012
|
+
]
|
|
18013
|
+
},
|
|
18014
|
+
check: (node) => {
|
|
18015
|
+
if (node.params.length === 2 && node.params[1]?.toLowerCase() === "telnet") {
|
|
18016
|
+
return {
|
|
18017
|
+
passed: false,
|
|
18018
|
+
message: 'The Telnet server is enabled ("feature telnet"). Telnet sends credentials in clear text: run "no feature telnet" and use SSH ("feature ssh").',
|
|
18019
|
+
ruleId: "CISCO-MGMT-009",
|
|
18020
|
+
nodeId: node.id,
|
|
18021
|
+
level: "error",
|
|
18022
|
+
loc: node.loc
|
|
18023
|
+
};
|
|
18024
|
+
}
|
|
18025
|
+
return passResult("CISCO-MGMT-009", node, "Not the Telnet feature.");
|
|
18026
|
+
}
|
|
18027
|
+
};
|
|
17872
18028
|
var BANNER_DISCLOSURE = /\b(cisco|ios|ios-xe)\b|\bversion\s+\d+\.\d+/i;
|
|
17873
18029
|
var CiscoLoginBannerNoDisclosure = {
|
|
17874
18030
|
id: "CISCO-MGMT-008",
|
|
@@ -18011,13 +18167,13 @@ var CiscoOspfInterfaceAuthentication = {
|
|
|
18011
18167
|
var CiscoBgpNeighborAuthentication = {
|
|
18012
18168
|
id: "CISCO-BGP-002",
|
|
18013
18169
|
selector: "router bgp",
|
|
18014
|
-
vendor: "cisco-ios",
|
|
18170
|
+
vendor: ["cisco-ios", "cisco-nxos"],
|
|
18015
18171
|
category: "Routing",
|
|
18016
18172
|
metadata: {
|
|
18017
18173
|
level: "warning",
|
|
18018
18174
|
obu: "Security",
|
|
18019
18175
|
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.',
|
|
18176
|
+
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
18177
|
security: {
|
|
18022
18178
|
cwe: ["CWE-306"],
|
|
18023
18179
|
cvssScore: 8.1
|
|
@@ -18034,14 +18190,16 @@ var CiscoBgpNeighborAuthentication = {
|
|
|
18034
18190
|
return passResult("CISCO-BGP-002", node, "No BGP neighbors configured.");
|
|
18035
18191
|
}
|
|
18036
18192
|
const findings = peers.filter((p) => !findBgpNeighborCommand(p.lines, "password") && !findBgpNeighborCommand(p.lines, "ao")).map((p) => {
|
|
18193
|
+
const line = peerLine(p, node);
|
|
18194
|
+
const section = line.children.length > 0;
|
|
18037
18195
|
const { level, message } = bgpAuthFinding(
|
|
18038
18196
|
bgpSessionKind(node, p),
|
|
18039
18197
|
p.id,
|
|
18040
18198
|
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"
|
|
18199
|
+
section ? 'TCP MD5 ("password <key>")' : `TCP-AO ("neighbor ${p.id} ao <key-chain>") or TCP MD5 ("neighbor ${p.id} password <key>")`,
|
|
18200
|
+
section ? `under "neighbor ${p.id}", its "template peer" or "template peer-session"` : "on the neighbor, its peer-group or peer-session template"
|
|
18043
18201
|
);
|
|
18044
|
-
return offenderResult("CISCO-BGP-002",
|
|
18202
|
+
return offenderResult("CISCO-BGP-002", line, message, level);
|
|
18045
18203
|
});
|
|
18046
18204
|
if (findings.length > 0) return findings;
|
|
18047
18205
|
return passResult("CISCO-BGP-002", node, "All BGP neighbors have authentication.");
|
|
@@ -18125,9 +18283,10 @@ var CiscoBgpLogNeighborChanges = {
|
|
|
18125
18283
|
},
|
|
18126
18284
|
check: (node) => {
|
|
18127
18285
|
if (!hasBgpLogNeighborChanges2(node)) {
|
|
18286
|
+
const explicitOff = hasChildCommand(node, "no bgp log-neighbor-changes");
|
|
18128
18287
|
return {
|
|
18129
18288
|
passed: false,
|
|
18130
|
-
message: 'BGP neighbor changes are not logged. Configure "bgp log-neighbor-changes" for visibility.',
|
|
18289
|
+
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
18290
|
ruleId: "CISCO-BGP-005",
|
|
18132
18291
|
nodeId: node.id,
|
|
18133
18292
|
level: "info",
|
|
@@ -18363,22 +18522,28 @@ var CiscoHsrpMd5Authentication = {
|
|
|
18363
18522
|
if (!hasHsrp) {
|
|
18364
18523
|
return passResult("CISCO-CTRL-003", node, "No HSRP configured.");
|
|
18365
18524
|
}
|
|
18366
|
-
const
|
|
18367
|
-
|
|
18368
|
-
|
|
18369
|
-
|
|
18525
|
+
const authByGroup = /* @__PURE__ */ new Map();
|
|
18526
|
+
for (const child of node.children) {
|
|
18527
|
+
const match = /^standby(?:\s+(\d+))?\s+authentication(?:\s+(\S+))?/i.exec(child.id.trim());
|
|
18528
|
+
if (!match) continue;
|
|
18529
|
+
authByGroup.set(Number(match[1] ?? 0), { line: child, md5: match[2]?.toLowerCase() === "md5" });
|
|
18530
|
+
}
|
|
18531
|
+
if (authByGroup.size === 0) {
|
|
18370
18532
|
return passResult("CISCO-CTRL-003", node, "No HSRP authentication (reported by NET-FHRP-002).");
|
|
18371
18533
|
}
|
|
18372
|
-
|
|
18373
|
-
|
|
18534
|
+
const findings = [];
|
|
18535
|
+
for (const [group, { line, md5 }] of authByGroup) {
|
|
18536
|
+
if (md5) continue;
|
|
18537
|
+
findings.push({
|
|
18374
18538
|
passed: false,
|
|
18375
|
-
message: `
|
|
18539
|
+
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
18540
|
ruleId: "CISCO-CTRL-003",
|
|
18377
|
-
nodeId:
|
|
18541
|
+
nodeId: line.id,
|
|
18378
18542
|
level: "warning",
|
|
18379
|
-
loc:
|
|
18380
|
-
};
|
|
18543
|
+
loc: line.loc
|
|
18544
|
+
});
|
|
18381
18545
|
}
|
|
18546
|
+
if (findings.length > 0) return findings;
|
|
18382
18547
|
return passResult("CISCO-CTRL-003", node, "HSRP has MD5 authentication configured.");
|
|
18383
18548
|
}
|
|
18384
18549
|
};
|
|
@@ -18898,6 +19063,7 @@ var allCiscoRules = [
|
|
|
18898
19063
|
CiscoNoPlaintextUsernamePasswords,
|
|
18899
19064
|
// Ported from the former commercial set (decision 0001 S3a)
|
|
18900
19065
|
CiscoSshVersion2,
|
|
19066
|
+
NxosTelnetFeature,
|
|
18901
19067
|
CiscoLoginBannerNoDisclosure,
|
|
18902
19068
|
CiscoSnmpv3AuthPriv,
|
|
18903
19069
|
CiscoNoDangerousServices,
|
|
@@ -18925,6 +19091,12 @@ var allCiscoRules = [
|
|
|
18925
19091
|
NxosSecretStorage
|
|
18926
19092
|
];
|
|
18927
19093
|
|
|
19094
|
+
// ../rules-default/src/common/top-level.ts
|
|
19095
|
+
var isTopLevel = (node, context) => {
|
|
19096
|
+
const ast = context?.getAst?.();
|
|
19097
|
+
return !ast || ast.includes(node);
|
|
19098
|
+
};
|
|
19099
|
+
|
|
18928
19100
|
// ../rules-default/src/juniper/junos-rules.ts
|
|
18929
19101
|
var offenderResult2 = (ruleId, offender, message, level) => ({
|
|
18930
19102
|
passed: false,
|
|
@@ -19524,10 +19696,6 @@ var failResult = (ruleId, node, message, level) => ({
|
|
|
19524
19696
|
level,
|
|
19525
19697
|
loc: node.loc
|
|
19526
19698
|
});
|
|
19527
|
-
var isTopLevel = (node, context) => {
|
|
19528
|
-
const ast = context.getAst?.();
|
|
19529
|
-
return !ast || ast.includes(node);
|
|
19530
|
-
};
|
|
19531
19699
|
var topLevelStanza = (context, name) => context.getAst?.()?.find((n) => equalsIgnoreCase(n.id.trim(), name));
|
|
19532
19700
|
var isPublicAsn = (asn) => {
|
|
19533
19701
|
const dot = asn.match(/^(\d+)\.(\d+)$/);
|
|
@@ -20233,6 +20401,7 @@ var JunosProtectRe = {
|
|
|
20233
20401
|
return passResult2("JUN-RE-001", node, "Protect-RE filter is applied to loopback interface.");
|
|
20234
20402
|
}
|
|
20235
20403
|
};
|
|
20404
|
+
var UNTRUSTED_ZONE = /untrust|external|internet/i;
|
|
20236
20405
|
var JunosZoneScreens = {
|
|
20237
20406
|
id: "JUN-ZONE-003",
|
|
20238
20407
|
selector: "security",
|
|
@@ -20256,7 +20425,7 @@ var JunosZoneScreens = {
|
|
|
20256
20425
|
const findings = [];
|
|
20257
20426
|
for (const zone of findStanzas3(zones, /^security-zone\s/i)) {
|
|
20258
20427
|
const zoneName = zone.id.replace(/^security-zone\s+/i, "").trim();
|
|
20259
|
-
const untrusted =
|
|
20428
|
+
const untrusted = UNTRUSTED_ZONE.test(zoneName);
|
|
20260
20429
|
if (untrusted && !hasZoneScreen(zone)) {
|
|
20261
20430
|
findings.push(offenderResult2("JUN-ZONE-003", zone, `Zone "${zoneName}" should have a security screen configured.`, "warning"));
|
|
20262
20431
|
}
|
|
@@ -20265,6 +20434,83 @@ var JunosZoneScreens = {
|
|
|
20265
20434
|
return passResult2("JUN-ZONE-003", node, "Security screens configured on appropriate zones.");
|
|
20266
20435
|
}
|
|
20267
20436
|
};
|
|
20437
|
+
var HOST_INBOUND_KINDS = ["system-services", "protocols"];
|
|
20438
|
+
var hostInboundMessage = (scope, kind, exceptions) => {
|
|
20439
|
+
const x = exceptions ? ' except those marked "except"' : "";
|
|
20440
|
+
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.`;
|
|
20441
|
+
};
|
|
20442
|
+
var paramIs = (node, index, word) => {
|
|
20443
|
+
const param = node.params[index];
|
|
20444
|
+
return param !== void 0 && equalsIgnoreCase(param, word);
|
|
20445
|
+
};
|
|
20446
|
+
var isExcepted = (node) => node.params.slice(1).some((p) => equalsIgnoreCase(p, "except")) || node.children.some((child) => paramIs(child, 0, "except"));
|
|
20447
|
+
var hostInboundAlls = (hostInbound) => {
|
|
20448
|
+
const found = [];
|
|
20449
|
+
for (const child of hostInbound.children) {
|
|
20450
|
+
const kind = HOST_INBOUND_KINDS.find((k) => paramIs(child, 0, k));
|
|
20451
|
+
if (!kind) continue;
|
|
20452
|
+
if (child.params.length === 2 && paramIs(child, 1, "all")) {
|
|
20453
|
+
found.push({ kind, entry: child, exceptions: false });
|
|
20454
|
+
continue;
|
|
20455
|
+
}
|
|
20456
|
+
const all = child.children.find((c) => paramIs(c, 0, "all"));
|
|
20457
|
+
if (!all) continue;
|
|
20458
|
+
const exceptions = child.children.some((c) => c !== all && isExcepted(c));
|
|
20459
|
+
found.push({ kind, entry: all, exceptions });
|
|
20460
|
+
}
|
|
20461
|
+
return found;
|
|
20462
|
+
};
|
|
20463
|
+
var hostInboundScopes = (zones) => {
|
|
20464
|
+
const scopes = [];
|
|
20465
|
+
for (const zone of findStanzas3(zones, /^(security-zone\s+\S|functional-zone\s+management\s*$)/i)) {
|
|
20466
|
+
const functional = /^functional-zone\s/i.test(zone.id);
|
|
20467
|
+
const name = functional ? "management" : zone.id.replace(/^security-zone\s+/i, "").trim();
|
|
20468
|
+
const zoneScope = functional ? `Functional zone "${name}"` : `Zone "${name}"`;
|
|
20469
|
+
const inZone = functional ? `in functional zone "${name}"` : `in zone "${name}"`;
|
|
20470
|
+
const own = findStanza4(zone, "host-inbound-traffic");
|
|
20471
|
+
if (own) scopes.push({ scope: zoneScope, zoneName: name, hostInbound: own });
|
|
20472
|
+
for (const ifl of findStanza4(zone, "interfaces")?.children ?? []) {
|
|
20473
|
+
const hostInbound = findStanza4(ifl, "host-inbound-traffic");
|
|
20474
|
+
if (hostInbound) scopes.push({ scope: `Interface ${ifl.id.trim()} ${inZone}`, zoneName: name, hostInbound });
|
|
20475
|
+
}
|
|
20476
|
+
}
|
|
20477
|
+
return scopes;
|
|
20478
|
+
};
|
|
20479
|
+
var JunosHostInboundAll = {
|
|
20480
|
+
id: "JUN-ZONE-004",
|
|
20481
|
+
selector: "security",
|
|
20482
|
+
vendor: "juniper-junos",
|
|
20483
|
+
category: "Service-Hardening",
|
|
20484
|
+
metadata: {
|
|
20485
|
+
level: "warning",
|
|
20486
|
+
obu: "Security",
|
|
20487
|
+
owner: "SecOps",
|
|
20488
|
+
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").',
|
|
20489
|
+
security: {
|
|
20490
|
+
cwe: ["CWE-284"]
|
|
20491
|
+
},
|
|
20492
|
+
tags: generalTags("host-inbound", "hardening")
|
|
20493
|
+
},
|
|
20494
|
+
check: (node) => {
|
|
20495
|
+
const zones = findStanza4(node, "zones");
|
|
20496
|
+
if (!zones) {
|
|
20497
|
+
return passResult2("JUN-ZONE-004", node, "Security zones not configured.");
|
|
20498
|
+
}
|
|
20499
|
+
const findings = [];
|
|
20500
|
+
for (const { scope, zoneName, hostInbound } of hostInboundScopes(zones)) {
|
|
20501
|
+
const level = UNTRUSTED_ZONE.test(zoneName) ? "warning" : "info";
|
|
20502
|
+
for (const { kind, entry, exceptions } of hostInboundAlls(hostInbound)) {
|
|
20503
|
+
findings.push({
|
|
20504
|
+
...offenderResult2("JUN-ZONE-004", entry, hostInboundMessage(scope, kind, exceptions), level),
|
|
20505
|
+
// One id in both forms: brace "all" and set "system-services all" (C1).
|
|
20506
|
+
nodeId: `${kind} all`
|
|
20507
|
+
});
|
|
20508
|
+
}
|
|
20509
|
+
}
|
|
20510
|
+
if (findings.length > 0) return findings;
|
|
20511
|
+
return passResult2("JUN-ZONE-004", node, "No zone accepts all host-inbound services or protocols.");
|
|
20512
|
+
}
|
|
20513
|
+
};
|
|
20268
20514
|
var WEAK_PROPOSAL_SET = /^proposal-set\s+(basic|compatible|standard)\b/i;
|
|
20269
20515
|
var JunosIkeDhGroup = {
|
|
20270
20516
|
id: "JUN-VPN-001",
|
|
@@ -20581,7 +20827,11 @@ var JunosSecretStorage = {
|
|
|
20581
20827
|
})
|
|
20582
20828
|
};
|
|
20583
20829
|
var SRX_SECURITY_STATEMENT = /^(zones|policies|screen|nat|flow|address-book|utm|alg|idp|application-firewall|log)\b/i;
|
|
20584
|
-
var
|
|
20830
|
+
var isLogicalSystemSecurity = (node, context) => {
|
|
20831
|
+
const logicalSystems = topLevelStanza(context, "logical-systems");
|
|
20832
|
+
return logicalSystems?.children.some((system) => system.children.some((child) => child === node)) ?? false;
|
|
20833
|
+
};
|
|
20834
|
+
var isSrxSecurityStanza = (node, context) => (isTopLevel(node, context) || isLogicalSystemSecurity(node, context)) && node.children.some((child) => SRX_SECURITY_STATEMENT.test(child.id.trim()));
|
|
20585
20835
|
var JunosOspfInterfaceAuth = {
|
|
20586
20836
|
id: "JUN-CTRL-001",
|
|
20587
20837
|
selector: "protocols",
|
|
@@ -20808,7 +21058,7 @@ var JunosSecurityLogging = {
|
|
|
20808
21058
|
level: "warning",
|
|
20809
21059
|
obu: "Security",
|
|
20810
21060
|
owner: "SecOps",
|
|
20811
|
-
remediation:
|
|
21061
|
+
remediation: 'Configure "security log mode stream" with a "stream" host. Event-mode security logs stay on the device unless forwarded.',
|
|
20812
21062
|
tags: generalTags("logging", "monitoring")
|
|
20813
21063
|
},
|
|
20814
21064
|
check: (node, context) => {
|
|
@@ -20819,7 +21069,7 @@ var JunosSecurityLogging = {
|
|
|
20819
21069
|
return failResult(
|
|
20820
21070
|
"JUN-LOG-002",
|
|
20821
21071
|
node,
|
|
20822
|
-
"
|
|
21072
|
+
"No security log stanza: no security log stream to a log host is configured.",
|
|
20823
21073
|
"warning"
|
|
20824
21074
|
);
|
|
20825
21075
|
}
|
|
@@ -20858,6 +21108,7 @@ var allJuniperRules = [
|
|
|
20858
21108
|
JunosGracefulRestart,
|
|
20859
21109
|
JunosProtectRe,
|
|
20860
21110
|
JunosZoneScreens,
|
|
21111
|
+
JunosHostInboundAll,
|
|
20861
21112
|
JunosIkeDhGroup,
|
|
20862
21113
|
JunosIpsecEncryption,
|
|
20863
21114
|
JunosIkeDpd,
|
|
@@ -20909,11 +21160,19 @@ var AOSSWITCH_MARKERS = [
|
|
|
20909
21160
|
/^(no )?web-management\b/,
|
|
20910
21161
|
/^(no )?telnet-server$/
|
|
20911
21162
|
];
|
|
21163
|
+
var WLC_MARKERS = [
|
|
21164
|
+
/^wlan (ssid-profile|virtual-ap) /,
|
|
21165
|
+
/^ap-group /,
|
|
21166
|
+
/^rf (arm-profile|dot11[ag]-radio-profile) /,
|
|
21167
|
+
/^aaa (authentication-server radius|profile) "/,
|
|
21168
|
+
/^netservice \S+ (tcp|udp|\d+)\b/
|
|
21169
|
+
];
|
|
20912
21170
|
var platformOf = (statements) => {
|
|
20913
21171
|
for (const statement2 of statements) {
|
|
20914
21172
|
const text = textOf2(statement2);
|
|
20915
21173
|
if (AOSCX_MARKERS.some((m) => m.test(text))) return "aoscx";
|
|
20916
21174
|
if (AOSSWITCH_MARKERS.some((m) => m.test(text))) return "aosswitch";
|
|
21175
|
+
if (WLC_MARKERS.some((m) => m.test(text))) return "wlc";
|
|
20917
21176
|
if (/^vlan \d+$/.test(text) && statement2.children.some((c) => /^(no )?(un)?tagged /.test(textOf2(c)))) {
|
|
20918
21177
|
return "aosswitch";
|
|
20919
21178
|
}
|
|
@@ -20930,24 +21189,26 @@ var indexOf = (context) => {
|
|
|
20930
21189
|
indexCache.set(ast, index);
|
|
20931
21190
|
return index;
|
|
20932
21191
|
};
|
|
20933
|
-
var
|
|
21192
|
+
var NTP_SERVER = /^ntp server \S+/;
|
|
21193
|
+
var SNTP_SERVER = /^sntp server (?:priority \d+ \S+|(?!priority\b)\S+)/;
|
|
21194
|
+
var configWideOn = (platforms, judge) => (node, context) => {
|
|
20934
21195
|
const index = indexOf(context);
|
|
20935
21196
|
const anchor = index?.statements[0];
|
|
20936
|
-
if (!index || anchor !== node || index.platform
|
|
20937
|
-
return judge(index.statements, anchor);
|
|
21197
|
+
if (!index?.platform || anchor !== node || !platforms.includes(index.platform)) return [];
|
|
21198
|
+
return judge(index.platform, index.statements, anchor);
|
|
20938
21199
|
};
|
|
21200
|
+
var configWide = (platform, judge) => configWideOn([platform], (_platform, statements, anchor) => judge(statements, anchor));
|
|
20939
21201
|
|
|
20940
21202
|
// ../rules-default/src/aruba/common-rules.ts
|
|
20941
21203
|
var SshEnabled = {
|
|
20942
21204
|
id: "ARU-SEC-001",
|
|
20943
|
-
|
|
20944
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21205
|
+
vendor: "aruba-aoscx",
|
|
20945
21206
|
category: "Session-Management",
|
|
20946
21207
|
metadata: {
|
|
20947
|
-
level: "
|
|
21208
|
+
level: "warning",
|
|
20948
21209
|
obu: "Security",
|
|
20949
21210
|
owner: "SecOps",
|
|
20950
|
-
remediation:
|
|
21211
|
+
remediation: 'Enable the SSH server on the management VRF ("ssh server vrf mgmt") and disable Telnet if it is enabled.',
|
|
20951
21212
|
security: {
|
|
20952
21213
|
cwe: ["CWE-319"]
|
|
20953
21214
|
},
|
|
@@ -20956,27 +21217,16 @@ var SshEnabled = {
|
|
|
20956
21217
|
{ type: "general", label: "encryption" }
|
|
20957
21218
|
]
|
|
20958
21219
|
},
|
|
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
|
-
}
|
|
21220
|
+
check: configWide("aoscx", (statements, anchor) => {
|
|
21221
|
+
const enabled = statements.find((s) => /^ssh server vrf \S+$/.test(textOf2(s)));
|
|
21222
|
+
if (enabled) return passAt("ARU-SEC-001", enabled, "SSH server is enabled on a VRF.");
|
|
21223
|
+
return failAbsent(
|
|
21224
|
+
"ARU-SEC-001",
|
|
21225
|
+
anchor,
|
|
21226
|
+
'SSH server is not enabled on any VRF (no "ssh server vrf <vrf>"). Enable it on the management VRF.',
|
|
21227
|
+
"warning"
|
|
21228
|
+
);
|
|
21229
|
+
})
|
|
20980
21230
|
};
|
|
20981
21231
|
var SnmpNotDefault = {
|
|
20982
21232
|
id: "ARU-SEC-002",
|
|
@@ -21063,8 +21313,7 @@ var TelnetDisabled = {
|
|
|
21063
21313
|
};
|
|
21064
21314
|
var NtpConfigured = {
|
|
21065
21315
|
id: "ARU-NTP-001",
|
|
21066
|
-
|
|
21067
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21316
|
+
vendor: ["aruba-aoscx", "aruba-wlc"],
|
|
21068
21317
|
category: "Time-Synchronization",
|
|
21069
21318
|
metadata: {
|
|
21070
21319
|
level: "warning",
|
|
@@ -21079,64 +21328,37 @@ var NtpConfigured = {
|
|
|
21079
21328
|
{ type: "general", label: "logging" }
|
|
21080
21329
|
]
|
|
21081
21330
|
},
|
|
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
|
-
}
|
|
21331
|
+
check: configWideOn(["aoscx", "wlc"], (_platform, statements, anchor) => {
|
|
21332
|
+
const server = statements.find((s) => NTP_SERVER.test(textOf2(s)));
|
|
21333
|
+
if (server) return passAt("ARU-NTP-001", server, "NTP server is configured.");
|
|
21334
|
+
return failAbsent("ARU-NTP-001", anchor, 'No NTP server is configured ("ntp server <address>").', "warning");
|
|
21335
|
+
})
|
|
21103
21336
|
};
|
|
21104
21337
|
var SntpConfigured = {
|
|
21105
21338
|
id: "ARU-NTP-002",
|
|
21106
|
-
|
|
21107
|
-
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21339
|
+
vendor: "aruba-aosswitch",
|
|
21108
21340
|
category: "Time-Synchronization",
|
|
21109
21341
|
metadata: {
|
|
21110
21342
|
level: "warning",
|
|
21111
21343
|
obu: "Network Engineering",
|
|
21112
21344
|
owner: "NetOps",
|
|
21113
|
-
remediation: "
|
|
21345
|
+
remediation: 'Add "timesync sntp" and "sntp unicast" so the configured SNTP servers are used.'
|
|
21114
21346
|
},
|
|
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
|
-
}
|
|
21347
|
+
check: configWide("aosswitch", (statements) => {
|
|
21348
|
+
const server = statements.find((s) => SNTP_SERVER.test(textOf2(s)));
|
|
21349
|
+
if (!server) return [];
|
|
21350
|
+
const has = (text) => statements.some((s) => textOf2(s) === text);
|
|
21351
|
+
if (has("timesync sntp") && has("sntp unicast")) return passAt("ARU-NTP-002", server, "SNTP servers are in use.");
|
|
21352
|
+
return failAt(
|
|
21353
|
+
"ARU-NTP-002",
|
|
21354
|
+
server,
|
|
21355
|
+
'SNTP servers are configured but not used: add "timesync sntp" and "sntp unicast".',
|
|
21356
|
+
"warning"
|
|
21357
|
+
);
|
|
21358
|
+
})
|
|
21136
21359
|
};
|
|
21137
21360
|
var LoggingConfigured = {
|
|
21138
21361
|
id: "ARU-LOG-001",
|
|
21139
|
-
selector: "logging",
|
|
21140
21362
|
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21141
21363
|
category: "Logging",
|
|
21142
21364
|
metadata: {
|
|
@@ -21152,31 +21374,20 @@ var LoggingConfigured = {
|
|
|
21152
21374
|
{ type: "general", label: "audit" }
|
|
21153
21375
|
]
|
|
21154
21376
|
},
|
|
21155
|
-
check: (
|
|
21156
|
-
const
|
|
21157
|
-
if (
|
|
21158
|
-
|
|
21159
|
-
|
|
21160
|
-
|
|
21161
|
-
|
|
21162
|
-
|
|
21163
|
-
|
|
21164
|
-
|
|
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
|
-
}
|
|
21377
|
+
check: configWideOn(["aoscx", "aosswitch", "wlc"], (_platform, statements, anchor) => {
|
|
21378
|
+
const server = statements.find((s) => /^logging \S*[.:]/.test(textOf2(s)));
|
|
21379
|
+
if (server) return passAt("ARU-LOG-001", server, "Remote syslog server is configured.");
|
|
21380
|
+
return failAbsent("ARU-LOG-001", anchor, 'No remote syslog server is configured ("logging <address>").', "warning");
|
|
21381
|
+
})
|
|
21382
|
+
};
|
|
21383
|
+
var isRemoteAuthentication = (node) => {
|
|
21384
|
+
const words = wordsOf(node);
|
|
21385
|
+
if (words[0] !== "aaa" || words[1] !== "authentication") return false;
|
|
21386
|
+
return words[2] === "login" ? words.includes("group") : words.slice(3).some((w) => w === "tacacs" || w === "radius");
|
|
21176
21387
|
};
|
|
21388
|
+
var isWlcManagementServerGroup = (node) => textOf2(node) === "aaa authentication mgmt" && node.children.some((c) => textOf2(c).startsWith("server-group "));
|
|
21177
21389
|
var AaaConfigured = {
|
|
21178
21390
|
id: "ARU-AAA-001",
|
|
21179
|
-
selector: "aaa",
|
|
21180
21391
|
vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
|
|
21181
21392
|
category: "Authentication",
|
|
21182
21393
|
metadata: {
|
|
@@ -21192,27 +21403,16 @@ var AaaConfigured = {
|
|
|
21192
21403
|
{ type: "general", label: "aaa" }
|
|
21193
21404
|
]
|
|
21194
21405
|
},
|
|
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
|
-
}
|
|
21406
|
+
check: configWideOn(["aoscx", "aosswitch", "wlc"], (platform, statements, anchor) => {
|
|
21407
|
+
const remote = statements.find(platform === "wlc" ? isWlcManagementServerGroup : isRemoteAuthentication);
|
|
21408
|
+
if (remote) return passAt("ARU-AAA-001", remote, "Management logins use a remote authentication server.");
|
|
21409
|
+
return failAbsent(
|
|
21410
|
+
"ARU-AAA-001",
|
|
21411
|
+
anchor,
|
|
21412
|
+
"Management logins use local accounts only; configure RADIUS or TACACS+ authentication.",
|
|
21413
|
+
"warning"
|
|
21414
|
+
);
|
|
21415
|
+
})
|
|
21216
21416
|
};
|
|
21217
21417
|
var serverKeyMissing = (node, context, kind) => {
|
|
21218
21418
|
const words = wordsOf(node);
|
|
@@ -21309,11 +21509,6 @@ var TacacsKeyConfigured = {
|
|
|
21309
21509
|
};
|
|
21310
21510
|
}
|
|
21311
21511
|
};
|
|
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
21512
|
var isRemoteAccounting = (node) => {
|
|
21318
21513
|
const words = wordsOf(node);
|
|
21319
21514
|
if (words[0] !== "aaa" || words[1] !== "accounting") return false;
|
|
@@ -22725,28 +22920,29 @@ var AosSwitchOperatorPassword = {
|
|
|
22725
22920
|
};
|
|
22726
22921
|
var AosSwitchSshEnabled = {
|
|
22727
22922
|
id: "AOSSW-SEC-003",
|
|
22728
|
-
selector: "ip ssh",
|
|
22729
22923
|
vendor: "aruba-aosswitch",
|
|
22730
22924
|
category: "Session-Management",
|
|
22731
22925
|
metadata: {
|
|
22732
22926
|
level: "error",
|
|
22733
22927
|
obu: "Security",
|
|
22734
22928
|
owner: "SecOps",
|
|
22735
|
-
remediation: '
|
|
22929
|
+
remediation: 'Remove "no ip ssh" (or enter "ip ssh") so the SSH server runs, and disable Telnet ("no telnet-server").',
|
|
22736
22930
|
security: {
|
|
22737
22931
|
cwe: ["CWE-319"]
|
|
22738
22932
|
}
|
|
22739
22933
|
},
|
|
22740
|
-
check: (
|
|
22741
|
-
|
|
22742
|
-
|
|
22743
|
-
|
|
22744
|
-
|
|
22745
|
-
|
|
22746
|
-
|
|
22747
|
-
|
|
22748
|
-
|
|
22749
|
-
|
|
22934
|
+
check: configWide("aosswitch", (statements, anchor) => {
|
|
22935
|
+
const disabled = statements.find((s) => textOf2(s) === "no ip ssh");
|
|
22936
|
+
if (disabled) {
|
|
22937
|
+
return failAt(
|
|
22938
|
+
"AOSSW-SEC-003",
|
|
22939
|
+
disabled,
|
|
22940
|
+
'SSH server is disabled ("no ip ssh"). Enable it with "ip ssh" and disable Telnet.',
|
|
22941
|
+
"error"
|
|
22942
|
+
);
|
|
22943
|
+
}
|
|
22944
|
+
return passAt("AOSSW-SEC-003", anchor, "SSH server is on (the AOS-Switch default).");
|
|
22945
|
+
})
|
|
22750
22946
|
};
|
|
22751
22947
|
var AosSwitchSpanningTree = {
|
|
22752
22948
|
id: "AOSSW-STP-001",
|
|
@@ -22899,38 +23095,33 @@ var AosSwitchConsoleTimeout = {
|
|
|
22899
23095
|
};
|
|
22900
23096
|
}
|
|
22901
23097
|
};
|
|
23098
|
+
var SNTP_LEARNED_MODE = /^sntp (dhcp|broadcast)$/;
|
|
23099
|
+
var TIMEP = /^ip timep (dhcp|manual \S+)/;
|
|
22902
23100
|
var AosSwitchTimesync = {
|
|
22903
23101
|
id: "AOSSW-TIME-001",
|
|
22904
|
-
selector: "timesync",
|
|
22905
23102
|
vendor: "aruba-aosswitch",
|
|
22906
23103
|
category: "Time-Synchronization",
|
|
22907
23104
|
metadata: {
|
|
22908
23105
|
level: "warning",
|
|
22909
23106
|
obu: "Network Engineering",
|
|
22910
23107
|
owner: "NetOps",
|
|
22911
|
-
remediation:
|
|
23108
|
+
remediation: 'Configure a time server: "sntp server priority 1 <address>" with "timesync sntp" and "sntp unicast", or "ntp server <address>".'
|
|
22912
23109
|
},
|
|
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
|
-
}
|
|
23110
|
+
check: configWide("aosswitch", (statements, anchor) => {
|
|
23111
|
+
const lines = statements.flatMap((s) => [s, ...s.children]);
|
|
23112
|
+
const server = lines.find((s) => NTP_SERVER.test(textOf2(s)) || SNTP_SERVER.test(textOf2(s)));
|
|
23113
|
+
if (server) return passAt("AOSSW-TIME-001", server, "Time server is configured.");
|
|
23114
|
+
const sntpMode = statements.some((s) => textOf2(s) === "timesync sntp") ? statements.find((s) => SNTP_LEARNED_MODE.test(textOf2(s))) : void 0;
|
|
23115
|
+
if (sntpMode) return passAt("AOSSW-TIME-001", sntpMode, "SNTP learns its time server by DHCP or broadcast.");
|
|
23116
|
+
const timep = lines.find((s) => TIMEP.test(textOf2(s)));
|
|
23117
|
+
if (timep) return passAt("AOSSW-TIME-001", timep, "TimeP time synchronization is configured.");
|
|
23118
|
+
return failAbsent(
|
|
23119
|
+
"AOSSW-TIME-001",
|
|
23120
|
+
anchor,
|
|
23121
|
+
'No time server is configured ("ntp server <address>" or "sntp server priority <n> <address>").',
|
|
23122
|
+
"warning"
|
|
23123
|
+
);
|
|
23124
|
+
})
|
|
22934
23125
|
};
|
|
22935
23126
|
var HttpDisabled = {
|
|
22936
23127
|
id: "ARU-HTTP-001",
|
|
@@ -23773,7 +23964,7 @@ var valueOf = (node, name) => {
|
|
|
23773
23964
|
const statement2 = childNamed(node, name);
|
|
23774
23965
|
return statement2 ? valuesOf(statement2)[0] : void 0;
|
|
23775
23966
|
};
|
|
23776
|
-
var
|
|
23967
|
+
var descendantsOf2 = (nodes) => {
|
|
23777
23968
|
const out = [];
|
|
23778
23969
|
const visit = (list) => {
|
|
23779
23970
|
for (const child of list) {
|
|
@@ -24296,7 +24487,7 @@ var isSecurityProfilesBlock = (ast, node) => {
|
|
|
24296
24487
|
return !parent || !NON_SECURITY_PROFILE_PARENTS.has(keywordOf(parent));
|
|
24297
24488
|
};
|
|
24298
24489
|
var namesProfile = (node) => node !== void 0 && (node.children.length > 0 || valuesOf(node).length > 0);
|
|
24299
|
-
var securityProfileAvailable = (ast, type) =>
|
|
24490
|
+
var securityProfileAvailable = (ast, type) => descendantsOf2(ast).some((n) => {
|
|
24300
24491
|
const keyword = keywordOf(n);
|
|
24301
24492
|
if (keyword === "profiles" && n.children.length > 0 && isSecurityProfilesBlock(ast, n)) {
|
|
24302
24493
|
return namesProfile(childNamed(n, type));
|
|
@@ -24711,6 +24902,50 @@ var InterfaceManagementSecure = {
|
|
|
24711
24902
|
return passResult3("PAN-MGMT-003", node, "Interface management profiles use secure protocols only.");
|
|
24712
24903
|
}
|
|
24713
24904
|
};
|
|
24905
|
+
var PanMgmtServiceCleartext = {
|
|
24906
|
+
id: "PAN-MGMT-004",
|
|
24907
|
+
selector: "deviceconfig",
|
|
24908
|
+
vendor: "paloalto-panos",
|
|
24909
|
+
category: "Service-Hardening",
|
|
24910
|
+
metadata: {
|
|
24911
|
+
level: "error",
|
|
24912
|
+
obu: "Security",
|
|
24913
|
+
owner: "SecOps",
|
|
24914
|
+
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.',
|
|
24915
|
+
security: {
|
|
24916
|
+
cwe: ["CWE-319"]
|
|
24917
|
+
},
|
|
24918
|
+
tags: generalTags3("cleartext", "hardening")
|
|
24919
|
+
},
|
|
24920
|
+
check: (node) => {
|
|
24921
|
+
const service = childNamed(childNamed(node, "system"), "service");
|
|
24922
|
+
const findings = [];
|
|
24923
|
+
const telnet = childNamed(service, "disable-telnet");
|
|
24924
|
+
if (telnet && valuesOf(telnet)[0] === "no") {
|
|
24925
|
+
findings.push(
|
|
24926
|
+
offenderResult3(
|
|
24927
|
+
"PAN-MGMT-004",
|
|
24928
|
+
telnet,
|
|
24929
|
+
'The management interface accepts Telnet ("disable-telnet no"). Telnet sends credentials in clear text: set "disable-telnet yes" and use SSH.',
|
|
24930
|
+
"error"
|
|
24931
|
+
)
|
|
24932
|
+
);
|
|
24933
|
+
}
|
|
24934
|
+
const http = childNamed(service, "disable-http");
|
|
24935
|
+
if (http && valuesOf(http)[0] === "no") {
|
|
24936
|
+
findings.push(
|
|
24937
|
+
offenderResult3(
|
|
24938
|
+
"PAN-MGMT-004",
|
|
24939
|
+
http,
|
|
24940
|
+
'The management interface accepts HTTP ("disable-http no"). HTTP sends credentials in clear text: set "disable-http yes" and use HTTPS.',
|
|
24941
|
+
"error"
|
|
24942
|
+
)
|
|
24943
|
+
);
|
|
24944
|
+
}
|
|
24945
|
+
if (findings.length > 0) return findings;
|
|
24946
|
+
return passResult3("PAN-MGMT-004", node, "The management interface does not accept Telnet or HTTP.");
|
|
24947
|
+
}
|
|
24948
|
+
};
|
|
24714
24949
|
var WEAK_TLS_VERSIONS = /* @__PURE__ */ new Set(["sslv3", "tls1-0", "tls1-1"]);
|
|
24715
24950
|
var DecryptionTlsMinVersion = {
|
|
24716
24951
|
id: "PAN-DEC-001",
|
|
@@ -24783,7 +25018,7 @@ var DecryptionRuleDescription = {
|
|
|
24783
25018
|
var nameOf = (node) => keywordOf(node);
|
|
24784
25019
|
var usedProfileNames = (ast, refKeyword, implicitDefault) => {
|
|
24785
25020
|
const used = /* @__PURE__ */ new Set();
|
|
24786
|
-
for (const node of
|
|
25021
|
+
for (const node of descendantsOf2(ast)) {
|
|
24787
25022
|
if (node.children.length === 0 && keywordOf(node) === refKeyword) {
|
|
24788
25023
|
const name = valuesOf(node)[0];
|
|
24789
25024
|
if (name) used.add(name);
|
|
@@ -25113,10 +25348,10 @@ var LogForwardingRequired = {
|
|
|
25113
25348
|
remediation: "Configure log forwarding to syslog server, Panorama, or SIEM for centralized logging."
|
|
25114
25349
|
},
|
|
25115
25350
|
check: (node, context) => {
|
|
25116
|
-
const logSettings =
|
|
25351
|
+
const logSettings = descendantsOf2(context.getAst?.() ?? [node]).filter(
|
|
25117
25352
|
(n) => n.children.length > 0 && keywordOf(n) === "log-settings"
|
|
25118
25353
|
);
|
|
25119
|
-
if (logSettings.some((settings) =>
|
|
25354
|
+
if (logSettings.some((settings) => descendantsOf2(settings.children).some(forwardsLogs))) {
|
|
25120
25355
|
return passResult3("PAN-LOG-001", node, "Log forwarding is configured.");
|
|
25121
25356
|
}
|
|
25122
25357
|
return {
|
|
@@ -25235,6 +25470,7 @@ var allPaloAltoRules = [
|
|
|
25235
25470
|
PasswordComplexityRequired,
|
|
25236
25471
|
SnmpSecurityRequired,
|
|
25237
25472
|
InterfaceManagementSecure,
|
|
25473
|
+
PanMgmtServiceCleartext,
|
|
25238
25474
|
DecryptionTlsMinVersion,
|
|
25239
25475
|
DecryptionRuleDescription,
|
|
25240
25476
|
IkeCryptoStrong,
|
|
@@ -27361,6 +27597,15 @@ var offenderResult4 = (ruleId, offender, message, level) => ({
|
|
|
27361
27597
|
level,
|
|
27362
27598
|
loc: locOf(offender)
|
|
27363
27599
|
});
|
|
27600
|
+
var absentResult = (ruleId, anchor, message, level) => ({ ...offenderResult4(ruleId, anchor, message, level), absent: true });
|
|
27601
|
+
var unquote = (text) => text.replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
27602
|
+
var valueChild = (stanza, keyword) => stanza.children.find(
|
|
27603
|
+
(child) => startsWithIgnoreCase(child.id, keyword) && unquote(child.params.slice(1).join(" ")) !== ""
|
|
27604
|
+
);
|
|
27605
|
+
var hasValue = (stanza, keyword) => valueChild(stanza, keyword) !== void 0;
|
|
27606
|
+
var isProtocolsStanza = (node, context) => isTopLevel(node, context) || (context.getAst?.() ?? []).some(
|
|
27607
|
+
(top) => equalsIgnoreCase(top.id.trim(), "vrf") && top.children.some((vrf) => startsWithIgnoreCase(vrf.id, "name ") && vrf.children.includes(node))
|
|
27608
|
+
);
|
|
27364
27609
|
var VyosHostnameRequired = {
|
|
27365
27610
|
id: "VYOS-SYS-001",
|
|
27366
27611
|
selector: "system",
|
|
@@ -27372,17 +27617,11 @@ var VyosHostnameRequired = {
|
|
|
27372
27617
|
owner: "NetOps",
|
|
27373
27618
|
remediation: 'Configure "host-name" under system stanza.'
|
|
27374
27619
|
},
|
|
27375
|
-
check: (node) => {
|
|
27620
|
+
check: (node, context) => {
|
|
27621
|
+
if (!isTopLevel(node, context)) return [];
|
|
27376
27622
|
const hasHostname = hasChildCommand(node, "host-name");
|
|
27377
27623
|
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
|
-
};
|
|
27624
|
+
return absentResult("VYOS-SYS-001", node, "System missing host-name configuration.", "warning");
|
|
27386
27625
|
}
|
|
27387
27626
|
return {
|
|
27388
27627
|
passed: true,
|
|
@@ -27406,30 +27645,17 @@ var VyosNtpRequired = {
|
|
|
27406
27645
|
remediation: 'Configure NTP servers under "service ntp server <address>" (VyOS 1.4+) or "system ntp server <address>" (1.3 and earlier).'
|
|
27407
27646
|
},
|
|
27408
27647
|
check: (node, context) => {
|
|
27648
|
+
if (!isTopLevel(node, context)) return [];
|
|
27409
27649
|
const service = (context.getAst?.() ?? []).find((n) => n.id.toLowerCase() === "service");
|
|
27410
27650
|
const serviceNtp = service ? findStanza7(service, "ntp") : void 0;
|
|
27411
27651
|
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
|
-
};
|
|
27652
|
+
return absentResult("VYOS-SYS-002", node, "System missing NTP configuration.", "warning");
|
|
27420
27653
|
}
|
|
27421
27654
|
const ntp = findStanza7(node, "ntp") ?? serviceNtp;
|
|
27422
27655
|
if (ntp) {
|
|
27423
27656
|
const hasServer = hasChildCommand(ntp, "server");
|
|
27424
27657
|
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
|
-
};
|
|
27658
|
+
return offenderResult4("VYOS-SYS-002", ntp, "NTP configured but no servers defined.", "warning");
|
|
27433
27659
|
}
|
|
27434
27660
|
}
|
|
27435
27661
|
return {
|
|
@@ -27453,16 +27679,10 @@ var VyosSyslogRequired = {
|
|
|
27453
27679
|
owner: "NetOps",
|
|
27454
27680
|
remediation: 'Configure "syslog" under system stanza with remote host or local file.'
|
|
27455
27681
|
},
|
|
27456
|
-
check: (node) => {
|
|
27682
|
+
check: (node, context) => {
|
|
27683
|
+
if (!isTopLevel(node, context)) return [];
|
|
27457
27684
|
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
|
-
};
|
|
27685
|
+
return absentResult("VYOS-SYS-003", node, "System missing syslog configuration.", "warning");
|
|
27466
27686
|
}
|
|
27467
27687
|
return {
|
|
27468
27688
|
passed: true,
|
|
@@ -27488,7 +27708,8 @@ var VyosUserAuthRequired = {
|
|
|
27488
27708
|
cwe: ["CWE-306"]
|
|
27489
27709
|
}
|
|
27490
27710
|
},
|
|
27491
|
-
check: (node) => {
|
|
27711
|
+
check: (node, context) => {
|
|
27712
|
+
if (!isTopLevel(node, context)) return [];
|
|
27492
27713
|
const login = getLoginConfig(node);
|
|
27493
27714
|
if (!login) {
|
|
27494
27715
|
return {
|
|
@@ -27519,11 +27740,12 @@ var VyosUserAuthRequired = {
|
|
|
27519
27740
|
findings.push(offenderResult4("VYOS-SYS-004", user, `User "${username}" has no authentication configured.`, "error"));
|
|
27520
27741
|
continue;
|
|
27521
27742
|
}
|
|
27522
|
-
const hasPassword =
|
|
27743
|
+
const hasPassword = hasValue(auth, "encrypted-password");
|
|
27523
27744
|
const hasPublicKeys = hasChildCommand(auth, "public-keys");
|
|
27524
27745
|
if (!hasPassword && !hasPublicKeys) {
|
|
27525
27746
|
const username = user.id.split(/\s+/)[1] || user.id;
|
|
27526
|
-
|
|
27747
|
+
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.`;
|
|
27748
|
+
findings.push(offenderResult4("VYOS-SYS-004", user, message, "error"));
|
|
27527
27749
|
}
|
|
27528
27750
|
}
|
|
27529
27751
|
if (findings.length > 0) return findings;
|
|
@@ -27552,19 +27774,16 @@ var VyosNoPlaintextPassword = {
|
|
|
27552
27774
|
}
|
|
27553
27775
|
},
|
|
27554
27776
|
check: (node) => {
|
|
27555
|
-
const
|
|
27556
|
-
|
|
27557
|
-
const value = child.params.slice(1).join(" ").replace(/^(["'])(.*)\1$/, "$2").trim();
|
|
27558
|
-
return value !== "";
|
|
27559
|
-
});
|
|
27560
|
-
if (hasPlaintext) {
|
|
27777
|
+
const plaintext = valueChild(node, "plaintext-password");
|
|
27778
|
+
if (plaintext) {
|
|
27561
27779
|
return {
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
|
|
27566
|
-
|
|
27567
|
-
|
|
27780
|
+
...offenderResult4(
|
|
27781
|
+
"VYOS-SEC-001",
|
|
27782
|
+
plaintext,
|
|
27783
|
+
"Plaintext password found in configuration. VyOS should store hashed passwords only.",
|
|
27784
|
+
"error"
|
|
27785
|
+
),
|
|
27786
|
+
nodeId: maskSecretLine(plaintext)
|
|
27568
27787
|
};
|
|
27569
27788
|
}
|
|
27570
27789
|
return {
|
|
@@ -27588,17 +27807,11 @@ var VyosNameServersRequired = {
|
|
|
27588
27807
|
owner: "NetOps",
|
|
27589
27808
|
remediation: 'Configure "name-server" under system stanza.'
|
|
27590
27809
|
},
|
|
27591
|
-
check: (node) => {
|
|
27810
|
+
check: (node, context) => {
|
|
27811
|
+
if (!isTopLevel(node, context)) return [];
|
|
27592
27812
|
const hasNameServer = hasChildCommand(node, "name-server");
|
|
27593
27813
|
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
|
-
};
|
|
27814
|
+
return absentResult("VYOS-SYS-005", node, "System has no name servers configured.", "info");
|
|
27602
27815
|
}
|
|
27603
27816
|
return {
|
|
27604
27817
|
passed: true,
|
|
@@ -27624,16 +27837,10 @@ var VyosSshRequired = {
|
|
|
27624
27837
|
cwe: ["CWE-319"]
|
|
27625
27838
|
}
|
|
27626
27839
|
},
|
|
27627
|
-
check: (node) => {
|
|
27840
|
+
check: (node, context) => {
|
|
27841
|
+
if (!isTopLevel(node, context)) return [];
|
|
27628
27842
|
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
|
-
};
|
|
27843
|
+
return absentResult("VYOS-SVC-001", node, "SSH service is not configured.", "warning");
|
|
27637
27844
|
}
|
|
27638
27845
|
return {
|
|
27639
27846
|
passed: true,
|
|
@@ -27659,7 +27866,8 @@ var VyosSshKeyAuth = {
|
|
|
27659
27866
|
cwe: ["CWE-309"]
|
|
27660
27867
|
}
|
|
27661
27868
|
},
|
|
27662
|
-
check: (node) => {
|
|
27869
|
+
check: (node, context) => {
|
|
27870
|
+
if (!isTopLevel(node, context)) return [];
|
|
27663
27871
|
const ssh = getSshConfig(node);
|
|
27664
27872
|
if (!ssh) {
|
|
27665
27873
|
return {
|
|
@@ -27673,14 +27881,7 @@ var VyosSshKeyAuth = {
|
|
|
27673
27881
|
}
|
|
27674
27882
|
const disablePassword = hasChildCommand(ssh, "disable-password-authentication");
|
|
27675
27883
|
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
|
-
};
|
|
27884
|
+
return offenderResult4("VYOS-SVC-002", ssh, "SSH password authentication is enabled. Consider using SSH keys only.", "info");
|
|
27684
27885
|
}
|
|
27685
27886
|
return {
|
|
27686
27887
|
passed: true,
|
|
@@ -27703,7 +27904,8 @@ var VyosSshNonDefaultPort = {
|
|
|
27703
27904
|
owner: "SecOps",
|
|
27704
27905
|
remediation: 'Consider using a non-standard SSH port: "set service ssh port <port>".'
|
|
27705
27906
|
},
|
|
27706
|
-
check: (node) => {
|
|
27907
|
+
check: (node, context) => {
|
|
27908
|
+
if (!isTopLevel(node, context)) return [];
|
|
27707
27909
|
const ssh = getSshConfig(node);
|
|
27708
27910
|
if (!ssh) {
|
|
27709
27911
|
return {
|
|
@@ -27719,25 +27921,11 @@ var VyosSshNonDefaultPort = {
|
|
|
27719
27921
|
(child) => startsWithIgnoreCase(child.id, "port")
|
|
27720
27922
|
);
|
|
27721
27923
|
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
|
-
};
|
|
27924
|
+
return offenderResult4("VYOS-SVC-003", ssh, "SSH using default port 22. Consider using a non-standard port.", "info");
|
|
27730
27925
|
}
|
|
27731
27926
|
const portMatch = portCmd.id.match(/port\s+['"]?(\d+)['"]?/i);
|
|
27732
27927
|
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
|
-
};
|
|
27928
|
+
return offenderResult4("VYOS-SVC-003", portCmd, "SSH configured on standard port 22. Consider using a non-standard port.", "info");
|
|
27741
27929
|
}
|
|
27742
27930
|
return {
|
|
27743
27931
|
passed: true,
|
|
@@ -27760,7 +27948,8 @@ var VyosInterfaceDescription = {
|
|
|
27760
27948
|
owner: "NetOps",
|
|
27761
27949
|
remediation: 'Add "description" to each physical interface.'
|
|
27762
27950
|
},
|
|
27763
|
-
check: (node) => {
|
|
27951
|
+
check: (node, context) => {
|
|
27952
|
+
if (!isTopLevel(node, context)) return [];
|
|
27764
27953
|
const findings = [];
|
|
27765
27954
|
const ethernetInterfaces = getEthernetInterfaces(node);
|
|
27766
27955
|
for (const iface of ethernetInterfaces) {
|
|
@@ -27795,7 +27984,8 @@ var VyosInterfaceAddress = {
|
|
|
27795
27984
|
owner: "NetOps",
|
|
27796
27985
|
remediation: 'Configure "address" (static IP or dhcp) for each active interface.'
|
|
27797
27986
|
},
|
|
27798
|
-
check: (node) => {
|
|
27987
|
+
check: (node, context) => {
|
|
27988
|
+
if (!isTopLevel(node, context)) return [];
|
|
27799
27989
|
const findings = [];
|
|
27800
27990
|
const ethernetInterfaces = getEthernetInterfaces(node);
|
|
27801
27991
|
const members = /* @__PURE__ */ new Set();
|
|
@@ -27842,7 +28032,8 @@ var VyosFirewallDefaultAction = {
|
|
|
27842
28032
|
owner: "SecOps",
|
|
27843
28033
|
remediation: 'Set "default-action drop" or "default-action reject" for each firewall ruleset.'
|
|
27844
28034
|
},
|
|
27845
|
-
check: (node) => {
|
|
28035
|
+
check: (node, context) => {
|
|
28036
|
+
if (!isTopLevel(node, context)) return [];
|
|
27846
28037
|
const rulesets = findStanzasByPrefix2(node, "name");
|
|
27847
28038
|
if (rulesets.length === 0) {
|
|
27848
28039
|
return {
|
|
@@ -27884,7 +28075,8 @@ var VyosFirewallRuleAction = {
|
|
|
27884
28075
|
owner: "SecOps",
|
|
27885
28076
|
remediation: 'Set "action accept", "action drop", or "action reject" for each firewall rule.'
|
|
27886
28077
|
},
|
|
27887
|
-
check: (node) => {
|
|
28078
|
+
check: (node, context) => {
|
|
28079
|
+
if (!isTopLevel(node, context)) return [];
|
|
27888
28080
|
const rulesets = findStanzasByPrefix2(node, "name");
|
|
27889
28081
|
if (rulesets.length === 0) {
|
|
27890
28082
|
return {
|
|
@@ -27930,7 +28122,8 @@ var VyosFirewallStateful = {
|
|
|
27930
28122
|
owner: "SecOps",
|
|
27931
28123
|
remediation: "Configure state-policy or add rules to accept established and related connections."
|
|
27932
28124
|
},
|
|
27933
|
-
check: (node) => {
|
|
28125
|
+
check: (node, context) => {
|
|
28126
|
+
if (!isTopLevel(node, context)) return [];
|
|
27934
28127
|
const statePolicy = findStanza7(node, "state-policy");
|
|
27935
28128
|
if (statePolicy) {
|
|
27936
28129
|
return {
|
|
@@ -27968,14 +28161,7 @@ var VyosFirewallStateful = {
|
|
|
27968
28161
|
if (hasStatefulRules) break;
|
|
27969
28162
|
}
|
|
27970
28163
|
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
|
-
};
|
|
28164
|
+
return absentResult("VYOS-FW-003", node, "No stateful firewall rules (established/related) found. Consider adding state-policy.", "info");
|
|
27979
28165
|
}
|
|
27980
28166
|
return {
|
|
27981
28167
|
passed: true,
|
|
@@ -27998,7 +28184,8 @@ var VyosNatOutboundInterface = {
|
|
|
27998
28184
|
owner: "NetOps",
|
|
27999
28185
|
remediation: 'Configure "outbound-interface" for source NAT rules.'
|
|
28000
28186
|
},
|
|
28001
|
-
check: (node) => {
|
|
28187
|
+
check: (node, context) => {
|
|
28188
|
+
if (!isTopLevel(node, context)) return [];
|
|
28002
28189
|
const source = findStanza7(node, "source");
|
|
28003
28190
|
if (!source) {
|
|
28004
28191
|
return {
|
|
@@ -28040,6 +28227,11 @@ var VyosNatOutboundInterface = {
|
|
|
28040
28227
|
};
|
|
28041
28228
|
}
|
|
28042
28229
|
};
|
|
28230
|
+
var translationNotRequired = (rule) => {
|
|
28231
|
+
if (hasChildCommand(rule, "exclude")) return true;
|
|
28232
|
+
const loadBalance = findStanza7(rule, "load-balance");
|
|
28233
|
+
return loadBalance !== void 0 && hasChildCommand(loadBalance, "backend");
|
|
28234
|
+
};
|
|
28043
28235
|
var VyosNatTranslation = {
|
|
28044
28236
|
id: "VYOS-NAT-002",
|
|
28045
28237
|
selector: "nat",
|
|
@@ -28051,12 +28243,14 @@ var VyosNatTranslation = {
|
|
|
28051
28243
|
owner: "NetOps",
|
|
28052
28244
|
remediation: 'Configure "translation address" for NAT rules (e.g., masquerade or static IP).'
|
|
28053
28245
|
},
|
|
28054
|
-
check: (node) => {
|
|
28246
|
+
check: (node, context) => {
|
|
28247
|
+
if (!isTopLevel(node, context)) return [];
|
|
28055
28248
|
const findings = [];
|
|
28056
28249
|
const source = findStanza7(node, "source");
|
|
28057
28250
|
if (source) {
|
|
28058
28251
|
const rules = findStanzasByPrefix2(source, "rule");
|
|
28059
28252
|
for (const rule of rules) {
|
|
28253
|
+
if (translationNotRequired(rule)) continue;
|
|
28060
28254
|
const hasTranslation = hasChildCommand(rule, "translation");
|
|
28061
28255
|
if (!hasTranslation) {
|
|
28062
28256
|
const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
|
|
@@ -28068,6 +28262,7 @@ var VyosNatTranslation = {
|
|
|
28068
28262
|
if (destination) {
|
|
28069
28263
|
const rules = findStanzasByPrefix2(destination, "rule");
|
|
28070
28264
|
for (const rule of rules) {
|
|
28265
|
+
if (translationNotRequired(rule)) continue;
|
|
28071
28266
|
const hasTranslation = hasChildCommand(rule, "translation");
|
|
28072
28267
|
if (!hasTranslation) {
|
|
28073
28268
|
const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
|
|
@@ -28100,7 +28295,8 @@ var VyosIpsecStrongEncryption = {
|
|
|
28100
28295
|
cwe: ["CWE-327"]
|
|
28101
28296
|
}
|
|
28102
28297
|
},
|
|
28103
|
-
check: (node) => {
|
|
28298
|
+
check: (node, context) => {
|
|
28299
|
+
if (!isTopLevel(node, context)) return [];
|
|
28104
28300
|
const ipsec = findStanza7(node, "ipsec");
|
|
28105
28301
|
if (!ipsec) {
|
|
28106
28302
|
return {
|
|
@@ -28161,7 +28357,8 @@ var VyosWireGuardAllowedIps = {
|
|
|
28161
28357
|
owner: "SecOps",
|
|
28162
28358
|
remediation: 'Configure "allowed-ips" for each WireGuard peer.'
|
|
28163
28359
|
},
|
|
28164
|
-
check: (node) => {
|
|
28360
|
+
check: (node, context) => {
|
|
28361
|
+
if (!isTopLevel(node, context)) return [];
|
|
28165
28362
|
const wgInterfaces = findStanzasByPrefix2(node, "wireguard");
|
|
28166
28363
|
if (wgInterfaces.length === 0) {
|
|
28167
28364
|
return {
|
|
@@ -28207,7 +28404,8 @@ var VyosBgpRouterId = {
|
|
|
28207
28404
|
owner: "NetOps",
|
|
28208
28405
|
remediation: 'Configure "parameters router-id" under BGP stanza.'
|
|
28209
28406
|
},
|
|
28210
|
-
check: (node) => {
|
|
28407
|
+
check: (node, context) => {
|
|
28408
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28211
28409
|
const bgp = findStanza7(node, "bgp");
|
|
28212
28410
|
if (!bgp) {
|
|
28213
28411
|
return {
|
|
@@ -28222,14 +28420,7 @@ var VyosBgpRouterId = {
|
|
|
28222
28420
|
const params = findStanza7(bgp, "parameters");
|
|
28223
28421
|
const hasRouterId = params ? hasChildCommand(params, "router-id") : hasChildCommand(bgp, "router-id");
|
|
28224
28422
|
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
|
-
};
|
|
28423
|
+
return offenderResult4("VYOS-BGP-001", params ?? bgp, "BGP missing explicit router-id.", "warning");
|
|
28233
28424
|
}
|
|
28234
28425
|
return {
|
|
28235
28426
|
passed: true,
|
|
@@ -28252,7 +28443,8 @@ var VyosBgpNeighborDescription = {
|
|
|
28252
28443
|
owner: "NetOps",
|
|
28253
28444
|
remediation: 'Add "description" to each BGP neighbor.'
|
|
28254
28445
|
},
|
|
28255
|
-
check: (node) => {
|
|
28446
|
+
check: (node, context) => {
|
|
28447
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28256
28448
|
const bgp = findStanza7(node, "bgp");
|
|
28257
28449
|
if (!bgp) {
|
|
28258
28450
|
return {
|
|
@@ -28305,7 +28497,8 @@ var VyosOspfAreaInterfaces = {
|
|
|
28305
28497
|
owner: "NetOps",
|
|
28306
28498
|
remediation: 'Configure interfaces under each OSPF area or use "interface" directly under OSPF.'
|
|
28307
28499
|
},
|
|
28308
|
-
check: (node) => {
|
|
28500
|
+
check: (node, context) => {
|
|
28501
|
+
if (!isProtocolsStanza(node, context)) return [];
|
|
28309
28502
|
const ospf = findStanza7(node, "ospf");
|
|
28310
28503
|
if (!ospf) {
|
|
28311
28504
|
return {
|
|
@@ -28320,14 +28513,7 @@ var VyosOspfAreaInterfaces = {
|
|
|
28320
28513
|
const hasDirectInterfaces = hasChildCommand(ospf, "interface");
|
|
28321
28514
|
const areas = findStanzasByPrefix2(ospf, "area");
|
|
28322
28515
|
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
|
-
};
|
|
28516
|
+
return offenderResult4("VYOS-OSPF-001", ospf, "OSPF configured but no interfaces or areas defined.", "warning");
|
|
28331
28517
|
}
|
|
28332
28518
|
const findings = [];
|
|
28333
28519
|
for (const area of areas) {
|
|
@@ -28360,7 +28546,8 @@ var VyosVrrpPreemptDelay = {
|
|
|
28360
28546
|
owner: "NetOps",
|
|
28361
28547
|
remediation: 'Configure "preempt-delay" in VRRP groups to prevent flapping.'
|
|
28362
28548
|
},
|
|
28363
|
-
check: (node) => {
|
|
28549
|
+
check: (node, context) => {
|
|
28550
|
+
if (!isTopLevel(node, context)) return [];
|
|
28364
28551
|
const vrrp = findStanza7(node, "vrrp");
|
|
28365
28552
|
if (!vrrp) {
|
|
28366
28553
|
return {
|
|
@@ -28402,6 +28589,49 @@ var VyosVrrpPreemptDelay = {
|
|
|
28402
28589
|
};
|
|
28403
28590
|
}
|
|
28404
28591
|
};
|
|
28592
|
+
var VyosSnmpDefaultCommunity = {
|
|
28593
|
+
id: "VYOS-SNMP-001",
|
|
28594
|
+
selector: "service",
|
|
28595
|
+
vendor: "vyos",
|
|
28596
|
+
category: "Protocol-Security",
|
|
28597
|
+
metadata: {
|
|
28598
|
+
level: "error",
|
|
28599
|
+
obu: "Security",
|
|
28600
|
+
owner: "SecOps",
|
|
28601
|
+
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").',
|
|
28602
|
+
security: {
|
|
28603
|
+
cwe: ["CWE-798"]
|
|
28604
|
+
}
|
|
28605
|
+
},
|
|
28606
|
+
check: (node, context) => {
|
|
28607
|
+
if (!isTopLevel(node, context)) return [];
|
|
28608
|
+
const snmp = findStanza7(node, "snmp");
|
|
28609
|
+
const findings = [];
|
|
28610
|
+
for (const child of snmp?.children ?? []) {
|
|
28611
|
+
if (child.params[0]?.toLowerCase() !== "community") continue;
|
|
28612
|
+
const name = unquote(child.params[1] ?? "");
|
|
28613
|
+
const lower = name.toLowerCase();
|
|
28614
|
+
if (lower !== "public" && lower !== "private") continue;
|
|
28615
|
+
findings.push(
|
|
28616
|
+
offenderResult4(
|
|
28617
|
+
"VYOS-SNMP-001",
|
|
28618
|
+
child,
|
|
28619
|
+
`SNMP community "${name}" is a well-known default. Use a unique community, or SNMPv3, and restrict which hosts may use it.`,
|
|
28620
|
+
"error"
|
|
28621
|
+
)
|
|
28622
|
+
);
|
|
28623
|
+
}
|
|
28624
|
+
if (findings.length > 0) return findings;
|
|
28625
|
+
return {
|
|
28626
|
+
passed: true,
|
|
28627
|
+
message: "No SNMP community uses a well-known name.",
|
|
28628
|
+
ruleId: "VYOS-SNMP-001",
|
|
28629
|
+
nodeId: node.id,
|
|
28630
|
+
level: "info",
|
|
28631
|
+
loc: node.loc
|
|
28632
|
+
};
|
|
28633
|
+
}
|
|
28634
|
+
};
|
|
28405
28635
|
var allVyosRules = [
|
|
28406
28636
|
VyosHostnameRequired,
|
|
28407
28637
|
VyosNtpRequired,
|
|
@@ -28424,7 +28654,8 @@ var allVyosRules = [
|
|
|
28424
28654
|
VyosBgpRouterId,
|
|
28425
28655
|
VyosBgpNeighborDescription,
|
|
28426
28656
|
VyosOspfAreaInterfaces,
|
|
28427
|
-
VyosVrrpPreemptDelay
|
|
28657
|
+
VyosVrrpPreemptDelay,
|
|
28658
|
+
VyosSnmpDefaultCommunity
|
|
28428
28659
|
];
|
|
28429
28660
|
|
|
28430
28661
|
// ../rules-default/src/vyos/index.ts
|
|
@@ -30351,8 +30582,8 @@ var ExosSysnameRequired = {
|
|
|
30351
30582
|
return [passAt2(id, sysname.node, `SNMP sysname is configured: ${name}`)];
|
|
30352
30583
|
})
|
|
30353
30584
|
};
|
|
30354
|
-
var
|
|
30355
|
-
var
|
|
30585
|
+
var SNTP_SERVER2 = /^configure\s+sntp-client\s+(?:primary|secondary)\s+(?:server\s+)?\S+/i;
|
|
30586
|
+
var NTP_SERVER2 = /^configure\s+ntp\s+server\s+add\s+\S+/i;
|
|
30356
30587
|
var ExosSntpRequired = {
|
|
30357
30588
|
id: "EXOS-SYS-002",
|
|
30358
30589
|
vendor: "extreme-exos",
|
|
@@ -30365,7 +30596,7 @@ var ExosSntpRequired = {
|
|
|
30365
30596
|
},
|
|
30366
30597
|
check: judgedOnce((index, anchor) => {
|
|
30367
30598
|
const id = "EXOS-SYS-002";
|
|
30368
|
-
const server = matching(index,
|
|
30599
|
+
const server = matching(index, SNTP_SERVER2)[0] ?? matching(index, NTP_SERVER2)[0];
|
|
30369
30600
|
if (!server) {
|
|
30370
30601
|
return [failAt2(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
|
|
30371
30602
|
}
|
|
@@ -30384,8 +30615,8 @@ var ExosSntpEnabled = {
|
|
|
30384
30615
|
},
|
|
30385
30616
|
check: judgedOnce((index, anchor) => {
|
|
30386
30617
|
const id = "EXOS-SYS-003";
|
|
30387
|
-
const sntpServer = matching(index,
|
|
30388
|
-
const ntpServer = matching(index,
|
|
30618
|
+
const sntpServer = matching(index, SNTP_SERVER2)[0];
|
|
30619
|
+
const ntpServer = matching(index, NTP_SERVER2)[0];
|
|
30389
30620
|
const sntp = lastMatching(index, /^(?:enable|disable)\s+sntp-client\s*$/i);
|
|
30390
30621
|
const ntp = lastMatching(index, /^(?:enable|disable)\s+ntp\s*$/i);
|
|
30391
30622
|
const on = [sntp, ntp].find((l) => l !== void 0 && /^enable/i.test(l.text));
|
|
@@ -37631,7 +37862,7 @@ var treeOf = (context, node) => {
|
|
|
37631
37862
|
return tree;
|
|
37632
37863
|
};
|
|
37633
37864
|
var kidsOf = (tree, node) => tree.children.get(node) ?? [];
|
|
37634
|
-
var
|
|
37865
|
+
var descendantsOf3 = (tree, node) => kidsOf(tree, node).flatMap((child) => [child, ...descendantsOf3(tree, child)]);
|
|
37635
37866
|
var parentWord = (tree, node) => {
|
|
37636
37867
|
const up = tree.parent.get(node);
|
|
37637
37868
|
return up ? wordOf(up) : "";
|
|
@@ -37694,7 +37925,7 @@ var AaaWithTacacsRequired = {
|
|
|
37694
37925
|
check: (node, context) => {
|
|
37695
37926
|
const tree = treeOf(context, node);
|
|
37696
37927
|
if (!isSystemSecurity(tree, node)) return [];
|
|
37697
|
-
const words = new Set(
|
|
37928
|
+
const words = new Set(descendantsOf3(tree, node).map(wordOf));
|
|
37698
37929
|
if (words.has("tacplus")) return npass("NOKIA-MGMT-001", node, "TACACS+ authentication is configured.");
|
|
37699
37930
|
if (words.has("radius") || words.has("ldap")) {
|
|
37700
37931
|
return npass("NOKIA-MGMT-001", node, "RADIUS or LDAP is configured. Consider TACACS+ for command-level authorization.");
|
|
@@ -37839,7 +38070,7 @@ var NtpAuthenticationRequired2 = {
|
|
|
37839
38070
|
return findings.length > 0 ? findings : npass("NOKIA-MGMT-004", node, "NTP authentication is configured.");
|
|
37840
38071
|
}
|
|
37841
38072
|
};
|
|
37842
|
-
var filterEffective = (tree, filter, defaultEnabled) => adminEnabled(tree, filter, defaultEnabled) &&
|
|
38073
|
+
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
38074
|
var FILTER_WORDS = /* @__PURE__ */ new Set(["ip-filter", "ipv6-filter", "mac-filter"]);
|
|
37844
38075
|
var ManagementAccessFilterRequired = {
|
|
37845
38076
|
id: "NOKIA-MGMT-005",
|
|
@@ -37909,7 +38140,7 @@ var instanceAuthCheck = (ruleId, pattern, protocol, defaultEnabled, extraWords,
|
|
|
37909
38140
|
if (!adminEnabled(tree, node, defaultEnabled)) return npass(ruleId, node, `${protocol} is not enabled.`);
|
|
37910
38141
|
if (applies && !applies(tree, node)) return npass(ruleId, node, `${protocol} has no sessions configured.`);
|
|
37911
38142
|
const words = /* @__PURE__ */ new Set([...AUTH_WORDS, ...extraWords]);
|
|
37912
|
-
if (!
|
|
38143
|
+
if (!descendantsOf3(tree, node).some((n) => words.has(wordOf(n)))) {
|
|
37913
38144
|
return nfail(ruleId, node, "warning", `${protocol} is enabled without authentication. Configure an authentication key or keychain.`);
|
|
37914
38145
|
}
|
|
37915
38146
|
return npass(ruleId, node, `${protocol} authentication is configured.`);
|
|
@@ -38041,7 +38272,7 @@ var BgpGracefulRestartRecommended = {
|
|
|
38041
38272
|
const tree = treeOf(context, node);
|
|
38042
38273
|
if (!isBgpInstance(tree, node)) return [];
|
|
38043
38274
|
if (!adminEnabled(tree, node, true)) return npass("NOKIA-BGP-005", node, "BGP is not enabled.");
|
|
38044
|
-
if (!
|
|
38275
|
+
if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "graceful-restart")) {
|
|
38045
38276
|
return nfail("NOKIA-BGP-005", node, "info", "BGP graceful restart is not configured. Consider enabling for high availability.", true);
|
|
38046
38277
|
}
|
|
38047
38278
|
return npass("NOKIA-BGP-005", node, "BGP graceful restart is configured.");
|
|
@@ -38281,7 +38512,7 @@ var IpFilterRequired = {
|
|
|
38281
38512
|
const tree = treeOf(context, node);
|
|
38282
38513
|
if (!isTransitInterface(tree, node)) return [];
|
|
38283
38514
|
const ingress = childWithWord(tree, node, "ingress");
|
|
38284
|
-
const filtered = ingress !== void 0 &&
|
|
38515
|
+
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
38516
|
if (!filtered) {
|
|
38286
38517
|
return nfail("NOKIA-DATA-001", node, "info", `Interface "${nameOf2(node)}" does not have an ingress IP filter. Consider adding ACLs for traffic filtering.`);
|
|
38287
38518
|
}
|
|
@@ -38309,7 +38540,7 @@ var UrpfRequired = {
|
|
|
38309
38540
|
check: (node, context) => {
|
|
38310
38541
|
const tree = treeOf(context, node);
|
|
38311
38542
|
if (!isTransitInterface(tree, node)) return [];
|
|
38312
|
-
if (!
|
|
38543
|
+
if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "urpf-check")) {
|
|
38313
38544
|
return nfail("NOKIA-URPF-001", node, "info", `Interface "${nameOf2(node)}" does not have uRPF configured. Consider enabling for anti-spoofing.`);
|
|
38314
38545
|
}
|
|
38315
38546
|
return npass("NOKIA-URPF-001", node, `Interface "${nameOf2(node)}" has uRPF enabled.`);
|
|
@@ -38330,7 +38561,7 @@ var VprnIsolationRequired = {
|
|
|
38330
38561
|
check: (node, context) => {
|
|
38331
38562
|
const tree = treeOf(context, node);
|
|
38332
38563
|
if (!isVprnService(tree, node)) return [];
|
|
38333
|
-
const words = new Set(
|
|
38564
|
+
const words = new Set(descendantsOf3(tree, node).map(wordOf));
|
|
38334
38565
|
const missing = [
|
|
38335
38566
|
words.has("route-distinguisher") ? "" : "route-distinguisher",
|
|
38336
38567
|
["vrf-target", "vrf-import", "vrf-export"].some((w) => words.has(w)) ? "" : "vrf-target"
|
|
@@ -38355,8 +38586,8 @@ var VprnGrtLeakingWarning = {
|
|
|
38355
38586
|
check: (node, context) => {
|
|
38356
38587
|
const tree = treeOf(context, node);
|
|
38357
38588
|
if (!isVprnService(tree, node)) return [];
|
|
38358
|
-
const leaking =
|
|
38359
|
-
if (leaking && !
|
|
38589
|
+
const leaking = descendantsOf3(tree, node).find((n) => wordOf(n) === "grt-leaking");
|
|
38590
|
+
if (leaking && !descendantsOf3(tree, leaking).some((n) => wordOf(n) === "export-grt")) {
|
|
38360
38591
|
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
38592
|
}
|
|
38362
38593
|
return npass("NOKIA-VPRN-002", node, `VPRN ${nameOf2(node)} has no uncontrolled GRT leaking.`);
|
|
@@ -38405,7 +38636,7 @@ var BfdRecommended = {
|
|
|
38405
38636
|
const tree = treeOf(context, node);
|
|
38406
38637
|
if (!isBgpInstance(tree, node)) return [];
|
|
38407
38638
|
if (!adminEnabled(tree, node, true)) return npass("NOKIA-HA-002", node, "BGP is not enabled.");
|
|
38408
|
-
const bfd =
|
|
38639
|
+
const bfd = descendantsOf3(tree, node).some(
|
|
38409
38640
|
(n) => wordOf(n) === "bfd-enable" || wordOf(n) === "bfd-liveness" && !/\sfalse$/i.test(keyOf2(n))
|
|
38410
38641
|
);
|
|
38411
38642
|
if (!bfd) {
|
|
@@ -38673,6 +38904,7 @@ function getRulesByNokiaVendor() {
|
|
|
38673
38904
|
}
|
|
38674
38905
|
|
|
38675
38906
|
// ../rules-default/src/cumulus/cumulus-rules.ts
|
|
38907
|
+
var isVlanDevice = (node, name) => /\.\d+$/.test(name) || hasChildCommand(node, "vlan-raw-device") || hasChildCommand(node, "vlan-id");
|
|
38676
38908
|
var CumulusInterfaceDescription = {
|
|
38677
38909
|
id: "CUM-IF-001",
|
|
38678
38910
|
selector: "iface",
|
|
@@ -38841,7 +39073,7 @@ var CumulusBridgeVlans = {
|
|
|
38841
39073
|
},
|
|
38842
39074
|
check: (node) => {
|
|
38843
39075
|
const ifaceName = getInterfaceName2(node);
|
|
38844
|
-
if (!isBridgeInterface(ifaceName)) {
|
|
39076
|
+
if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38845
39077
|
return {
|
|
38846
39078
|
passed: true,
|
|
38847
39079
|
message: "Not a bridge interface.",
|
|
@@ -38894,7 +39126,7 @@ var CumulusBridgePorts = {
|
|
|
38894
39126
|
},
|
|
38895
39127
|
check: (node) => {
|
|
38896
39128
|
const ifaceName = getInterfaceName2(node);
|
|
38897
|
-
if (!isBridgeInterface(ifaceName)) {
|
|
39129
|
+
if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38898
39130
|
return {
|
|
38899
39131
|
passed: true,
|
|
38900
39132
|
message: "Not a bridge interface.",
|
|
@@ -38937,7 +39169,7 @@ var CumulusBondSlaves = {
|
|
|
38937
39169
|
},
|
|
38938
39170
|
check: (node) => {
|
|
38939
39171
|
const ifaceName = getInterfaceName2(node);
|
|
38940
|
-
if (!isBondInterface(ifaceName)) {
|
|
39172
|
+
if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38941
39173
|
return {
|
|
38942
39174
|
passed: true,
|
|
38943
39175
|
message: "Not a bond interface.",
|
|
@@ -38980,7 +39212,7 @@ var CumulusBondClagId = {
|
|
|
38980
39212
|
},
|
|
38981
39213
|
check: (node) => {
|
|
38982
39214
|
const ifaceName = getInterfaceName2(node);
|
|
38983
|
-
if (!isBondInterface(ifaceName)) {
|
|
39215
|
+
if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
|
|
38984
39216
|
return {
|
|
38985
39217
|
passed: true,
|
|
38986
39218
|
message: "Not a bond interface.",
|
|
@@ -40076,6 +40308,42 @@ var CumulusSecretEncryption = {
|
|
|
40076
40308
|
return findings;
|
|
40077
40309
|
})
|
|
40078
40310
|
};
|
|
40311
|
+
var NVUE_READONLY_COMMUNITY = /^nv\s+set\s+(?:system|service)\s+snmp-server\s+readonly-community(?:-v6)?\s+(\S+)/i;
|
|
40312
|
+
var CumulusSnmpDefaultCommunity = {
|
|
40313
|
+
id: "CUM-SNMP-001",
|
|
40314
|
+
vendor: "cumulus-linux",
|
|
40315
|
+
category: "Protocol-Security",
|
|
40316
|
+
metadata: {
|
|
40317
|
+
level: "error",
|
|
40318
|
+
obu: "Security",
|
|
40319
|
+
owner: "SecOps",
|
|
40320
|
+
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 ...").',
|
|
40321
|
+
security: {
|
|
40322
|
+
cwe: ["CWE-798"]
|
|
40323
|
+
},
|
|
40324
|
+
tags: [
|
|
40325
|
+
{ type: "general", label: "cleartext" },
|
|
40326
|
+
{ type: "general", label: "snmp" }
|
|
40327
|
+
]
|
|
40328
|
+
},
|
|
40329
|
+
check: judgeWholeConfig("CUM-SNMP-001", "No SNMP community uses a well-known name.", (ast) => {
|
|
40330
|
+
const findings = [];
|
|
40331
|
+
walkStatements(ast, (node) => {
|
|
40332
|
+
const value = NVUE_READONLY_COMMUNITY.exec(node.id)?.[1];
|
|
40333
|
+
if (!value) return;
|
|
40334
|
+
const name = value.replace(/^(['"])(.*)\1$/, "$2");
|
|
40335
|
+
const lower = name.toLowerCase();
|
|
40336
|
+
if (lower !== "public" && lower !== "private") return;
|
|
40337
|
+
findings.push({
|
|
40338
|
+
node,
|
|
40339
|
+
level: "error",
|
|
40340
|
+
message: `SNMP community "${name}" is a well-known default (NVUE "readonly-community"). Use a unique string restricted with "access <prefix>", or SNMPv3.`,
|
|
40341
|
+
masked: maskSecretLine(node)
|
|
40342
|
+
});
|
|
40343
|
+
});
|
|
40344
|
+
return findings;
|
|
40345
|
+
})
|
|
40346
|
+
};
|
|
40079
40347
|
var allCumulusRules = [
|
|
40080
40348
|
CumulusInterfaceDescription,
|
|
40081
40349
|
CumulusBpduGuard,
|
|
@@ -40110,7 +40378,8 @@ var allCumulusRules = [
|
|
|
40110
40378
|
CumulusVniVxlanId,
|
|
40111
40379
|
CumulusEvpnAnycastIp,
|
|
40112
40380
|
CumulusStormControl,
|
|
40113
|
-
CumulusSecretEncryption
|
|
40381
|
+
CumulusSecretEncryption,
|
|
40382
|
+
CumulusSnmpDefaultCommunity
|
|
40114
40383
|
];
|
|
40115
40384
|
|
|
40116
40385
|
// ../rules-default/src/cumulus/index.ts
|
|
@@ -40625,7 +40894,7 @@ function resolveVersion(injected) {
|
|
|
40625
40894
|
|
|
40626
40895
|
// src/sarif.ts
|
|
40627
40896
|
var TOOL_VERSION = resolveVersion(
|
|
40628
|
-
true ? "0.11.0-rc.
|
|
40897
|
+
true ? "0.11.0-rc.2" : void 0
|
|
40629
40898
|
);
|
|
40630
40899
|
var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
|
|
40631
40900
|
function cweNumber(cweId) {
|
|
@@ -43079,7 +43348,7 @@ async function exitIfVendorUndetected() {
|
|
|
43079
43348
|
}
|
|
43080
43349
|
}
|
|
43081
43350
|
var program = new Command2();
|
|
43082
|
-
var cliVersion = resolveVersion(true ? "0.11.0-rc.
|
|
43351
|
+
var cliVersion = resolveVersion(true ? "0.11.0-rc.2" : void 0);
|
|
43083
43352
|
var pluginPackLoaders = [];
|
|
43084
43353
|
var pluginRequests = pluginRequestsFromEnv(process.env);
|
|
43085
43354
|
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(
|