@socketsecurity/cli-with-sentry 1.1.19 → 1.1.21

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 (76) hide show
  1. package/CHANGELOG.md +27 -9
  2. package/dist/cli.js +226 -160
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +28 -4
  5. package/dist/constants.js.map +1 -1
  6. package/dist/flags.js +21 -3
  7. package/dist/flags.js.map +1 -1
  8. package/dist/shadow-npm-bin2.js +2 -29
  9. package/dist/shadow-npm-bin2.js.map +1 -1
  10. package/dist/shadow-pnpm-bin2.js +7 -30
  11. package/dist/shadow-pnpm-bin2.js.map +1 -1
  12. package/dist/shadow-yarn-bin.js +9 -28
  13. package/dist/shadow-yarn-bin.js.map +1 -1
  14. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  15. package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
  16. package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
  17. package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
  18. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  19. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  20. package/dist/types/commands/manifest/cmd-manifest.d.mts.map +1 -1
  21. package/dist/types/commands/optimize/handle-optimize.d.mts.map +1 -1
  22. package/dist/types/commands/optimize/ls-by-agent.d.mts.map +1 -1
  23. package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +1 -1
  24. package/dist/types/commands/organization/cmd-organization.d.mts.map +1 -1
  25. package/dist/types/commands/package/cmd-package.d.mts.map +1 -1
  26. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
  27. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
  28. package/dist/types/commands/raw-npm/run-raw-npm.d.mts.map +1 -1
  29. package/dist/types/commands/raw-npx/run-raw-npx.d.mts.map +1 -1
  30. package/dist/types/commands/repository/cmd-repository-create.d.mts.map +1 -1
  31. package/dist/types/commands/repository/cmd-repository-del.d.mts.map +1 -1
  32. package/dist/types/commands/repository/cmd-repository-update.d.mts.map +1 -1
  33. package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -1
  34. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
  35. package/dist/types/commands/scan/cmd-scan-list.d.mts.map +1 -1
  36. package/dist/types/commands/scan/cmd-scan.d.mts.map +1 -1
  37. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  38. package/dist/types/commands/scan/output-diff-scan.d.mts.map +1 -1
  39. package/dist/types/commands/scan/output-scan-view.d.mts.map +1 -1
  40. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  41. package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
  42. package/dist/types/constants.d.mts +6 -1
  43. package/dist/types/constants.d.mts.map +1 -1
  44. package/dist/types/flags.d.mts.map +1 -1
  45. package/dist/types/shadow/npm-base.d.mts.map +1 -1
  46. package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
  47. package/dist/types/shadow/yarn/bin.d.mts.map +1 -1
  48. package/dist/types/test/json-output-validation.d.mts +37 -0
  49. package/dist/types/test/json-output-validation.d.mts.map +1 -0
  50. package/dist/types/test/mocks/socket-auth.d.mts +88 -0
  51. package/dist/types/test/mocks/socket-auth.d.mts.map +1 -0
  52. package/dist/types/utils/agent.d.mts.map +1 -1
  53. package/dist/types/utils/config.d.mts +1 -1
  54. package/dist/types/utils/determine-org-slug.d.mts.map +1 -1
  55. package/dist/types/utils/dlx-binary.d.mts +58 -0
  56. package/dist/types/utils/dlx-binary.d.mts.map +1 -0
  57. package/dist/types/utils/dlx-detection.d.mts +29 -0
  58. package/dist/types/utils/dlx-detection.d.mts.map +1 -0
  59. package/dist/types/utils/meow-with-subcommands.d.mts +33 -12
  60. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  61. package/dist/types/utils/package-environment.d.mts.map +1 -1
  62. package/dist/types/utils/shadow-links.d.mts +5 -0
  63. package/dist/types/utils/shadow-links.d.mts.map +1 -0
  64. package/dist/types/utils/terminal-link.d.mts +52 -0
  65. package/dist/types/utils/terminal-link.d.mts.map +1 -0
  66. package/dist/types/utils/yarn-version.d.mts.map +1 -1
  67. package/dist/utils.js +537 -118
  68. package/dist/utils.js.map +1 -1
  69. package/dist/vendor.js +372 -372
  70. package/package.json +1 -1
  71. package/dist/types/shadow/npm/link.d.mts +0 -2
  72. package/dist/types/shadow/npm/link.d.mts.map +0 -1
  73. package/dist/types/shadow/pnpm/link.d.mts +0 -2
  74. package/dist/types/shadow/pnpm/link.d.mts.map +0 -1
  75. package/dist/types/shadow/yarn/link.d.mts +0 -2
  76. package/dist/types/shadow/yarn/link.d.mts.map +0 -1
package/dist/utils.js CHANGED
@@ -23,9 +23,10 @@ var require$$13 = require('../external/@socketsecurity/registry/lib/url');
23
23
  var agent = require('../external/@socketsecurity/registry/lib/agent');
24
24
  var bin = require('../external/@socketsecurity/registry/lib/bin');
25
25
  var packages = require('../external/@socketsecurity/registry/lib/packages');
26
- var promises = require('node:timers/promises');
26
+ var require$$0 = require('node:url');
27
27
  var globs = require('../external/@socketsecurity/registry/lib/globs');
28
28
  var streams = require('../external/@socketsecurity/registry/lib/streams');
29
+ var promises = require('node:timers/promises');
29
30
 
30
31
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
31
32
  /**
@@ -400,8 +401,8 @@ function getSupportedConfigEntries() {
400
401
  function getSupportedConfigKeys() {
401
402
  return [...supportedConfigKeys];
402
403
  }
403
- function isReadOnlyConfig() {
404
- return _readOnlyConfig;
404
+ function isConfigFromFlag() {
405
+ return _configFromFlag;
405
406
  }
406
407
  function isSensitiveConfigKey(key) {
407
408
  return sensitiveConfigKeyLookup.has(key);
@@ -411,7 +412,7 @@ function isSupportedConfigKey(key) {
411
412
  }
412
413
  let _cachedConfig;
413
414
  // When using --config or SOCKET_CLI_CONFIG, do not persist the config.
414
- let _readOnlyConfig = false;
415
+ let _configFromFlag = false;
415
416
  function overrideCachedConfig(jsonConfig) {
416
417
  require$$9.debugFn('notice', 'override: full config (not stored)');
417
418
  let config;
@@ -429,7 +430,7 @@ function overrideCachedConfig(jsonConfig) {
429
430
  } catch {
430
431
  // Force set an empty config to prevent accidentally using system settings.
431
432
  _cachedConfig = {};
432
- _readOnlyConfig = true;
433
+ _configFromFlag = true;
433
434
  return {
434
435
  ok: false,
435
436
  message: 'Could not parse Config as JSON',
@@ -439,7 +440,7 @@ function overrideCachedConfig(jsonConfig) {
439
440
 
440
441
  // @ts-ignore Override an illegal object.
441
442
  _cachedConfig = config;
442
- _readOnlyConfig = true;
443
+ _configFromFlag = true;
443
444
 
444
445
  // Normalize apiKey to apiToken.
445
446
  if (_cachedConfig['apiKey']) {
@@ -463,7 +464,7 @@ function overrideConfigApiToken(apiToken) {
463
464
  apiToken: String(apiToken)
464
465
  })
465
466
  };
466
- _readOnlyConfig = true;
467
+ _configFromFlag = true;
467
468
  }
468
469
  let _pendingSave = false;
469
470
  function updateConfigValue(configKey, value) {
@@ -488,7 +489,7 @@ function updateConfigValue(configKey, value) {
488
489
  }
489
490
  localConfig[key] = value;
490
491
  }
491
- if (_readOnlyConfig) {
492
+ if (_configFromFlag) {
492
493
  return {
493
494
  ok: true,
494
495
  message: `Config key '${key}' was ${wasDeleted ? 'deleted' : `updated`}`,
@@ -528,7 +529,7 @@ function updateConfigValue(configKey, value) {
528
529
  * - Used for permission validation and help text
529
530
  */
530
531
 
531
- const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
532
+ const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
532
533
  let _requirements;
533
534
  function getRequirements() {
534
535
  if (_requirements === undefined) {
@@ -1230,6 +1231,92 @@ function serializeResultJson(data) {
1230
1231
  }
1231
1232
  }
1232
1233
 
1234
+ /**
1235
+ * Creates a terminal link to a local file.
1236
+ * @param filePath The file path to link to
1237
+ * @param text Optional display text (defaults to the file path itself)
1238
+ * @returns A terminal link to the file
1239
+ */
1240
+ function fileLink(filePath, text) {
1241
+ const absolutePath = path.isAbsolute(filePath) ? filePath : path.resolve(filePath);
1242
+ return vendor.terminalLinkExports(filePath, `file://${absolutePath}`);
1243
+ }
1244
+
1245
+ /**
1246
+ * Creates a terminal link to an email address.
1247
+ * @param email The email address
1248
+ * @param text Optional display text (defaults to the email address itself)
1249
+ * @returns A terminal link to compose an email
1250
+ */
1251
+ function mailtoLink(email, text) {
1252
+ return vendor.terminalLinkExports(email, `mailto:${email}`);
1253
+ }
1254
+
1255
+ /**
1256
+ * Creates a terminal link to the Socket.dev dashboard.
1257
+ * @param path The path within the dashboard (e.g., '/org/YOURORG/alerts')
1258
+ * @param text Optional display text
1259
+ * @returns A terminal link to the Socket.dev dashboard URL
1260
+ */
1261
+ function socketDashboardLink(dashPath, text) {
1262
+ const url = `https://socket.dev/dashboard${dashPath.startsWith('/') ? dashPath : `/${dashPath}`}`;
1263
+ return vendor.terminalLinkExports(text, url);
1264
+ }
1265
+
1266
+ /**
1267
+ * Creates a terminal link to the Socket.dev website.
1268
+ * @param text Display text for the link (defaults to 'Socket.dev')
1269
+ * @param urlPath Optional path to append to the base URL (e.g., '/pricing')
1270
+ * @returns A terminal link to Socket.dev
1271
+ */
1272
+ function socketDevLink(text, urlPath) {
1273
+ return vendor.terminalLinkExports(text ?? 'Socket.dev', `${constants.SOCKET_WEBSITE_URL}${urlPath || ''}`);
1274
+ }
1275
+
1276
+ /**
1277
+ * Creates a terminal link to Socket.dev documentation.
1278
+ * @param docPath The documentation path (e.g., '/docs/api-keys')
1279
+ * @param text Optional display text
1280
+ * @returns A terminal link to the Socket.dev documentation
1281
+ */
1282
+ function socketDocsLink(docPath, text) {
1283
+ const url = `https://docs.socket.dev${docPath.startsWith('/') ? docPath : `/${docPath}`}`;
1284
+ return vendor.terminalLinkExports(text ?? url, url);
1285
+ }
1286
+
1287
+ /**
1288
+ * Creates a terminal link to Socket.dev package page.
1289
+ * @param ecosystem The package ecosystem (e.g., 'npm')
1290
+ * @param packageName The package name
1291
+ * @param version Optional package version or path (e.g., 'files/1.0.0/CHANGELOG.md')
1292
+ * @param text Optional display text
1293
+ * @returns A terminal link to the Socket.dev package page
1294
+ */
1295
+ function socketPackageLink(ecosystem, packageName, version, text) {
1296
+ let url;
1297
+ if (version) {
1298
+ // Check if version contains a path like 'files/1.0.0/CHANGELOG.md'.
1299
+ if (version.includes('/')) {
1300
+ url = `https://socket.dev/${ecosystem}/package/${packageName}/${version}`;
1301
+ } else {
1302
+ url = `https://socket.dev/${ecosystem}/package/${packageName}/overview/${version}`;
1303
+ }
1304
+ } else {
1305
+ url = `https://socket.dev/${ecosystem}/package/${packageName}`;
1306
+ }
1307
+ return vendor.terminalLinkExports(text ?? url, url);
1308
+ }
1309
+
1310
+ /**
1311
+ * Creates a terminal link to a web URL.
1312
+ * @param url The web URL to link to
1313
+ * @param text Optional display text (defaults to the URL itself)
1314
+ * @returns A terminal link to the URL
1315
+ */
1316
+ function webLink(url, text) {
1317
+ return vendor.terminalLinkExports(text ?? url, url);
1318
+ }
1319
+
1233
1320
  function checkCommandInput(outputKind, ...checks) {
1234
1321
  if (checks.every(d => d.test)) {
1235
1322
  return true;
@@ -1466,30 +1553,65 @@ function findBestCommandMatch(input, subcommands, aliases) {
1466
1553
  return bestMatch;
1467
1554
  }
1468
1555
 
1556
+ /**
1557
+ * Determine the origin of the API token.
1558
+ */
1559
+ function getTokenOrigin() {
1560
+ if (constants.default.ENV.SOCKET_CLI_NO_API_TOKEN) {
1561
+ return '';
1562
+ }
1563
+ if (constants.default.ENV.SOCKET_CLI_API_TOKEN) {
1564
+ return '(env)';
1565
+ }
1566
+ const configToken = getConfigValueOrUndef(constants.CONFIG_KEY_API_TOKEN);
1567
+ if (configToken) {
1568
+ return isConfigFromFlag() ? '(--config flag)' : '(config)';
1569
+ }
1570
+ return '';
1571
+ }
1572
+
1469
1573
  /**
1470
1574
  * Generate the ASCII banner header for Socket CLI commands.
1471
1575
  */
1472
- function getAsciiHeader(command, orgFlag) {
1576
+ function getAsciiHeader(command, orgFlag, compactMode = false) {
1473
1577
  // Note: In tests we return <redacted> because otherwise snapshots will fail.
1474
1578
  const {
1475
1579
  REDACTED
1476
1580
  } = constants.default;
1477
1581
  const redacting = constants.default.ENV.VITEST;
1478
- const cliVersion = redacting ? REDACTED : constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
1582
+
1583
+ // Version display: show hash in debug mode, otherwise show semantic version.
1584
+ const fullVersion = constants.default.ENV.INLINED_SOCKET_CLI_VERSION;
1585
+ const versionHash = constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
1586
+ const cliVersion = redacting ? REDACTED : require$$9.isDebug() ? versionHash : `v${fullVersion}`;
1479
1587
  const nodeVersion = redacting ? REDACTED : process.version;
1588
+ const showNodeVersion = require$$9.isDebug();
1480
1589
  const defaultOrg = getConfigValueOrUndef(constants.CONFIG_KEY_DEFAULT_ORG);
1481
- const readOnlyConfig = isReadOnlyConfig() ? '*' : '.';
1482
- const shownToken = redacting ? REDACTED : getVisibleTokenPrefix() || '(not set)';
1590
+ const readOnlyConfig = isConfigFromFlag() ? '*' : '.';
1591
+
1592
+ // Token display with origin indicator.
1593
+ const tokenPrefix = getVisibleTokenPrefix();
1594
+ const tokenOrigin = redacting ? '' : getTokenOrigin();
1595
+ const noApiToken = constants.default.ENV.SOCKET_CLI_NO_API_TOKEN;
1596
+ const shownToken = redacting ? REDACTED : noApiToken ? vendor.yoctocolorsCjsExports.red('(disabled)') : tokenPrefix ? `${vendor.yoctocolorsCjsExports.green(tokenPrefix)}***${tokenOrigin ? ` ${tokenOrigin}` : ''}` : vendor.yoctocolorsCjsExports.yellow('(not set)');
1483
1597
  const relCwd = redacting ? REDACTED : path$1.normalizePath(tildify(process.cwd()));
1484
- // Note: we must redact org when creating snapshots because dev machine probably
1485
- // has a default org set but CI won't. Showing --org is fine either way.
1486
- const orgPart = orgFlag ? `--org: ${orgFlag}` : redacting ? 'org: <redacted>' : defaultOrg ? `default org: ${defaultOrg}` : '(org not set)';
1598
+
1599
+ // Consolidated org display format.
1600
+ const orgPart = redacting ? `org: ${REDACTED}` : orgFlag ? `org: ${vendor.yoctocolorsCjsExports.cyan(orgFlag)} (${constants.FLAG_ORG} flag)` : defaultOrg && defaultOrg !== 'null' ? `org: ${vendor.yoctocolorsCjsExports.cyan(defaultOrg)} (config)` : vendor.yoctocolorsCjsExports.yellow('org: (not set)');
1601
+
1602
+ // Compact mode for CI/automation.
1603
+ if (compactMode) {
1604
+ const compactToken = noApiToken ? '(disabled)' : tokenPrefix ? `${tokenPrefix}***${tokenOrigin ? ` ${tokenOrigin}` : ''}` : '(not set)';
1605
+ const compactOrg = orgFlag || (defaultOrg && defaultOrg !== 'null' ? defaultOrg : '(not set)');
1606
+ return `CLI: ${cliVersion} | cmd: ${command} | org: ${compactOrg} | token: ${compactToken}`;
1607
+ }
1608
+
1487
1609
  // Note: We could draw these with ascii box art instead but I worry about
1488
1610
  // portability and paste-ability. "simple" ascii chars just work.
1489
1611
  const body = `
1490
1612
  _____ _ _ /---------------
1491
- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
1492
- |__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token: ${shownToken}, ${orgPart}
1613
+ | __|___ ___| |_ ___| |_ | ${socketDevLink()} CLI: ${cliVersion}
1614
+ |__ | ${readOnlyConfig} | _| '_| -_| _| | ${showNodeVersion ? `Node: ${nodeVersion}, ` : ''}token: ${shownToken}, ${orgPart}
1493
1615
  |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}
1494
1616
  `.trim();
1495
1617
  // Note: logger will auto-append a newline.
@@ -1534,7 +1656,7 @@ function shouldSuppressBanner(flags) {
1534
1656
  /**
1535
1657
  * Emit the Socket CLI banner to stderr for branding and debugging.
1536
1658
  */
1537
- function emitBanner(name, orgFlag) {
1659
+ function emitBanner(name, orgFlag, compactMode = false) {
1538
1660
  // Print a banner at the top of each command.
1539
1661
  // This helps with brand recognition and marketing.
1540
1662
  // It also helps with debugging since it contains version and command details.
@@ -1543,19 +1665,32 @@ function emitBanner(name, orgFlag) {
1543
1665
  // and pipe the result to other tools. By emitting the banner over stderr
1544
1666
  // you can do something like `socket scan view xyz | jq | process`.
1545
1667
  // The spinner also emits over stderr for example.
1546
- logger.logger.error(getAsciiHeader(name, orgFlag));
1668
+ logger.logger.error(getAsciiHeader(name, orgFlag, compactMode));
1547
1669
  }
1548
1670
 
1549
1671
  /**
1550
1672
  * Main function for handling CLI with subcommands using meow.
1673
+ * @param config Configuration object with name, argv, importMeta, and subcommands.
1674
+ * @param options Optional settings like aliases and defaultSub.
1675
+ * @example
1676
+ * meowWithSubcommands(
1677
+ * { name, argv, importMeta, subcommands },
1678
+ * { aliases, defaultSub }
1679
+ * )
1551
1680
  */
1552
- async function meowWithSubcommands(subcommands, options) {
1681
+ async function meowWithSubcommands(config, options) {
1553
1682
  const {
1554
- aliases = {},
1555
1683
  argv,
1556
- defaultSub,
1557
1684
  importMeta,
1558
1685
  name,
1686
+ subcommands
1687
+ } = {
1688
+ __proto__: null,
1689
+ ...config
1690
+ };
1691
+ const {
1692
+ aliases = {},
1693
+ defaultSub,
1559
1694
  ...additionalOptions
1560
1695
  } = {
1561
1696
  __proto__: null,
@@ -1583,24 +1718,29 @@ async function meowWithSubcommands(subcommands, options) {
1583
1718
  if (!isRootCommand) {
1584
1719
  if (commandOrAliasName?.startsWith('pkg:')) {
1585
1720
  logger.logger.info('Invoking `socket package score`.');
1586
- return await meowWithSubcommands(subcommands, {
1587
- ...options,
1588
- argv: ['package', 'deep', ...argv]
1589
- });
1721
+ return await meowWithSubcommands({
1722
+ name,
1723
+ argv: ['package', 'deep', ...argv],
1724
+ importMeta,
1725
+ subcommands
1726
+ }, options);
1590
1727
  }
1591
1728
  // Support `socket npm/lodash` or whatever as a shorthand, too.
1592
1729
  // Accept any ecosystem and let the remote sort it out.
1593
1730
  if (/^[a-z]+\//.test(commandOrAliasName || '')) {
1594
1731
  logger.logger.info('Invoking `socket package score`.');
1595
- return await meowWithSubcommands(subcommands, {
1596
- ...options,
1597
- argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv]
1598
- });
1732
+ return await meowWithSubcommands({
1733
+ name,
1734
+ argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv],
1735
+ importMeta,
1736
+ subcommands
1737
+ }, options);
1599
1738
  }
1600
1739
  }
1601
1740
  if (isRootCommand) {
1602
- flags$1['help'] = {
1603
- ...flags$1['help'],
1741
+ const hiddenDebugFlag = !require$$9.isDebug();
1742
+ flags$1['compactHeader'] = {
1743
+ ...flags$1['compactHeader'],
1604
1744
  hidden: false
1605
1745
  };
1606
1746
  flags$1['config'] = {
@@ -1611,13 +1751,21 @@ async function meowWithSubcommands(subcommands, options) {
1611
1751
  ...flags$1['dryRun'],
1612
1752
  hidden: false
1613
1753
  };
1754
+ flags$1['help'] = {
1755
+ ...flags$1['help'],
1756
+ hidden: false
1757
+ };
1758
+ flags$1['helpFull'] = {
1759
+ ...flags$1['helpFull'],
1760
+ hidden: false
1761
+ };
1614
1762
  flags$1['maxOldSpaceSize'] = {
1615
1763
  ...flags$1['maxOldSpaceSize'],
1616
- hidden: false
1764
+ hidden: hiddenDebugFlag
1617
1765
  };
1618
1766
  flags$1['maxSemiSpaceSize'] = {
1619
1767
  ...flags$1['maxSemiSpaceSize'],
1620
- hidden: false
1768
+ hidden: hiddenDebugFlag
1621
1769
  };
1622
1770
  flags$1['version'] = {
1623
1771
  ...flags$1['version'],
@@ -1627,6 +1775,7 @@ async function meowWithSubcommands(subcommands, options) {
1627
1775
  delete flags$1['markdown'];
1628
1776
  } else {
1629
1777
  delete flags$1['help'];
1778
+ delete flags$1['helpFull'];
1630
1779
  delete flags$1['version'];
1631
1780
  }
1632
1781
 
@@ -1646,10 +1795,12 @@ async function meowWithSubcommands(subcommands, options) {
1646
1795
  booleanDefault: undefined
1647
1796
  });
1648
1797
  const {
1798
+ compactHeader: compactHeaderFlag,
1649
1799
  config: configFlag,
1650
1800
  org: orgFlag,
1651
1801
  spinner: spinnerFlag
1652
1802
  } = cli1.flags;
1803
+ const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
1653
1804
  const noSpinner = spinnerFlag === false || require$$9.isDebug();
1654
1805
 
1655
1806
  // Use CI spinner style when --no-spinner is passed or debug mode is enabled.
@@ -1680,7 +1831,7 @@ async function meowWithSubcommands(subcommands, options) {
1680
1831
  }
1681
1832
  if (configOverrideResult?.ok === false) {
1682
1833
  if (!shouldSuppressBanner(cli1.flags)) {
1683
- emitBanner(name, orgFlag);
1834
+ emitBanner(name, orgFlag, compactMode);
1684
1835
  // Add newline in stderr.
1685
1836
  logger.logger.error('');
1686
1837
  }
@@ -1717,7 +1868,7 @@ async function meowWithSubcommands(subcommands, options) {
1717
1868
  }
1718
1869
  const lines = ['', 'Usage', ` $ ${name} <command>`];
1719
1870
  if (isRootCommand) {
1720
- lines.push(` $ ${name} scan create --json`, ` $ ${name} package score npm lodash --markdown`);
1871
+ lines.push(` $ ${name} scan create${constants.FLAG_JSON}`, ` $ ${name} package score ${constants.NPM} lodash ${constants.FLAG_MARKDOWN}`);
1721
1872
  }
1722
1873
  lines.push('');
1723
1874
  if (isRootCommand) {
@@ -1790,7 +1941,15 @@ async function meowWithSubcommands(subcommands, options) {
1790
1941
  padName: HELP_PAD_NAME
1791
1942
  })}`);
1792
1943
  if (isRootCommand) {
1793
- lines.push('', 'Environment variables', ' SOCKET_CLI_API_TOKEN Set the Socket API token', ' SOCKET_CLI_CONFIG A JSON stringified Socket configuration object', ' SOCKET_CLI_GITHUB_API_URL Change the base URL for GitHub REST API calls', ' SOCKET_CLI_GIT_USER_EMAIL The git config `user.email` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]@users.noreply.github.com`, ' SOCKET_CLI_GIT_USER_NAME The git config `user.name` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]`, ` SOCKET_CLI_GITHUB_TOKEN A classic or fine-grained ${vendor.terminalLinkExports('GitHub personal access token', 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens')}`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} GITHUB_TOKEN`, ' SOCKET_CLI_NO_API_TOKEN Make the default API token `undefined`', ' SOCKET_CLI_NPM_PATH The absolute location of the npm directory', ' SOCKET_CLI_ORG_SLUG Specify the Socket organization slug', '', ' SOCKET_CLI_ACCEPT_RISKS Accept risks of a Socket wrapped npm/npx run', ' SOCKET_CLI_VIEW_ALL_RISKS View all risks of a Socket wrapped npm/npx run', '', 'Environment variables for development', ' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`, ` if present, else ${constants.API_V0_URL}`, ' SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to', ` ${vendor.terminalLinkExports('http://127.0.0.1:9090', 'https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries')} then all request are passed through that proxy`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy`, ' SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests', ' SOCKET_CLI_DEBUG Enable debug logging in Socket CLI', ` DEBUG Enable debug logging based on the ${vendor.terminalLinkExports('debug', `${constants.SOCKET_WEBSITE_URL}/npm/package/debug`)} package`);
1944
+ // Check if we should show full help with environment variables.
1945
+ const showFullHelp = argv.includes(constants.FLAG_HELP_FULL);
1946
+ if (showFullHelp) {
1947
+ // Show full help with environment variables.
1948
+ lines.push('', 'Environment variables', ' SOCKET_CLI_API_TOKEN Set the Socket API token', ' SOCKET_CLI_CONFIG A JSON stringified Socket configuration object', ' SOCKET_CLI_GITHUB_API_URL Change the base URL for GitHub REST API calls', ' SOCKET_CLI_GIT_USER_EMAIL The git config `user.email` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]@users.noreply.github.com`, ' SOCKET_CLI_GIT_USER_NAME The git config `user.name` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]`, ` SOCKET_CLI_GITHUB_TOKEN A classic or fine-grained ${vendor.terminalLinkExports('GitHub personal access token', 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens')}`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} GITHUB_TOKEN`, ' SOCKET_CLI_NO_API_TOKEN Make the default API token `undefined`', ' SOCKET_CLI_NPM_PATH The absolute location of the npm directory', ' SOCKET_CLI_ORG_SLUG Specify the Socket organization slug', '', ' SOCKET_CLI_ACCEPT_RISKS Accept risks of a Socket wrapped npm/npx run', ' SOCKET_CLI_VIEW_ALL_RISKS View all risks of a Socket wrapped npm/npx run', '', 'Environment variables for development', ' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`, ` if present, else ${constants.API_V0_URL}`, ' SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to', ` ${vendor.terminalLinkExports('http://127.0.0.1:9090', 'https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries')} then all request are passed through that proxy`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy`, ' SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests', ' SOCKET_CLI_DEBUG Enable debug logging in Socket CLI', ` DEBUG Enable debug logging based on the ${socketPackageLink('npm', 'debug', undefined, 'debug')} package`);
1949
+ } else {
1950
+ // Show condensed help with hint about --help-full.
1951
+ lines.push('', 'Environment variables [more...]', ` Use ${vendor.yoctocolorsCjsExports.bold(constants.FLAG_HELP_FULL)} to view all environment variables`);
1952
+ }
1794
1953
  }
1795
1954
 
1796
1955
  // Parse it again. Config overrides should now be applied (may affect help).
@@ -1811,34 +1970,53 @@ async function meowWithSubcommands(subcommands, options) {
1811
1970
  booleanDefault: undefined,
1812
1971
  help: lines.map(l => strings.indentString(l, HELP_INDENT)).join('\n')
1813
1972
  });
1973
+ const {
1974
+ dryRun,
1975
+ help: helpFlag
1976
+ } = cli2.flags;
1814
1977
 
1815
1978
  // ...else we provide basic instructions and help.
1816
1979
  if (!shouldSuppressBanner(cli2.flags)) {
1817
- emitBanner(name, orgFlag);
1980
+ emitBanner(name, orgFlag, compactMode);
1818
1981
  // Meow will add newline so don't add stderr spacing here.
1819
1982
  }
1820
- if (!cli2.flags['help'] && cli2.flags['dryRun']) {
1983
+ if (!helpFlag && dryRun) {
1821
1984
  process.exitCode = 0;
1822
1985
  logger.logger.log(`${constants.default.DRY_RUN_LABEL}: No-op, call a sub-command; ok`);
1823
1986
  } else {
1824
1987
  // When you explicitly request --help, the command should be successful
1825
1988
  // so we exit(0). If we do it because we need more input, we exit(2).
1826
- cli2.showHelp(cli2.flags['help'] ? 0 : 2);
1989
+ cli2.showHelp(helpFlag ? 0 : 2);
1827
1990
  }
1828
1991
  }
1829
-
1830
1992
  /**
1831
1993
  * Create meow CLI instance or exit with help/error (meow will exit immediately
1832
1994
  * if it calls .showHelp()).
1995
+ * @param config Configuration object with argv, config, parentName, and importMeta.
1996
+ * @param options Optional settings like allowUnknownFlags.
1997
+ * @example
1998
+ * meowOrExit(
1999
+ * { argv, config, parentName, importMeta },
2000
+ * { allowUnknownFlags: false }
2001
+ * )
1833
2002
  */
1834
- function meowOrExit({
1835
- allowUnknownFlags = true,
1836
- argv,
1837
- config,
1838
- importMeta,
1839
- parentName
1840
- }) {
1841
- const command = `${parentName} ${config.commandName}`;
2003
+ function meowOrExit(config, options) {
2004
+ const {
2005
+ argv,
2006
+ config: cliConfig,
2007
+ importMeta,
2008
+ parentName
2009
+ } = {
2010
+ __proto__: null,
2011
+ ...config
2012
+ };
2013
+ const {
2014
+ allowUnknownFlags = true
2015
+ } = {
2016
+ __proto__: null,
2017
+ ...options
2018
+ };
2019
+ const command = `${parentName} ${cliConfig.commandName}`;
1842
2020
 
1843
2021
  // This exits if .printHelp() is called either by meow itself or by us.
1844
2022
  const cli = vendor.meow({
@@ -1849,17 +2027,19 @@ function meowOrExit({
1849
2027
  // We want to detect whether a bool flag is given at all.
1850
2028
  booleanDefault: undefined,
1851
2029
  collectUnknownFlags: true,
1852
- description: config.description,
1853
- flags: config.flags,
1854
- help: strings.trimNewlines(config.help(command, config)),
2030
+ description: cliConfig.description,
2031
+ flags: cliConfig.flags,
2032
+ help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
1855
2033
  importMeta
1856
2034
  });
1857
2035
  const {
2036
+ compactHeader: compactHeaderFlag,
1858
2037
  help: helpFlag,
1859
2038
  org: orgFlag,
1860
2039
  spinner: spinnerFlag,
1861
2040
  version: versionFlag
1862
2041
  } = cli.flags;
2042
+ const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
1863
2043
  const noSpinner = spinnerFlag === false || require$$9.isDebug();
1864
2044
 
1865
2045
  // Use CI spinner style when --no-spinner is passed.
@@ -1868,7 +2048,7 @@ function meowOrExit({
1868
2048
  constants.default.spinner.spinner = spinner.getCliSpinners('ci');
1869
2049
  }
1870
2050
  if (!shouldSuppressBanner(cli.flags)) {
1871
- emitBanner(command, orgFlag);
2051
+ emitBanner(command, orgFlag, compactMode);
1872
2052
  // Add newline in stderr.
1873
2053
  // Meow help adds a newline too so we do it here.
1874
2054
  logger.logger.error('');
@@ -1897,7 +2077,7 @@ function meowOrExit({
1897
2077
  }
1898
2078
 
1899
2079
  // Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
1900
- if (versionFlag && !require$$11.hasOwn(config.flags, 'version')) {
2080
+ if (versionFlag && !require$$11.hasOwn(cliConfig.flags, 'version')) {
1901
2081
  // Use `console.error` here instead of `logger.error` to match Meow behavior.
1902
2082
  console.error('Unknown flag\n--version');
1903
2083
  // eslint-disable-next-line n/no-process-exit
@@ -1918,10 +2098,10 @@ function meowOrExit({
1918
2098
  // Prevent meow from potentially exiting early.
1919
2099
  autoHelp: false,
1920
2100
  autoVersion: false,
1921
- description: config.description,
1922
- help: strings.trimNewlines(config.help(command, config)),
2101
+ description: cliConfig.description,
2102
+ help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
1923
2103
  importMeta,
1924
- flags: config.flags
2104
+ flags: cliConfig.flags
1925
2105
  });
1926
2106
  // Ok, no help, reset to default.
1927
2107
  process.exitCode = 0;
@@ -2067,7 +2247,7 @@ async function determineOrgSlug(orgFlag, interactive, dryRun) {
2067
2247
  logger.logger.warn('');
2068
2248
  logger.logger.warn('Note: When running in CI, you probably want to set the `--org` flag.');
2069
2249
  logger.logger.warn('');
2070
- logger.logger.warn('For details, see: https://docs.socket.dev/docs/v1-migration-guide');
2250
+ logger.logger.warn(`For details, see the ${webLink(constants.V1_MIGRATION_GUIDE_URL, 'v1 migration guide')}`);
2071
2251
  logger.logger.warn('');
2072
2252
  logger.logger.warn('This command will exit now because the org slug is required to proceed.');
2073
2253
  return ['', undefined];
@@ -3135,6 +3315,9 @@ function isYarnBerry() {
3135
3315
  const yarnBinPath = getYarnBinPath();
3136
3316
  const result = spawn.spawnSync(yarnBinPath, ['--version'], {
3137
3317
  encoding: 'utf8',
3318
+ // On Windows, yarn is often a .cmd file that requires shell execution.
3319
+ // The spawn function from @socketsecurity/registry will handle this properly
3320
+ // when shell is true.
3138
3321
  shell: constants.default.WIN32
3139
3322
  });
3140
3323
  if (result.status === 0 && result.stdout) {
@@ -3172,7 +3355,7 @@ function isYarnBerry() {
3172
3355
  * - Configures environment for third-party tools
3173
3356
  */
3174
3357
 
3175
- const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
3358
+ const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
3176
3359
  const {
3177
3360
  PACKAGE_LOCK_JSON,
3178
3361
  PNPM_LOCK_YAML,
@@ -4256,6 +4439,9 @@ function runAgentInstall(pkgEnvDetails, options) {
4256
4439
  const installArgs = isPnpm && isCi ? ['install', '--no-frozen-lockfile', ...args] : ['install', ...args];
4257
4440
  return spawn.spawn(agentExecPath, installArgs, {
4258
4441
  cwd: pkgPath,
4442
+ // On Windows, package managers are often .cmd files that require shell execution.
4443
+ // The spawn function from @socketsecurity/registry will handle this properly
4444
+ // when shell is true.
4259
4445
  shell: constants.default.WIN32,
4260
4446
  spinner,
4261
4447
  stdio: 'inherit',
@@ -4344,6 +4530,9 @@ const readLockFileByAgent = (() => {
4344
4530
  // https://bun.sh/guides/install/yarnlock
4345
4531
  return (await spawn.spawn(agentExecPath, [lockPath], {
4346
4532
  cwd,
4533
+ // On Windows, bun is often a .cmd file that requires shell execution.
4534
+ // The spawn function from @socketsecurity/registry will handle this properly
4535
+ // when shell is true.
4347
4536
  shell: constants.default.WIN32
4348
4537
  })).stdout;
4349
4538
  }
@@ -4364,7 +4553,7 @@ const LOCKS = {
4364
4553
  [constants.PNPM_LOCK_YAML]: PNPM,
4365
4554
  [constants.YARN_LOCK]: YARN_CLASSIC,
4366
4555
  [VLT_LOCK_JSON]: VLT,
4367
- // Lastly, look for a hidden lock file which is present if .npmrc has package-lock=false:
4556
+ // Lastly, look for a hidden lockfile which is present if .npmrc has package-lock=false:
4368
4557
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-lock-json#hidden-lockfiles
4369
4558
  //
4370
4559
  // Unlike the other LOCKS keys this key contains a directory AND filename so
@@ -4419,6 +4608,9 @@ async function getAgentVersion(agent, agentExecPath, cwd) {
4419
4608
  // All package managers support the "--version" flag.
4420
4609
  (await spawn.spawn(agentExecPath, [constants.FLAG_VERSION], {
4421
4610
  cwd,
4611
+ // On Windows, package managers are often .cmd files that require shell execution.
4612
+ // The spawn function from @socketsecurity/registry will handle this properly
4613
+ // when shell is true.
4422
4614
  shell: constants.default.WIN32
4423
4615
  })).stdout) ?? undefined;
4424
4616
  } catch (e) {
@@ -4616,7 +4808,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
4616
4808
  cause: cmdPrefixMessage(cmdName, `Package engine "node" requires ${pkgRequirements.node}. Current version: ${nodeVersion}`)
4617
4809
  };
4618
4810
  }
4619
- const lockName = details.lockName ?? 'lock file';
4811
+ const lockName = details.lockName ?? 'lockfile';
4620
4812
  if (details.lockName === undefined || details.lockSrc === undefined) {
4621
4813
  return {
4622
4814
  ok: false,
@@ -4684,6 +4876,275 @@ function getEcosystemChoicesForMeow() {
4684
4876
  return [...ALL_ECOSYSTEMS];
4685
4877
  }
4686
4878
 
4879
+ /**
4880
+ * Temporary package executor detection utilities for Socket CLI.
4881
+ * Identifies and handles temporary execution contexts.
4882
+ *
4883
+ * Key Functions:
4884
+ * - isRunningInTemporaryExecutor: Detects if running in npx/dlx/exec context
4885
+ * - shouldSkipShadow: Determines if shadow installation should be skipped
4886
+ *
4887
+ * Temporary Execution Contexts:
4888
+ * - npm exec/npx: Runs packages in temporary npm cache
4889
+ * - pnpm dlx: Executes packages in temporary pnpm store
4890
+ * - yarn dlx: Runs packages in temporary yarn environment
4891
+ *
4892
+ * Detection Methods:
4893
+ * - Environment variable analysis (npm_config_user_agent)
4894
+ * - Path pattern matching for temporary directories
4895
+ * - Cache directory identification
4896
+ *
4897
+ * Usage:
4898
+ * - Prevents shadow installation in temporary contexts
4899
+ * - Avoids PATH pollution in ephemeral environments
4900
+ * - Ensures package manager commands work correctly
4901
+ */
4902
+
4903
+ /**
4904
+ * Determines if shadow binaries should be installed.
4905
+ * Shadows should NOT be installed when:
4906
+ * - Running in a temporary execution context (exec/npx/dlx)
4907
+ * - On Windows with an existing binary path (required for Windows to function)
4908
+ *
4909
+ * @param binPath - Path to the binary being shadowed
4910
+ * @param options - Configuration options
4911
+ * @param options.cwd - Current working directory path to check
4912
+ * @param options.win32 - Whether running on Windows
4913
+ * @returns true if shadow installation should be skipped
4914
+ */
4915
+ function shouldSkipShadow(binPath, options) {
4916
+ const {
4917
+ cwd = process.cwd(),
4918
+ win32 = false
4919
+ } = {
4920
+ __proto__: null,
4921
+ ...options
4922
+ };
4923
+
4924
+ // Windows compatibility: Skip shadow installation if binary is already found.
4925
+ //
4926
+ // This check is required because Windows handles executables differently than Unix:
4927
+ // 1. File locking - Windows locks running executables, so cmd-shim creation would
4928
+ // fail with EBUSY/EACCES errors when trying to create wrapper files.
4929
+ // 2. PATH conflicts - Attempting to shadow an already-resolved binary can create
4930
+ // circular references or ambiguous command resolution.
4931
+ // 3. Registry integration - Windows package managers often use system-level
4932
+ // integrations beyond just PATH that our shadowing would interfere with.
4933
+ //
4934
+ // Without this check, users would see "Access Denied" or file locking errors
4935
+ // that are difficult to debug. This is not a performance optimization - the
4936
+ // shadow installation will fail without it.
4937
+ if (win32 && binPath) {
4938
+ return true;
4939
+ }
4940
+
4941
+ // Check environment variable for exec/npx/dlx indicators.
4942
+ const userAgent = constants.default.ENV.npm_config_user_agent;
4943
+ if (userAgent?.includes('exec') || userAgent?.includes('npx') || userAgent?.includes('dlx')) {
4944
+ return true;
4945
+ }
4946
+
4947
+ // Normalize the cwd path for consistent checking across platforms.
4948
+ const normalizedCwd = path$1.normalizePath(cwd);
4949
+
4950
+ // Check if running from npm's npx cache.
4951
+ const npmCache = constants.default.ENV.npm_config_cache;
4952
+ if (npmCache && normalizedCwd.includes(path$1.normalizePath(npmCache))) {
4953
+ return true;
4954
+ }
4955
+
4956
+ // Check common temporary execution path patterns.
4957
+ const tempPatterns = ['_npx',
4958
+ // npm's npx cache directory
4959
+ '.pnpm-store',
4960
+ // pnpm dlx temporary store
4961
+ 'dlx-',
4962
+ // Common dlx directory prefix
4963
+ '.yarn/$$',
4964
+ // Yarn Berry PnP virtual packages
4965
+ path.sep === '\\' ? 'AppData\\Local\\Temp\\xfs-' : 'AppData/Local/Temp/xfs-' // Yarn on Windows
4966
+ ];
4967
+ return tempPatterns.some(pattern => normalizedCwd.includes(pattern));
4968
+ }
4969
+
4970
+ /**
4971
+ * PNPM path resolution utilities for Socket CLI.
4972
+ * Locates and caches PNPM binary paths.
4973
+ *
4974
+ * Key Functions:
4975
+ * - getPnpmBinPath: Get cached PNPM binary path
4976
+ * - getPnpmBinPathDetails: Get detailed PNPM path information
4977
+ *
4978
+ * Error Handling:
4979
+ * - Exits with code 127 if PNPM not found
4980
+ * - Provides clear error messages for missing binaries
4981
+ *
4982
+ * Caching:
4983
+ * - Caches binary path lookups for performance
4984
+ * - Prevents repeated PATH searches
4985
+ */
4986
+
4987
+ function exitWithBinPathError(binName) {
4988
+ logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
4989
+ // The exit code 127 indicates that the command or binary being executed
4990
+ // could not be found.
4991
+ // eslint-disable-next-line n/no-process-exit
4992
+ process.exit(127);
4993
+ // This line is never reached in production, but helps tests.
4994
+ throw new Error('process.exit called');
4995
+ }
4996
+ let _pnpmBinPath;
4997
+ function getPnpmBinPath() {
4998
+ if (_pnpmBinPath === undefined) {
4999
+ _pnpmBinPath = getPnpmBinPathDetails().path;
5000
+ if (!_pnpmBinPath) {
5001
+ exitWithBinPathError('pnpm');
5002
+ }
5003
+ }
5004
+ return _pnpmBinPath;
5005
+ }
5006
+ let _pnpmBinPathDetails;
5007
+ function getPnpmBinPathDetails() {
5008
+ if (_pnpmBinPathDetails === undefined) {
5009
+ _pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
5010
+ }
5011
+ return _pnpmBinPathDetails;
5012
+ }
5013
+ function isPnpmBinPathShadowed() {
5014
+ return getPnpmBinPathDetails().shadowed;
5015
+ }
5016
+
5017
+ /**
5018
+ * Shadow binary link installation utilities for Socket CLI.
5019
+ * Manages installation of shadow binaries for package managers.
5020
+ *
5021
+ * Key Functions:
5022
+ * - installNpmLinks: Install shadow links for npm binary
5023
+ * - installNpxLinks: Install shadow links for npx binary
5024
+ * - installPnpmLinks: Install shadow links for pnpm binary
5025
+ * - installYarnLinks: Install shadow links for yarn binary
5026
+ *
5027
+ * Shadow Installation:
5028
+ * - Creates symlinks/cmd-shims to intercept package manager commands
5029
+ * - Modifies PATH to prioritize shadow binaries
5030
+ * - Skips installation in temporary execution contexts
5031
+ *
5032
+ * Security Integration:
5033
+ * - Enables security scanning before package operations
5034
+ * - Transparent interception of package manager commands
5035
+ * - Preserves original binary functionality
5036
+ */
5037
+
5038
+ const __filename$1 = require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
5039
+ const __dirname$1 = path.dirname(__filename$1);
5040
+ async function installNpmLinks(shadowBinPath) {
5041
+ // Find npm being shadowed by this process.
5042
+ const binPath = getNpmBinPath();
5043
+ const {
5044
+ WIN32
5045
+ } = constants.default;
5046
+
5047
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5048
+ if (shouldSkipShadow(binPath, {
5049
+ cwd: __dirname$1,
5050
+ win32: WIN32
5051
+ })) {
5052
+ return binPath;
5053
+ }
5054
+ const shadowed = isNpmBinPathShadowed();
5055
+ // Move our bin directory to front of PATH so its found first.
5056
+ if (!shadowed) {
5057
+ if (WIN32) {
5058
+ await vendor.libExports(path.join(constants.default.distPath, 'npm-cli.js'), path.join(shadowBinPath, 'npm'));
5059
+ }
5060
+ const {
5061
+ env
5062
+ } = process;
5063
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5064
+ }
5065
+ return binPath;
5066
+ }
5067
+ async function installNpxLinks(shadowBinPath) {
5068
+ // Find npx being shadowed by this process.
5069
+ const binPath = getNpxBinPath();
5070
+ const {
5071
+ WIN32
5072
+ } = constants.default;
5073
+
5074
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5075
+ if (shouldSkipShadow(binPath, {
5076
+ cwd: __dirname$1,
5077
+ win32: WIN32
5078
+ })) {
5079
+ return binPath;
5080
+ }
5081
+ const shadowed = isNpxBinPathShadowed();
5082
+ // Move our bin directory to front of PATH so its found first.
5083
+ if (!shadowed) {
5084
+ if (WIN32) {
5085
+ await vendor.libExports(path.join(constants.default.distPath, 'npx-cli.js'), path.join(shadowBinPath, 'npx'));
5086
+ }
5087
+ const {
5088
+ env
5089
+ } = process;
5090
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5091
+ }
5092
+ return binPath;
5093
+ }
5094
+ async function installPnpmLinks(shadowBinPath) {
5095
+ // Find pnpm being shadowed by this process.
5096
+ const binPath = getPnpmBinPath();
5097
+ const {
5098
+ WIN32
5099
+ } = constants.default;
5100
+
5101
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5102
+ if (shouldSkipShadow(binPath, {
5103
+ cwd: __dirname$1,
5104
+ win32: WIN32
5105
+ })) {
5106
+ return binPath;
5107
+ }
5108
+ const shadowed = isPnpmBinPathShadowed();
5109
+
5110
+ // Move our bin directory to front of PATH so its found first.
5111
+ if (!shadowed) {
5112
+ if (WIN32) {
5113
+ await vendor.libExports(path.join(constants.default.distPath, 'pnpm-cli.js'), path.join(shadowBinPath, 'pnpm'));
5114
+ }
5115
+ const {
5116
+ env
5117
+ } = process;
5118
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5119
+ }
5120
+ return binPath;
5121
+ }
5122
+ async function installYarnLinks(shadowBinPath) {
5123
+ const binPath = getYarnBinPath();
5124
+ const {
5125
+ WIN32
5126
+ } = constants.default;
5127
+
5128
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5129
+ if (shouldSkipShadow(binPath, {
5130
+ cwd: __dirname$1,
5131
+ win32: WIN32
5132
+ })) {
5133
+ return binPath;
5134
+ }
5135
+ const shadowed = isYarnBinPathShadowed();
5136
+ if (!shadowed) {
5137
+ if (WIN32) {
5138
+ await vendor.libExports(path.join(constants.default.distPath, 'yarn-cli.js'), path.join(shadowBinPath, 'yarn'));
5139
+ }
5140
+ const {
5141
+ env
5142
+ } = process;
5143
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5144
+ }
5145
+ return binPath;
5146
+ }
5147
+
4687
5148
  /**
4688
5149
  * Filter configuration utilities for Socket CLI.
4689
5150
  * Manages filter configuration normalization for security scanning.
@@ -4855,7 +5316,7 @@ class ColorOrMarkdown {
4855
5316
  }
4856
5317
  }
4857
5318
 
4858
- const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
5319
+ const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
4859
5320
  let _translations;
4860
5321
  function getTranslations() {
4861
5322
  if (_translations === undefined) {
@@ -5480,53 +5941,6 @@ function safeNpmSpecToPurl(pkgSpec) {
5480
5941
  return purlObj?.toString() ?? `pkg:${constants.NPM}/${name}${version ? `@${version}` : ''}`;
5481
5942
  }
5482
5943
 
5483
- /**
5484
- * PNPM path resolution utilities for Socket CLI.
5485
- * Locates and caches PNPM binary paths.
5486
- *
5487
- * Key Functions:
5488
- * - getPnpmBinPath: Get cached PNPM binary path
5489
- * - getPnpmBinPathDetails: Get detailed PNPM path information
5490
- *
5491
- * Error Handling:
5492
- * - Exits with code 127 if PNPM not found
5493
- * - Provides clear error messages for missing binaries
5494
- *
5495
- * Caching:
5496
- * - Caches binary path lookups for performance
5497
- * - Prevents repeated PATH searches
5498
- */
5499
-
5500
- function exitWithBinPathError(binName) {
5501
- logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
5502
- // The exit code 127 indicates that the command or binary being executed
5503
- // could not be found.
5504
- // eslint-disable-next-line n/no-process-exit
5505
- process.exit(127);
5506
- // This line is never reached in production, but helps tests.
5507
- throw new Error('process.exit called');
5508
- }
5509
- let _pnpmBinPath;
5510
- function getPnpmBinPath() {
5511
- if (_pnpmBinPath === undefined) {
5512
- _pnpmBinPath = getPnpmBinPathDetails().path;
5513
- if (!_pnpmBinPath) {
5514
- exitWithBinPathError('pnpm');
5515
- }
5516
- }
5517
- return _pnpmBinPath;
5518
- }
5519
- let _pnpmBinPathDetails;
5520
- function getPnpmBinPathDetails() {
5521
- if (_pnpmBinPathDetails === undefined) {
5522
- _pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
5523
- }
5524
- return _pnpmBinPathDetails;
5525
- }
5526
- function isPnpmBinPathShadowed() {
5527
- return getPnpmBinPathDetails().shadowed;
5528
- }
5529
-
5530
5944
  exports.AuthError = AuthError;
5531
5945
  exports.COMPLETION_CMD_PREFIX = COMPLETION_CMD_PREFIX;
5532
5946
  exports.InputError = InputError;
@@ -5550,6 +5964,7 @@ exports.extractTier1ReachabilityScanId = extractTier1ReachabilityScanId;
5550
5964
  exports.failMsgWithBadge = failMsgWithBadge;
5551
5965
  exports.fetchGhsaDetails = fetchGhsaDetails;
5552
5966
  exports.fetchOrganization = fetchOrganization;
5967
+ exports.fileLink = fileLink;
5553
5968
  exports.filterFlags = filterFlags;
5554
5969
  exports.findUp = findUp;
5555
5970
  exports.formatErrorWithDetail = formatErrorWithDetail;
@@ -5574,7 +5989,6 @@ exports.getOctokitGraphql = getOctokitGraphql;
5574
5989
  exports.getOrgSlugs = getOrgSlugs;
5575
5990
  exports.getOutputKind = getOutputKind;
5576
5991
  exports.getPackageFilesForScan = getPackageFilesForScan;
5577
- exports.getPnpmBinPath = getPnpmBinPath;
5578
5992
  exports.getPublicApiToken = getPublicApiToken;
5579
5993
  exports.getPurlObject = getPurlObject;
5580
5994
  exports.getRepoInfo = getRepoInfo;
@@ -5583,7 +5997,6 @@ exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlF
5583
5997
  exports.getSupportedConfigEntries = getSupportedConfigEntries;
5584
5998
  exports.getSupportedConfigKeys = getSupportedConfigKeys;
5585
5999
  exports.getVisibleTokenPrefix = getVisibleTokenPrefix;
5586
- exports.getYarnBinPath = getYarnBinPath;
5587
6000
  exports.gitBranch = gitBranch;
5588
6001
  exports.gitCheckoutBranch = gitCheckoutBranch;
5589
6002
  exports.gitCommit = gitCommit;
@@ -5599,17 +6012,18 @@ exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
5599
6012
  exports.hasDefaultApiToken = hasDefaultApiToken;
5600
6013
  exports.hasEnterpriseOrgPlan = hasEnterpriseOrgPlan;
5601
6014
  exports.idToNpmPurl = idToNpmPurl;
6015
+ exports.installNpmLinks = installNpmLinks;
6016
+ exports.installNpxLinks = installNpxLinks;
6017
+ exports.installPnpmLinks = installPnpmLinks;
6018
+ exports.installYarnLinks = installYarnLinks;
6019
+ exports.isConfigFromFlag = isConfigFromFlag;
5602
6020
  exports.isHelpFlag = isHelpFlag;
5603
- exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
5604
- exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
5605
- exports.isPnpmBinPathShadowed = isPnpmBinPathShadowed;
5606
- exports.isReadOnlyConfig = isReadOnlyConfig;
5607
6021
  exports.isReportSupportedFile = isReportSupportedFile;
5608
6022
  exports.isSensitiveConfigKey = isSensitiveConfigKey;
5609
6023
  exports.isSupportedConfigKey = isSupportedConfigKey;
5610
6024
  exports.isYarnBerry = isYarnBerry;
5611
- exports.isYarnBinPathShadowed = isYarnBinPathShadowed;
5612
6025
  exports.logAlertsMap = logAlertsMap;
6026
+ exports.mailtoLink = mailtoLink;
5613
6027
  exports.mapToObject = mapToObject;
5614
6028
  exports.mdTable = mdTable;
5615
6029
  exports.mdTableOfPairs = mdTableOfPairs;
@@ -5632,6 +6046,10 @@ exports.sendApiRequest = sendApiRequest;
5632
6046
  exports.serializeResultJson = serializeResultJson;
5633
6047
  exports.setGitRemoteGithubRepoUrl = setGitRemoteGithubRepoUrl;
5634
6048
  exports.setupSdk = setupSdk;
6049
+ exports.socketDashboardLink = socketDashboardLink;
6050
+ exports.socketDevLink = socketDevLink;
6051
+ exports.socketDocsLink = socketDocsLink;
6052
+ exports.socketPackageLink = socketPackageLink;
5635
6053
  exports.spawnCdxgenDlx = spawnCdxgenDlx;
5636
6054
  exports.spawnCoanaDlx = spawnCoanaDlx;
5637
6055
  exports.spawnSynpDlx = spawnSynpDlx;
@@ -5640,6 +6058,7 @@ exports.tildify = tildify;
5640
6058
  exports.toFilterConfig = toFilterConfig;
5641
6059
  exports.updateConfigValue = updateConfigValue;
5642
6060
  exports.walkNestedMap = walkNestedMap;
6061
+ exports.webLink = webLink;
5643
6062
  exports.writeSocketJson = writeSocketJson;
5644
- //# debugId=cf6fa269-bd5d-472d-ba3c-ad112752f863
6063
+ //# debugId=aca3fb2c-1435-481e-a911-c0547052c313
5645
6064
  //# sourceMappingURL=utils.js.map