@sentriflow/cli 0.10.0 → 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.
Files changed (3) hide show
  1. package/README.md +5 -5
  2. package/dist/index.js +1563 -874
  3. 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|console|aux)\s+\S+/i, depth: 0 },
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 (/^set\s+(interfaces\s+ethernet|service\s+ssh|nat\s+source|firewall\s+name|high-availability|vpn\s+ipsec|traffic-policy|container\s+name)\s+/m.test(sampleText)) {
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 (/^set\s+(system|chassis|interfaces|protocols|policy-options|routing-options|routing-instances|security|firewall)/m.test(sampleText)) {
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
- own.set(id, [...own.get(id) ?? [], child]);
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.children ?? []);
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
  };
@@ -8244,11 +8301,12 @@ var getManagementApiNodes = (ast) => {
8244
8301
  };
8245
8302
  var hasHttpsTransport = (apiNode) => {
8246
8303
  if (!apiNode?.children) return false;
8304
+ const enabled = (child) => !!child?.id && !/^no\s/i.test(child.id.trim());
8247
8305
  const hasProtocolHttps = apiNode.children.some(
8248
- (child) => child?.id && includesIgnoreCase(child.id, "protocol https")
8306
+ (child) => enabled(child) && includesIgnoreCase(child.id, "protocol https")
8249
8307
  );
8250
8308
  const hasTransportHttps = apiNode.children.some(
8251
- (child) => child?.id && includesIgnoreCase(child.id, "transport https")
8309
+ (child) => enabled(child) && includesIgnoreCase(child.id, "transport https")
8252
8310
  );
8253
8311
  return hasProtocolHttps || hasTransportHttps;
8254
8312
  };
@@ -8902,11 +8960,11 @@ var hasWeakUsernamePassword = (node) => {
8902
8960
  }
8903
8961
  return false;
8904
8962
  };
8963
+ var IOS_LINE_SECTION = /^line\s+(?:con(?:s(?:o(?:l(?:e)?)?)?)?|aux|tty|vty|\d+)(?:\s|$)/i;
8905
8964
  var isLineConfigPassword = (ast, node) => {
8906
8965
  const parent = findParentSection(ast, node);
8907
8966
  if (!parent) return false;
8908
- const parentId = parent.id.toLowerCase();
8909
- return parentId.startsWith("line vty") || parentId.startsWith("line console") || parentId.startsWith("line aux");
8967
+ return IOS_LINE_SECTION.test(parent.id.trim());
8910
8968
  };
8911
8969
  var getSshVersion = (node) => {
8912
8970
  if (includesIgnoreCase(node.rawText, "ip ssh version")) {
@@ -12584,6 +12642,11 @@ var getDestinationZones = (ruleNode) => {
12584
12642
  if (!to?.children) return [];
12585
12643
  return to.children.map((child) => child?.id?.trim() ?? "").filter(Boolean);
12586
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
+ };
12587
12650
  var getApplications = (ruleNode) => {
12588
12651
  if (!ruleNode?.children) return [];
12589
12652
  const application = findStanza6(ruleNode, "application");
@@ -12594,10 +12657,7 @@ var getApplications = (ruleNode) => {
12594
12657
  (child) => child?.id?.toLowerCase().startsWith("application ")
12595
12658
  );
12596
12659
  if (appCommands.length > 0) {
12597
- return appCommands.map((cmd) => {
12598
- const parts = cmd?.id?.split(/\s+/) ?? [];
12599
- return parts.slice(1).join(" ").replace(/;$/, "").trim();
12600
- }).filter(Boolean);
12660
+ return appCommands.flatMap((cmd) => memberValues(cmd));
12601
12661
  }
12602
12662
  return [];
12603
12663
  };
@@ -12618,10 +12678,9 @@ var hasAnySource = (ruleNode) => {
12618
12678
  (child) => child?.id?.toLowerCase().startsWith("source ")
12619
12679
  );
12620
12680
  if (sourceCommands.length > 0) {
12621
- return sourceCommands.some((cmd) => {
12622
- const value = cmd?.id?.split(/\s+/).slice(1).join(" ").toLowerCase().replace(/;$/, "").trim();
12623
- return value === "any" || value === "0.0.0.0/0";
12624
- });
12681
+ return sourceCommands.some(
12682
+ (cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
12683
+ );
12625
12684
  }
12626
12685
  return false;
12627
12686
  };
@@ -12638,10 +12697,9 @@ var hasAnyDestination = (ruleNode) => {
12638
12697
  (child) => child?.id?.toLowerCase().startsWith("destination ")
12639
12698
  );
12640
12699
  if (destCommands.length > 0) {
12641
- return destCommands.some((cmd) => {
12642
- const value = cmd?.id?.split(/\s+/).slice(1).join(" ").toLowerCase().replace(/;$/, "").trim();
12643
- return value === "any" || value === "0.0.0.0/0";
12644
- });
12700
+ return destCommands.some(
12701
+ (cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any" || v === "0.0.0.0/0")
12702
+ );
12645
12703
  }
12646
12704
  return false;
12647
12705
  };
@@ -12658,10 +12716,7 @@ var hasAnyService2 = (ruleNode) => {
12658
12716
  (child) => child?.id?.toLowerCase().startsWith("service ")
12659
12717
  );
12660
12718
  if (serviceCommands2.length > 0) {
12661
- return serviceCommands2.some((cmd) => {
12662
- const value = cmd?.id?.split(/\s+/).slice(1).join(" ").toLowerCase().replace(/;$/, "").trim();
12663
- return value === "any";
12664
- });
12719
+ return serviceCommands2.some((cmd) => memberValues(cmd).some((v) => v.toLowerCase() === "any"));
12665
12720
  }
12666
12721
  return false;
12667
12722
  };
@@ -16238,484 +16293,19 @@ function applySuppressions(results, options) {
16238
16293
  return { kept, suppressed };
16239
16294
  }
16240
16295
 
16296
+ // ../core/src/ruleDocs.ts
16297
+ var RULE_DOCS_BASE = "https://www.sentriflow.com.au/rules/";
16298
+ var BUILT_IN_RULE_ID = /^[A-Z0-9][A-Z0-9-]*$/;
16299
+ function ruleDocsUrl(ruleId) {
16300
+ return BUILT_IN_RULE_ID.test(ruleId) ? `${RULE_DOCS_BASE}${ruleId}/` : void 0;
16301
+ }
16302
+
16241
16303
  // index.ts
16242
16304
  import { readFile as readFile2 } from "fs/promises";
16243
16305
  import { statSync as statSync4 } from "fs";
16244
16306
  import { basename as basename2 } from "path";
16245
16307
  import { isMainThread, parentPort, workerData } from "worker_threads";
16246
16308
 
16247
- // src/sarif.ts
16248
- import { relative } from "path";
16249
- import { createHash } from "crypto";
16250
-
16251
- // src/cliOptions.ts
16252
- import { readFileSync } from "fs";
16253
- var FAIL_ON_LEVELS = ["error", "warning", "info", "never"];
16254
- var SEVERITY_RANK = {
16255
- info: 0,
16256
- warning: 1,
16257
- error: 2
16258
- };
16259
- function parseFailOn(value) {
16260
- const v = value.trim().toLowerCase();
16261
- const match = FAIL_ON_LEVELS.find((l) => l === v);
16262
- if (!match) {
16263
- throw new Error(
16264
- `Invalid --fail-on value '${value}'. Expected one of: ${FAIL_ON_LEVELS.join(", ")}`
16265
- );
16266
- }
16267
- return match;
16268
- }
16269
- var OUTPUT_FORMATS = ["json", "human", "sarif"];
16270
- function parseFormat(value) {
16271
- const v = value.trim().toLowerCase();
16272
- const match = OUTPUT_FORMATS.find((f) => f === v);
16273
- if (!match) {
16274
- throw new Error(
16275
- `Invalid --format value '${value}'. Expected one of: ${OUTPUT_FORMATS.join(", ")}`
16276
- );
16277
- }
16278
- return match;
16279
- }
16280
- var LIST_FORMATS = ["table", "json", "csv"];
16281
- function parseListFormat(value) {
16282
- const v = value.trim().toLowerCase();
16283
- const match = LIST_FORMATS.find((f) => f === v);
16284
- if (!match) {
16285
- throw new Error(
16286
- `Invalid --list-format value '${value}'. Expected one of: ${LIST_FORMATS.join(", ")}`
16287
- );
16288
- }
16289
- return match;
16290
- }
16291
- function shouldFail(results, threshold) {
16292
- if (threshold === "never") return false;
16293
- const min = SEVERITY_RANK[threshold];
16294
- return results.some((r) => !r.passed && SEVERITY_RANK[r.level] >= min);
16295
- }
16296
- function normalizeExtensions(value) {
16297
- return value.split(",").map((e) => e.trim().replace(/^\.+/, "").toLowerCase()).filter((e) => e.length > 0);
16298
- }
16299
- function resolveVersion(injected) {
16300
- if (injected !== void 0) return injected;
16301
- try {
16302
- const pkg = JSON.parse(
16303
- readFileSync(new URL("../package.json", import.meta.url), "utf-8")
16304
- );
16305
- if (pkg && typeof pkg === "object" && "version" in pkg && typeof pkg.version === "string") {
16306
- return pkg.version;
16307
- }
16308
- } catch {
16309
- }
16310
- return "unknown";
16311
- }
16312
-
16313
- // src/sarif.ts
16314
- var TOOL_VERSION = resolveVersion(
16315
- true ? "0.10.0" : void 0
16316
- );
16317
- var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
16318
- function cweNumber(cweId) {
16319
- return cweId.replace(/^cwe-/i, "").trim();
16320
- }
16321
- var LEVEL_SECURITY_SEVERITY = {
16322
- error: "8.0",
16323
- warning: "5.0",
16324
- info: "2.0"
16325
- };
16326
- function securitySeverity(rule) {
16327
- const sec = rule.metadata.security;
16328
- if (sec?.cvssScore !== void 0) return String(sec.cvssScore);
16329
- if (sec?.cwe && sec.cwe.length > 0) return LEVEL_SECURITY_SEVERITY[rule.metadata.level];
16330
- return void 0;
16331
- }
16332
- function toUri(filePath, options) {
16333
- return options.relativePaths ? relative(options.baseDir ?? process.cwd(), filePath) : filePath;
16334
- }
16335
- function fingerprintPath(filePath, options) {
16336
- if (filePath.startsWith("<")) return filePath;
16337
- return relative(options.baseDir ?? process.cwd(), filePath).replace(
16338
- /\\/g,
16339
- "/"
16340
- );
16341
- }
16342
- function normaliseText(text) {
16343
- return text.trim().replace(/\s+/g, " ");
16344
- }
16345
- function fingerprintLine(lineText, nodeId) {
16346
- const line = normaliseText(maskSecretWords(lineText));
16347
- const at2 = nodeId.indexOf(SECRET_MASK);
16348
- if (at2 < 0 || line.includes(SECRET_MASK)) return line;
16349
- const shown2 = normaliseText(nodeId.slice(0, at2));
16350
- if (shown2 === "" || !line.startsWith(shown2)) return line;
16351
- const snmp = normaliseText(maskSecretWords(lineText, { snmp: true }));
16352
- return snmp.includes(SECRET_MASK) ? snmp : `${shown2} ${SECRET_MASK}`;
16353
- }
16354
- function normaliseMessage(message) {
16355
- return normaliseText(message).replace(/\d+/g, "#");
16356
- }
16357
- function buildSarifResults(results, filePath, sourceText, ruleIndexById, options, suppressed = []) {
16358
- const uri = toUri(filePath, options);
16359
- const fpPath = fingerprintPath(filePath, options);
16360
- const lines = sourceText?.split(/\r\n|\r|\n/);
16361
- const occurrences = /* @__PURE__ */ new Map();
16362
- const items = [
16363
- ...results.filter((result2) => options.includePassed || !result2.passed).map((result2) => ({ result: result2 })),
16364
- ...suppressed
16365
- ];
16366
- const hashes = items.map(({ result: result2 }) => {
16367
- const lineText = result2.loc ? lines?.[result2.loc.startLine] : void 0;
16368
- const where = result2.absent ? "" : lineText !== void 0 && lineText.trim() !== "" ? fingerprintLine(lineText, result2.nodeId) : normaliseText(result2.nodeId);
16369
- return createHash("sha256").update(`${result2.ruleId}
16370
- ${normaliseMessage(result2.message)}
16371
- ${where}
16372
- ${fpPath}`).digest("hex").slice(0, 32);
16373
- });
16374
- const occurrenceOf = new Array(items.length).fill(1);
16375
- const byLine = items.map((item, i) => ({ i, line: item.result.loc?.startLine ?? Number.POSITIVE_INFINITY })).sort((a, b) => a.line - b.line || a.i - b.i);
16376
- for (const { i } of byLine) {
16377
- const hash = hashes[i] ?? "";
16378
- const occurrence = (occurrences.get(hash) ?? 0) + 1;
16379
- occurrences.set(hash, occurrence);
16380
- occurrenceOf[i] = occurrence;
16381
- }
16382
- return items.map(({ result: result2, suppression }, i) => {
16383
- const hash = hashes[i] ?? "";
16384
- const occurrence = occurrenceOf[i] ?? 1;
16385
- const ruleIndex = ruleIndexById.get(result2.ruleId);
16386
- return {
16387
- ruleId: result2.ruleId,
16388
- ...ruleIndex !== void 0 && { ruleIndex },
16389
- ...result2.passed && { kind: "pass" },
16390
- level: result2.level === "info" ? "note" : result2.level,
16391
- message: {
16392
- text: result2.message
16393
- },
16394
- locations: result2.loc ? [
16395
- {
16396
- physicalLocation: {
16397
- artifactLocation: { uri },
16398
- region: {
16399
- startLine: result2.loc.startLine + 1,
16400
- // SARIF is 1-based
16401
- endLine: result2.loc.endLine + 1
16402
- }
16403
- }
16404
- }
16405
- ] : [],
16406
- partialFingerprints: {
16407
- primaryLocationLineHash: `${hash}:${occurrence}`
16408
- },
16409
- ...suppression && {
16410
- suppressions: [
16411
- {
16412
- kind: suppression.kind,
16413
- status: "accepted",
16414
- justification: suppression.justification
16415
- }
16416
- ]
16417
- }
16418
- };
16419
- });
16420
- }
16421
- function buildRulesAndTaxonomy(rules) {
16422
- const cweIds = /* @__PURE__ */ new Set();
16423
- const sarifRules = rules?.map((rule) => {
16424
- const base = {
16425
- id: rule.id,
16426
- name: rule.id,
16427
- shortDescription: { text: rule.metadata.remediation ?? rule.id },
16428
- defaultConfiguration: {
16429
- level: rule.metadata.level === "info" ? "note" : rule.metadata.level
16430
- }
16431
- };
16432
- const secMeta = rule.metadata.security;
16433
- if (secMeta?.cwe && secMeta.cwe.length > 0) {
16434
- base.relationships = secMeta.cwe.map((cweId) => {
16435
- const id = cweNumber(cweId);
16436
- cweIds.add(id);
16437
- return {
16438
- target: { id, toolComponent: { name: "CWE" } },
16439
- kinds: ["relevant"]
16440
- };
16441
- });
16442
- }
16443
- const severity = securitySeverity(rule);
16444
- const hasTags = rule.metadata.tags && rule.metadata.tags.length > 0;
16445
- const hasCategory = rule.category !== void 0;
16446
- if (severity !== void 0 || secMeta?.cvssVector || hasTags || hasCategory) {
16447
- base.properties = {};
16448
- if (hasCategory) {
16449
- base.properties.category = rule.category;
16450
- }
16451
- if (severity !== void 0) {
16452
- base.properties["security-severity"] = severity;
16453
- }
16454
- if (secMeta?.cvssVector) {
16455
- base.properties["cvss-vector"] = secMeta.cvssVector;
16456
- }
16457
- if (hasTags) {
16458
- base.properties.tags = rule.metadata.tags.map((t) => t.label);
16459
- }
16460
- }
16461
- return base;
16462
- }) ?? [];
16463
- const ruleIndexById = /* @__PURE__ */ new Map();
16464
- sarifRules.forEach((r, i) => {
16465
- if (!ruleIndexById.has(r.id)) ruleIndexById.set(r.id, i);
16466
- });
16467
- const hasCwe = cweIds.size > 0;
16468
- const cweTaxonomy = hasCwe ? {
16469
- name: "CWE",
16470
- version: "4.13",
16471
- guid: CWE_GUID,
16472
- informationUri: "https://cwe.mitre.org/",
16473
- organization: "MITRE",
16474
- shortDescription: { text: "Common Weakness Enumeration" },
16475
- taxa: [...cweIds].sort((a, b) => Number(a) - Number(b) || a.localeCompare(b)).map((id) => ({ id, name: `CWE-${id}` }))
16476
- } : void 0;
16477
- const supportedTaxonomies = hasCwe ? [{ name: "CWE", index: 0, guid: CWE_GUID }] : void 0;
16478
- return { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies };
16479
- }
16480
- function buildSarif(results, filePath, rules, options = {}, ipSummary) {
16481
- const { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies } = buildRulesAndTaxonomy(rules);
16482
- const sarifResults = buildSarifResults(
16483
- results,
16484
- filePath,
16485
- options.sourceText,
16486
- ruleIndexById,
16487
- options,
16488
- options.suppressed
16489
- );
16490
- const report = {
16491
- version: "2.1.0",
16492
- $schema: "https://json.schemastore.org/sarif-2.1.0.json",
16493
- runs: [
16494
- {
16495
- tool: {
16496
- driver: {
16497
- name: "Sentriflow",
16498
- version: TOOL_VERSION,
16499
- informationUri: "https://github.com/sentriflow/sentriflow",
16500
- rules: sarifRules,
16501
- ...supportedTaxonomies && { supportedTaxonomies }
16502
- }
16503
- },
16504
- ...cweTaxonomy && { taxonomies: [cweTaxonomy] },
16505
- results: sarifResults,
16506
- // Include IP summary in properties if available
16507
- ...ipSummary && {
16508
- properties: {
16509
- ipSummary
16510
- }
16511
- }
16512
- }
16513
- ]
16514
- };
16515
- return report;
16516
- }
16517
- function aggregateIPSummaries(summaries) {
16518
- if (summaries.length === 0) return void 0;
16519
- const ipv4Set = /* @__PURE__ */ new Set();
16520
- const ipv6Set = /* @__PURE__ */ new Set();
16521
- const ipv4SubnetSet = /* @__PURE__ */ new Set();
16522
- const ipv6SubnetSet = /* @__PURE__ */ new Set();
16523
- for (const summary of summaries) {
16524
- for (const ip of summary.ipv4Addresses) ipv4Set.add(ip);
16525
- for (const ip of summary.ipv6Addresses) ipv6Set.add(ip);
16526
- for (const subnet of summary.ipv4Subnets) ipv4SubnetSet.add(subnet);
16527
- for (const subnet of summary.ipv6Subnets) ipv6SubnetSet.add(subnet);
16528
- }
16529
- const ipv4Addresses = [...ipv4Set].sort((a, b) => {
16530
- const aParts = a.split(".").map(Number);
16531
- const bParts = b.split(".").map(Number);
16532
- for (let i = 0; i < 4; i++) {
16533
- if ((aParts[i] ?? 0) !== (bParts[i] ?? 0)) {
16534
- return (aParts[i] ?? 0) - (bParts[i] ?? 0);
16535
- }
16536
- }
16537
- return 0;
16538
- });
16539
- const ipv6Addresses = [...ipv6Set].sort();
16540
- const ipv4Subnets = [...ipv4SubnetSet].sort();
16541
- const ipv6Subnets = [...ipv6SubnetSet].sort();
16542
- return {
16543
- ipv4Addresses,
16544
- ipv6Addresses,
16545
- ipv4Subnets,
16546
- ipv6Subnets,
16547
- counts: {
16548
- ipv4: ipv4Addresses.length,
16549
- ipv6: ipv6Addresses.length,
16550
- ipv4Subnets: ipv4Subnets.length,
16551
- ipv6Subnets: ipv6Subnets.length,
16552
- total: ipv4Addresses.length + ipv6Addresses.length + ipv4Subnets.length + ipv6Subnets.length
16553
- }
16554
- };
16555
- }
16556
- function buildMultiFileSarif(fileResults, rules, options = {}) {
16557
- const aggregatedIpSummary = aggregateIPSummaries(
16558
- fileResults.map((fr) => fr.ipSummary).filter((s) => !!s)
16559
- );
16560
- const { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies } = buildRulesAndTaxonomy(rules);
16561
- const allSarifResults = fileResults.flatMap(
16562
- ({ filePath, results, content, suppressed }) => buildSarifResults(results, filePath, content, ruleIndexById, options, suppressed)
16563
- );
16564
- const skippedNotifications = fileResults.filter((fr) => fr.skipped).map((fr) => ({
16565
- level: "error",
16566
- message: {
16567
- text: `Skipped ${options.relativePaths ? relative(options.baseDir ?? process.cwd(), fr.filePath) : fr.filePath}: ${fr.skipped?.reason ?? "not scanned"}. Re-run with --vendor <vendor>.`
16568
- }
16569
- }));
16570
- const artifactUris = [
16571
- ...new Set(
16572
- fileResults.map(
16573
- ({ filePath }) => options.relativePaths ? relative(options.baseDir ?? process.cwd(), filePath) : filePath
16574
- )
16575
- )
16576
- ];
16577
- const report = {
16578
- version: "2.1.0",
16579
- $schema: "https://json.schemastore.org/sarif-2.1.0.json",
16580
- runs: [
16581
- {
16582
- tool: {
16583
- driver: {
16584
- name: "Sentriflow",
16585
- version: TOOL_VERSION,
16586
- informationUri: "https://github.com/sentriflow/sentriflow",
16587
- rules: sarifRules,
16588
- ...supportedTaxonomies && { supportedTaxonomies }
16589
- }
16590
- },
16591
- // Include artifacts array for multi-file reports
16592
- artifacts: artifactUris.map((uri) => ({
16593
- location: { uri }
16594
- })),
16595
- ...cweTaxonomy && { taxonomies: [cweTaxonomy] },
16596
- results: allSarifResults,
16597
- ...skippedNotifications.length > 0 && {
16598
- invocations: [
16599
- {
16600
- executionSuccessful: false,
16601
- toolExecutionNotifications: skippedNotifications
16602
- }
16603
- ]
16604
- },
16605
- // Include aggregated IP summary in properties if available
16606
- ...aggregatedIpSummary && {
16607
- properties: {
16608
- ipSummary: aggregatedIpSummary
16609
- }
16610
- }
16611
- }
16612
- ]
16613
- };
16614
- return report;
16615
- }
16616
-
16617
- // src/human.ts
16618
- var COLORS = {
16619
- red: "\x1B[31m",
16620
- yellow: "\x1B[33m",
16621
- blue: "\x1B[34m",
16622
- gray: "\x1B[90m",
16623
- bold: "\x1B[1m",
16624
- reset: "\x1B[0m"
16625
- };
16626
- var SEVERITY_COLORS = {
16627
- error: COLORS.red,
16628
- warning: COLORS.yellow,
16629
- info: COLORS.blue
16630
- };
16631
- function countSeverities(results) {
16632
- const counts = { error: 0, warning: 0, info: 0, total: 0 };
16633
- for (const r of results) {
16634
- if (!r.passed) {
16635
- if (r.level === "error" || r.level === "warning" || r.level === "info") {
16636
- counts[r.level]++;
16637
- }
16638
- counts.total++;
16639
- }
16640
- }
16641
- return counts;
16642
- }
16643
- function formatFinding(result2, color) {
16644
- const line = result2.loc ? result2.loc.startLine + 1 : 0;
16645
- const col = 1;
16646
- const location = `${line}:${col}`.padEnd(8);
16647
- const severityColor = color ? SEVERITY_COLORS[result2.level] ?? "" : "";
16648
- const reset = color ? COLORS.reset : "";
16649
- const severityText = result2.level.padEnd(7);
16650
- const severity = `${severityColor}${severityText}${reset}`;
16651
- const ruleColor = color ? COLORS.gray : "";
16652
- const ruleId = `${ruleColor}${result2.ruleId}${reset}`;
16653
- return ` ${location} ${severity} ${result2.message} ${ruleId}`;
16654
- }
16655
- function formatSummary(counts, color) {
16656
- if (counts.total === 0) {
16657
- const check = color ? `${COLORS.bold}\u2714${COLORS.reset}` : "\u2714";
16658
- return `
16659
- ${check} No problems found
16660
- `;
16661
- }
16662
- const x = color ? `${COLORS.red}\u2716${COLORS.reset}` : "\u2716";
16663
- const parts = [];
16664
- if (counts.error > 0) {
16665
- parts.push(`${counts.error} error${counts.error !== 1 ? "s" : ""}`);
16666
- }
16667
- if (counts.warning > 0) {
16668
- parts.push(`${counts.warning} warning${counts.warning !== 1 ? "s" : ""}`);
16669
- }
16670
- if (counts.info > 0) {
16671
- parts.push(`${counts.info} info`);
16672
- }
16673
- const problemText = counts.total === 1 ? "problem" : "problems";
16674
- return `
16675
- ${x} ${counts.total} ${problemText} (${parts.join(", ")})
16676
- `;
16677
- }
16678
- function formatHuman(results, filePath, options) {
16679
- const color = options?.color ?? false;
16680
- const failures = results.filter((r) => !r.passed);
16681
- const lines = [];
16682
- const header = color ? `${COLORS.bold}${filePath}${COLORS.reset}` : filePath;
16683
- lines.push(header);
16684
- for (const result2 of failures) {
16685
- lines.push(formatFinding(result2, color));
16686
- }
16687
- const counts = countSeverities(results);
16688
- lines.push(formatSummary(counts, color));
16689
- return lines.join("\n");
16690
- }
16691
- function formatMultiFileHuman(files, options) {
16692
- const color = options?.color ?? false;
16693
- const lines = [];
16694
- const totalCounts = { error: 0, warning: 0, info: 0, total: 0 };
16695
- for (const { file, results } of files) {
16696
- const failures = results.filter((r) => !r.passed);
16697
- if (failures.length === 0) continue;
16698
- const header = color ? `${COLORS.bold}${file}${COLORS.reset}` : file;
16699
- lines.push(header);
16700
- for (const result2 of failures) {
16701
- lines.push(formatFinding(result2, color));
16702
- }
16703
- lines.push("");
16704
- const counts = countSeverities(results);
16705
- totalCounts.error += counts.error;
16706
- totalCounts.warning += counts.warning;
16707
- totalCounts.info += counts.info;
16708
- totalCounts.total += counts.total;
16709
- }
16710
- lines.push(formatSummary(totalCounts, color));
16711
- return lines.join("\n");
16712
- }
16713
-
16714
- // src/parseWarnings.ts
16715
- function formatParseWarnings(warnings, source) {
16716
- return warnings.map((warning) => `Warning: ${source}: ${warning.message}`);
16717
- }
16718
-
16719
16309
  // ../rules-default/src/common/network-rules.ts
16720
16310
  var isContiguousMask = (mask) => mask !== null && ((~mask >>> 0) + 1 & ~mask >>> 0) === 0;
16721
16311
  var NoMulticastBroadcastIp = {
@@ -17426,7 +17016,7 @@ var VtyNoTelnet = {
17426
17016
  ruleId: "NET-MGMT-001",
17427
17017
  nodeId: node.id,
17428
17018
  level: "error",
17429
- loc: node.loc
17019
+ loc: transportCmd.loc
17430
17020
  };
17431
17021
  }
17432
17022
  if (!includesIgnoreCase(transportText, "ssh")) {
@@ -17436,7 +17026,7 @@ var VtyNoTelnet = {
17436
17026
  ruleId: "NET-MGMT-001",
17437
17027
  nodeId: node.id,
17438
17028
  level: "error",
17439
- loc: node.loc
17029
+ loc: transportCmd.loc
17440
17030
  };
17441
17031
  }
17442
17032
  return { passed: true, message: "VTY configured for SSH only.", ruleId: "NET-MGMT-001", nodeId: node.id, level: "info", loc: node.loc };
@@ -17475,33 +17065,32 @@ var VtyExecTimeout = {
17475
17065
  }
17476
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 };
17477
17067
  }
17478
- const timeoutMatch = timeoutCmd.id.match(/exec-timeout\s+(\d+)/i);
17479
- const minutesStr = timeoutMatch?.[1];
17480
- if (!minutesStr) {
17481
- return { passed: true, message: "Exec-timeout configured.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
17482
- }
17483
- const minutes = parseInteger(minutesStr);
17068
+ const minutes = parseInteger(timeoutCmd.params[1] ?? "");
17484
17069
  if (minutes === null) {
17485
17070
  return { passed: true, message: "Exec-timeout configured.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
17486
17071
  }
17487
- if (minutes === 0) {
17072
+ const seconds = parseInteger(timeoutCmd.params[2] ?? "0") ?? 0;
17073
+ const total = minutes * 60 + seconds;
17074
+ if (total === 0) {
17488
17075
  return {
17489
17076
  passed: false,
17490
17077
  message: "VTY exec-timeout is disabled (0). Configure a timeout (max 15 minutes).",
17491
17078
  ruleId: "NET-MGMT-003",
17492
- nodeId: node.id,
17079
+ nodeId: timeoutCmd.id,
17493
17080
  level: "warning",
17494
- loc: node.loc
17081
+ loc: timeoutCmd.loc
17495
17082
  };
17496
17083
  }
17497
- if (minutes > 15) {
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");
17498
17087
  return {
17499
17088
  passed: false,
17500
- message: `VTY exec-timeout of ${minutes} minutes exceeds maximum 15 minutes.`,
17089
+ message: `VTY exec-timeout of ${value} exceeds maximum 15 minutes.`,
17501
17090
  ruleId: "NET-MGMT-003",
17502
- nodeId: node.id,
17091
+ nodeId: timeoutCmd.id,
17503
17092
  level: "warning",
17504
- loc: node.loc
17093
+ loc: timeoutCmd.loc
17505
17094
  };
17506
17095
  }
17507
17096
  return { passed: true, message: "Exec-timeout configured within limits.", ruleId: "NET-MGMT-003", nodeId: node.id, level: "info", loc: node.loc };
@@ -17828,6 +17417,45 @@ var SnmpNoRwAccess = {
17828
17417
  return { passed: true, message: "SNMP is read-only.", ruleId: "NET-SNMP-004", nodeId: node.id, level: "info", loc: node.loc };
17829
17418
  }
17830
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.';
17831
17459
  var CdpDisabledOnExternal = {
17832
17460
  id: "NET-SVC-005",
17833
17461
  selector: "interface",
@@ -17846,10 +17474,13 @@ var CdpDisabledOnExternal = {
17846
17474
  { type: "general", label: "cdp" }
17847
17475
  ]
17848
17476
  },
17849
- check: (node) => {
17477
+ check: (node, context) => {
17850
17478
  if (!isPhysicalPort(node.id) || isShutdown3(node)) {
17851
17479
  return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-005", nodeId: node.id, level: "info", loc: node.loc };
17852
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
+ }
17853
17484
  if (isPhoneOrAP(node)) {
17854
17485
  const desc = getChildCommand(node, "description");
17855
17486
  const descText = desc?.rawText.toLowerCase() || "";
@@ -17912,10 +17543,17 @@ var LldpDisabledOnExternal = {
17912
17543
  { type: "general", label: "lldp" }
17913
17544
  ]
17914
17545
  },
17915
- check: (node) => {
17546
+ check: (node, context) => {
17916
17547
  if (!isPhysicalPort(node.id) || isShutdown3(node)) {
17917
17548
  return { passed: true, message: "Not applicable.", ruleId: "NET-SVC-006", nodeId: node.id, level: "info", loc: node.loc };
17918
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 : "";
17919
17557
  if (isPhoneOrAP(node)) {
17920
17558
  const desc = getChildCommand(node, "description");
17921
17559
  const descText = desc?.rawText.toLowerCase() || "";
@@ -17925,10 +17563,10 @@ var LldpDisabledOnExternal = {
17925
17563
  if (!noLldpTx || !noLldpRx) {
17926
17564
  return {
17927
17565
  passed: false,
17928
- 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}`,
17929
17567
  ruleId: "NET-SVC-006",
17930
17568
  nodeId: node.id,
17931
- level: "warning",
17569
+ level,
17932
17570
  loc: node.loc
17933
17571
  };
17934
17572
  }
@@ -17941,10 +17579,10 @@ var LldpDisabledOnExternal = {
17941
17579
  if (!noLldpTx || !noLldpRx) {
17942
17580
  return {
17943
17581
  passed: false,
17944
- 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}`,
17945
17583
  ruleId: "NET-SVC-006",
17946
17584
  nodeId: node.id,
17947
- level: "warning",
17585
+ level,
17948
17586
  loc: node.loc
17949
17587
  };
17950
17588
  }
@@ -17955,10 +17593,10 @@ var LldpDisabledOnExternal = {
17955
17593
  if (!noLldpTx || !noLldpRx) {
17956
17594
  return {
17957
17595
  passed: false,
17958
- 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}`,
17959
17597
  ruleId: "NET-SVC-006",
17960
17598
  nodeId: node.id,
17961
- level: "warning",
17599
+ level,
17962
17600
  loc: node.loc
17963
17601
  };
17964
17602
  }
@@ -18151,6 +17789,21 @@ var evaluatePasswordStorage = ({ ruleId, node, label, fix, args }) => {
18151
17789
  loc: node.loc
18152
17790
  };
18153
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
+ };
18154
17807
  var CiscoNoPlaintextPasswords = {
18155
17808
  id: "NET-SEC-001",
18156
17809
  selector: "password",
@@ -18185,6 +17838,12 @@ var CiscoNoPlaintextPasswords = {
18185
17838
  return notApplicable2;
18186
17839
  }
18187
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
+ }
18188
17847
  const onLine = ast ? isLineConfigPassword(ast, node) : false;
18189
17848
  return evaluatePasswordStorage({
18190
17849
  ruleId: "NET-SEC-001",
@@ -18333,6 +17992,39 @@ var CiscoSshVersion2 = {
18333
17992
  return passResult("CISCO-MGMT-004", node, "SSH version 2 is configured.");
18334
17993
  }
18335
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
+ };
18336
18028
  var BANNER_DISCLOSURE = /\b(cisco|ios|ios-xe)\b|\bversion\s+\d+\.\d+/i;
18337
18029
  var CiscoLoginBannerNoDisclosure = {
18338
18030
  id: "CISCO-MGMT-008",
@@ -18475,13 +18167,13 @@ var CiscoOspfInterfaceAuthentication = {
18475
18167
  var CiscoBgpNeighborAuthentication = {
18476
18168
  id: "CISCO-BGP-002",
18477
18169
  selector: "router bgp",
18478
- vendor: "cisco-ios",
18170
+ vendor: ["cisco-ios", "cisco-nxos"],
18479
18171
  category: "Routing",
18480
18172
  metadata: {
18481
18173
  level: "warning",
18482
18174
  obu: "Security",
18483
18175
  owner: "SecOps",
18484
- 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.',
18485
18177
  security: {
18486
18178
  cwe: ["CWE-306"],
18487
18179
  cvssScore: 8.1
@@ -18498,14 +18190,16 @@ var CiscoBgpNeighborAuthentication = {
18498
18190
  return passResult("CISCO-BGP-002", node, "No BGP neighbors configured.");
18499
18191
  }
18500
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;
18501
18195
  const { level, message } = bgpAuthFinding(
18502
18196
  bgpSessionKind(node, p),
18503
18197
  p.id,
18504
18198
  p.remoteAs,
18505
- `TCP-AO ("neighbor ${p.id} ao <key-chain>") or TCP MD5 ("neighbor ${p.id} password <key>")`,
18506
- "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"
18507
18201
  );
18508
- return offenderResult("CISCO-BGP-002", peerLine(p, node), message, level);
18202
+ return offenderResult("CISCO-BGP-002", line, message, level);
18509
18203
  });
18510
18204
  if (findings.length > 0) return findings;
18511
18205
  return passResult("CISCO-BGP-002", node, "All BGP neighbors have authentication.");
@@ -18589,9 +18283,10 @@ var CiscoBgpLogNeighborChanges = {
18589
18283
  },
18590
18284
  check: (node) => {
18591
18285
  if (!hasBgpLogNeighborChanges2(node)) {
18286
+ const explicitOff = hasChildCommand(node, "no bgp log-neighbor-changes");
18592
18287
  return {
18593
18288
  passed: false,
18594
- 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.',
18595
18290
  ruleId: "CISCO-BGP-005",
18596
18291
  nodeId: node.id,
18597
18292
  level: "info",
@@ -18770,6 +18465,88 @@ var CiscoNoDirectedBroadcast = {
18770
18465
  return passResult("CISCO-DATA-005", node, "Directed broadcast is disabled (default).");
18771
18466
  }
18772
18467
  };
18468
+ var CiscoSnmpNoDefaultCommunity = {
18469
+ id: "CISCO-SNMP-001",
18470
+ selector: "snmp-server community",
18471
+ vendor: "cisco-ios",
18472
+ category: "Protocol-Security",
18473
+ metadata: {
18474
+ level: "error",
18475
+ obu: "Security",
18476
+ owner: "SecOps",
18477
+ remediation: "Use complex, non-default SNMP community strings. Preferably migrate to SNMPv3.",
18478
+ security: {
18479
+ cwe: ["CWE-798"],
18480
+ cvssScore: 9.8
18481
+ },
18482
+ tags: [
18483
+ { type: "general", label: "snmp" },
18484
+ { type: "general", label: "default-credentials" }
18485
+ ]
18486
+ },
18487
+ check: (node) => {
18488
+ const community = node.params[2]?.toLowerCase();
18489
+ if (community && community !== "public" && community !== "private" && isDefaultSnmpCommunity(community)) {
18490
+ return {
18491
+ passed: false,
18492
+ message: `Default SNMP community string "${community}" detected. Use a complex string or migrate to SNMPv3.`,
18493
+ ruleId: "CISCO-SNMP-001",
18494
+ nodeId: node.id,
18495
+ level: "error",
18496
+ loc: node.loc
18497
+ };
18498
+ }
18499
+ return passResult("CISCO-SNMP-001", node, "SNMP community is not a default name.");
18500
+ }
18501
+ };
18502
+ var CiscoHsrpMd5Authentication = {
18503
+ id: "CISCO-CTRL-003",
18504
+ selector: "interface",
18505
+ vendor: "cisco-ios",
18506
+ category: "High-Availability",
18507
+ metadata: {
18508
+ level: "warning",
18509
+ obu: "Network Engineering",
18510
+ owner: "NetOps",
18511
+ remediation: 'Configure "standby <group> authentication md5 key-string <key>" for HSRP.',
18512
+ security: {
18513
+ cwe: ["CWE-306"]
18514
+ },
18515
+ tags: [
18516
+ { type: "general", label: "fhrp" },
18517
+ { type: "general", label: "authentication" }
18518
+ ]
18519
+ },
18520
+ check: (node) => {
18521
+ const hasHsrp = node.children.some((child) => /^standby(?:\s+\d+)?\s+ip(?:\s|$)/i.test(child.id.trim()));
18522
+ if (!hasHsrp) {
18523
+ return passResult("CISCO-CTRL-003", node, "No HSRP configured.");
18524
+ }
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) {
18532
+ return passResult("CISCO-CTRL-003", node, "No HSRP authentication (reported by NET-FHRP-002).");
18533
+ }
18534
+ const findings = [];
18535
+ for (const [group, { line, md5 }] of authByGroup) {
18536
+ if (md5) continue;
18537
+ findings.push({
18538
+ passed: false,
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>".`,
18540
+ ruleId: "CISCO-CTRL-003",
18541
+ nodeId: line.id,
18542
+ level: "warning",
18543
+ loc: line.loc
18544
+ });
18545
+ }
18546
+ if (findings.length > 0) return findings;
18547
+ return passResult("CISCO-CTRL-003", node, "HSRP has MD5 authentication configured.");
18548
+ }
18549
+ };
18773
18550
  var firstStatementCache = /* @__PURE__ */ new WeakMap();
18774
18551
  var firstStatementOf2 = (ast) => {
18775
18552
  const cached = firstStatementCache.get(ast);
@@ -19286,6 +19063,7 @@ var allCiscoRules = [
19286
19063
  CiscoNoPlaintextUsernamePasswords,
19287
19064
  // Ported from the former commercial set (decision 0001 S3a)
19288
19065
  CiscoSshVersion2,
19066
+ NxosTelnetFeature,
19289
19067
  CiscoLoginBannerNoDisclosure,
19290
19068
  CiscoSnmpv3AuthPriv,
19291
19069
  CiscoNoDangerousServices,
@@ -19299,6 +19077,9 @@ var allCiscoRules = [
19299
19077
  CiscoWanNoIpUnreachables,
19300
19078
  CiscoWanNoProxyArp,
19301
19079
  CiscoNoDirectedBroadcast,
19080
+ // Paid-only rules opened (gecko#60)
19081
+ CiscoSnmpNoDefaultCommunity,
19082
+ CiscoHsrpMd5Authentication,
19302
19083
  // Reference rules on the symbol table (gecko#59, experimental)
19303
19084
  CiscoUndefinedFilterAcl,
19304
19085
  CiscoUndefinedAclReference,
@@ -19310,6 +19091,12 @@ var allCiscoRules = [
19310
19091
  NxosSecretStorage
19311
19092
  ];
19312
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
+
19313
19100
  // ../rules-default/src/juniper/junos-rules.ts
19314
19101
  var offenderResult2 = (ruleId, offender, message, level) => ({
19315
19102
  passed: false,
@@ -19909,10 +19696,6 @@ var failResult = (ruleId, node, message, level) => ({
19909
19696
  level,
19910
19697
  loc: node.loc
19911
19698
  });
19912
- var isTopLevel = (node, context) => {
19913
- const ast = context.getAst?.();
19914
- return !ast || ast.includes(node);
19915
- };
19916
19699
  var topLevelStanza = (context, name) => context.getAst?.()?.find((n) => equalsIgnoreCase(n.id.trim(), name));
19917
19700
  var isPublicAsn = (asn) => {
19918
19701
  const dot = asn.match(/^(\d+)\.(\d+)$/);
@@ -19931,7 +19714,7 @@ var bgpPeerAs = (peer) => {
19931
19714
  return void 0;
19932
19715
  };
19933
19716
  var activeBgpPeers = (bgp) => getBgpPeers2(bgp).filter((p) => p.neighborNode || hasChildCommand(p.groupNode, "allow"));
19934
- var groupPeerFindings = (ruleId, peers, failing, what) => {
19717
+ var groupPeerFindings = (ruleId, peers, failing, what, level = "warning") => {
19935
19718
  const findings = [];
19936
19719
  const groups = [...new Set(failing.map((p) => p.group))];
19937
19720
  for (const group of groups) {
@@ -19939,12 +19722,12 @@ var groupPeerFindings = (ruleId, peers, failing, what) => {
19939
19722
  const bad = failing.filter((p) => p.group === group);
19940
19723
  const groupNode = bad[0]?.groupNode;
19941
19724
  if (bad.length === all.length && groupNode) {
19942
- findings.push(offenderResult2(ruleId, groupNode, `eBGP group ${group} has ${what}.`, "warning"));
19725
+ findings.push(offenderResult2(ruleId, groupNode, `eBGP group ${group} has ${what}.`, level));
19943
19726
  continue;
19944
19727
  }
19945
19728
  for (const peer of bad) {
19946
19729
  findings.push(
19947
- offenderResult2(ruleId, peer.neighborNode ?? peer.groupNode, `eBGP group ${group}: neighbor ${peer.neighbor ?? "(dynamic)"} has ${what}.`, "warning")
19730
+ offenderResult2(ruleId, peer.neighborNode ?? peer.groupNode, `eBGP group ${group}: neighbor ${peer.neighbor ?? "(dynamic)"} has ${what}.`, level)
19948
19731
  );
19949
19732
  }
19950
19733
  }
@@ -20618,6 +20401,7 @@ var JunosProtectRe = {
20618
20401
  return passResult2("JUN-RE-001", node, "Protect-RE filter is applied to loopback interface.");
20619
20402
  }
20620
20403
  };
20404
+ var UNTRUSTED_ZONE = /untrust|external|internet/i;
20621
20405
  var JunosZoneScreens = {
20622
20406
  id: "JUN-ZONE-003",
20623
20407
  selector: "security",
@@ -20641,7 +20425,7 @@ var JunosZoneScreens = {
20641
20425
  const findings = [];
20642
20426
  for (const zone of findStanzas3(zones, /^security-zone\s/i)) {
20643
20427
  const zoneName = zone.id.replace(/^security-zone\s+/i, "").trim();
20644
- const untrusted = /untrust|external|internet/i.test(zoneName);
20428
+ const untrusted = UNTRUSTED_ZONE.test(zoneName);
20645
20429
  if (untrusted && !hasZoneScreen(zone)) {
20646
20430
  findings.push(offenderResult2("JUN-ZONE-003", zone, `Zone "${zoneName}" should have a security screen configured.`, "warning"));
20647
20431
  }
@@ -20650,6 +20434,83 @@ var JunosZoneScreens = {
20650
20434
  return passResult2("JUN-ZONE-003", node, "Security screens configured on appropriate zones.");
20651
20435
  }
20652
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
+ };
20653
20514
  var WEAK_PROPOSAL_SET = /^proposal-set\s+(basic|compatible|standard)\b/i;
20654
20515
  var JunosIkeDhGroup = {
20655
20516
  id: "JUN-VPN-001",
@@ -20965,6 +20826,256 @@ var JunosSecretStorage = {
20965
20826
  return findings;
20966
20827
  })
20967
20828
  };
20829
+ var SRX_SECURITY_STATEMENT = /^(zones|policies|screen|nat|flow|address-book|utm|alg|idp|application-firewall|log)\b/i;
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()));
20835
+ var JunosOspfInterfaceAuth = {
20836
+ id: "JUN-CTRL-001",
20837
+ selector: "protocols",
20838
+ vendor: "juniper-junos",
20839
+ category: "Routing",
20840
+ metadata: {
20841
+ level: "warning",
20842
+ obu: "Security",
20843
+ owner: "NetOps",
20844
+ remediation: "Configure OSPF authentication (MD5) on every non-passive OSPF interface in the area.",
20845
+ security: {
20846
+ cwe: ["CWE-287"]
20847
+ },
20848
+ tags: generalTags("routing", "authentication", "ospf")
20849
+ },
20850
+ check: (node, context) => {
20851
+ if (!isTopLevel(node, context)) {
20852
+ return passResult2("JUN-CTRL-001", node, "Not the top-level protocols stanza.");
20853
+ }
20854
+ const ospf = findStanza4(node, "ospf");
20855
+ if (!ospf) {
20856
+ return passResult2("JUN-CTRL-001", node, "OSPF not configured.");
20857
+ }
20858
+ const findings = [];
20859
+ for (const area of findStanzas3(ospf, /^area\s/i)) {
20860
+ const interfaces = findStanzas3(area, /^interface\s/i);
20861
+ if (!interfaces.some((iface) => hasOspfInterfaceAuth(iface))) continue;
20862
+ for (const iface of interfaces) {
20863
+ const ifaceName = iface.id.replace(/^interface\s+/i, "").trim();
20864
+ if (isLoopback3(ifaceName) || hasOspfInterfaceAuth(iface) || hasChildCommand(iface, "passive") || isDisabled(iface)) continue;
20865
+ findings.push(
20866
+ offenderResult2(
20867
+ "JUN-CTRL-001",
20868
+ iface,
20869
+ `OSPF interface ${ifaceName} in ${area.id.trim()} has no authentication while other interfaces in the area do.`,
20870
+ "warning"
20871
+ )
20872
+ );
20873
+ }
20874
+ }
20875
+ if (findings.length > 0) return findings;
20876
+ return passResult2("JUN-CTRL-001", node, "OSPF interfaces are authenticated.");
20877
+ }
20878
+ };
20879
+ var JunosIcmpRateLimit = {
20880
+ id: "JUN-CTRL-004",
20881
+ selector: "system",
20882
+ vendor: "juniper-junos",
20883
+ category: "Protocol-Security",
20884
+ metadata: {
20885
+ level: "info",
20886
+ obu: "Security",
20887
+ owner: "SecOps",
20888
+ remediation: 'Configure ICMP rate limiting under "system internet-options" (icmpv4-rate-limit, icmpv6-rate-limit).',
20889
+ security: {
20890
+ cwe: ["CWE-770"]
20891
+ },
20892
+ tags: generalTags("ddos", "rate-limiting", "icmp")
20893
+ },
20894
+ check: (node, context) => {
20895
+ if (!isTopLevel(node, context)) {
20896
+ return passResult2("JUN-CTRL-004", node, "Not the top-level system stanza.");
20897
+ }
20898
+ const internetOptions = findStanza4(node, "internet-options");
20899
+ if (!internetOptions) {
20900
+ return failResult(
20901
+ "JUN-CTRL-004",
20902
+ node,
20903
+ "System internet-options not configured. Configure ICMP rate limiting.",
20904
+ "info"
20905
+ );
20906
+ }
20907
+ if (!hasChildCommand(internetOptions, "icmpv4-rate-limit") && !hasChildCommand(internetOptions, "icmpv6-rate-limit")) {
20908
+ return failResult(
20909
+ "JUN-CTRL-004",
20910
+ internetOptions,
20911
+ "ICMP rate limiting not configured in internet-options.",
20912
+ "info"
20913
+ );
20914
+ }
20915
+ return passResult2("JUN-CTRL-004", node, "ICMP rate limiting is configured.");
20916
+ }
20917
+ };
20918
+ var isMultihopPeer = (peer) => peer.levels.some((level) => level.children.some((child) => /^multihop\b/i.test(child.id.trim())));
20919
+ var hasGtsmTtl = (peer) => peer.levels.some(
20920
+ (level) => level.children.some((child) => /^ttl\s+255\s*;?$|^apply-macro\s+ttl-security\b/i.test(child.id.trim()))
20921
+ );
20922
+ var JunosBgpTtlSecurity = {
20923
+ id: "JUN-BGP-004",
20924
+ selector: "protocols",
20925
+ vendor: "juniper-junos",
20926
+ category: "Routing",
20927
+ metadata: {
20928
+ level: "warning",
20929
+ obu: "Security",
20930
+ owner: "NetOps",
20931
+ remediation: 'Set "ttl 255" on the eBGP group and apply an inbound firewall filter that discards BGP packets with a TTL below 255 (ttl-except 255).',
20932
+ security: {
20933
+ cwe: ["CWE-346"]
20934
+ },
20935
+ tags: generalTags("bgp", "spoofing", "routing")
20936
+ },
20937
+ check: (node, context) => {
20938
+ if (!isTopLevel(node, context)) {
20939
+ return passResult2("JUN-BGP-004", node, "Not the top-level protocols stanza.");
20940
+ }
20941
+ const bgp = findStanza4(node, "bgp");
20942
+ if (!bgp) {
20943
+ return passResult2("JUN-BGP-004", node, "BGP not configured.");
20944
+ }
20945
+ const external = activeBgpPeers(bgp).filter((p) => p.external);
20946
+ const failing = external.filter((peer) => !hasGtsmTtl(peer));
20947
+ const multihop = failing.filter((peer) => isMultihopPeer(peer));
20948
+ const singleHop = failing.filter((peer) => !isMultihopPeer(peer));
20949
+ const findings = [
20950
+ ...groupPeerFindings("JUN-BGP-004", external, singleHop, "no TTL security (ttl 255) configured"),
20951
+ ...groupPeerFindings(
20952
+ "JUN-BGP-004",
20953
+ external,
20954
+ multihop,
20955
+ "multihop: TTL security (GTSM) does not apply to multihop sessions; restrict BGP with a TTL-aware firewall filter or suppress",
20956
+ "info"
20957
+ )
20958
+ ];
20959
+ if (findings.length > 0) return findings;
20960
+ return passResult2("JUN-BGP-004", node, "eBGP groups have TTL security configured.");
20961
+ }
20962
+ };
20963
+ var JunosSecurityZonesRequired = {
20964
+ id: "JUN-ZONE-001",
20965
+ selector: "security",
20966
+ vendor: "juniper-junos",
20967
+ category: "Network-Segmentation",
20968
+ metadata: {
20969
+ level: "warning",
20970
+ obu: "Security",
20971
+ owner: "SecOps",
20972
+ remediation: "Configure security zones for traffic segmentation on SRX devices.",
20973
+ tags: generalTags("segmentation", "zones")
20974
+ },
20975
+ check: (node, context) => {
20976
+ if (!isSrxSecurityStanza(node, context)) {
20977
+ return passResult2("JUN-ZONE-001", node, "Not an SRX security stanza.");
20978
+ }
20979
+ if (!hasSecurityZones(node)) {
20980
+ return failResult(
20981
+ "JUN-ZONE-001",
20982
+ node,
20983
+ "Security zones not configured. Configure zones for traffic segmentation.",
20984
+ "warning"
20985
+ );
20986
+ }
20987
+ return passResult2("JUN-ZONE-001", node, "Security zones are configured.");
20988
+ }
20989
+ };
20990
+ var JunosSecurityPoliciesRequired = {
20991
+ id: "JUN-ZONE-002",
20992
+ selector: "security",
20993
+ vendor: "juniper-junos",
20994
+ category: "Network-Segmentation",
20995
+ metadata: {
20996
+ level: "warning",
20997
+ obu: "Security",
20998
+ owner: "SecOps",
20999
+ remediation: "Configure security policies for inter-zone traffic control.",
21000
+ tags: generalTags("segmentation", "policies")
21001
+ },
21002
+ check: (node, context) => {
21003
+ if (!isSrxSecurityStanza(node, context)) {
21004
+ return passResult2("JUN-ZONE-002", node, "Not an SRX security stanza.");
21005
+ }
21006
+ if (!hasSecurityPolicies(node)) {
21007
+ return failResult(
21008
+ "JUN-ZONE-002",
21009
+ node,
21010
+ "Security policies not configured. Configure policies for inter-zone traffic.",
21011
+ "warning"
21012
+ );
21013
+ }
21014
+ return passResult2("JUN-ZONE-002", node, "Security policies are configured.");
21015
+ }
21016
+ };
21017
+ var JunosSyslogLocalFile = {
21018
+ id: "JUN-LOG-001",
21019
+ selector: "system",
21020
+ vendor: "juniper-junos",
21021
+ category: "Logging",
21022
+ metadata: {
21023
+ level: "warning",
21024
+ obu: "Security",
21025
+ owner: "SecOps",
21026
+ remediation: 'Configure at least one local syslog "file" in addition to the remote host.',
21027
+ security: {
21028
+ cwe: ["CWE-778"]
21029
+ },
21030
+ tags: generalTags("logging", "monitoring")
21031
+ },
21032
+ check: (node, context) => {
21033
+ if (!isTopLevel(node, context)) {
21034
+ return passResult2("JUN-LOG-001", node, "Not the top-level system stanza.");
21035
+ }
21036
+ const syslog = findStanza4(node, "syslog");
21037
+ if (!syslog) {
21038
+ return passResult2("JUN-LOG-001", node, "No syslog stanza (reported by JUN-SYS-003).");
21039
+ }
21040
+ const hasFile = findStanzas3(syslog, /^file\b/i).length > 0 || hasChildCommand(syslog, "file");
21041
+ if (!hasFile && hasRemoteSyslog(syslog)) {
21042
+ return failResult(
21043
+ "JUN-LOG-001",
21044
+ syslog,
21045
+ "No local syslog file configured; logs go only to the remote host.",
21046
+ "warning"
21047
+ );
21048
+ }
21049
+ return passResult2("JUN-LOG-001", node, "Syslog keeps a local file.");
21050
+ }
21051
+ };
21052
+ var JunosSecurityLogging = {
21053
+ id: "JUN-LOG-002",
21054
+ selector: "security",
21055
+ vendor: "juniper-junos",
21056
+ category: "Logging",
21057
+ metadata: {
21058
+ level: "warning",
21059
+ obu: "Security",
21060
+ owner: "SecOps",
21061
+ remediation: 'Configure "security log mode stream" with a "stream" host. Event-mode security logs stay on the device unless forwarded.',
21062
+ tags: generalTags("logging", "monitoring")
21063
+ },
21064
+ check: (node, context) => {
21065
+ if (!isSrxSecurityStanza(node, context)) {
21066
+ return passResult2("JUN-LOG-002", node, "Not an SRX security stanza.");
21067
+ }
21068
+ if (!hasSecurityLogging(node)) {
21069
+ return failResult(
21070
+ "JUN-LOG-002",
21071
+ node,
21072
+ "No security log stanza: no security log stream to a log host is configured.",
21073
+ "warning"
21074
+ );
21075
+ }
21076
+ return passResult2("JUN-LOG-002", node, "Security logging is configured.");
21077
+ }
21078
+ };
20968
21079
  var allJuniperRules = [
20969
21080
  RootAuthRequired,
20970
21081
  SshServiceRequired,
@@ -20997,12 +21108,21 @@ var allJuniperRules = [
20997
21108
  JunosGracefulRestart,
20998
21109
  JunosProtectRe,
20999
21110
  JunosZoneScreens,
21111
+ JunosHostInboundAll,
21000
21112
  JunosIkeDhGroup,
21001
21113
  JunosIpsecEncryption,
21002
21114
  JunosIkeDpd,
21003
21115
  JunosFlowMonitoring,
21004
21116
  JunosNonstopRouting,
21005
- JunosSecretStorage
21117
+ JunosSecretStorage,
21118
+ // Paid-only rules opened (gecko#60)
21119
+ JunosOspfInterfaceAuth,
21120
+ JunosIcmpRateLimit,
21121
+ JunosBgpTtlSecurity,
21122
+ JunosSecurityZonesRequired,
21123
+ JunosSecurityPoliciesRequired,
21124
+ JunosSyslogLocalFile,
21125
+ JunosSecurityLogging
21006
21126
  ];
21007
21127
 
21008
21128
  // ../rules-default/src/aruba/ported-shared.ts
@@ -21040,11 +21160,19 @@ var AOSSWITCH_MARKERS = [
21040
21160
  /^(no )?web-management\b/,
21041
21161
  /^(no )?telnet-server$/
21042
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
+ ];
21043
21170
  var platformOf = (statements) => {
21044
21171
  for (const statement2 of statements) {
21045
21172
  const text = textOf2(statement2);
21046
21173
  if (AOSCX_MARKERS.some((m) => m.test(text))) return "aoscx";
21047
21174
  if (AOSSWITCH_MARKERS.some((m) => m.test(text))) return "aosswitch";
21175
+ if (WLC_MARKERS.some((m) => m.test(text))) return "wlc";
21048
21176
  if (/^vlan \d+$/.test(text) && statement2.children.some((c) => /^(no )?(un)?tagged /.test(textOf2(c)))) {
21049
21177
  return "aosswitch";
21050
21178
  }
@@ -21061,24 +21189,26 @@ var indexOf = (context) => {
21061
21189
  indexCache.set(ast, index);
21062
21190
  return index;
21063
21191
  };
21064
- var configWide = (platform, judge) => (node, context) => {
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) => {
21065
21195
  const index = indexOf(context);
21066
21196
  const anchor = index?.statements[0];
21067
- if (!index || anchor !== node || index.platform !== platform) return [];
21068
- return judge(index.statements, anchor);
21197
+ if (!index?.platform || anchor !== node || !platforms.includes(index.platform)) return [];
21198
+ return judge(index.platform, index.statements, anchor);
21069
21199
  };
21200
+ var configWide = (platform, judge) => configWideOn([platform], (_platform, statements, anchor) => judge(statements, anchor));
21070
21201
 
21071
21202
  // ../rules-default/src/aruba/common-rules.ts
21072
21203
  var SshEnabled = {
21073
21204
  id: "ARU-SEC-001",
21074
- selector: "ssh",
21075
- vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
21205
+ vendor: "aruba-aoscx",
21076
21206
  category: "Session-Management",
21077
21207
  metadata: {
21078
- level: "error",
21208
+ level: "warning",
21079
21209
  obu: "Security",
21080
21210
  owner: "SecOps",
21081
- remediation: "Enable SSH server for secure remote management. Disable telnet if enabled.",
21211
+ remediation: 'Enable the SSH server on the management VRF ("ssh server vrf mgmt") and disable Telnet if it is enabled.',
21082
21212
  security: {
21083
21213
  cwe: ["CWE-319"]
21084
21214
  },
@@ -21087,27 +21217,16 @@ var SshEnabled = {
21087
21217
  { type: "general", label: "encryption" }
21088
21218
  ]
21089
21219
  },
21090
- check: (node, context) => {
21091
- const nodeId = node.id.toLowerCase();
21092
- if (nodeId.includes("ssh server") || nodeId === "ip ssh" || nodeId.includes("ssh server-enabled")) {
21093
- return {
21094
- passed: true,
21095
- message: "SSH is enabled.",
21096
- ruleId: "ARU-SEC-001",
21097
- nodeId: node.id,
21098
- level: "info",
21099
- loc: node.loc
21100
- };
21101
- }
21102
- return {
21103
- passed: true,
21104
- message: "SSH configuration found.",
21105
- ruleId: "ARU-SEC-001",
21106
- nodeId: node.id,
21107
- level: "info",
21108
- loc: node.loc
21109
- };
21110
- }
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
+ })
21111
21230
  };
21112
21231
  var SnmpNotDefault = {
21113
21232
  id: "ARU-SEC-002",
@@ -21194,8 +21313,7 @@ var TelnetDisabled = {
21194
21313
  };
21195
21314
  var NtpConfigured = {
21196
21315
  id: "ARU-NTP-001",
21197
- selector: "ntp",
21198
- vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
21316
+ vendor: ["aruba-aoscx", "aruba-wlc"],
21199
21317
  category: "Time-Synchronization",
21200
21318
  metadata: {
21201
21319
  level: "warning",
@@ -21210,64 +21328,37 @@ var NtpConfigured = {
21210
21328
  { type: "general", label: "logging" }
21211
21329
  ]
21212
21330
  },
21213
- check: (node) => {
21214
- const nodeId = node.id.toLowerCase();
21215
- if (nodeId.includes("ntp server") || nodeId.includes("ntp enable")) {
21216
- return {
21217
- passed: true,
21218
- message: "NTP is configured.",
21219
- ruleId: "ARU-NTP-001",
21220
- nodeId: node.id,
21221
- level: "info",
21222
- loc: node.loc
21223
- };
21224
- }
21225
- return {
21226
- passed: true,
21227
- message: "NTP configuration found.",
21228
- ruleId: "ARU-NTP-001",
21229
- nodeId: node.id,
21230
- level: "info",
21231
- loc: node.loc
21232
- };
21233
- }
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
+ })
21234
21336
  };
21235
21337
  var SntpConfigured = {
21236
21338
  id: "ARU-NTP-002",
21237
- selector: "sntp",
21238
- vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
21339
+ vendor: "aruba-aosswitch",
21239
21340
  category: "Time-Synchronization",
21240
21341
  metadata: {
21241
21342
  level: "warning",
21242
21343
  obu: "Network Engineering",
21243
21344
  owner: "NetOps",
21244
- remediation: "Configure SNTP server for time synchronization."
21345
+ remediation: 'Add "timesync sntp" and "sntp unicast" so the configured SNTP servers are used.'
21245
21346
  },
21246
- check: (node) => {
21247
- const nodeId = node.id.toLowerCase();
21248
- if (nodeId.includes("sntp server") || nodeId.includes("sntp unicast")) {
21249
- return {
21250
- passed: true,
21251
- message: "SNTP is configured.",
21252
- ruleId: "ARU-NTP-002",
21253
- nodeId: maskSecretLine(node),
21254
- level: "info",
21255
- loc: node.loc
21256
- };
21257
- }
21258
- return {
21259
- passed: true,
21260
- message: "SNTP configuration found.",
21261
- ruleId: "ARU-NTP-002",
21262
- nodeId: maskSecretLine(node),
21263
- level: "info",
21264
- loc: node.loc
21265
- };
21266
- }
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
+ })
21267
21359
  };
21268
21360
  var LoggingConfigured = {
21269
21361
  id: "ARU-LOG-001",
21270
- selector: "logging",
21271
21362
  vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
21272
21363
  category: "Logging",
21273
21364
  metadata: {
@@ -21283,31 +21374,20 @@ var LoggingConfigured = {
21283
21374
  { type: "general", label: "audit" }
21284
21375
  ]
21285
21376
  },
21286
- check: (node) => {
21287
- const nodeId = node.id.toLowerCase();
21288
- if (nodeId.match(/logging\s+\d+\.\d+\.\d+\.\d+/) || nodeId.includes("logging host") || nodeId.includes("logging server")) {
21289
- return {
21290
- passed: true,
21291
- message: "Logging server is configured.",
21292
- ruleId: "ARU-LOG-001",
21293
- nodeId: node.id,
21294
- level: "info",
21295
- loc: node.loc
21296
- };
21297
- }
21298
- return {
21299
- passed: true,
21300
- message: "Logging configuration found.",
21301
- ruleId: "ARU-LOG-001",
21302
- nodeId: node.id,
21303
- level: "info",
21304
- loc: node.loc
21305
- };
21306
- }
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
+ })
21307
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");
21387
+ };
21388
+ var isWlcManagementServerGroup = (node) => textOf2(node) === "aaa authentication mgmt" && node.children.some((c) => textOf2(c).startsWith("server-group "));
21308
21389
  var AaaConfigured = {
21309
21390
  id: "ARU-AAA-001",
21310
- selector: "aaa",
21311
21391
  vendor: ["aruba-aoscx", "aruba-aosswitch", "aruba-wlc"],
21312
21392
  category: "Authentication",
21313
21393
  metadata: {
@@ -21323,27 +21403,16 @@ var AaaConfigured = {
21323
21403
  { type: "general", label: "aaa" }
21324
21404
  ]
21325
21405
  },
21326
- check: (node) => {
21327
- const nodeId = node.id.toLowerCase();
21328
- if (nodeId.includes("aaa authentication") || nodeId.includes("aaa group server") || nodeId.includes("aaa profile")) {
21329
- return {
21330
- passed: true,
21331
- message: "AAA authentication is configured.",
21332
- ruleId: "ARU-AAA-001",
21333
- nodeId: maskSecretLine(node),
21334
- level: "info",
21335
- loc: node.loc
21336
- };
21337
- }
21338
- return {
21339
- passed: true,
21340
- message: "AAA configuration found.",
21341
- ruleId: "ARU-AAA-001",
21342
- nodeId: maskSecretLine(node),
21343
- level: "info",
21344
- loc: node.loc
21345
- };
21346
- }
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
+ })
21347
21416
  };
21348
21417
  var serverKeyMissing = (node, context, kind) => {
21349
21418
  const words = wordsOf(node);
@@ -21440,11 +21509,6 @@ var TacacsKeyConfigured = {
21440
21509
  };
21441
21510
  }
21442
21511
  };
21443
- var isRemoteAuthentication = (node) => {
21444
- const words = wordsOf(node);
21445
- if (words[0] !== "aaa" || words[1] !== "authentication") return false;
21446
- return words[2] === "login" ? words.includes("group") : words.slice(3).some((w) => w === "tacacs" || w === "radius");
21447
- };
21448
21512
  var isRemoteAccounting = (node) => {
21449
21513
  const words = wordsOf(node);
21450
21514
  if (words[0] !== "aaa" || words[1] !== "accounting") return false;
@@ -22856,28 +22920,29 @@ var AosSwitchOperatorPassword = {
22856
22920
  };
22857
22921
  var AosSwitchSshEnabled = {
22858
22922
  id: "AOSSW-SEC-003",
22859
- selector: "ip ssh",
22860
22923
  vendor: "aruba-aosswitch",
22861
22924
  category: "Session-Management",
22862
22925
  metadata: {
22863
22926
  level: "error",
22864
22927
  obu: "Security",
22865
22928
  owner: "SecOps",
22866
- remediation: 'Enable SSH with "ip ssh" command.',
22929
+ remediation: 'Remove "no ip ssh" (or enter "ip ssh") so the SSH server runs, and disable Telnet ("no telnet-server").',
22867
22930
  security: {
22868
22931
  cwe: ["CWE-319"]
22869
22932
  }
22870
22933
  },
22871
- check: (node) => {
22872
- return {
22873
- passed: true,
22874
- message: "SSH is enabled.",
22875
- ruleId: "AOSSW-SEC-003",
22876
- nodeId: node.id,
22877
- level: "info",
22878
- loc: node.loc
22879
- };
22880
- }
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
+ })
22881
22946
  };
22882
22947
  var AosSwitchSpanningTree = {
22883
22948
  id: "AOSSW-STP-001",
@@ -23030,38 +23095,33 @@ var AosSwitchConsoleTimeout = {
23030
23095
  };
23031
23096
  }
23032
23097
  };
23098
+ var SNTP_LEARNED_MODE = /^sntp (dhcp|broadcast)$/;
23099
+ var TIMEP = /^ip timep (dhcp|manual \S+)/;
23033
23100
  var AosSwitchTimesync = {
23034
23101
  id: "AOSSW-TIME-001",
23035
- selector: "timesync",
23036
23102
  vendor: "aruba-aosswitch",
23037
23103
  category: "Time-Synchronization",
23038
23104
  metadata: {
23039
23105
  level: "warning",
23040
23106
  obu: "Network Engineering",
23041
23107
  owner: "NetOps",
23042
- remediation: "Configure time synchronization using SNTP."
23108
+ remediation: 'Configure a time server: "sntp server priority 1 <address>" with "timesync sntp" and "sntp unicast", or "ntp server <address>".'
23043
23109
  },
23044
- check: (node) => {
23045
- const nodeId = node.id;
23046
- if (includesIgnoreCase(nodeId, "sntp") || includesIgnoreCase(nodeId, "ntp")) {
23047
- return {
23048
- passed: true,
23049
- message: "Time synchronization is configured.",
23050
- ruleId: "AOSSW-TIME-001",
23051
- nodeId: node.id,
23052
- level: "info",
23053
- loc: node.loc
23054
- };
23055
- }
23056
- return {
23057
- passed: true,
23058
- message: "Timesync configuration found.",
23059
- ruleId: "AOSSW-TIME-001",
23060
- nodeId: node.id,
23061
- level: "info",
23062
- loc: node.loc
23063
- };
23064
- }
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
+ })
23065
23125
  };
23066
23126
  var HttpDisabled = {
23067
23127
  id: "ARU-HTTP-001",
@@ -23784,6 +23844,32 @@ var WlcWpa3Enterprise = {
23784
23844
  );
23785
23845
  }
23786
23846
  };
23847
+ var WlcWpa3SaePassphrase = {
23848
+ id: "ARU-WIFI-002",
23849
+ selector: "wlan ssid-profile",
23850
+ vendor: "aruba-wlc",
23851
+ category: "Wireless",
23852
+ metadata: {
23853
+ level: "warning",
23854
+ obu: "Security",
23855
+ owner: "SecOps",
23856
+ remediation: 'Set the SAE passphrase on the SSID profile with "wpa-passphrase <passphrase>". Choose a long, random passphrase; its strength cannot be checked from the configuration.',
23857
+ security: {
23858
+ cwe: ["CWE-521"]
23859
+ },
23860
+ tags: generalTags2("wireless-security", "wpa3", "password-policy")
23861
+ },
23862
+ check: (node) => {
23863
+ if (node.type !== "section") return [];
23864
+ if (!opmodesOf(node).some((m) => m.startsWith("wpa3") && m.includes("sae"))) return [];
23865
+ const name = profileNameOf(node);
23866
+ const hasPassphrase = node.children.some((c) => wordsOf(c)[0] === "wpa-passphrase" && c.params.length > 1);
23867
+ if (!hasPassphrase) {
23868
+ return failAt("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has no wpa-passphrase configured.`, "warning");
23869
+ }
23870
+ return passAt("ARU-WIFI-002", node, `WPA3-SAE SSID profile "${name}" has a passphrase configured.`);
23871
+ }
23872
+ };
23787
23873
  var WlcSsidMaxClients = {
23788
23874
  id: "ARUWLC-WLAN-004",
23789
23875
  selector: "wlan ssid-profile",
@@ -23828,6 +23914,7 @@ var allWlcRules = [
23828
23914
  WlcUserRoleFirewall,
23829
23915
  WlcSsidLimit,
23830
23916
  WlcWpa3Enterprise,
23917
+ WlcWpa3SaePassphrase,
23831
23918
  WlcSsidMaxClients
23832
23919
  ];
23833
23920
 
@@ -23877,7 +23964,7 @@ var valueOf = (node, name) => {
23877
23964
  const statement2 = childNamed(node, name);
23878
23965
  return statement2 ? valuesOf(statement2)[0] : void 0;
23879
23966
  };
23880
- var descendantsOf = (nodes) => {
23967
+ var descendantsOf2 = (nodes) => {
23881
23968
  const out = [];
23882
23969
  const visit = (list) => {
23883
23970
  for (const child of list) {
@@ -24400,7 +24487,7 @@ var isSecurityProfilesBlock = (ast, node) => {
24400
24487
  return !parent || !NON_SECURITY_PROFILE_PARENTS.has(keywordOf(parent));
24401
24488
  };
24402
24489
  var namesProfile = (node) => node !== void 0 && (node.children.length > 0 || valuesOf(node).length > 0);
24403
- var securityProfileAvailable = (ast, type) => descendantsOf(ast).some((n) => {
24490
+ var securityProfileAvailable = (ast, type) => descendantsOf2(ast).some((n) => {
24404
24491
  const keyword = keywordOf(n);
24405
24492
  if (keyword === "profiles" && n.children.length > 0 && isSecurityProfilesBlock(ast, n)) {
24406
24493
  return namesProfile(childNamed(n, type));
@@ -24815,6 +24902,50 @@ var InterfaceManagementSecure = {
24815
24902
  return passResult3("PAN-MGMT-003", node, "Interface management profiles use secure protocols only.");
24816
24903
  }
24817
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
+ };
24818
24949
  var WEAK_TLS_VERSIONS = /* @__PURE__ */ new Set(["sslv3", "tls1-0", "tls1-1"]);
24819
24950
  var DecryptionTlsMinVersion = {
24820
24951
  id: "PAN-DEC-001",
@@ -24887,7 +25018,7 @@ var DecryptionRuleDescription = {
24887
25018
  var nameOf = (node) => keywordOf(node);
24888
25019
  var usedProfileNames = (ast, refKeyword, implicitDefault) => {
24889
25020
  const used = /* @__PURE__ */ new Set();
24890
- for (const node of descendantsOf(ast)) {
25021
+ for (const node of descendantsOf2(ast)) {
24891
25022
  if (node.children.length === 0 && keywordOf(node) === refKeyword) {
24892
25023
  const name = valuesOf(node)[0];
24893
25024
  if (name) used.add(name);
@@ -25217,10 +25348,10 @@ var LogForwardingRequired = {
25217
25348
  remediation: "Configure log forwarding to syslog server, Panorama, or SIEM for centralized logging."
25218
25349
  },
25219
25350
  check: (node, context) => {
25220
- const logSettings = descendantsOf(context.getAst?.() ?? [node]).filter(
25351
+ const logSettings = descendantsOf2(context.getAst?.() ?? [node]).filter(
25221
25352
  (n) => n.children.length > 0 && keywordOf(n) === "log-settings"
25222
25353
  );
25223
- if (logSettings.some((settings) => descendantsOf(settings.children).some(forwardsLogs))) {
25354
+ if (logSettings.some((settings) => descendantsOf2(settings.children).some(forwardsLogs))) {
25224
25355
  return passResult3("PAN-LOG-001", node, "Log forwarding is configured.");
25225
25356
  }
25226
25357
  return {
@@ -25339,6 +25470,7 @@ var allPaloAltoRules = [
25339
25470
  PasswordComplexityRequired,
25340
25471
  SnmpSecurityRequired,
25341
25472
  InterfaceManagementSecure,
25473
+ PanMgmtServiceCleartext,
25342
25474
  DecryptionTlsMinVersion,
25343
25475
  DecryptionRuleDescription,
25344
25476
  IkeCryptoStrong,
@@ -25648,6 +25780,10 @@ var VxlanVniMappings = {
25648
25780
  };
25649
25781
  }
25650
25782
  };
25783
+ var eapiPlainHttpLine = (node) => {
25784
+ if (node.children.some((child) => /^no\s+protocol\s+http$/i.test(child.id.trim()))) return void 0;
25785
+ return node.children.find((child) => /^protocol\s+http(?:\s+port\s+\d+)?$/i.test(child.id.trim()));
25786
+ };
25651
25787
  var ManagementApiHttps = {
25652
25788
  id: "ARI-API-001",
25653
25789
  selector: "management api",
@@ -25679,9 +25815,7 @@ var ManagementApiHttps = {
25679
25815
  loc: node.loc
25680
25816
  };
25681
25817
  }
25682
- const hasHttp = node.children.some(
25683
- (child) => /protocol\s+http(?!s)/i.test(child.id)
25684
- );
25818
+ const hasHttp = eapiPlainHttpLine(node) !== void 0;
25685
25819
  const hasHttps = hasHttpsTransport(node);
25686
25820
  if (hasHttp && !hasHttps) {
25687
25821
  return {
@@ -27362,6 +27496,36 @@ var EosSecretStorage = {
27362
27496
  return findings;
27363
27497
  })
27364
27498
  };
27499
+ var EosEapiHttpWithHttps = {
27500
+ id: "ARISTA-MGMT-014",
27501
+ selector: "management api http-commands",
27502
+ vendor: "arista-eos",
27503
+ category: "Authentication",
27504
+ metadata: {
27505
+ level: "error",
27506
+ obu: "Security",
27507
+ owner: "SecOps",
27508
+ remediation: "Configure eAPI with HTTPS only: protocol https / no protocol http",
27509
+ security: {
27510
+ cwe: ["CWE-319"],
27511
+ cvssScore: 7.5,
27512
+ cvssVector: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
27513
+ },
27514
+ tags: generalTags4("api", "unencrypted-transport")
27515
+ },
27516
+ check: (node) => {
27517
+ const httpNode = eapiPlainHttpLine(node);
27518
+ if (httpNode && hasHttpsTransport(node)) {
27519
+ return failResult2(
27520
+ "ARISTA-MGMT-014",
27521
+ httpNode,
27522
+ 'eAPI HTTP (insecure) is enabled alongside HTTPS. Disable with "no protocol http" and use HTTPS only.',
27523
+ "error"
27524
+ );
27525
+ }
27526
+ return passResult4("ARISTA-MGMT-014", node, "eAPI does not serve HTTP alongside HTTPS.");
27527
+ }
27528
+ };
27365
27529
  var allAristaRules = [
27366
27530
  HostnameRequired2,
27367
27531
  NtpRequired3,
@@ -27414,7 +27578,9 @@ var allAristaRules = [
27414
27578
  EosLoggingSourceInterface,
27415
27579
  EosVrrpAuthentication,
27416
27580
  EosVirtualRouterMac,
27417
- EosSecretStorage
27581
+ EosSecretStorage,
27582
+ // Paid-only rules opened (gecko#60)
27583
+ EosEapiHttpWithHttps
27418
27584
  ];
27419
27585
 
27420
27586
  // ../rules-default/src/arista/index.ts
@@ -27431,6 +27597,15 @@ var offenderResult4 = (ruleId, offender, message, level) => ({
27431
27597
  level,
27432
27598
  loc: locOf(offender)
27433
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
+ );
27434
27609
  var VyosHostnameRequired = {
27435
27610
  id: "VYOS-SYS-001",
27436
27611
  selector: "system",
@@ -27442,17 +27617,11 @@ var VyosHostnameRequired = {
27442
27617
  owner: "NetOps",
27443
27618
  remediation: 'Configure "host-name" under system stanza.'
27444
27619
  },
27445
- check: (node) => {
27620
+ check: (node, context) => {
27621
+ if (!isTopLevel(node, context)) return [];
27446
27622
  const hasHostname = hasChildCommand(node, "host-name");
27447
27623
  if (!hasHostname) {
27448
- return {
27449
- passed: false,
27450
- message: "System missing host-name configuration.",
27451
- ruleId: "VYOS-SYS-001",
27452
- nodeId: node.id,
27453
- level: "warning",
27454
- loc: node.loc
27455
- };
27624
+ return absentResult("VYOS-SYS-001", node, "System missing host-name configuration.", "warning");
27456
27625
  }
27457
27626
  return {
27458
27627
  passed: true,
@@ -27476,30 +27645,17 @@ var VyosNtpRequired = {
27476
27645
  remediation: 'Configure NTP servers under "service ntp server <address>" (VyOS 1.4+) or "system ntp server <address>" (1.3 and earlier).'
27477
27646
  },
27478
27647
  check: (node, context) => {
27648
+ if (!isTopLevel(node, context)) return [];
27479
27649
  const service = (context.getAst?.() ?? []).find((n) => n.id.toLowerCase() === "service");
27480
27650
  const serviceNtp = service ? findStanza7(service, "ntp") : void 0;
27481
27651
  if (!hasNtpConfig(node) && !serviceNtp) {
27482
- return {
27483
- passed: false,
27484
- message: "System missing NTP configuration.",
27485
- ruleId: "VYOS-SYS-002",
27486
- nodeId: node.id,
27487
- level: "warning",
27488
- loc: node.loc
27489
- };
27652
+ return absentResult("VYOS-SYS-002", node, "System missing NTP configuration.", "warning");
27490
27653
  }
27491
27654
  const ntp = findStanza7(node, "ntp") ?? serviceNtp;
27492
27655
  if (ntp) {
27493
27656
  const hasServer = hasChildCommand(ntp, "server");
27494
27657
  if (!hasServer) {
27495
- return {
27496
- passed: false,
27497
- message: "NTP configured but no servers defined.",
27498
- ruleId: "VYOS-SYS-002",
27499
- nodeId: node.id,
27500
- level: "warning",
27501
- loc: node.loc
27502
- };
27658
+ return offenderResult4("VYOS-SYS-002", ntp, "NTP configured but no servers defined.", "warning");
27503
27659
  }
27504
27660
  }
27505
27661
  return {
@@ -27523,16 +27679,10 @@ var VyosSyslogRequired = {
27523
27679
  owner: "NetOps",
27524
27680
  remediation: 'Configure "syslog" under system stanza with remote host or local file.'
27525
27681
  },
27526
- check: (node) => {
27682
+ check: (node, context) => {
27683
+ if (!isTopLevel(node, context)) return [];
27527
27684
  if (!hasSyslogConfig(node)) {
27528
- return {
27529
- passed: false,
27530
- message: "System missing syslog configuration.",
27531
- ruleId: "VYOS-SYS-003",
27532
- nodeId: node.id,
27533
- level: "warning",
27534
- loc: node.loc
27535
- };
27685
+ return absentResult("VYOS-SYS-003", node, "System missing syslog configuration.", "warning");
27536
27686
  }
27537
27687
  return {
27538
27688
  passed: true,
@@ -27558,7 +27708,8 @@ var VyosUserAuthRequired = {
27558
27708
  cwe: ["CWE-306"]
27559
27709
  }
27560
27710
  },
27561
- check: (node) => {
27711
+ check: (node, context) => {
27712
+ if (!isTopLevel(node, context)) return [];
27562
27713
  const login = getLoginConfig(node);
27563
27714
  if (!login) {
27564
27715
  return {
@@ -27589,11 +27740,12 @@ var VyosUserAuthRequired = {
27589
27740
  findings.push(offenderResult4("VYOS-SYS-004", user, `User "${username}" has no authentication configured.`, "error"));
27590
27741
  continue;
27591
27742
  }
27592
- const hasPassword = hasChildCommand(auth, "encrypted-password");
27743
+ const hasPassword = hasValue(auth, "encrypted-password");
27593
27744
  const hasPublicKeys = hasChildCommand(auth, "public-keys");
27594
27745
  if (!hasPassword && !hasPublicKeys) {
27595
27746
  const username = user.id.split(/\s+/)[1] || user.id;
27596
- findings.push(offenderResult4("VYOS-SYS-004", user, `User "${username}" has no password or SSH keys configured.`, "error"));
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"));
27597
27749
  }
27598
27750
  }
27599
27751
  if (findings.length > 0) return findings;
@@ -27622,19 +27774,16 @@ var VyosNoPlaintextPassword = {
27622
27774
  }
27623
27775
  },
27624
27776
  check: (node) => {
27625
- const hasPlaintext = node.children.some((child) => {
27626
- if (!startsWithIgnoreCase(child.id, "plaintext-password")) return false;
27627
- const value = child.params.slice(1).join(" ").replace(/^(["'])(.*)\1$/, "$2").trim();
27628
- return value !== "";
27629
- });
27630
- if (hasPlaintext) {
27777
+ const plaintext = valueChild(node, "plaintext-password");
27778
+ if (plaintext) {
27631
27779
  return {
27632
- passed: false,
27633
- message: "Plaintext password found in configuration. VyOS should store hashed passwords only.",
27634
- ruleId: "VYOS-SEC-001",
27635
- nodeId: node.id,
27636
- level: "error",
27637
- loc: node.loc
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)
27638
27787
  };
27639
27788
  }
27640
27789
  return {
@@ -27658,17 +27807,11 @@ var VyosNameServersRequired = {
27658
27807
  owner: "NetOps",
27659
27808
  remediation: 'Configure "name-server" under system stanza.'
27660
27809
  },
27661
- check: (node) => {
27810
+ check: (node, context) => {
27811
+ if (!isTopLevel(node, context)) return [];
27662
27812
  const hasNameServer = hasChildCommand(node, "name-server");
27663
27813
  if (!hasNameServer) {
27664
- return {
27665
- passed: false,
27666
- message: "System has no name servers configured.",
27667
- ruleId: "VYOS-SYS-005",
27668
- nodeId: node.id,
27669
- level: "info",
27670
- loc: node.loc
27671
- };
27814
+ return absentResult("VYOS-SYS-005", node, "System has no name servers configured.", "info");
27672
27815
  }
27673
27816
  return {
27674
27817
  passed: true,
@@ -27694,16 +27837,10 @@ var VyosSshRequired = {
27694
27837
  cwe: ["CWE-319"]
27695
27838
  }
27696
27839
  },
27697
- check: (node) => {
27840
+ check: (node, context) => {
27841
+ if (!isTopLevel(node, context)) return [];
27698
27842
  if (!hasSshService(node)) {
27699
- return {
27700
- passed: false,
27701
- message: "SSH service is not configured.",
27702
- ruleId: "VYOS-SVC-001",
27703
- nodeId: node.id,
27704
- level: "warning",
27705
- loc: node.loc
27706
- };
27843
+ return absentResult("VYOS-SVC-001", node, "SSH service is not configured.", "warning");
27707
27844
  }
27708
27845
  return {
27709
27846
  passed: true,
@@ -27729,7 +27866,8 @@ var VyosSshKeyAuth = {
27729
27866
  cwe: ["CWE-309"]
27730
27867
  }
27731
27868
  },
27732
- check: (node) => {
27869
+ check: (node, context) => {
27870
+ if (!isTopLevel(node, context)) return [];
27733
27871
  const ssh = getSshConfig(node);
27734
27872
  if (!ssh) {
27735
27873
  return {
@@ -27743,14 +27881,7 @@ var VyosSshKeyAuth = {
27743
27881
  }
27744
27882
  const disablePassword = hasChildCommand(ssh, "disable-password-authentication");
27745
27883
  if (!disablePassword) {
27746
- return {
27747
- passed: false,
27748
- message: "SSH password authentication is enabled. Consider using SSH keys only.",
27749
- ruleId: "VYOS-SVC-002",
27750
- nodeId: node.id,
27751
- level: "info",
27752
- loc: node.loc
27753
- };
27884
+ return offenderResult4("VYOS-SVC-002", ssh, "SSH password authentication is enabled. Consider using SSH keys only.", "info");
27754
27885
  }
27755
27886
  return {
27756
27887
  passed: true,
@@ -27773,7 +27904,8 @@ var VyosSshNonDefaultPort = {
27773
27904
  owner: "SecOps",
27774
27905
  remediation: 'Consider using a non-standard SSH port: "set service ssh port <port>".'
27775
27906
  },
27776
- check: (node) => {
27907
+ check: (node, context) => {
27908
+ if (!isTopLevel(node, context)) return [];
27777
27909
  const ssh = getSshConfig(node);
27778
27910
  if (!ssh) {
27779
27911
  return {
@@ -27789,25 +27921,11 @@ var VyosSshNonDefaultPort = {
27789
27921
  (child) => startsWithIgnoreCase(child.id, "port")
27790
27922
  );
27791
27923
  if (!portCmd) {
27792
- return {
27793
- passed: false,
27794
- message: "SSH using default port 22. Consider using a non-standard port.",
27795
- ruleId: "VYOS-SVC-003",
27796
- nodeId: node.id,
27797
- level: "info",
27798
- loc: node.loc
27799
- };
27924
+ return offenderResult4("VYOS-SVC-003", ssh, "SSH using default port 22. Consider using a non-standard port.", "info");
27800
27925
  }
27801
27926
  const portMatch = portCmd.id.match(/port\s+['"]?(\d+)['"]?/i);
27802
27927
  if (portMatch && portMatch[1] === "22") {
27803
- return {
27804
- passed: false,
27805
- message: "SSH configured on standard port 22. Consider using a non-standard port.",
27806
- ruleId: "VYOS-SVC-003",
27807
- nodeId: node.id,
27808
- level: "info",
27809
- loc: node.loc
27810
- };
27928
+ return offenderResult4("VYOS-SVC-003", portCmd, "SSH configured on standard port 22. Consider using a non-standard port.", "info");
27811
27929
  }
27812
27930
  return {
27813
27931
  passed: true,
@@ -27830,7 +27948,8 @@ var VyosInterfaceDescription = {
27830
27948
  owner: "NetOps",
27831
27949
  remediation: 'Add "description" to each physical interface.'
27832
27950
  },
27833
- check: (node) => {
27951
+ check: (node, context) => {
27952
+ if (!isTopLevel(node, context)) return [];
27834
27953
  const findings = [];
27835
27954
  const ethernetInterfaces = getEthernetInterfaces(node);
27836
27955
  for (const iface of ethernetInterfaces) {
@@ -27865,7 +27984,8 @@ var VyosInterfaceAddress = {
27865
27984
  owner: "NetOps",
27866
27985
  remediation: 'Configure "address" (static IP or dhcp) for each active interface.'
27867
27986
  },
27868
- check: (node) => {
27987
+ check: (node, context) => {
27988
+ if (!isTopLevel(node, context)) return [];
27869
27989
  const findings = [];
27870
27990
  const ethernetInterfaces = getEthernetInterfaces(node);
27871
27991
  const members = /* @__PURE__ */ new Set();
@@ -27912,7 +28032,8 @@ var VyosFirewallDefaultAction = {
27912
28032
  owner: "SecOps",
27913
28033
  remediation: 'Set "default-action drop" or "default-action reject" for each firewall ruleset.'
27914
28034
  },
27915
- check: (node) => {
28035
+ check: (node, context) => {
28036
+ if (!isTopLevel(node, context)) return [];
27916
28037
  const rulesets = findStanzasByPrefix2(node, "name");
27917
28038
  if (rulesets.length === 0) {
27918
28039
  return {
@@ -27954,7 +28075,8 @@ var VyosFirewallRuleAction = {
27954
28075
  owner: "SecOps",
27955
28076
  remediation: 'Set "action accept", "action drop", or "action reject" for each firewall rule.'
27956
28077
  },
27957
- check: (node) => {
28078
+ check: (node, context) => {
28079
+ if (!isTopLevel(node, context)) return [];
27958
28080
  const rulesets = findStanzasByPrefix2(node, "name");
27959
28081
  if (rulesets.length === 0) {
27960
28082
  return {
@@ -28000,7 +28122,8 @@ var VyosFirewallStateful = {
28000
28122
  owner: "SecOps",
28001
28123
  remediation: "Configure state-policy or add rules to accept established and related connections."
28002
28124
  },
28003
- check: (node) => {
28125
+ check: (node, context) => {
28126
+ if (!isTopLevel(node, context)) return [];
28004
28127
  const statePolicy = findStanza7(node, "state-policy");
28005
28128
  if (statePolicy) {
28006
28129
  return {
@@ -28038,14 +28161,7 @@ var VyosFirewallStateful = {
28038
28161
  if (hasStatefulRules) break;
28039
28162
  }
28040
28163
  if (!hasStatefulRules) {
28041
- return {
28042
- passed: false,
28043
- message: "No stateful firewall rules (established/related) found. Consider adding state-policy.",
28044
- ruleId: "VYOS-FW-003",
28045
- nodeId: node.id,
28046
- level: "info",
28047
- loc: node.loc
28048
- };
28164
+ return absentResult("VYOS-FW-003", node, "No stateful firewall rules (established/related) found. Consider adding state-policy.", "info");
28049
28165
  }
28050
28166
  return {
28051
28167
  passed: true,
@@ -28068,7 +28184,8 @@ var VyosNatOutboundInterface = {
28068
28184
  owner: "NetOps",
28069
28185
  remediation: 'Configure "outbound-interface" for source NAT rules.'
28070
28186
  },
28071
- check: (node) => {
28187
+ check: (node, context) => {
28188
+ if (!isTopLevel(node, context)) return [];
28072
28189
  const source = findStanza7(node, "source");
28073
28190
  if (!source) {
28074
28191
  return {
@@ -28110,6 +28227,11 @@ var VyosNatOutboundInterface = {
28110
28227
  };
28111
28228
  }
28112
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
+ };
28113
28235
  var VyosNatTranslation = {
28114
28236
  id: "VYOS-NAT-002",
28115
28237
  selector: "nat",
@@ -28121,12 +28243,14 @@ var VyosNatTranslation = {
28121
28243
  owner: "NetOps",
28122
28244
  remediation: 'Configure "translation address" for NAT rules (e.g., masquerade or static IP).'
28123
28245
  },
28124
- check: (node) => {
28246
+ check: (node, context) => {
28247
+ if (!isTopLevel(node, context)) return [];
28125
28248
  const findings = [];
28126
28249
  const source = findStanza7(node, "source");
28127
28250
  if (source) {
28128
28251
  const rules = findStanzasByPrefix2(source, "rule");
28129
28252
  for (const rule of rules) {
28253
+ if (translationNotRequired(rule)) continue;
28130
28254
  const hasTranslation = hasChildCommand(rule, "translation");
28131
28255
  if (!hasTranslation) {
28132
28256
  const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
@@ -28138,6 +28262,7 @@ var VyosNatTranslation = {
28138
28262
  if (destination) {
28139
28263
  const rules = findStanzasByPrefix2(destination, "rule");
28140
28264
  for (const rule of rules) {
28265
+ if (translationNotRequired(rule)) continue;
28141
28266
  const hasTranslation = hasChildCommand(rule, "translation");
28142
28267
  if (!hasTranslation) {
28143
28268
  const ruleNum = rule.id.split(/\s+/)[1] || rule.id;
@@ -28170,7 +28295,8 @@ var VyosIpsecStrongEncryption = {
28170
28295
  cwe: ["CWE-327"]
28171
28296
  }
28172
28297
  },
28173
- check: (node) => {
28298
+ check: (node, context) => {
28299
+ if (!isTopLevel(node, context)) return [];
28174
28300
  const ipsec = findStanza7(node, "ipsec");
28175
28301
  if (!ipsec) {
28176
28302
  return {
@@ -28231,7 +28357,8 @@ var VyosWireGuardAllowedIps = {
28231
28357
  owner: "SecOps",
28232
28358
  remediation: 'Configure "allowed-ips" for each WireGuard peer.'
28233
28359
  },
28234
- check: (node) => {
28360
+ check: (node, context) => {
28361
+ if (!isTopLevel(node, context)) return [];
28235
28362
  const wgInterfaces = findStanzasByPrefix2(node, "wireguard");
28236
28363
  if (wgInterfaces.length === 0) {
28237
28364
  return {
@@ -28277,7 +28404,8 @@ var VyosBgpRouterId = {
28277
28404
  owner: "NetOps",
28278
28405
  remediation: 'Configure "parameters router-id" under BGP stanza.'
28279
28406
  },
28280
- check: (node) => {
28407
+ check: (node, context) => {
28408
+ if (!isProtocolsStanza(node, context)) return [];
28281
28409
  const bgp = findStanza7(node, "bgp");
28282
28410
  if (!bgp) {
28283
28411
  return {
@@ -28292,14 +28420,7 @@ var VyosBgpRouterId = {
28292
28420
  const params = findStanza7(bgp, "parameters");
28293
28421
  const hasRouterId = params ? hasChildCommand(params, "router-id") : hasChildCommand(bgp, "router-id");
28294
28422
  if (!hasRouterId) {
28295
- return {
28296
- passed: false,
28297
- message: "BGP missing explicit router-id.",
28298
- ruleId: "VYOS-BGP-001",
28299
- nodeId: node.id,
28300
- level: "warning",
28301
- loc: node.loc
28302
- };
28423
+ return offenderResult4("VYOS-BGP-001", params ?? bgp, "BGP missing explicit router-id.", "warning");
28303
28424
  }
28304
28425
  return {
28305
28426
  passed: true,
@@ -28322,7 +28443,8 @@ var VyosBgpNeighborDescription = {
28322
28443
  owner: "NetOps",
28323
28444
  remediation: 'Add "description" to each BGP neighbor.'
28324
28445
  },
28325
- check: (node) => {
28446
+ check: (node, context) => {
28447
+ if (!isProtocolsStanza(node, context)) return [];
28326
28448
  const bgp = findStanza7(node, "bgp");
28327
28449
  if (!bgp) {
28328
28450
  return {
@@ -28375,7 +28497,8 @@ var VyosOspfAreaInterfaces = {
28375
28497
  owner: "NetOps",
28376
28498
  remediation: 'Configure interfaces under each OSPF area or use "interface" directly under OSPF.'
28377
28499
  },
28378
- check: (node) => {
28500
+ check: (node, context) => {
28501
+ if (!isProtocolsStanza(node, context)) return [];
28379
28502
  const ospf = findStanza7(node, "ospf");
28380
28503
  if (!ospf) {
28381
28504
  return {
@@ -28390,14 +28513,7 @@ var VyosOspfAreaInterfaces = {
28390
28513
  const hasDirectInterfaces = hasChildCommand(ospf, "interface");
28391
28514
  const areas = findStanzasByPrefix2(ospf, "area");
28392
28515
  if (!hasDirectInterfaces && areas.length === 0) {
28393
- return {
28394
- passed: false,
28395
- message: "OSPF configured but no interfaces or areas defined.",
28396
- ruleId: "VYOS-OSPF-001",
28397
- nodeId: node.id,
28398
- level: "warning",
28399
- loc: node.loc
28400
- };
28516
+ return offenderResult4("VYOS-OSPF-001", ospf, "OSPF configured but no interfaces or areas defined.", "warning");
28401
28517
  }
28402
28518
  const findings = [];
28403
28519
  for (const area of areas) {
@@ -28430,7 +28546,8 @@ var VyosVrrpPreemptDelay = {
28430
28546
  owner: "NetOps",
28431
28547
  remediation: 'Configure "preempt-delay" in VRRP groups to prevent flapping.'
28432
28548
  },
28433
- check: (node) => {
28549
+ check: (node, context) => {
28550
+ if (!isTopLevel(node, context)) return [];
28434
28551
  const vrrp = findStanza7(node, "vrrp");
28435
28552
  if (!vrrp) {
28436
28553
  return {
@@ -28472,6 +28589,49 @@ var VyosVrrpPreemptDelay = {
28472
28589
  };
28473
28590
  }
28474
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
+ };
28475
28635
  var allVyosRules = [
28476
28636
  VyosHostnameRequired,
28477
28637
  VyosNtpRequired,
@@ -28494,7 +28654,8 @@ var allVyosRules = [
28494
28654
  VyosBgpRouterId,
28495
28655
  VyosBgpNeighborDescription,
28496
28656
  VyosOspfAreaInterfaces,
28497
- VyosVrrpPreemptDelay
28657
+ VyosVrrpPreemptDelay,
28658
+ VyosSnmpDefaultCommunity
28498
28659
  ];
28499
28660
 
28500
28661
  // ../rules-default/src/vyos/index.ts
@@ -30421,8 +30582,8 @@ var ExosSysnameRequired = {
30421
30582
  return [passAt2(id, sysname.node, `SNMP sysname is configured: ${name}`)];
30422
30583
  })
30423
30584
  };
30424
- var SNTP_SERVER = /^configure\s+sntp-client\s+(?:primary|secondary)\s+(?:server\s+)?\S+/i;
30425
- var NTP_SERVER = /^configure\s+ntp\s+server\s+add\s+\S+/i;
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;
30426
30587
  var ExosSntpRequired = {
30427
30588
  id: "EXOS-SYS-002",
30428
30589
  vendor: "extreme-exos",
@@ -30435,7 +30596,7 @@ var ExosSntpRequired = {
30435
30596
  },
30436
30597
  check: judgedOnce((index, anchor) => {
30437
30598
  const id = "EXOS-SYS-002";
30438
- const server = matching(index, SNTP_SERVER)[0] ?? matching(index, NTP_SERVER)[0];
30599
+ const server = matching(index, SNTP_SERVER2)[0] ?? matching(index, NTP_SERVER2)[0];
30439
30600
  if (!server) {
30440
30601
  return [failAt2(id, anchor, "warning", "No SNTP or NTP server is configured. Time synchronization is critical for logging.", true)];
30441
30602
  }
@@ -30454,8 +30615,8 @@ var ExosSntpEnabled = {
30454
30615
  },
30455
30616
  check: judgedOnce((index, anchor) => {
30456
30617
  const id = "EXOS-SYS-003";
30457
- const sntpServer = matching(index, SNTP_SERVER)[0];
30458
- const ntpServer = matching(index, NTP_SERVER)[0];
30618
+ const sntpServer = matching(index, SNTP_SERVER2)[0];
30619
+ const ntpServer = matching(index, NTP_SERVER2)[0];
30459
30620
  const sntp = lastMatching(index, /^(?:enable|disable)\s+sntp-client\s*$/i);
30460
30621
  const ntp = lastMatching(index, /^(?:enable|disable)\s+ntp\s*$/i);
30461
30622
  const on = [sntp, ntp].find((l) => l !== void 0 && /^enable/i.test(l.text));
@@ -37701,7 +37862,7 @@ var treeOf = (context, node) => {
37701
37862
  return tree;
37702
37863
  };
37703
37864
  var kidsOf = (tree, node) => tree.children.get(node) ?? [];
37704
- var descendantsOf2 = (tree, node) => kidsOf(tree, node).flatMap((child) => [child, ...descendantsOf2(tree, child)]);
37865
+ var descendantsOf3 = (tree, node) => kidsOf(tree, node).flatMap((child) => [child, ...descendantsOf3(tree, child)]);
37705
37866
  var parentWord = (tree, node) => {
37706
37867
  const up = tree.parent.get(node);
37707
37868
  return up ? wordOf(up) : "";
@@ -37764,7 +37925,7 @@ var AaaWithTacacsRequired = {
37764
37925
  check: (node, context) => {
37765
37926
  const tree = treeOf(context, node);
37766
37927
  if (!isSystemSecurity(tree, node)) return [];
37767
- const words = new Set(descendantsOf2(tree, node).map(wordOf));
37928
+ const words = new Set(descendantsOf3(tree, node).map(wordOf));
37768
37929
  if (words.has("tacplus")) return npass("NOKIA-MGMT-001", node, "TACACS+ authentication is configured.");
37769
37930
  if (words.has("radius") || words.has("ldap")) {
37770
37931
  return npass("NOKIA-MGMT-001", node, "RADIUS or LDAP is configured. Consider TACACS+ for command-level authorization.");
@@ -37909,7 +38070,7 @@ var NtpAuthenticationRequired2 = {
37909
38070
  return findings.length > 0 ? findings : npass("NOKIA-MGMT-004", node, "NTP authentication is configured.");
37910
38071
  }
37911
38072
  };
37912
- var filterEffective = (tree, filter, defaultEnabled) => adminEnabled(tree, filter, defaultEnabled) && descendantsOf2(tree, filter).some((n) => wordOf(n) === "entry" || /^default-action\s+(drop|deny|reject)\b/i.test(keyOf2(n)));
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)));
37913
38074
  var FILTER_WORDS = /* @__PURE__ */ new Set(["ip-filter", "ipv6-filter", "mac-filter"]);
37914
38075
  var ManagementAccessFilterRequired = {
37915
38076
  id: "NOKIA-MGMT-005",
@@ -37979,7 +38140,7 @@ var instanceAuthCheck = (ruleId, pattern, protocol, defaultEnabled, extraWords,
37979
38140
  if (!adminEnabled(tree, node, defaultEnabled)) return npass(ruleId, node, `${protocol} is not enabled.`);
37980
38141
  if (applies && !applies(tree, node)) return npass(ruleId, node, `${protocol} has no sessions configured.`);
37981
38142
  const words = /* @__PURE__ */ new Set([...AUTH_WORDS, ...extraWords]);
37982
- if (!descendantsOf2(tree, node).some((n) => words.has(wordOf(n)))) {
38143
+ if (!descendantsOf3(tree, node).some((n) => words.has(wordOf(n)))) {
37983
38144
  return nfail(ruleId, node, "warning", `${protocol} is enabled without authentication. Configure an authentication key or keychain.`);
37984
38145
  }
37985
38146
  return npass(ruleId, node, `${protocol} authentication is configured.`);
@@ -38111,7 +38272,7 @@ var BgpGracefulRestartRecommended = {
38111
38272
  const tree = treeOf(context, node);
38112
38273
  if (!isBgpInstance(tree, node)) return [];
38113
38274
  if (!adminEnabled(tree, node, true)) return npass("NOKIA-BGP-005", node, "BGP is not enabled.");
38114
- if (!descendantsOf2(tree, node).some((n) => wordOf(n) === "graceful-restart")) {
38275
+ if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "graceful-restart")) {
38115
38276
  return nfail("NOKIA-BGP-005", node, "info", "BGP graceful restart is not configured. Consider enabling for high availability.", true);
38116
38277
  }
38117
38278
  return npass("NOKIA-BGP-005", node, "BGP graceful restart is configured.");
@@ -38351,7 +38512,7 @@ var IpFilterRequired = {
38351
38512
  const tree = treeOf(context, node);
38352
38513
  if (!isTransitInterface(tree, node)) return [];
38353
38514
  const ingress = childWithWord(tree, node, "ingress");
38354
- const filtered = ingress !== void 0 && descendantsOf2(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");
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");
38355
38516
  if (!filtered) {
38356
38517
  return nfail("NOKIA-DATA-001", node, "info", `Interface "${nameOf2(node)}" does not have an ingress IP filter. Consider adding ACLs for traffic filtering.`);
38357
38518
  }
@@ -38379,7 +38540,7 @@ var UrpfRequired = {
38379
38540
  check: (node, context) => {
38380
38541
  const tree = treeOf(context, node);
38381
38542
  if (!isTransitInterface(tree, node)) return [];
38382
- if (!descendantsOf2(tree, node).some((n) => wordOf(n) === "urpf-check")) {
38543
+ if (!descendantsOf3(tree, node).some((n) => wordOf(n) === "urpf-check")) {
38383
38544
  return nfail("NOKIA-URPF-001", node, "info", `Interface "${nameOf2(node)}" does not have uRPF configured. Consider enabling for anti-spoofing.`);
38384
38545
  }
38385
38546
  return npass("NOKIA-URPF-001", node, `Interface "${nameOf2(node)}" has uRPF enabled.`);
@@ -38400,7 +38561,7 @@ var VprnIsolationRequired = {
38400
38561
  check: (node, context) => {
38401
38562
  const tree = treeOf(context, node);
38402
38563
  if (!isVprnService(tree, node)) return [];
38403
- const words = new Set(descendantsOf2(tree, node).map(wordOf));
38564
+ const words = new Set(descendantsOf3(tree, node).map(wordOf));
38404
38565
  const missing = [
38405
38566
  words.has("route-distinguisher") ? "" : "route-distinguisher",
38406
38567
  ["vrf-target", "vrf-import", "vrf-export"].some((w) => words.has(w)) ? "" : "vrf-target"
@@ -38425,8 +38586,8 @@ var VprnGrtLeakingWarning = {
38425
38586
  check: (node, context) => {
38426
38587
  const tree = treeOf(context, node);
38427
38588
  if (!isVprnService(tree, node)) return [];
38428
- const leaking = descendantsOf2(tree, node).find((n) => wordOf(n) === "grt-leaking");
38429
- if (leaking && !descendantsOf2(tree, leaking).some((n) => wordOf(n) === "export-grt")) {
38589
+ const leaking = descendantsOf3(tree, node).find((n) => wordOf(n) === "grt-leaking");
38590
+ if (leaking && !descendantsOf3(tree, leaking).some((n) => wordOf(n) === "export-grt")) {
38430
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.`);
38431
38592
  }
38432
38593
  return npass("NOKIA-VPRN-002", node, `VPRN ${nameOf2(node)} has no uncontrolled GRT leaking.`);
@@ -38475,7 +38636,7 @@ var BfdRecommended = {
38475
38636
  const tree = treeOf(context, node);
38476
38637
  if (!isBgpInstance(tree, node)) return [];
38477
38638
  if (!adminEnabled(tree, node, true)) return npass("NOKIA-HA-002", node, "BGP is not enabled.");
38478
- const bfd = descendantsOf2(tree, node).some(
38639
+ const bfd = descendantsOf3(tree, node).some(
38479
38640
  (n) => wordOf(n) === "bfd-enable" || wordOf(n) === "bfd-liveness" && !/\sfalse$/i.test(keyOf2(n))
38480
38641
  );
38481
38642
  if (!bfd) {
@@ -38743,6 +38904,7 @@ function getRulesByNokiaVendor() {
38743
38904
  }
38744
38905
 
38745
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");
38746
38908
  var CumulusInterfaceDescription = {
38747
38909
  id: "CUM-IF-001",
38748
38910
  selector: "iface",
@@ -38911,7 +39073,7 @@ var CumulusBridgeVlans = {
38911
39073
  },
38912
39074
  check: (node) => {
38913
39075
  const ifaceName = getInterfaceName2(node);
38914
- if (!isBridgeInterface(ifaceName)) {
39076
+ if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
38915
39077
  return {
38916
39078
  passed: true,
38917
39079
  message: "Not a bridge interface.",
@@ -38964,7 +39126,7 @@ var CumulusBridgePorts = {
38964
39126
  },
38965
39127
  check: (node) => {
38966
39128
  const ifaceName = getInterfaceName2(node);
38967
- if (!isBridgeInterface(ifaceName)) {
39129
+ if (!isBridgeInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
38968
39130
  return {
38969
39131
  passed: true,
38970
39132
  message: "Not a bridge interface.",
@@ -39007,7 +39169,7 @@ var CumulusBondSlaves = {
39007
39169
  },
39008
39170
  check: (node) => {
39009
39171
  const ifaceName = getInterfaceName2(node);
39010
- if (!isBondInterface(ifaceName)) {
39172
+ if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
39011
39173
  return {
39012
39174
  passed: true,
39013
39175
  message: "Not a bond interface.",
@@ -39050,7 +39212,7 @@ var CumulusBondClagId = {
39050
39212
  },
39051
39213
  check: (node) => {
39052
39214
  const ifaceName = getInterfaceName2(node);
39053
- if (!isBondInterface(ifaceName)) {
39215
+ if (!isBondInterface(ifaceName) || isVlanDevice(node, ifaceName)) {
39054
39216
  return {
39055
39217
  passed: true,
39056
39218
  message: "Not a bond interface.",
@@ -40146,6 +40308,42 @@ var CumulusSecretEncryption = {
40146
40308
  return findings;
40147
40309
  })
40148
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
+ };
40149
40347
  var allCumulusRules = [
40150
40348
  CumulusInterfaceDescription,
40151
40349
  CumulusBpduGuard,
@@ -40180,7 +40378,8 @@ var allCumulusRules = [
40180
40378
  CumulusVniVxlanId,
40181
40379
  CumulusEvpnAnycastIp,
40182
40380
  CumulusStormControl,
40183
- CumulusSecretEncryption
40381
+ CumulusSecretEncryption,
40382
+ CumulusSnmpDefaultCommunity
40184
40383
  ];
40185
40384
 
40186
40385
  // ../rules-default/src/cumulus/index.ts
@@ -40346,7 +40545,7 @@ var cisco_json_rules_default = {
40346
40545
  type: "child_not_exists",
40347
40546
  selector: "access-class"
40348
40547
  },
40349
- failureMessage: "VTY line {nodeId} is missing access-class for SSH access control"
40548
+ failureMessage: '"{nodeId}" is missing access-class for SSH access control'
40350
40549
  }
40351
40550
  ]
40352
40551
  };
@@ -40591,6 +40790,10 @@ var allRules = [
40591
40790
  // JSON-defined rules (compiled from JSON files)
40592
40791
  ...allJsonRules
40593
40792
  ];
40793
+ var builtInRuleIds = new Set(allRules.map((rule) => rule.id));
40794
+ function builtInRuleDocsUrl(ruleId) {
40795
+ return builtInRuleIds.has(ruleId) ? ruleDocsUrl(ruleId) : void 0;
40796
+ }
40594
40797
  var ciscoRulesFor = (vendorId) => allCiscoRules.filter((rule) => ruleAppliesToVendor(rule, vendorId));
40595
40798
  var vendorRulesRegistry = {
40596
40799
  // Cisco platforms share one rule array; each rule's `vendor` field says
@@ -40623,6 +40826,492 @@ function getRulesByVendor(vendorId) {
40623
40826
  return allRules;
40624
40827
  }
40625
40828
 
40829
+ // src/sarif.ts
40830
+ import { relative } from "path";
40831
+ import { createHash } from "crypto";
40832
+
40833
+ // src/cliOptions.ts
40834
+ import { readFileSync } from "fs";
40835
+ var FAIL_ON_LEVELS = ["error", "warning", "info", "never"];
40836
+ var SEVERITY_RANK = {
40837
+ info: 0,
40838
+ warning: 1,
40839
+ error: 2
40840
+ };
40841
+ function parseFailOn(value) {
40842
+ const v = value.trim().toLowerCase();
40843
+ const match = FAIL_ON_LEVELS.find((l) => l === v);
40844
+ if (!match) {
40845
+ throw new Error(
40846
+ `Invalid --fail-on value '${value}'. Expected one of: ${FAIL_ON_LEVELS.join(", ")}`
40847
+ );
40848
+ }
40849
+ return match;
40850
+ }
40851
+ var OUTPUT_FORMATS = ["json", "human", "sarif"];
40852
+ function parseFormat(value) {
40853
+ const v = value.trim().toLowerCase();
40854
+ const match = OUTPUT_FORMATS.find((f) => f === v);
40855
+ if (!match) {
40856
+ throw new Error(
40857
+ `Invalid --format value '${value}'. Expected one of: ${OUTPUT_FORMATS.join(", ")}`
40858
+ );
40859
+ }
40860
+ return match;
40861
+ }
40862
+ var LIST_FORMATS = ["table", "json", "csv"];
40863
+ function parseListFormat(value) {
40864
+ const v = value.trim().toLowerCase();
40865
+ const match = LIST_FORMATS.find((f) => f === v);
40866
+ if (!match) {
40867
+ throw new Error(
40868
+ `Invalid --list-format value '${value}'. Expected one of: ${LIST_FORMATS.join(", ")}`
40869
+ );
40870
+ }
40871
+ return match;
40872
+ }
40873
+ function shouldFail(results, threshold) {
40874
+ if (threshold === "never") return false;
40875
+ const min = SEVERITY_RANK[threshold];
40876
+ return results.some((r) => !r.passed && SEVERITY_RANK[r.level] >= min);
40877
+ }
40878
+ function normalizeExtensions(value) {
40879
+ return value.split(",").map((e) => e.trim().replace(/^\.+/, "").toLowerCase()).filter((e) => e.length > 0);
40880
+ }
40881
+ function resolveVersion(injected) {
40882
+ if (injected !== void 0) return injected;
40883
+ try {
40884
+ const pkg = JSON.parse(
40885
+ readFileSync(new URL("../package.json", import.meta.url), "utf-8")
40886
+ );
40887
+ if (pkg && typeof pkg === "object" && "version" in pkg && typeof pkg.version === "string") {
40888
+ return pkg.version;
40889
+ }
40890
+ } catch {
40891
+ }
40892
+ return "unknown";
40893
+ }
40894
+
40895
+ // src/sarif.ts
40896
+ var TOOL_VERSION = resolveVersion(
40897
+ true ? "0.11.0-rc.2" : void 0
40898
+ );
40899
+ var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
40900
+ function cweNumber(cweId) {
40901
+ return cweId.replace(/^cwe-/i, "").trim();
40902
+ }
40903
+ var LEVEL_SECURITY_SEVERITY = {
40904
+ error: "8.0",
40905
+ warning: "5.0",
40906
+ info: "2.0"
40907
+ };
40908
+ function securitySeverity(rule) {
40909
+ const sec = rule.metadata.security;
40910
+ if (sec?.cvssScore !== void 0) return String(sec.cvssScore);
40911
+ if (sec?.cwe && sec.cwe.length > 0) return LEVEL_SECURITY_SEVERITY[rule.metadata.level];
40912
+ return void 0;
40913
+ }
40914
+ function toUri(filePath, options) {
40915
+ return options.relativePaths ? relative(options.baseDir ?? process.cwd(), filePath) : filePath;
40916
+ }
40917
+ function fingerprintPath(filePath, options) {
40918
+ if (filePath.startsWith("<")) return filePath;
40919
+ return relative(options.baseDir ?? process.cwd(), filePath).replace(
40920
+ /\\/g,
40921
+ "/"
40922
+ );
40923
+ }
40924
+ function normaliseText(text) {
40925
+ return text.trim().replace(/\s+/g, " ");
40926
+ }
40927
+ function fingerprintLine(lineText, nodeId) {
40928
+ const line = normaliseText(maskSecretWords(lineText));
40929
+ const at2 = nodeId.indexOf(SECRET_MASK);
40930
+ if (at2 < 0 || line.includes(SECRET_MASK)) return line;
40931
+ const shown2 = normaliseText(nodeId.slice(0, at2));
40932
+ if (shown2 === "" || !line.startsWith(shown2)) return line;
40933
+ const snmp = normaliseText(maskSecretWords(lineText, { snmp: true }));
40934
+ return snmp.includes(SECRET_MASK) ? snmp : `${shown2} ${SECRET_MASK}`;
40935
+ }
40936
+ function normaliseMessage(message) {
40937
+ return normaliseText(message).replace(/\d+/g, "#");
40938
+ }
40939
+ function buildSarifResults(results, filePath, sourceText, ruleIndexById, options, suppressed = []) {
40940
+ const uri = toUri(filePath, options);
40941
+ const fpPath = fingerprintPath(filePath, options);
40942
+ const lines = sourceText?.split(/\r\n|\r|\n/);
40943
+ const occurrences = /* @__PURE__ */ new Map();
40944
+ const items = [
40945
+ ...results.filter((result2) => options.includePassed || !result2.passed).map((result2) => ({ result: result2 })),
40946
+ ...suppressed
40947
+ ];
40948
+ const hashes = items.map(({ result: result2 }) => {
40949
+ const lineText = result2.loc ? lines?.[result2.loc.startLine] : void 0;
40950
+ const where = result2.absent ? "" : lineText !== void 0 && lineText.trim() !== "" ? fingerprintLine(lineText, result2.nodeId) : normaliseText(result2.nodeId);
40951
+ return createHash("sha256").update(`${result2.ruleId}
40952
+ ${normaliseMessage(result2.message)}
40953
+ ${where}
40954
+ ${fpPath}`).digest("hex").slice(0, 32);
40955
+ });
40956
+ const occurrenceOf = new Array(items.length).fill(1);
40957
+ const byLine = items.map((item, i) => ({ i, line: item.result.loc?.startLine ?? Number.POSITIVE_INFINITY })).sort((a, b) => a.line - b.line || a.i - b.i);
40958
+ for (const { i } of byLine) {
40959
+ const hash = hashes[i] ?? "";
40960
+ const occurrence = (occurrences.get(hash) ?? 0) + 1;
40961
+ occurrences.set(hash, occurrence);
40962
+ occurrenceOf[i] = occurrence;
40963
+ }
40964
+ return items.map(({ result: result2, suppression }, i) => {
40965
+ const hash = hashes[i] ?? "";
40966
+ const occurrence = occurrenceOf[i] ?? 1;
40967
+ const ruleIndex = ruleIndexById.get(result2.ruleId);
40968
+ return {
40969
+ ruleId: result2.ruleId,
40970
+ ...ruleIndex !== void 0 && { ruleIndex },
40971
+ ...result2.passed && { kind: "pass" },
40972
+ level: result2.level === "info" ? "note" : result2.level,
40973
+ message: {
40974
+ text: result2.message
40975
+ },
40976
+ locations: result2.loc ? [
40977
+ {
40978
+ physicalLocation: {
40979
+ artifactLocation: { uri },
40980
+ region: {
40981
+ startLine: result2.loc.startLine + 1,
40982
+ // SARIF is 1-based
40983
+ endLine: result2.loc.endLine + 1
40984
+ }
40985
+ }
40986
+ }
40987
+ ] : [],
40988
+ partialFingerprints: {
40989
+ primaryLocationLineHash: `${hash}:${occurrence}`
40990
+ },
40991
+ ...suppression && {
40992
+ suppressions: [
40993
+ {
40994
+ kind: suppression.kind,
40995
+ status: "accepted",
40996
+ justification: suppression.justification
40997
+ }
40998
+ ]
40999
+ }
41000
+ };
41001
+ });
41002
+ }
41003
+ function buildRulesAndTaxonomy(rules) {
41004
+ const cweIds = /* @__PURE__ */ new Set();
41005
+ const sarifRules = rules?.map((rule) => {
41006
+ const base = {
41007
+ id: rule.id,
41008
+ name: rule.id,
41009
+ shortDescription: { text: rule.metadata.remediation ?? rule.id },
41010
+ defaultConfiguration: {
41011
+ level: rule.metadata.level === "info" ? "note" : rule.metadata.level
41012
+ }
41013
+ };
41014
+ const docsUrl = builtInRuleDocsUrl(rule.id);
41015
+ if (docsUrl !== void 0) {
41016
+ const remediation = rule.metadata.remediation;
41017
+ const link = `[Rule documentation](${docsUrl})`;
41018
+ base.helpUri = docsUrl;
41019
+ base.help = {
41020
+ text: remediation ? `${remediation}
41021
+
41022
+ See ${docsUrl}` : `See ${docsUrl}`,
41023
+ markdown: remediation ? `${remediation}
41024
+
41025
+ ${link}` : link
41026
+ };
41027
+ }
41028
+ const secMeta = rule.metadata.security;
41029
+ if (secMeta?.cwe && secMeta.cwe.length > 0) {
41030
+ base.relationships = secMeta.cwe.map((cweId) => {
41031
+ const id = cweNumber(cweId);
41032
+ cweIds.add(id);
41033
+ return {
41034
+ target: { id, toolComponent: { name: "CWE" } },
41035
+ kinds: ["relevant"]
41036
+ };
41037
+ });
41038
+ }
41039
+ const severity = securitySeverity(rule);
41040
+ const hasTags = rule.metadata.tags && rule.metadata.tags.length > 0;
41041
+ const hasCategory = rule.category !== void 0;
41042
+ if (severity !== void 0 || secMeta?.cvssVector || hasTags || hasCategory) {
41043
+ base.properties = {};
41044
+ if (hasCategory) {
41045
+ base.properties.category = rule.category;
41046
+ }
41047
+ if (severity !== void 0) {
41048
+ base.properties["security-severity"] = severity;
41049
+ }
41050
+ if (secMeta?.cvssVector) {
41051
+ base.properties["cvss-vector"] = secMeta.cvssVector;
41052
+ }
41053
+ if (hasTags) {
41054
+ base.properties.tags = rule.metadata.tags.map((t) => t.label);
41055
+ }
41056
+ }
41057
+ return base;
41058
+ }) ?? [];
41059
+ const ruleIndexById = /* @__PURE__ */ new Map();
41060
+ sarifRules.forEach((r, i) => {
41061
+ if (!ruleIndexById.has(r.id)) ruleIndexById.set(r.id, i);
41062
+ });
41063
+ const hasCwe = cweIds.size > 0;
41064
+ const cweTaxonomy = hasCwe ? {
41065
+ name: "CWE",
41066
+ version: "4.13",
41067
+ guid: CWE_GUID,
41068
+ informationUri: "https://cwe.mitre.org/",
41069
+ organization: "MITRE",
41070
+ shortDescription: { text: "Common Weakness Enumeration" },
41071
+ taxa: [...cweIds].sort((a, b) => Number(a) - Number(b) || a.localeCompare(b)).map((id) => ({ id, name: `CWE-${id}` }))
41072
+ } : void 0;
41073
+ const supportedTaxonomies = hasCwe ? [{ name: "CWE", index: 0, guid: CWE_GUID }] : void 0;
41074
+ return { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies };
41075
+ }
41076
+ function buildSarif(results, filePath, rules, options = {}, ipSummary) {
41077
+ const { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies } = buildRulesAndTaxonomy(rules);
41078
+ const sarifResults = buildSarifResults(
41079
+ results,
41080
+ filePath,
41081
+ options.sourceText,
41082
+ ruleIndexById,
41083
+ options,
41084
+ options.suppressed
41085
+ );
41086
+ const report = {
41087
+ version: "2.1.0",
41088
+ $schema: "https://json.schemastore.org/sarif-2.1.0.json",
41089
+ runs: [
41090
+ {
41091
+ tool: {
41092
+ driver: {
41093
+ name: "Sentriflow",
41094
+ version: TOOL_VERSION,
41095
+ informationUri: "https://github.com/sentriflow/sentriflow",
41096
+ rules: sarifRules,
41097
+ ...supportedTaxonomies && { supportedTaxonomies }
41098
+ }
41099
+ },
41100
+ ...cweTaxonomy && { taxonomies: [cweTaxonomy] },
41101
+ results: sarifResults,
41102
+ // Include IP summary in properties if available
41103
+ ...ipSummary && {
41104
+ properties: {
41105
+ ipSummary
41106
+ }
41107
+ }
41108
+ }
41109
+ ]
41110
+ };
41111
+ return report;
41112
+ }
41113
+ function aggregateIPSummaries(summaries) {
41114
+ if (summaries.length === 0) return void 0;
41115
+ const ipv4Set = /* @__PURE__ */ new Set();
41116
+ const ipv6Set = /* @__PURE__ */ new Set();
41117
+ const ipv4SubnetSet = /* @__PURE__ */ new Set();
41118
+ const ipv6SubnetSet = /* @__PURE__ */ new Set();
41119
+ for (const summary of summaries) {
41120
+ for (const ip of summary.ipv4Addresses) ipv4Set.add(ip);
41121
+ for (const ip of summary.ipv6Addresses) ipv6Set.add(ip);
41122
+ for (const subnet of summary.ipv4Subnets) ipv4SubnetSet.add(subnet);
41123
+ for (const subnet of summary.ipv6Subnets) ipv6SubnetSet.add(subnet);
41124
+ }
41125
+ const ipv4Addresses = [...ipv4Set].sort((a, b) => {
41126
+ const aParts = a.split(".").map(Number);
41127
+ const bParts = b.split(".").map(Number);
41128
+ for (let i = 0; i < 4; i++) {
41129
+ if ((aParts[i] ?? 0) !== (bParts[i] ?? 0)) {
41130
+ return (aParts[i] ?? 0) - (bParts[i] ?? 0);
41131
+ }
41132
+ }
41133
+ return 0;
41134
+ });
41135
+ const ipv6Addresses = [...ipv6Set].sort();
41136
+ const ipv4Subnets = [...ipv4SubnetSet].sort();
41137
+ const ipv6Subnets = [...ipv6SubnetSet].sort();
41138
+ return {
41139
+ ipv4Addresses,
41140
+ ipv6Addresses,
41141
+ ipv4Subnets,
41142
+ ipv6Subnets,
41143
+ counts: {
41144
+ ipv4: ipv4Addresses.length,
41145
+ ipv6: ipv6Addresses.length,
41146
+ ipv4Subnets: ipv4Subnets.length,
41147
+ ipv6Subnets: ipv6Subnets.length,
41148
+ total: ipv4Addresses.length + ipv6Addresses.length + ipv4Subnets.length + ipv6Subnets.length
41149
+ }
41150
+ };
41151
+ }
41152
+ function buildMultiFileSarif(fileResults, rules, options = {}) {
41153
+ const aggregatedIpSummary = aggregateIPSummaries(
41154
+ fileResults.map((fr) => fr.ipSummary).filter((s) => !!s)
41155
+ );
41156
+ const { sarifRules, ruleIndexById, cweTaxonomy, supportedTaxonomies } = buildRulesAndTaxonomy(rules);
41157
+ const allSarifResults = fileResults.flatMap(
41158
+ ({ filePath, results, content, suppressed }) => buildSarifResults(results, filePath, content, ruleIndexById, options, suppressed)
41159
+ );
41160
+ const skippedNotifications = fileResults.filter((fr) => fr.skipped).map((fr) => ({
41161
+ level: "error",
41162
+ message: {
41163
+ text: `Skipped ${options.relativePaths ? relative(options.baseDir ?? process.cwd(), fr.filePath) : fr.filePath}: ${fr.skipped?.reason ?? "not scanned"}. Re-run with --vendor <vendor>.`
41164
+ }
41165
+ }));
41166
+ const artifactUris = [
41167
+ ...new Set(
41168
+ fileResults.map(
41169
+ ({ filePath }) => options.relativePaths ? relative(options.baseDir ?? process.cwd(), filePath) : filePath
41170
+ )
41171
+ )
41172
+ ];
41173
+ const report = {
41174
+ version: "2.1.0",
41175
+ $schema: "https://json.schemastore.org/sarif-2.1.0.json",
41176
+ runs: [
41177
+ {
41178
+ tool: {
41179
+ driver: {
41180
+ name: "Sentriflow",
41181
+ version: TOOL_VERSION,
41182
+ informationUri: "https://github.com/sentriflow/sentriflow",
41183
+ rules: sarifRules,
41184
+ ...supportedTaxonomies && { supportedTaxonomies }
41185
+ }
41186
+ },
41187
+ // Include artifacts array for multi-file reports
41188
+ artifacts: artifactUris.map((uri) => ({
41189
+ location: { uri }
41190
+ })),
41191
+ ...cweTaxonomy && { taxonomies: [cweTaxonomy] },
41192
+ results: allSarifResults,
41193
+ ...skippedNotifications.length > 0 && {
41194
+ invocations: [
41195
+ {
41196
+ executionSuccessful: false,
41197
+ toolExecutionNotifications: skippedNotifications
41198
+ }
41199
+ ]
41200
+ },
41201
+ // Include aggregated IP summary in properties if available
41202
+ ...aggregatedIpSummary && {
41203
+ properties: {
41204
+ ipSummary: aggregatedIpSummary
41205
+ }
41206
+ }
41207
+ }
41208
+ ]
41209
+ };
41210
+ return report;
41211
+ }
41212
+
41213
+ // src/human.ts
41214
+ var COLORS = {
41215
+ red: "\x1B[31m",
41216
+ yellow: "\x1B[33m",
41217
+ blue: "\x1B[34m",
41218
+ gray: "\x1B[90m",
41219
+ bold: "\x1B[1m",
41220
+ reset: "\x1B[0m"
41221
+ };
41222
+ var SEVERITY_COLORS = {
41223
+ error: COLORS.red,
41224
+ warning: COLORS.yellow,
41225
+ info: COLORS.blue
41226
+ };
41227
+ function countSeverities(results) {
41228
+ const counts = { error: 0, warning: 0, info: 0, total: 0 };
41229
+ for (const r of results) {
41230
+ if (!r.passed) {
41231
+ if (r.level === "error" || r.level === "warning" || r.level === "info") {
41232
+ counts[r.level]++;
41233
+ }
41234
+ counts.total++;
41235
+ }
41236
+ }
41237
+ return counts;
41238
+ }
41239
+ function formatFinding(result2, color) {
41240
+ const line = result2.loc ? result2.loc.startLine + 1 : 0;
41241
+ const col = 1;
41242
+ const location = `${line}:${col}`.padEnd(8);
41243
+ const severityColor = color ? SEVERITY_COLORS[result2.level] ?? "" : "";
41244
+ const reset = color ? COLORS.reset : "";
41245
+ const severityText = result2.level.padEnd(7);
41246
+ const severity = `${severityColor}${severityText}${reset}`;
41247
+ const ruleColor = color ? COLORS.gray : "";
41248
+ const ruleId = `${ruleColor}${result2.ruleId}${reset}`;
41249
+ return ` ${location} ${severity} ${result2.message} ${ruleId}`;
41250
+ }
41251
+ function formatSummary(counts, color) {
41252
+ if (counts.total === 0) {
41253
+ const check = color ? `${COLORS.bold}\u2714${COLORS.reset}` : "\u2714";
41254
+ return `
41255
+ ${check} No problems found
41256
+ `;
41257
+ }
41258
+ const x = color ? `${COLORS.red}\u2716${COLORS.reset}` : "\u2716";
41259
+ const parts = [];
41260
+ if (counts.error > 0) {
41261
+ parts.push(`${counts.error} error${counts.error !== 1 ? "s" : ""}`);
41262
+ }
41263
+ if (counts.warning > 0) {
41264
+ parts.push(`${counts.warning} warning${counts.warning !== 1 ? "s" : ""}`);
41265
+ }
41266
+ if (counts.info > 0) {
41267
+ parts.push(`${counts.info} info`);
41268
+ }
41269
+ const problemText = counts.total === 1 ? "problem" : "problems";
41270
+ return `
41271
+ ${x} ${counts.total} ${problemText} (${parts.join(", ")})
41272
+ `;
41273
+ }
41274
+ function formatHuman(results, filePath, options) {
41275
+ const color = options?.color ?? false;
41276
+ const failures = results.filter((r) => !r.passed);
41277
+ const lines = [];
41278
+ const header = color ? `${COLORS.bold}${filePath}${COLORS.reset}` : filePath;
41279
+ lines.push(header);
41280
+ for (const result2 of failures) {
41281
+ lines.push(formatFinding(result2, color));
41282
+ }
41283
+ const counts = countSeverities(results);
41284
+ lines.push(formatSummary(counts, color));
41285
+ return lines.join("\n");
41286
+ }
41287
+ function formatMultiFileHuman(files, options) {
41288
+ const color = options?.color ?? false;
41289
+ const lines = [];
41290
+ const totalCounts = { error: 0, warning: 0, info: 0, total: 0 };
41291
+ for (const { file, results } of files) {
41292
+ const failures = results.filter((r) => !r.passed);
41293
+ if (failures.length === 0) continue;
41294
+ const header = color ? `${COLORS.bold}${file}${COLORS.reset}` : file;
41295
+ lines.push(header);
41296
+ for (const result2 of failures) {
41297
+ lines.push(formatFinding(result2, color));
41298
+ }
41299
+ lines.push("");
41300
+ const counts = countSeverities(results);
41301
+ totalCounts.error += counts.error;
41302
+ totalCounts.warning += counts.warning;
41303
+ totalCounts.info += counts.info;
41304
+ totalCounts.total += counts.total;
41305
+ }
41306
+ lines.push(formatSummary(totalCounts, color));
41307
+ return lines.join("\n");
41308
+ }
41309
+
41310
+ // src/parseWarnings.ts
41311
+ function formatParseWarnings(warnings, source) {
41312
+ return warnings.map((warning) => `Warning: ${source}: ${warning.message}`);
41313
+ }
41314
+
40626
41315
  // src/config.ts
40627
41316
  import { existsSync as existsSync2 } from "fs";
40628
41317
  import { readFile as readFileAsync } from "fs/promises";
@@ -42659,7 +43348,7 @@ async function exitIfVendorUndetected() {
42659
43348
  }
42660
43349
  }
42661
43350
  var program = new Command2();
42662
- var cliVersion = resolveVersion(true ? "0.10.0" : void 0);
43351
+ var cliVersion = resolveVersion(true ? "0.11.0-rc.2" : void 0);
42663
43352
  var pluginPackLoaders = [];
42664
43353
  var pluginRequests = pluginRequestsFromEnv(process.env);
42665
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(