@socketsecurity/cli-with-sentry 1.1.20 → 1.1.22

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 (73) hide show
  1. package/CHANGELOG.md +34 -10
  2. package/dist/cli.js +194 -151
  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/npm-cli.js +6 -2
  9. package/dist/npm-cli.js.map +1 -1
  10. package/dist/pnpm-cli.js +6 -2
  11. package/dist/pnpm-cli.js.map +1 -1
  12. package/dist/shadow-npm-bin2.js +8 -31
  13. package/dist/shadow-npm-bin2.js.map +1 -1
  14. package/dist/shadow-pnpm-bin2.js +41 -64
  15. package/dist/shadow-pnpm-bin2.js.map +1 -1
  16. package/dist/shadow-yarn-bin.js +17 -33
  17. package/dist/shadow-yarn-bin.js.map +1 -1
  18. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  19. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  20. package/dist/types/commands/fix/handle-fix.d.mts +2 -2
  21. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  22. package/dist/types/commands/fix/types.d.mts +1 -1
  23. package/dist/types/commands/fix/types.d.mts.map +1 -1
  24. package/dist/types/commands/manifest/cmd-manifest.d.mts.map +1 -1
  25. package/dist/types/commands/optimize/handle-optimize.d.mts.map +1 -1
  26. package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +1 -1
  27. package/dist/types/commands/organization/cmd-organization.d.mts.map +1 -1
  28. package/dist/types/commands/package/cmd-package.d.mts.map +1 -1
  29. package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
  30. package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
  31. package/dist/types/commands/scan/cmd-scan.d.mts.map +1 -1
  32. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  33. package/dist/types/commands/scan/suggest_branch_slug.d.mts.map +1 -1
  34. package/dist/types/constants.d.mts +8 -1
  35. package/dist/types/constants.d.mts.map +1 -1
  36. package/dist/types/flags.d.mts.map +1 -1
  37. package/dist/types/shadow/common.d.mts +0 -8
  38. package/dist/types/shadow/common.d.mts.map +1 -1
  39. package/dist/types/shadow/npm-base.d.mts.map +1 -1
  40. package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
  41. package/dist/types/shadow/yarn/bin.d.mts.map +1 -1
  42. package/dist/types/test/json-output-validation.d.mts +37 -0
  43. package/dist/types/test/json-output-validation.d.mts.map +1 -0
  44. package/dist/types/test/mocks/socket-auth.d.mts +88 -0
  45. package/dist/types/test/mocks/socket-auth.d.mts.map +1 -0
  46. package/dist/types/utils/agent.d.mts.map +1 -1
  47. package/dist/types/utils/cmd.d.mts +25 -4
  48. package/dist/types/utils/cmd.d.mts.map +1 -1
  49. package/dist/types/utils/config.d.mts +1 -1
  50. package/dist/types/utils/dlx-binary.d.mts +58 -0
  51. package/dist/types/utils/dlx-binary.d.mts.map +1 -0
  52. package/dist/types/utils/dlx-detection.d.mts +29 -0
  53. package/dist/types/utils/dlx-detection.d.mts.map +1 -0
  54. package/dist/types/utils/extract-names.d.mts +15 -0
  55. package/dist/types/utils/extract-names.d.mts.map +1 -0
  56. package/dist/types/utils/git.d.mts.map +1 -1
  57. package/dist/types/utils/meow-with-subcommands.d.mts +33 -12
  58. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  59. package/dist/types/utils/shadow-links.d.mts +5 -0
  60. package/dist/types/utils/shadow-links.d.mts.map +1 -0
  61. package/dist/types/utils/terminal-link.d.mts +19 -12
  62. package/dist/types/utils/terminal-link.d.mts.map +1 -1
  63. package/dist/utils.js +533 -146
  64. package/dist/utils.js.map +1 -1
  65. package/dist/yarn-cli.js +6 -2
  66. package/dist/yarn-cli.js.map +1 -1
  67. package/package.json +1 -1
  68. package/dist/types/shadow/npm/link.d.mts +0 -2
  69. package/dist/types/shadow/npm/link.d.mts.map +0 -1
  70. package/dist/types/shadow/pnpm/link.d.mts +0 -2
  71. package/dist/types/shadow/pnpm/link.d.mts.map +0 -1
  72. package/dist/types/shadow/yarn/link.d.mts +0 -2
  73. 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) {
@@ -1251,16 +1252,6 @@ function mailtoLink(email, text) {
1251
1252
  return vendor.terminalLinkExports(email, `mailto:${email}`);
1252
1253
  }
1253
1254
 
1254
- /**
1255
- * Creates a terminal link to a web URL.
1256
- * @param url The web URL to link to
1257
- * @param text Optional display text (defaults to the URL itself)
1258
- * @returns A terminal link to the URL
1259
- */
1260
- function webLink(url, text) {
1261
- return vendor.terminalLinkExports(text ?? url, url);
1262
- }
1263
-
1264
1255
  /**
1265
1256
  * Creates a terminal link to the Socket.dev dashboard.
1266
1257
  * @param path The path within the dashboard (e.g., '/org/YOURORG/alerts')
@@ -1272,6 +1263,16 @@ function socketDashboardLink(dashPath, text) {
1272
1263
  return vendor.terminalLinkExports(text, url);
1273
1264
  }
1274
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, `${constants.SOCKET_WEBSITE_URL}${urlPath}`);
1274
+ }
1275
+
1275
1276
  /**
1276
1277
  * Creates a terminal link to Socket.dev documentation.
1277
1278
  * @param docPath The documentation path (e.g., '/docs/api-keys')
@@ -1303,7 +1304,17 @@ function socketPackageLink(ecosystem, packageName, version, text) {
1303
1304
  } else {
1304
1305
  url = `https://socket.dev/${ecosystem}/package/${packageName}`;
1305
1306
  }
1306
- return vendor.terminalLinkExports(text, url);
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);
1307
1318
  }
1308
1319
 
1309
1320
  function checkCommandInput(outputKind, ...checks) {
@@ -1542,30 +1553,65 @@ function findBestCommandMatch(input, subcommands, aliases) {
1542
1553
  return bestMatch;
1543
1554
  }
1544
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
+
1545
1573
  /**
1546
1574
  * Generate the ASCII banner header for Socket CLI commands.
1547
1575
  */
1548
- function getAsciiHeader(command, orgFlag) {
1576
+ function getAsciiHeader(command, orgFlag, compactMode = false) {
1549
1577
  // Note: In tests we return <redacted> because otherwise snapshots will fail.
1550
1578
  const {
1551
1579
  REDACTED
1552
1580
  } = constants.default;
1553
1581
  const redacting = constants.default.ENV.VITEST;
1554
- 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}`;
1555
1587
  const nodeVersion = redacting ? REDACTED : process.version;
1588
+ const showNodeVersion = !redacting && require$$9.isDebug();
1556
1589
  const defaultOrg = getConfigValueOrUndef(constants.CONFIG_KEY_DEFAULT_ORG);
1557
- const readOnlyConfig = isReadOnlyConfig() ? '*' : '.';
1558
- const shownToken = redacting ? REDACTED : getVisibleTokenPrefix() || '(not set)';
1590
+ const configFromFlagDot = 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)');
1559
1597
  const relCwd = redacting ? REDACTED : path$1.normalizePath(tildify(process.cwd()));
1560
- // Note: we must redact org when creating snapshots because dev machine probably
1561
- // has a default org set but CI won't. Showing --org is fine either way.
1562
- 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
+
1563
1609
  // Note: We could draw these with ascii box art instead but I worry about
1564
1610
  // portability and paste-ability. "simple" ascii chars just work.
1565
1611
  const body = `
1566
1612
  _____ _ _ /---------------
1567
- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
1568
- |__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token: ${shownToken}, ${orgPart}
1613
+ | __|___ ___| |_ ___| |_ | CLI: ${cliVersion}
1614
+ |__ | ${configFromFlagDot} | _| '_| -_| _| | ${showNodeVersion ? `Node: ${nodeVersion}, ` : ''}token: ${shownToken}, ${orgPart}
1569
1615
  |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}
1570
1616
  `.trim();
1571
1617
  // Note: logger will auto-append a newline.
@@ -1610,7 +1656,7 @@ function shouldSuppressBanner(flags) {
1610
1656
  /**
1611
1657
  * Emit the Socket CLI banner to stderr for branding and debugging.
1612
1658
  */
1613
- function emitBanner(name, orgFlag) {
1659
+ function emitBanner(name, orgFlag, compactMode = false) {
1614
1660
  // Print a banner at the top of each command.
1615
1661
  // This helps with brand recognition and marketing.
1616
1662
  // It also helps with debugging since it contains version and command details.
@@ -1619,19 +1665,32 @@ function emitBanner(name, orgFlag) {
1619
1665
  // and pipe the result to other tools. By emitting the banner over stderr
1620
1666
  // you can do something like `socket scan view xyz | jq | process`.
1621
1667
  // The spinner also emits over stderr for example.
1622
- logger.logger.error(getAsciiHeader(name, orgFlag));
1668
+ logger.logger.error(getAsciiHeader(name, orgFlag, compactMode));
1623
1669
  }
1624
1670
 
1625
1671
  /**
1626
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
+ * )
1627
1680
  */
1628
- async function meowWithSubcommands(subcommands, options) {
1681
+ async function meowWithSubcommands(config, options) {
1629
1682
  const {
1630
- aliases = {},
1631
1683
  argv,
1632
- defaultSub,
1633
1684
  importMeta,
1634
1685
  name,
1686
+ subcommands
1687
+ } = {
1688
+ __proto__: null,
1689
+ ...config
1690
+ };
1691
+ const {
1692
+ aliases = {},
1693
+ defaultSub,
1635
1694
  ...additionalOptions
1636
1695
  } = {
1637
1696
  __proto__: null,
@@ -1659,24 +1718,29 @@ async function meowWithSubcommands(subcommands, options) {
1659
1718
  if (!isRootCommand) {
1660
1719
  if (commandOrAliasName?.startsWith('pkg:')) {
1661
1720
  logger.logger.info('Invoking `socket package score`.');
1662
- return await meowWithSubcommands(subcommands, {
1663
- ...options,
1664
- argv: ['package', 'deep', ...argv]
1665
- });
1721
+ return await meowWithSubcommands({
1722
+ name,
1723
+ argv: ['package', 'deep', ...argv],
1724
+ importMeta,
1725
+ subcommands
1726
+ }, options);
1666
1727
  }
1667
1728
  // Support `socket npm/lodash` or whatever as a shorthand, too.
1668
1729
  // Accept any ecosystem and let the remote sort it out.
1669
1730
  if (/^[a-z]+\//.test(commandOrAliasName || '')) {
1670
1731
  logger.logger.info('Invoking `socket package score`.');
1671
- return await meowWithSubcommands(subcommands, {
1672
- ...options,
1673
- argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv]
1674
- });
1732
+ return await meowWithSubcommands({
1733
+ name,
1734
+ argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv],
1735
+ importMeta,
1736
+ subcommands
1737
+ }, options);
1675
1738
  }
1676
1739
  }
1677
1740
  if (isRootCommand) {
1678
- flags$1['help'] = {
1679
- ...flags$1['help'],
1741
+ const hiddenDebugFlag = !require$$9.isDebug();
1742
+ flags$1['compactHeader'] = {
1743
+ ...flags$1['compactHeader'],
1680
1744
  hidden: false
1681
1745
  };
1682
1746
  flags$1['config'] = {
@@ -1687,13 +1751,21 @@ async function meowWithSubcommands(subcommands, options) {
1687
1751
  ...flags$1['dryRun'],
1688
1752
  hidden: false
1689
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
+ };
1690
1762
  flags$1['maxOldSpaceSize'] = {
1691
1763
  ...flags$1['maxOldSpaceSize'],
1692
- hidden: false
1764
+ hidden: hiddenDebugFlag
1693
1765
  };
1694
1766
  flags$1['maxSemiSpaceSize'] = {
1695
1767
  ...flags$1['maxSemiSpaceSize'],
1696
- hidden: false
1768
+ hidden: hiddenDebugFlag
1697
1769
  };
1698
1770
  flags$1['version'] = {
1699
1771
  ...flags$1['version'],
@@ -1703,6 +1775,7 @@ async function meowWithSubcommands(subcommands, options) {
1703
1775
  delete flags$1['markdown'];
1704
1776
  } else {
1705
1777
  delete flags$1['help'];
1778
+ delete flags$1['helpFull'];
1706
1779
  delete flags$1['version'];
1707
1780
  }
1708
1781
 
@@ -1722,10 +1795,12 @@ async function meowWithSubcommands(subcommands, options) {
1722
1795
  booleanDefault: undefined
1723
1796
  });
1724
1797
  const {
1798
+ compactHeader: compactHeaderFlag,
1725
1799
  config: configFlag,
1726
1800
  org: orgFlag,
1727
1801
  spinner: spinnerFlag
1728
1802
  } = cli1.flags;
1803
+ const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
1729
1804
  const noSpinner = spinnerFlag === false || require$$9.isDebug();
1730
1805
 
1731
1806
  // Use CI spinner style when --no-spinner is passed or debug mode is enabled.
@@ -1756,7 +1831,7 @@ async function meowWithSubcommands(subcommands, options) {
1756
1831
  }
1757
1832
  if (configOverrideResult?.ok === false) {
1758
1833
  if (!shouldSuppressBanner(cli1.flags)) {
1759
- emitBanner(name, orgFlag);
1834
+ emitBanner(name, orgFlag, compactMode);
1760
1835
  // Add newline in stderr.
1761
1836
  logger.logger.error('');
1762
1837
  }
@@ -1793,7 +1868,7 @@ async function meowWithSubcommands(subcommands, options) {
1793
1868
  }
1794
1869
  const lines = ['', 'Usage', ` $ ${name} <command>`];
1795
1870
  if (isRootCommand) {
1796
- 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}`);
1797
1872
  }
1798
1873
  lines.push('');
1799
1874
  if (isRootCommand) {
@@ -1866,7 +1941,15 @@ async function meowWithSubcommands(subcommands, options) {
1866
1941
  padName: HELP_PAD_NAME
1867
1942
  })}`);
1868
1943
  if (isRootCommand) {
1869
- 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
+ }
1870
1953
  }
1871
1954
 
1872
1955
  // Parse it again. Config overrides should now be applied (may affect help).
@@ -1887,34 +1970,53 @@ async function meowWithSubcommands(subcommands, options) {
1887
1970
  booleanDefault: undefined,
1888
1971
  help: lines.map(l => strings.indentString(l, HELP_INDENT)).join('\n')
1889
1972
  });
1973
+ const {
1974
+ dryRun,
1975
+ help: helpFlag
1976
+ } = cli2.flags;
1890
1977
 
1891
1978
  // ...else we provide basic instructions and help.
1892
1979
  if (!shouldSuppressBanner(cli2.flags)) {
1893
- emitBanner(name, orgFlag);
1980
+ emitBanner(name, orgFlag, compactMode);
1894
1981
  // Meow will add newline so don't add stderr spacing here.
1895
1982
  }
1896
- if (!cli2.flags['help'] && cli2.flags['dryRun']) {
1983
+ if (!helpFlag && dryRun) {
1897
1984
  process.exitCode = 0;
1898
1985
  logger.logger.log(`${constants.default.DRY_RUN_LABEL}: No-op, call a sub-command; ok`);
1899
1986
  } else {
1900
1987
  // When you explicitly request --help, the command should be successful
1901
1988
  // so we exit(0). If we do it because we need more input, we exit(2).
1902
- cli2.showHelp(cli2.flags['help'] ? 0 : 2);
1989
+ cli2.showHelp(helpFlag ? 0 : 2);
1903
1990
  }
1904
1991
  }
1905
-
1906
1992
  /**
1907
1993
  * Create meow CLI instance or exit with help/error (meow will exit immediately
1908
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
+ * )
1909
2002
  */
1910
- function meowOrExit({
1911
- allowUnknownFlags = true,
1912
- argv,
1913
- config,
1914
- importMeta,
1915
- parentName
1916
- }) {
1917
- 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}`;
1918
2020
 
1919
2021
  // This exits if .printHelp() is called either by meow itself or by us.
1920
2022
  const cli = vendor.meow({
@@ -1925,17 +2027,19 @@ function meowOrExit({
1925
2027
  // We want to detect whether a bool flag is given at all.
1926
2028
  booleanDefault: undefined,
1927
2029
  collectUnknownFlags: true,
1928
- description: config.description,
1929
- flags: config.flags,
1930
- help: strings.trimNewlines(config.help(command, config)),
2030
+ description: cliConfig.description,
2031
+ flags: cliConfig.flags,
2032
+ help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
1931
2033
  importMeta
1932
2034
  });
1933
2035
  const {
2036
+ compactHeader: compactHeaderFlag,
1934
2037
  help: helpFlag,
1935
2038
  org: orgFlag,
1936
2039
  spinner: spinnerFlag,
1937
2040
  version: versionFlag
1938
2041
  } = cli.flags;
2042
+ const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
1939
2043
  const noSpinner = spinnerFlag === false || require$$9.isDebug();
1940
2044
 
1941
2045
  // Use CI spinner style when --no-spinner is passed.
@@ -1944,7 +2048,7 @@ function meowOrExit({
1944
2048
  constants.default.spinner.spinner = spinner.getCliSpinners('ci');
1945
2049
  }
1946
2050
  if (!shouldSuppressBanner(cli.flags)) {
1947
- emitBanner(command, orgFlag);
2051
+ emitBanner(command, orgFlag, compactMode);
1948
2052
  // Add newline in stderr.
1949
2053
  // Meow help adds a newline too so we do it here.
1950
2054
  logger.logger.error('');
@@ -1973,7 +2077,7 @@ function meowOrExit({
1973
2077
  }
1974
2078
 
1975
2079
  // Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
1976
- if (versionFlag && !require$$11.hasOwn(config.flags, 'version')) {
2080
+ if (versionFlag && !require$$11.hasOwn(cliConfig.flags, 'version')) {
1977
2081
  // Use `console.error` here instead of `logger.error` to match Meow behavior.
1978
2082
  console.error('Unknown flag\n--version');
1979
2083
  // eslint-disable-next-line n/no-process-exit
@@ -1994,10 +2098,10 @@ function meowOrExit({
1994
2098
  // Prevent meow from potentially exiting early.
1995
2099
  autoHelp: false,
1996
2100
  autoVersion: false,
1997
- description: config.description,
1998
- help: strings.trimNewlines(config.help(command, config)),
2101
+ description: cliConfig.description,
2102
+ help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
1999
2103
  importMeta,
2000
- flags: config.flags
2104
+ flags: cliConfig.flags
2001
2105
  });
2002
2106
  // Ok, no help, reset to default.
2003
2107
  process.exitCode = 0;
@@ -2213,6 +2317,45 @@ async function getDefaultOrgSlug() {
2213
2317
  };
2214
2318
  }
2215
2319
 
2320
+ /**
2321
+ * Sanitizes a name to comply with repository naming constraints.
2322
+ * Constraints: 100 or less A-Za-z0-9 characters only with non-repeating,
2323
+ * non-leading or trailing ., _ or - only.
2324
+ *
2325
+ * @param name - The name to sanitize
2326
+ * @returns Sanitized name that complies with repository naming rules, or empty string if no valid characters
2327
+ */
2328
+ function sanitizeName(name) {
2329
+ if (!name) {
2330
+ return '';
2331
+ }
2332
+
2333
+ // Replace sequences of illegal characters with underscores.
2334
+ const sanitized = name
2335
+ // Replace any sequence of non-alphanumeric characters (except ., _, -) with underscore.
2336
+ .replace(/[^A-Za-z0-9._-]+/g, '_')
2337
+ // Replace sequences of multiple allowed special chars with single underscore.
2338
+ .replace(/[._-]{2,}/g, '_')
2339
+ // Remove leading special characters.
2340
+ .replace(/^[._-]+/, '')
2341
+ // Remove trailing special characters.
2342
+ .replace(/[._-]+$/, '')
2343
+ // Truncate to 100 characters max.
2344
+ .slice(0, 100);
2345
+ return sanitized;
2346
+ }
2347
+
2348
+ /**
2349
+ * Extracts and sanitizes a repository name.
2350
+ *
2351
+ * @param name - The repository name to extract and sanitize
2352
+ * @returns Sanitized repository name, or default repository name if empty
2353
+ */
2354
+ function extractName(name) {
2355
+ const sanitized = sanitizeName(name);
2356
+ return sanitized || constants.default.SOCKET_DEFAULT_REPOSITORY;
2357
+ }
2358
+
2216
2359
  /**
2217
2360
  * Git utilities for Socket CLI.
2218
2361
  * Provides git operations for repository management, branch handling, and commits.
@@ -2305,7 +2448,7 @@ async function getRepoInfo(cwd = process.cwd()) {
2305
2448
  }
2306
2449
  async function getRepoName(cwd = process.cwd()) {
2307
2450
  const repoInfo = await getRepoInfo(cwd);
2308
- return repoInfo?.repo ?? constants.default.SOCKET_DEFAULT_REPOSITORY;
2451
+ return repoInfo?.repo ? extractName(repoInfo.repo) : constants.default.SOCKET_DEFAULT_REPOSITORY;
2309
2452
  }
2310
2453
  async function gitBranch(cwd = process.cwd()) {
2311
2454
  const stdioPipeOptions = {
@@ -3209,8 +3352,8 @@ function isYarnBerry() {
3209
3352
  if (_isYarnBerry === undefined) {
3210
3353
  try {
3211
3354
  const yarnBinPath = getYarnBinPath();
3212
- const result = spawn.spawnSync(yarnBinPath, ['--version'], {
3213
- encoding: 'utf8',
3355
+ const result = spawn.spawnSync(yarnBinPath, [constants.FLAG_VERSION], {
3356
+ encoding: constants.UTF8,
3214
3357
  // On Windows, yarn is often a .cmd file that requires shell execution.
3215
3358
  // The spawn function from @socketsecurity/registry will handle this properly
3216
3359
  // when shell is true.
@@ -3251,7 +3394,7 @@ function isYarnBerry() {
3251
3394
  * - Configures environment for third-party tools
3252
3395
  */
3253
3396
 
3254
- 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)));
3397
+ 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)));
3255
3398
  const {
3256
3399
  PACKAGE_LOCK_JSON,
3257
3400
  PNPM_LOCK_YAML,
@@ -3851,6 +3994,19 @@ async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()
3851
3994
 
3852
3995
  const helpFlags = new Set([constants.FLAG_HELP, '-h']);
3853
3996
 
3997
+ /**
3998
+ * Convert flag values to array format for processing.
3999
+ */
4000
+ function cmdFlagValueToArray(value) {
4001
+ if (typeof value === 'string') {
4002
+ return value.trim().split(/, */).filter(Boolean);
4003
+ }
4004
+ if (Array.isArray(value)) {
4005
+ return value.flatMap(cmdFlagValueToArray);
4006
+ }
4007
+ return [];
4008
+ }
4009
+
3854
4010
  /**
3855
4011
  * Convert command arguments to a properly formatted string representation.
3856
4012
  */
@@ -3877,19 +4033,6 @@ function cmdFlagsToString(args) {
3877
4033
  return result.join(' ');
3878
4034
  }
3879
4035
 
3880
- /**
3881
- * Convert flag values to array format for processing.
3882
- */
3883
- function cmdFlagValueToArray(value) {
3884
- if (typeof value === 'string') {
3885
- return value.trim().split(/, */).filter(Boolean);
3886
- }
3887
- if (Array.isArray(value)) {
3888
- return value.flatMap(cmdFlagValueToArray);
3889
- }
3890
- return [];
3891
- }
3892
-
3893
4036
  /**
3894
4037
  * Add command name prefix to message text.
3895
4038
  */
@@ -3961,6 +4104,15 @@ function filterFlags(argv, flagsToFilter, exceptions) {
3961
4104
  return filtered;
3962
4105
  }
3963
4106
 
4107
+ /**
4108
+ * Check if command is an add command (adds new dependencies).
4109
+ * Supported by: pnpm, yarn.
4110
+ * Note: npm uses 'install' with package names instead of 'add'.
4111
+ */
4112
+ function isAddCommand(command) {
4113
+ return command === 'add';
4114
+ }
4115
+
3964
4116
  /**
3965
4117
  * Check if argument is a help flag.
3966
4118
  */
@@ -3968,6 +4120,14 @@ function isHelpFlag(cmdArg) {
3968
4120
  return helpFlags.has(cmdArg);
3969
4121
  }
3970
4122
 
4123
+ /**
4124
+ * Check if pnpm command requires lockfile scanning.
4125
+ * pnpm uses: install, i, update, up
4126
+ */
4127
+ function isPnpmLockfileScanCommand(command) {
4128
+ return command === 'install' || command === 'i' || command === 'update' || command === 'up';
4129
+ }
4130
+
3971
4131
  /**
3972
4132
  * Converts CVE IDs to GHSA IDs using GitHub API.
3973
4133
  */
@@ -4241,7 +4401,7 @@ function shadowNpmInstall(options) {
4241
4401
  const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
4242
4402
  const progressArg = rawBinArgs.findLast(agent.isNpmProgressFlag) !== '--no-progress';
4243
4403
  const isSilent = !useDebug && !binArgs.some(agent.isNpmLoglevelFlag);
4244
- const logLevelArgs = isSilent ? ['--loglevel', 'silent'] : [];
4404
+ const logLevelArgs = isSilent ? [constants.FLAG_LOGLEVEL, 'silent'] : [];
4245
4405
  const useIpc = require$$11.isObject(ipc);
4246
4406
 
4247
4407
  // Include 'ipc' in the spawnOpts.stdio when an options.ipc object is provided.
@@ -4262,7 +4422,7 @@ function shadowNpmInstall(options) {
4262
4422
  '--no-audit', '--no-fund',
4263
4423
  // Add '--no-progress' to fix input being swallowed by the npm spinner.
4264
4424
  '--no-progress',
4265
- // Add '--loglevel=silent' if a loglevel flag is not provided and the
4425
+ // Add 'FLAG_LOGLEVEL silent' if a loglevel flag is not provided and the
4266
4426
  // SOCKET_CLI_DEBUG environment variable is not truthy.
4267
4427
  ...logLevelArgs, ...binArgs, ...otherArgs], {
4268
4428
  ...spawnOpts,
@@ -4331,8 +4491,8 @@ function runAgentInstall(pkgEnvDetails, options) {
4331
4491
  const skipNodeHardenFlags = isPnpm && pkgEnvDetails.agentVersion.major < 11;
4332
4492
  // In CI mode, pnpm uses --frozen-lockfile by default, which prevents lockfile updates.
4333
4493
  // We need to explicitly disable it when updating the lockfile with overrides.
4334
- const isCi = constants.default.ENV['CI'];
4335
- const installArgs = isPnpm && isCi ? ['install', '--no-frozen-lockfile', ...args] : ['install', ...args];
4494
+ // Also add --config.confirmModulesPurge=false to avoid interactive prompts.
4495
+ const installArgs = isPnpm ? ['install', '--config.confirmModulesPurge=false', '--no-frozen-lockfile', ...args] : ['install', ...args];
4336
4496
  return spawn.spawn(agentExecPath, installArgs, {
4337
4497
  cwd: pkgPath,
4338
4498
  // On Windows, package managers are often .cmd files that require shell execution.
@@ -4345,6 +4505,10 @@ function runAgentInstall(pkgEnvDetails, options) {
4345
4505
  env: {
4346
4506
  ...process.env,
4347
4507
  ...constants.default.processEnv,
4508
+ // Set CI for pnpm to ensure non-interactive mode and consistent behavior.
4509
+ ...(isPnpm ? {
4510
+ CI: '1'
4511
+ } : {}),
4348
4512
  NODE_OPTIONS: cmdFlagsToString([...(skipNodeHardenFlags ? [] : constants.default.nodeHardenFlags), ...constants.default.nodeNoWarningsFlags]),
4349
4513
  ...require$$11.getOwn(spawnOpts, 'env')
4350
4514
  }
@@ -4772,6 +4936,275 @@ function getEcosystemChoicesForMeow() {
4772
4936
  return [...ALL_ECOSYSTEMS];
4773
4937
  }
4774
4938
 
4939
+ /**
4940
+ * Temporary package executor detection utilities for Socket CLI.
4941
+ * Identifies and handles temporary execution contexts.
4942
+ *
4943
+ * Key Functions:
4944
+ * - isRunningInTemporaryExecutor: Detects if running in npx/dlx/exec context
4945
+ * - shouldSkipShadow: Determines if shadow installation should be skipped
4946
+ *
4947
+ * Temporary Execution Contexts:
4948
+ * - npm exec/npx: Runs packages in temporary npm cache
4949
+ * - pnpm dlx: Executes packages in temporary pnpm store
4950
+ * - yarn dlx: Runs packages in temporary yarn environment
4951
+ *
4952
+ * Detection Methods:
4953
+ * - Environment variable analysis (npm_config_user_agent)
4954
+ * - Path pattern matching for temporary directories
4955
+ * - Cache directory identification
4956
+ *
4957
+ * Usage:
4958
+ * - Prevents shadow installation in temporary contexts
4959
+ * - Avoids PATH pollution in ephemeral environments
4960
+ * - Ensures package manager commands work correctly
4961
+ */
4962
+
4963
+ /**
4964
+ * Determines if shadow binaries should be installed.
4965
+ * Shadows should NOT be installed when:
4966
+ * - Running in a temporary execution context (exec/npx/dlx)
4967
+ * - On Windows with an existing binary path (required for Windows to function)
4968
+ *
4969
+ * @param binPath - Path to the binary being shadowed
4970
+ * @param options - Configuration options
4971
+ * @param options.cwd - Current working directory path to check
4972
+ * @param options.win32 - Whether running on Windows
4973
+ * @returns true if shadow installation should be skipped
4974
+ */
4975
+ function shouldSkipShadow(binPath, options) {
4976
+ const {
4977
+ cwd = process.cwd(),
4978
+ win32 = false
4979
+ } = {
4980
+ __proto__: null,
4981
+ ...options
4982
+ };
4983
+
4984
+ // Windows compatibility: Skip shadow installation if binary is already found.
4985
+ //
4986
+ // This check is required because Windows handles executables differently than Unix:
4987
+ // 1. File locking - Windows locks running executables, so cmd-shim creation would
4988
+ // fail with EBUSY/EACCES errors when trying to create wrapper files.
4989
+ // 2. PATH conflicts - Attempting to shadow an already-resolved binary can create
4990
+ // circular references or ambiguous command resolution.
4991
+ // 3. Registry integration - Windows package managers often use system-level
4992
+ // integrations beyond just PATH that our shadowing would interfere with.
4993
+ //
4994
+ // Without this check, users would see "Access Denied" or file locking errors
4995
+ // that are difficult to debug. This is not a performance optimization - the
4996
+ // shadow installation will fail without it.
4997
+ if (win32 && binPath) {
4998
+ return true;
4999
+ }
5000
+
5001
+ // Check environment variable for exec/npx/dlx indicators.
5002
+ const userAgent = constants.default.ENV.npm_config_user_agent;
5003
+ if (userAgent?.includes('exec') || userAgent?.includes('npx') || userAgent?.includes('dlx')) {
5004
+ return true;
5005
+ }
5006
+
5007
+ // Normalize the cwd path for consistent checking across platforms.
5008
+ const normalizedCwd = path$1.normalizePath(cwd);
5009
+
5010
+ // Check if running from npm's npx cache.
5011
+ const npmCache = constants.default.ENV.npm_config_cache;
5012
+ if (npmCache && normalizedCwd.includes(path$1.normalizePath(npmCache))) {
5013
+ return true;
5014
+ }
5015
+
5016
+ // Check common temporary execution path patterns.
5017
+ const tempPatterns = ['_npx',
5018
+ // npm's npx cache directory
5019
+ '.pnpm-store',
5020
+ // pnpm dlx temporary store
5021
+ 'dlx-',
5022
+ // Common dlx directory prefix
5023
+ '.yarn/$$',
5024
+ // Yarn Berry PnP virtual packages
5025
+ path.sep === '\\' ? 'AppData\\Local\\Temp\\xfs-' : 'AppData/Local/Temp/xfs-' // Yarn on Windows
5026
+ ];
5027
+ return tempPatterns.some(pattern => normalizedCwd.includes(pattern));
5028
+ }
5029
+
5030
+ /**
5031
+ * PNPM path resolution utilities for Socket CLI.
5032
+ * Locates and caches PNPM binary paths.
5033
+ *
5034
+ * Key Functions:
5035
+ * - getPnpmBinPath: Get cached PNPM binary path
5036
+ * - getPnpmBinPathDetails: Get detailed PNPM path information
5037
+ *
5038
+ * Error Handling:
5039
+ * - Exits with code 127 if PNPM not found
5040
+ * - Provides clear error messages for missing binaries
5041
+ *
5042
+ * Caching:
5043
+ * - Caches binary path lookups for performance
5044
+ * - Prevents repeated PATH searches
5045
+ */
5046
+
5047
+ function exitWithBinPathError(binName) {
5048
+ logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
5049
+ // The exit code 127 indicates that the command or binary being executed
5050
+ // could not be found.
5051
+ // eslint-disable-next-line n/no-process-exit
5052
+ process.exit(127);
5053
+ // This line is never reached in production, but helps tests.
5054
+ throw new Error('process.exit called');
5055
+ }
5056
+ let _pnpmBinPath;
5057
+ function getPnpmBinPath() {
5058
+ if (_pnpmBinPath === undefined) {
5059
+ _pnpmBinPath = getPnpmBinPathDetails().path;
5060
+ if (!_pnpmBinPath) {
5061
+ exitWithBinPathError('pnpm');
5062
+ }
5063
+ }
5064
+ return _pnpmBinPath;
5065
+ }
5066
+ let _pnpmBinPathDetails;
5067
+ function getPnpmBinPathDetails() {
5068
+ if (_pnpmBinPathDetails === undefined) {
5069
+ _pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
5070
+ }
5071
+ return _pnpmBinPathDetails;
5072
+ }
5073
+ function isPnpmBinPathShadowed() {
5074
+ return getPnpmBinPathDetails().shadowed;
5075
+ }
5076
+
5077
+ /**
5078
+ * Shadow binary link installation utilities for Socket CLI.
5079
+ * Manages installation of shadow binaries for package managers.
5080
+ *
5081
+ * Key Functions:
5082
+ * - installNpmLinks: Install shadow links for npm binary
5083
+ * - installNpxLinks: Install shadow links for npx binary
5084
+ * - installPnpmLinks: Install shadow links for pnpm binary
5085
+ * - installYarnLinks: Install shadow links for yarn binary
5086
+ *
5087
+ * Shadow Installation:
5088
+ * - Creates symlinks/cmd-shims to intercept package manager commands
5089
+ * - Modifies PATH to prioritize shadow binaries
5090
+ * - Skips installation in temporary execution contexts
5091
+ *
5092
+ * Security Integration:
5093
+ * - Enables security scanning before package operations
5094
+ * - Transparent interception of package manager commands
5095
+ * - Preserves original binary functionality
5096
+ */
5097
+
5098
+ 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)));
5099
+ const __dirname$1 = path.dirname(__filename$1);
5100
+ async function installNpmLinks(shadowBinPath) {
5101
+ // Find npm being shadowed by this process.
5102
+ const binPath = getNpmBinPath();
5103
+ const {
5104
+ WIN32
5105
+ } = constants.default;
5106
+
5107
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5108
+ if (shouldSkipShadow(binPath, {
5109
+ cwd: __dirname$1,
5110
+ win32: WIN32
5111
+ })) {
5112
+ return binPath;
5113
+ }
5114
+ const shadowed = isNpmBinPathShadowed();
5115
+ // Move our bin directory to front of PATH so its found first.
5116
+ if (!shadowed) {
5117
+ if (WIN32) {
5118
+ await vendor.libExports(path.join(constants.default.distPath, 'npm-cli.js'), path.join(shadowBinPath, 'npm'));
5119
+ }
5120
+ const {
5121
+ env
5122
+ } = process;
5123
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5124
+ }
5125
+ return binPath;
5126
+ }
5127
+ async function installNpxLinks(shadowBinPath) {
5128
+ // Find npx being shadowed by this process.
5129
+ const binPath = getNpxBinPath();
5130
+ const {
5131
+ WIN32
5132
+ } = constants.default;
5133
+
5134
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5135
+ if (shouldSkipShadow(binPath, {
5136
+ cwd: __dirname$1,
5137
+ win32: WIN32
5138
+ })) {
5139
+ return binPath;
5140
+ }
5141
+ const shadowed = isNpxBinPathShadowed();
5142
+ // Move our bin directory to front of PATH so its found first.
5143
+ if (!shadowed) {
5144
+ if (WIN32) {
5145
+ await vendor.libExports(path.join(constants.default.distPath, 'npx-cli.js'), path.join(shadowBinPath, 'npx'));
5146
+ }
5147
+ const {
5148
+ env
5149
+ } = process;
5150
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5151
+ }
5152
+ return binPath;
5153
+ }
5154
+ async function installPnpmLinks(shadowBinPath) {
5155
+ // Find pnpm being shadowed by this process.
5156
+ const binPath = getPnpmBinPath();
5157
+ const {
5158
+ WIN32
5159
+ } = constants.default;
5160
+
5161
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5162
+ if (shouldSkipShadow(binPath, {
5163
+ cwd: __dirname$1,
5164
+ win32: WIN32
5165
+ })) {
5166
+ return binPath;
5167
+ }
5168
+ const shadowed = isPnpmBinPathShadowed();
5169
+
5170
+ // Move our bin directory to front of PATH so its found first.
5171
+ if (!shadowed) {
5172
+ if (WIN32) {
5173
+ await vendor.libExports(path.join(constants.default.distPath, 'pnpm-cli.js'), path.join(shadowBinPath, 'pnpm'));
5174
+ }
5175
+ const {
5176
+ env
5177
+ } = process;
5178
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5179
+ }
5180
+ return binPath;
5181
+ }
5182
+ async function installYarnLinks(shadowBinPath) {
5183
+ const binPath = getYarnBinPath();
5184
+ const {
5185
+ WIN32
5186
+ } = constants.default;
5187
+
5188
+ // Skip shadow installation when in temporary execution context or when required for Windows.
5189
+ if (shouldSkipShadow(binPath, {
5190
+ cwd: __dirname$1,
5191
+ win32: WIN32
5192
+ })) {
5193
+ return binPath;
5194
+ }
5195
+ const shadowed = isYarnBinPathShadowed();
5196
+ if (!shadowed) {
5197
+ if (WIN32) {
5198
+ await vendor.libExports(path.join(constants.default.distPath, 'yarn-cli.js'), path.join(shadowBinPath, 'yarn'));
5199
+ }
5200
+ const {
5201
+ env
5202
+ } = process;
5203
+ env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
5204
+ }
5205
+ return binPath;
5206
+ }
5207
+
4775
5208
  /**
4776
5209
  * Filter configuration utilities for Socket CLI.
4777
5210
  * Manages filter configuration normalization for security scanning.
@@ -4943,7 +5376,7 @@ class ColorOrMarkdown {
4943
5376
  }
4944
5377
  }
4945
5378
 
4946
- 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)));
5379
+ 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)));
4947
5380
  let _translations;
4948
5381
  function getTranslations() {
4949
5382
  if (_translations === undefined) {
@@ -5568,53 +6001,6 @@ function safeNpmSpecToPurl(pkgSpec) {
5568
6001
  return purlObj?.toString() ?? `pkg:${constants.NPM}/${name}${version ? `@${version}` : ''}`;
5569
6002
  }
5570
6003
 
5571
- /**
5572
- * PNPM path resolution utilities for Socket CLI.
5573
- * Locates and caches PNPM binary paths.
5574
- *
5575
- * Key Functions:
5576
- * - getPnpmBinPath: Get cached PNPM binary path
5577
- * - getPnpmBinPathDetails: Get detailed PNPM path information
5578
- *
5579
- * Error Handling:
5580
- * - Exits with code 127 if PNPM not found
5581
- * - Provides clear error messages for missing binaries
5582
- *
5583
- * Caching:
5584
- * - Caches binary path lookups for performance
5585
- * - Prevents repeated PATH searches
5586
- */
5587
-
5588
- function exitWithBinPathError(binName) {
5589
- logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
5590
- // The exit code 127 indicates that the command or binary being executed
5591
- // could not be found.
5592
- // eslint-disable-next-line n/no-process-exit
5593
- process.exit(127);
5594
- // This line is never reached in production, but helps tests.
5595
- throw new Error('process.exit called');
5596
- }
5597
- let _pnpmBinPath;
5598
- function getPnpmBinPath() {
5599
- if (_pnpmBinPath === undefined) {
5600
- _pnpmBinPath = getPnpmBinPathDetails().path;
5601
- if (!_pnpmBinPath) {
5602
- exitWithBinPathError('pnpm');
5603
- }
5604
- }
5605
- return _pnpmBinPath;
5606
- }
5607
- let _pnpmBinPathDetails;
5608
- function getPnpmBinPathDetails() {
5609
- if (_pnpmBinPathDetails === undefined) {
5610
- _pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
5611
- }
5612
- return _pnpmBinPathDetails;
5613
- }
5614
- function isPnpmBinPathShadowed() {
5615
- return getPnpmBinPathDetails().shadowed;
5616
- }
5617
-
5618
6004
  exports.AuthError = AuthError;
5619
6005
  exports.COMPLETION_CMD_PREFIX = COMPLETION_CMD_PREFIX;
5620
6006
  exports.InputError = InputError;
@@ -5663,7 +6049,6 @@ exports.getOctokitGraphql = getOctokitGraphql;
5663
6049
  exports.getOrgSlugs = getOrgSlugs;
5664
6050
  exports.getOutputKind = getOutputKind;
5665
6051
  exports.getPackageFilesForScan = getPackageFilesForScan;
5666
- exports.getPnpmBinPath = getPnpmBinPath;
5667
6052
  exports.getPublicApiToken = getPublicApiToken;
5668
6053
  exports.getPurlObject = getPurlObject;
5669
6054
  exports.getRepoInfo = getRepoInfo;
@@ -5672,7 +6057,6 @@ exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlF
5672
6057
  exports.getSupportedConfigEntries = getSupportedConfigEntries;
5673
6058
  exports.getSupportedConfigKeys = getSupportedConfigKeys;
5674
6059
  exports.getVisibleTokenPrefix = getVisibleTokenPrefix;
5675
- exports.getYarnBinPath = getYarnBinPath;
5676
6060
  exports.gitBranch = gitBranch;
5677
6061
  exports.gitCheckoutBranch = gitCheckoutBranch;
5678
6062
  exports.gitCommit = gitCommit;
@@ -5688,16 +6072,18 @@ exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
5688
6072
  exports.hasDefaultApiToken = hasDefaultApiToken;
5689
6073
  exports.hasEnterpriseOrgPlan = hasEnterpriseOrgPlan;
5690
6074
  exports.idToNpmPurl = idToNpmPurl;
6075
+ exports.installNpmLinks = installNpmLinks;
6076
+ exports.installNpxLinks = installNpxLinks;
6077
+ exports.installPnpmLinks = installPnpmLinks;
6078
+ exports.installYarnLinks = installYarnLinks;
6079
+ exports.isAddCommand = isAddCommand;
6080
+ exports.isConfigFromFlag = isConfigFromFlag;
5691
6081
  exports.isHelpFlag = isHelpFlag;
5692
- exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
5693
- exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
5694
- exports.isPnpmBinPathShadowed = isPnpmBinPathShadowed;
5695
- exports.isReadOnlyConfig = isReadOnlyConfig;
6082
+ exports.isPnpmLockfileScanCommand = isPnpmLockfileScanCommand;
5696
6083
  exports.isReportSupportedFile = isReportSupportedFile;
5697
6084
  exports.isSensitiveConfigKey = isSensitiveConfigKey;
5698
6085
  exports.isSupportedConfigKey = isSupportedConfigKey;
5699
6086
  exports.isYarnBerry = isYarnBerry;
5700
- exports.isYarnBinPathShadowed = isYarnBinPathShadowed;
5701
6087
  exports.logAlertsMap = logAlertsMap;
5702
6088
  exports.mailtoLink = mailtoLink;
5703
6089
  exports.mapToObject = mapToObject;
@@ -5723,6 +6109,7 @@ exports.serializeResultJson = serializeResultJson;
5723
6109
  exports.setGitRemoteGithubRepoUrl = setGitRemoteGithubRepoUrl;
5724
6110
  exports.setupSdk = setupSdk;
5725
6111
  exports.socketDashboardLink = socketDashboardLink;
6112
+ exports.socketDevLink = socketDevLink;
5726
6113
  exports.socketDocsLink = socketDocsLink;
5727
6114
  exports.socketPackageLink = socketPackageLink;
5728
6115
  exports.spawnCdxgenDlx = spawnCdxgenDlx;
@@ -5735,5 +6122,5 @@ exports.updateConfigValue = updateConfigValue;
5735
6122
  exports.walkNestedMap = walkNestedMap;
5736
6123
  exports.webLink = webLink;
5737
6124
  exports.writeSocketJson = writeSocketJson;
5738
- //# debugId=ea20d1df-782c-49c5-bbda-ab4eac27ce58
6125
+ //# debugId=7c5c00b7-6234-4a3a-ac1b-54b81da28c25
5739
6126
  //# sourceMappingURL=utils.js.map