@sentriflow/cli 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -3
  2. package/dist/index.js +41 -73
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -127,11 +127,11 @@ JSON and SARIF output include an `ipSummary` of the IP addresses and subnets fou
127
127
 
128
128
  A rule source you name must load, or the CLI prints the reason and exits with code 2 before scanning: a `--pack`, `--json-rules` or `--rules` entry that is missing, invalid or unsafe, and the `rules`, `rulePacks` and `jsonRules` entries of a config file.
129
129
 
130
- The CLI loads plain JS/TS rule packs. Encrypted pack files (`.grx2`, `.grpx`) are rejected with `unsupported pack format (encrypted packs need the SentriFlow licensing plugin)` and exit code 2, unless a plugin has registered a loader for them.
130
+ The CLI loads plain JS/TS rule packs (`.js`, `.ts`, `.mjs`, `.cjs`). Any other pack file is rejected with `unsupported pack format: <file>` and exit code 2, unless a plugin has registered a loader for it.
131
131
 
132
- Plugins are ES modules the CLI imports before parsing the command line: `@sentriflow/licensing/cli` if it is installed, plus any listed in `SENTRIFLOW_PLUGINS` (comma-separated package names or file paths). A plugin exports `registerCommands(program, context)`; it may add commands and options to `program` and call `context.registerPackLoader({ name, canLoad, load })` to handle extra pack formats. Plugins are trusted code. The contract is documented in [`src/plugins.ts`](src/plugins.ts).
132
+ Plugins are ES modules the CLI imports before parsing the command line, only from `SENTRIFLOW_PLUGINS` (comma-separated package names or file paths); no plugin is loaded when it is unset. A plugin exports `registerCommands(program, context)`; it may add commands and options to `program` and call `context.registerPackLoader({ name, canLoad, load })` to handle extra pack formats. Plugins are trusted code. The contract is documented in [`src/plugins.ts`](src/plugins.ts).
133
133
 
134
- A plugin that fails to load stops the run with exit code 2 and a message such as `Failed to load plugin './my-plugin.js': <reason>`, naming the plugin as written in `SENTRIFLOW_PLUGINS`. This includes `@sentriflow/licensing/cli` when it is installed but throws on load; when it is not installed, the CLI says nothing.
134
+ A plugin that fails to load stops the run with exit code 2 and a message such as `Failed to load plugin './my-plugin.js': <reason>`, naming the plugin as written in `SENTRIFLOW_PLUGINS`.
135
135
 
136
136
  ### Directory Scanning
137
137
 
package/dist/index.js CHANGED
@@ -202,7 +202,7 @@ var JuniperJunOSSchema = {
202
202
  /^#/,
203
203
  /^\/\*.*\*\/$/,
204
204
  /^inactive:/,
205
- // CLI context captured with `show configuration` output (gecko#43): the
205
+ // CLI context captured with `show configuration` output: the
206
206
  // routing-engine, Virtual Chassis member or cluster-node state printed
207
207
  // above the prompt (`{master:0}`, `{backup}`, `{primary:node0}`,
208
208
  // `{master:member0-re0}`), optionally followed by the configuration-mode
@@ -735,7 +735,7 @@ var PaloAltoPANOSSchema = {
735
735
  // Block comments
736
736
  /^!.*$/,
737
737
  // Exclamation comments (some CLI modes)
738
- // CLI output captured with the configuration (gecko#43): the
738
+ // CLI output captured with the configuration: the
739
739
  // configuration-mode path (`[edit]`) and the prompt
740
740
  // (`admin@fw1>`, `admin@fw1(active-secondary)#`)
741
741
  /^\[edit(?:\s[^\]]*)?\]$/,
@@ -967,14 +967,14 @@ var AristaEOSSchema = {
967
967
  // Only at the top level: indented under a section the same words are
968
968
  // sub-commands (`spanning-tree portfast`, `lldp receive`, `ip pim
969
969
  // sparse-mode`, `mpls ip` under an interface; `bfd default` under a
970
- // router; `interface disabled default` under mpls ldp) (gecko#83)
970
+ // router; `interface disabled default` under mpls ldp)
971
971
  // Interface blocks (all interface types)
972
972
  { pattern: /^interface\s+\S+/i, depth: 0, parents: [] },
973
973
  // Routing protocols
974
974
  { pattern: /^router\s+(?!router-id)\S+/i, depth: 0, parents: [] },
975
975
  // VLAN configuration. Under router bgp, "vlan N" opens a MAC-VRF and
976
976
  // "vlan-aware-bundle" a bundle of them; inside a bundle "vlan 10-20"
977
- // only lists its VLANs (gecko#83)
977
+ // only lists its VLANs
978
978
  { pattern: /^vlan\s+\d+/i, depth: 0, parents: [] },
979
979
  { pattern: /^vlan\s+\d+$/i, depth: 1, parents: [/^router\s+bgp\b/i] },
980
980
  { pattern: /^vlan-aware-bundle\s+\S+/i, depth: 1, parents: [/^router\s+bgp\b/i] },
@@ -1069,7 +1069,7 @@ var AristaEOSSchema = {
1069
1069
  { pattern: /^ntp\s+\S+/i, depth: 0, parents: [] },
1070
1070
  // ============ DEPTH 1: Inside routing protocols ============
1071
1071
  // EOS has no neighbor, network or redistribute sub-mode: those lines are
1072
- // commands at every level, so they must not close a section (gecko#83)
1072
+ // commands at every level, so they must not close a section
1073
1073
  { pattern: /^address-family\s+\S+/i, depth: 1 },
1074
1074
  // A vrf sub-mode exists under router bgp (and other routers) and the
1075
1075
  // management services; under an interface `vrf X` only assigns the VRF
@@ -2429,7 +2429,6 @@ var MAX_LINE_COUNT = 1e5;
2429
2429
  var ALLOWED_CONFIG_EXTENSIONS = [".js", ".ts", ".mjs", ".cjs"];
2430
2430
  var ALLOWED_JSON_RULES_EXTENSIONS = [".json"];
2431
2431
  var MAX_CONFIG_FILE_SIZE = 1024 * 1024;
2432
- var MAX_ENCRYPTED_PACK_SIZE = 5 * 1024 * 1024;
2433
2432
  var RULE_PER_NODE_TIMEOUT_MS = 100;
2434
2433
  var RULE_ID_PATTERN = /^[A-Z][A-Z0-9_-]{2,49}$/;
2435
2434
  var MAX_PATTERN_LENGTH = 500;
@@ -7347,7 +7346,7 @@ var RuleEngine = class {
7347
7346
  /**
7348
7347
  * Run rules against nodes using the index for fast lookup.
7349
7348
  *
7350
- * Every result leaves the engine with its secrets masked (gecko#85): the
7349
+ * Every result leaves the engine with its secrets masked: the
7351
7350
  * nodeId as a configuration line (`maskSecretText`), and the nodeId,
7352
7351
  * message and remediation by the secret values of the lines the result
7353
7352
  * reports on (the checked node, the nodes on the result's line, its
@@ -22279,7 +22278,7 @@ var allCiscoRules = [
22279
22278
  EnableSecretStrong,
22280
22279
  CiscoNoPlaintextPasswords,
22281
22280
  CiscoNoPlaintextUsernamePasswords,
22282
- // Ported from the former commercial set (decision 0001 S3a)
22281
+ // Ported rules
22283
22282
  CiscoSshVersion2,
22284
22283
  NxosTelnetFeature,
22285
22284
  CiscoLoginBannerNoDisclosure,
@@ -22295,16 +22294,16 @@ var allCiscoRules = [
22295
22294
  CiscoWanNoIpUnreachables,
22296
22295
  CiscoWanNoProxyArp,
22297
22296
  CiscoNoDirectedBroadcast,
22298
- // Paid-only rules opened (gecko#60)
22297
+ // More ported rules
22299
22298
  CiscoSnmpNoDefaultCommunity,
22300
22299
  CiscoHsrpMd5Authentication,
22301
- // Reference rules on the symbol table (gecko#59, experimental)
22300
+ // Reference rules on the symbol table
22302
22301
  CiscoUndefinedFilterAcl,
22303
22302
  CiscoUndefinedAclReference,
22304
22303
  CiscoUndefinedRouteMap,
22305
22304
  CiscoUndefinedPrefixList,
22306
22305
  CiscoUnusedObject,
22307
- // Secret storage (gecko#60)
22306
+ // Secret storage
22308
22307
  CiscoSecretStorage,
22309
22308
  NxosSecretStorage
22310
22309
  ];
@@ -24367,7 +24366,7 @@ var allJuniperRules = [
24367
24366
  JunosFirewallDefaultDeny,
24368
24367
  JunosSnmpNoCommunity,
24369
24368
  JunosLldpExternal,
24370
- // Ported from the former commercial set (decision 0001 S3b)
24369
+ // Ported rules
24371
24370
  JunosInsecureServices,
24372
24371
  JunosSshRootLogin,
24373
24372
  JunosAaaRequired,
@@ -24393,7 +24392,7 @@ var allJuniperRules = [
24393
24392
  JunosFlowMonitoring,
24394
24393
  JunosNonstopRouting,
24395
24394
  JunosSecretStorage,
24396
- // Paid-only rules opened (gecko#60)
24395
+ // More ported rules
24397
24396
  JunosOspfInterfaceAuth,
24398
24397
  JunosIcmpRateLimit,
24399
24398
  JunosBgpTtlSecurity,
@@ -24831,7 +24830,7 @@ var allArubaCommonRules = [
24831
24830
  AaaConfigured,
24832
24831
  RadiusKeyConfigured,
24833
24832
  TacacsKeyConfigured,
24834
- // Ported from the former commercial set (decision 0001 S3b)
24833
+ // Ported rules
24835
24834
  AaaAccountingEnabled
24836
24835
  ];
24837
24836
 
@@ -26013,7 +26012,7 @@ var allAosCxRules = [
26013
26012
  AosCxOspfRouterId,
26014
26013
  AosCxBgpRouterId,
26015
26014
  AosCxLagLacp,
26016
- // Ported from the former commercial set (decision 0001 S3b)
26015
+ // Ported rules
26017
26016
  AosCxUsbDisabled,
26018
26017
  AosCxPasswordComplexity,
26019
26018
  AosCxHostname,
@@ -26528,9 +26527,9 @@ var allAosSwitchRules = [
26528
26527
  AosSwitchMgmtVlanIp,
26529
26528
  AosSwitchConsoleTimeout,
26530
26529
  AosSwitchTimesync,
26531
- // Ported from the former commercial set (decision 0001 S3b)
26530
+ // Ported rules
26532
26531
  HttpDisabled,
26533
- // Secret storage (gecko#60)
26532
+ // Secret storage
26534
26533
  AosSwitchSecretStorage
26535
26534
  ];
26536
26535
 
@@ -27187,7 +27186,7 @@ var allWlcRules = [
27187
27186
  WlcApGroupRegDomain,
27188
27187
  WlcArmProfile,
27189
27188
  WlcRadioArmProfile,
27190
- // Ported from the former commercial set (decision 0001 S3b)
27189
+ // Ported rules
27191
27190
  WlcCpsecEnabled,
27192
27191
  WlcUserRoleFirewall,
27193
27192
  WlcSsidLimit,
@@ -28758,7 +28757,7 @@ var allPaloAltoRules = [
28758
28757
  NatRuleDescription,
28759
28758
  HARecommended,
28760
28759
  VirtualRouterDefaultRoute,
28761
- // Ported from the former commercial set (decision 0001 S3b)
28760
+ // Ported rules
28762
28761
  PasswordComplexityRequired,
28763
28762
  SnmpSecurityRequired,
28764
28763
  InterfaceManagementSecure,
@@ -30835,7 +30834,7 @@ var allAristaRules = [
30835
30834
  AaaConfigured2,
30836
30835
  ManagementSshEnabled,
30837
30836
  VrfDescription,
30838
- // Ported from the former commercial set (decision 0001 S3a)
30837
+ // Ported rules
30839
30838
  EosUsernamePasswordEncryption,
30840
30839
  EosEnableSecretEncryption,
30841
30840
  EosHttpServerDisabled,
@@ -30871,7 +30870,7 @@ var allAristaRules = [
30871
30870
  EosVrrpAuthentication,
30872
30871
  EosVirtualRouterMac,
30873
30872
  EosSecretStorage,
30874
- // Paid-only rules opened (gecko#60)
30873
+ // More ported rules
30875
30874
  EosEapiHttpWithHttps
30876
30875
  ];
30877
30876
 
@@ -35062,7 +35061,7 @@ var allExosRules = [
35062
35061
  ExosEapsControlVlan,
35063
35062
  ExosStackingPriority,
35064
35063
  ExosMlagIsc,
35065
- // Ported from the former commercial set (decision 0001 S3b)
35064
+ // Ported rules
35066
35065
  ExosIdleTimeout,
35067
35066
  ExosSnmpv3UserSecurity,
35068
35067
  ExosSnmpV1V2cDisabled,
@@ -36463,7 +36462,7 @@ var allVossRules = [
36463
36462
  VossIsisEnabled,
36464
36463
  VossIsisSpbm,
36465
36464
  VossDvrDomainId,
36466
- // Ported from the former commercial set (decision 0001 S3b)
36465
+ // Ported rules
36467
36466
  VossTelnetDisabled,
36468
36467
  VossCliTimeout,
36469
36468
  VossWebServerSecure,
@@ -38337,7 +38336,7 @@ var allHuaweiRules = [
38337
38336
  SyslogServerRequired,
38338
38337
  SshServerEnabled,
38339
38338
  TelnetDisabled2,
38340
- // Ported from the former commercial set (decision 0001 S3b)
38339
+ // Ported rules
38341
38340
  BgpPeerAuthenticationRequired,
38342
38341
  BgpPeerGtsmRequired,
38343
38342
  BgpPeerMaxPrefixRequired,
@@ -42168,7 +42167,7 @@ var allNokiaRules = [
42168
42167
  LagDescriptionRequired,
42169
42168
  LagAdminStateRequired,
42170
42169
  LogConfigured,
42171
- // Ported from the former commercial set (decision 0001 S3b)
42170
+ // Ported rules
42172
42171
  AaaWithTacacsRequired,
42173
42172
  SshV2Required,
42174
42173
  SnmpV3Required,
@@ -43662,7 +43661,7 @@ var allCumulusRules = [
43662
43661
  CumulusNcluCommit,
43663
43662
  CumulusNvueApply,
43664
43663
  CumulusLoopbackAddress,
43665
- // Ported from the former commercial set (decision 0001 S3b)
43664
+ // Ported rules
43666
43665
  CumulusManagementVrf,
43667
43666
  CumulusUplinkMtu,
43668
43667
  CumulusRootGuard,
@@ -44198,7 +44197,7 @@ function resolveVersion(injected) {
44198
44197
 
44199
44198
  // src/sarif.ts
44200
44199
  var TOOL_VERSION = resolveVersion(
44201
- true ? "0.11.0" : void 0
44200
+ true ? "0.12.0" : void 0
44202
44201
  );
44203
44202
  var CWE_GUID = "1A0F2A4E-3B93-4C4E-8CC7-9A4E3A5B9A3A";
44204
44203
  function cweNumber(cweId) {
@@ -44731,12 +44730,13 @@ function validateInputFilePath(filePath, maxSize = 10 * 1024 * 1024, baseDirs) {
44731
44730
  mustExist: true
44732
44731
  });
44733
44732
  }
44733
+ var MAX_PACK_FILE_SIZE = 5 * 1024 * 1024;
44734
44734
  function validatePackPath(packPath, baseDirs) {
44735
44735
  return validatePath(packPath, {
44736
44736
  allowedBaseDirs: baseDirs,
44737
44737
  allowedExtensions: [],
44738
- // Allow any extension - format detected via magic bytes
44739
- maxFileSize: MAX_ENCRYPTED_PACK_SIZE,
44738
+ // Any extension: the caller checks the format
44739
+ maxFileSize: MAX_PACK_FILE_SIZE,
44740
44740
  mustExist: true
44741
44741
  });
44742
44742
  }
@@ -44772,22 +44772,14 @@ function describeLoadError(error, fallback) {
44772
44772
  }
44773
44773
 
44774
44774
  // src/loaders/pack-detector.ts
44775
- var UNENCRYPTED_PACK_PRIORITY = 100;
44776
- var UNSUPPORTED_PACK_FORMAT_MESSAGE = "unsupported pack format (encrypted packs need the SentriFlow licensing plugin)";
44775
+ var PLAIN_PACK_PRIORITY = 100;
44776
+ var UNSUPPORTED_PACK_FORMAT_MESSAGE = "unsupported pack format";
44777
44777
  var UnsupportedPackFormatError = class extends SentriflowConfigError {
44778
44778
  constructor(filePath) {
44779
44779
  super(`${UNSUPPORTED_PACK_FORMAT_MESSAGE}: ${redactPath(filePath)}`, { filePath });
44780
44780
  this.name = "UnsupportedPackFormatError";
44781
44781
  }
44782
44782
  };
44783
- var MAGIC = [
44784
- ["GRX2", "grx2"],
44785
- ["GRPX", "grpx"]
44786
- ];
44787
- var EXTENSIONS = {
44788
- ".grx2": "grx2",
44789
- ".grpx": "grpx"
44790
- };
44791
44783
  async function readPackHeader(filePath, length) {
44792
44784
  let handle;
44793
44785
  try {
@@ -44804,15 +44796,8 @@ async function readPackHeader(filePath, length) {
44804
44796
  await handle?.close();
44805
44797
  }
44806
44798
  }
44807
- function detectPackFormat(filePath, header) {
44808
- const magic = Buffer.from(header.subarray(0, 4)).toString("latin1");
44809
- for (const [bytes, format2] of MAGIC) {
44810
- if (magic === bytes) return format2;
44811
- }
44812
- return EXTENSIONS[extname2(filePath).toLowerCase()] ?? "unencrypted";
44813
- }
44814
- function isEncryptedPackFormat(format2) {
44815
- return format2 !== "unencrypted";
44799
+ function isPlainPackFile(filePath) {
44800
+ return ALLOWED_CONFIG_EXTENSIONS.includes(extname2(filePath).toLowerCase());
44816
44801
  }
44817
44802
 
44818
44803
  // src/loaders/index.ts
@@ -44857,7 +44842,6 @@ import { resolve as resolve2, isAbsolute as isAbsolute2 } from "path";
44857
44842
  import { fileURLToPath, pathToFileURL } from "url";
44858
44843
  var PACK_HEADER_BYTES = 16;
44859
44844
  var DEFAULT_PLUGIN_PACK_PRIORITY = 300;
44860
- var DEFAULT_PLUGIN_MODULES = ["@sentriflow/licensing/cli"];
44861
44845
  var PLUGINS_ENV_VAR = "SENTRIFLOW_PLUGINS";
44862
44846
  function pluginRequestsFromEnv(env, cwd = process.cwd()) {
44863
44847
  const raw = env[PLUGINS_ENV_VAR];
@@ -44876,12 +44860,6 @@ function pluginLabel(request) {
44876
44860
  return redactPath(request);
44877
44861
  }
44878
44862
  }
44879
- function isModuleNotFound(error, specifier) {
44880
- if (!(error instanceof Error)) return false;
44881
- const code = error.code;
44882
- const notFound = code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND" || error.message.includes("Cannot find module") || error.message.includes("Cannot find package");
44883
- return notFound && error.message.includes(specifier.split("/").slice(0, 2).join("/"));
44884
- }
44885
44863
  function isPluginModule(value2) {
44886
44864
  if (typeof value2 !== "object" || value2 === null) return false;
44887
44865
  const register = value2.registerCommands;
@@ -44898,7 +44876,6 @@ var PluginLoadError = class extends Error {
44898
44876
  async function loadPlugins(program2, options) {
44899
44877
  const {
44900
44878
  cliVersion: cliVersion2,
44901
- optionalModules = DEFAULT_PLUGIN_MODULES,
44902
44879
  requestedModules = [],
44903
44880
  importer = (specifier) => import(
44904
44881
  /* @vite-ignore */
@@ -44915,19 +44892,11 @@ async function loadPlugins(program2, options) {
44915
44892
  loaders.push(loader);
44916
44893
  }
44917
44894
  };
44918
- const entries = [
44919
- ...optionalModules.map((specifier) => ({
44920
- specifier,
44921
- label: pluginLabel(specifier),
44922
- optional: true
44923
- })),
44924
- ...requestedModules.map((request) => ({
44925
- specifier: typeof request === "string" ? request : request.specifier,
44926
- label: pluginLabel(request),
44927
- optional: false
44928
- }))
44929
- ];
44930
- for (const { specifier, label, optional } of entries) {
44895
+ const entries = requestedModules.map((request) => ({
44896
+ specifier: typeof request === "string" ? request : request.specifier,
44897
+ label: pluginLabel(request)
44898
+ }));
44899
+ for (const { specifier, label } of entries) {
44931
44900
  try {
44932
44901
  const mod = await importer(specifier);
44933
44902
  if (!isPluginModule(mod)) {
@@ -44935,7 +44904,6 @@ async function loadPlugins(program2, options) {
44935
44904
  }
44936
44905
  await mod.registerCommands?.(program2, context);
44937
44906
  } catch (error) {
44938
- if (optional && isModuleNotFound(error, specifier)) continue;
44939
44907
  const message = describeLoadError(error, String(error));
44940
44908
  throw new PluginLoadError(specifier, message, label);
44941
44909
  }
@@ -45344,11 +45312,11 @@ async function resolveRules(options = {}) {
45344
45312
  }
45345
45313
  loadedPack = pack;
45346
45314
  loadedPack.priority = (pluginLoader.basePriority ?? DEFAULT_PLUGIN_PACK_PRIORITY) + i;
45347
- } else if (isEncryptedPackFormat(detectPackFormat(canonicalPath, header))) {
45315
+ } else if (!isPlainPackFile(canonicalPath)) {
45348
45316
  throw new UnsupportedPackFormatError(canonicalPath);
45349
45317
  } else {
45350
45318
  loadedPack = await loadRulePackFile(canonicalPath, allowedBaseDirs);
45351
- loadedPack.priority = UNENCRYPTED_PACK_PRIORITY + i;
45319
+ loadedPack.priority = PLAIN_PACK_PRIORITY + i;
45352
45320
  }
45353
45321
  allPacks.push(loadedPack);
45354
45322
  loadedCount++;
@@ -46736,7 +46704,7 @@ async function exitIfVendorUndetected() {
46736
46704
  }
46737
46705
  }
46738
46706
  var program = new Command2();
46739
- var cliVersion = resolveVersion(true ? "0.11.0" : void 0);
46707
+ var cliVersion = resolveVersion(true ? "0.12.0" : void 0);
46740
46708
  var pluginPackLoaders = [];
46741
46709
  var pluginRequests = pluginRequestsFromEnv(process.env);
46742
46710
  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(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentriflow/cli",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "SentriFlow CLI - Network configuration linter and validator",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -40,8 +40,8 @@
40
40
  "commander": "^14.0.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@sentriflow/core": "0.11.0",
44
- "@sentriflow/rules-default": "0.11.0",
43
+ "@sentriflow/core": "0.12.0",
44
+ "@sentriflow/rules-default": "0.12.0",
45
45
  "bun-types": "latest",
46
46
  "esbuild": "^0.27.0"
47
47
  },