socket 1.1.13 → 1.1.15

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 (65) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cli.js +150 -75
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +107 -5
  5. package/dist/constants.js.map +1 -1
  6. package/dist/flags.js.map +1 -1
  7. package/dist/npm-cli.js +3 -2
  8. package/dist/npm-cli.js.map +1 -1
  9. package/dist/shadow-npm-inject.js.map +1 -1
  10. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  11. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  12. package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
  13. package/dist/types/commands/fix/env-helpers.d.mts +13 -0
  14. package/dist/types/commands/fix/env-helpers.d.mts.map +1 -1
  15. package/dist/types/commands/fix/git.d.mts +1 -1
  16. package/dist/types/commands/fix/git.d.mts.map +1 -1
  17. package/dist/types/commands/fix/handle-fix.d.mts +2 -1
  18. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  19. package/dist/types/commands/fix/pull-request.d.mts +1 -1
  20. package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
  21. package/dist/types/commands/fix/types.d.mts +1 -0
  22. package/dist/types/commands/fix/types.d.mts.map +1 -1
  23. package/dist/types/commands/login/apply-login.d.mts.map +1 -1
  24. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  25. package/dist/types/commands/logout/apply-logout.d.mts.map +1 -1
  26. package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
  27. package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -1
  28. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
  29. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  30. package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
  31. package/dist/types/constants.d.mts +74 -6
  32. package/dist/types/constants.d.mts.map +1 -1
  33. package/dist/types/flags.d.mts +1 -1
  34. package/dist/types/flags.d.mts.map +1 -1
  35. package/dist/types/shadow/npm/arborist/types.d.mts +10 -10
  36. package/dist/types/shadow/npm/arborist/types.d.mts.map +1 -1
  37. package/dist/types/types.d.mts +4 -4
  38. package/dist/types/types.d.mts.map +1 -1
  39. package/dist/types/utils/agent.d.mts.map +1 -1
  40. package/dist/types/utils/alert/artifact.d.mts +1 -1
  41. package/dist/types/utils/alert/artifact.d.mts.map +1 -1
  42. package/dist/types/utils/api.d.mts +2 -2
  43. package/dist/types/utils/api.d.mts.map +1 -1
  44. package/dist/types/utils/coana.d.mts +0 -4
  45. package/dist/types/utils/coana.d.mts.map +1 -1
  46. package/dist/types/utils/config.d.mts +4 -3
  47. package/dist/types/utils/config.d.mts.map +1 -1
  48. package/dist/types/utils/determine-org-slug.d.mts.map +1 -1
  49. package/dist/types/utils/dlx.d.mts +33 -0
  50. package/dist/types/utils/dlx.d.mts.map +1 -0
  51. package/dist/types/utils/errors.d.mts +1 -1
  52. package/dist/types/utils/errors.d.mts.map +1 -1
  53. package/dist/types/utils/github.d.mts +3 -3
  54. package/dist/types/utils/github.d.mts.map +1 -1
  55. package/dist/types/utils/glob.d.mts.map +1 -1
  56. package/dist/types/utils/meow-with-subcommands.d.mts +1 -1
  57. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  58. package/dist/types/utils/package-environment.d.mts.map +1 -1
  59. package/dist/types/utils/sdk.d.mts.map +1 -1
  60. package/dist/types/utils/socket-json.d.mts +27 -27
  61. package/dist/types/utils/socket-json.d.mts.map +1 -1
  62. package/dist/utils.js +288 -142
  63. package/dist/utils.js.map +1 -1
  64. package/dist/vendor.js +235 -235
  65. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.1.15](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.15) - 2025-09-16
8
+
9
+ ### Changed
10
+ - Improved `socket fix` environment variable detection with clearer error messages when required variables are missing
11
+
12
+ ### Fixed
13
+ - Resolved path handling issue in `socket optimize` command
14
+ - Command flag parsing now correctly detects subsequent arguments
15
+
16
+ ## [1.1.14](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.14) - 2025-09-17
17
+
18
+ ### Changed
19
+ - Enhanced 3rd-party on-demand download and execution
20
+
7
21
  ## [1.1.13](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.13) - 2025-09-16
8
22
 
9
23
  ### Added
package/dist/cli.js CHANGED
@@ -19,7 +19,6 @@ var spawn = require('../external/@socketsecurity/registry/lib/spawn');
19
19
  var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
20
20
  var strings = require('../external/@socketsecurity/registry/lib/strings');
21
21
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
22
- var shadowNpmBin = require('./shadow-npm-bin.js');
23
22
  var require$$11 = require('../external/@socketsecurity/registry/lib/objects');
24
23
  var registry = require('../external/@socketsecurity/registry');
25
24
  var packages = require('../external/@socketsecurity/registry/lib/packages');
@@ -68,7 +67,7 @@ async function fetchRepoAnalyticsData(repo, time, options) {
68
67
 
69
68
  // Note: Widgets does not seem to actually work as code :'(
70
69
 
71
- const require$8 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
70
+ const require$7 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
72
71
  const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
73
72
 
74
73
  // Note: This maps `new Date(date).getMonth()` to English three letters
@@ -147,11 +146,11 @@ ${utils.mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
147
146
  `.trim() + '\n';
148
147
  }
149
148
  function displayAnalyticsScreen(data) {
150
- const ScreenWidget = /*@__PURE__*/require$8('../external/blessed/lib/widgets/screen.js');
149
+ const ScreenWidget = /*@__PURE__*/require$7('../external/blessed/lib/widgets/screen.js');
151
150
  const screen = new ScreenWidget({
152
151
  ...constants.default.blessedOptions
153
152
  });
154
- const GridLayout = /*@__PURE__*/require$8('../external/blessed-contrib/lib/layout/grid.js');
153
+ const GridLayout = /*@__PURE__*/require$7('../external/blessed-contrib/lib/layout/grid.js');
155
154
  const grid = new GridLayout({
156
155
  rows: 5,
157
156
  cols: 4,
@@ -165,7 +164,7 @@ function displayAnalyticsScreen(data) {
165
164
  renderLineCharts(grid, screen, 'Total high alerts prevented from the main branch', [2, 2, 1, 2], data['total_high_prevented']);
166
165
  renderLineCharts(grid, screen, 'Total medium alerts prevented from the main branch', [3, 0, 1, 2], data['total_medium_prevented']);
167
166
  renderLineCharts(grid, screen, 'Total low alerts prevented from the main branch', [3, 2, 1, 2], data['total_low_prevented']);
168
- const BarChart = /*@__PURE__*/require$8('../external/blessed-contrib/lib/widget/charts/bar.js');
167
+ const BarChart = /*@__PURE__*/require$7('../external/blessed-contrib/lib/widget/charts/bar.js');
169
168
  const bar = grid.set(4, 0, 1, 2, BarChart, {
170
169
  label: 'Top 5 alert types',
171
170
  barWidth: 10,
@@ -231,10 +230,10 @@ function formatDataOrg(data) {
231
230
  const topFiveAlertTypes = entry['top_five_alert_types'];
232
231
  for (const type of Object.keys(topFiveAlertTypes)) {
233
232
  const count = topFiveAlertTypes[type] ?? 0;
234
- if (!totalTopAlerts[type]) {
235
- totalTopAlerts[type] = count;
236
- } else {
233
+ if (totalTopAlerts[type]) {
237
234
  totalTopAlerts[type] += count;
235
+ } else {
236
+ totalTopAlerts[type] = count;
238
237
  }
239
238
  }
240
239
  }
@@ -242,10 +241,10 @@ function formatDataOrg(data) {
242
241
  const formatted = formattedData[metric];
243
242
  for (const entry of data) {
244
243
  const date = formatDate(entry['created_at']);
245
- if (!formatted[date]) {
246
- formatted[date] = entry[metric];
247
- } else {
244
+ if (formatted[date]) {
248
245
  formatted[date] += entry[metric];
246
+ } else {
247
+ formatted[date] = entry[metric];
249
248
  }
250
249
  }
251
250
  }
@@ -265,7 +264,7 @@ function formatDate(date) {
265
264
  return `${Months[new Date(date).getMonth()]} ${new Date(date).getDate()}`;
266
265
  }
267
266
  function renderLineCharts(grid, screen, title, coords, data) {
268
- const LineChart = /*@__PURE__*/require$8('../external/blessed-contrib/lib/widget/charts/line.js');
267
+ const LineChart = /*@__PURE__*/require$7('../external/blessed-contrib/lib/widget/charts/line.js');
269
268
  const line = grid.set(...coords, LineChart, {
270
269
  style: {
271
270
  line: 'cyan',
@@ -500,7 +499,7 @@ async function fetchAuditLog(config, options) {
500
499
  });
501
500
  }
502
501
 
503
- const require$7 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
502
+ const require$6 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
504
503
  async function outputAuditLog(result, {
505
504
  logType,
506
505
  orgSlug,
@@ -628,7 +627,7 @@ async function outputWithBlessed(data, orgSlug) {
628
627
  const headers = [' Event id', ' Created at', ' Event type', ' User email', ' IP address', ' User agent'];
629
628
 
630
629
  // Note: this temporarily takes over the terminal (just like `man` does).
631
- const ScreenWidget = /*@__PURE__*/require$7('../external/blessed/lib/widgets/screen.js');
630
+ const ScreenWidget = /*@__PURE__*/require$6('../external/blessed/lib/widgets/screen.js');
632
631
  const screen = new ScreenWidget({
633
632
  ...constants.default.blessedOptions
634
633
  });
@@ -637,7 +636,7 @@ async function outputWithBlessed(data, orgSlug) {
637
636
  // node process just to exit it. That's very bad UX.
638
637
  // eslint-disable-next-line n/no-process-exit
639
638
  screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
640
- const TableWidget = /*@__PURE__*/require$7('../external/blessed-contrib/lib/widget/table.js');
639
+ const TableWidget = /*@__PURE__*/require$6('../external/blessed-contrib/lib/widget/table.js');
641
640
  const tipsBoxHeight = 1; // 1 row for tips box
642
641
  const detailsBoxHeight = 20; // bottom N rows for details box. 20 gives 4 lines for condensed payload before it scrolls out of view
643
642
 
@@ -667,7 +666,7 @@ async function outputWithBlessed(data, orgSlug) {
667
666
  columnSpacing: 4,
668
667
  truncate: '_'
669
668
  });
670
- const BoxWidget = /*@__PURE__*/require$7('../external/blessed/lib/widgets/box.js');
669
+ const BoxWidget = /*@__PURE__*/require$6('../external/blessed/lib/widgets/box.js');
671
670
  const tipsBox = new BoxWidget({
672
671
  bottom: detailsBoxHeight,
673
672
  // sits just above the details box
@@ -1636,7 +1635,7 @@ async function performReachabilityAnalysis(options) {
1636
1635
  }
1637
1636
 
1638
1637
  // Run Coana with the manifests tar hash.
1639
- const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
1638
+ const coanaResult = await utils.spawnCoanaDlx(coanaArgs, orgSlug, {
1640
1639
  cwd,
1641
1640
  env: coanaEnv,
1642
1641
  spinner,
@@ -3395,21 +3394,72 @@ function ciRepoInfo() {
3395
3394
  repo: ownerSlashRepo.slice(slashIndex + 1)
3396
3395
  };
3397
3396
  }
3397
+ /**
3398
+ * Get formatted instructions for setting CI environment variables.
3399
+ */
3400
+ function getCiEnvInstructions() {
3401
+ return 'To enable automatic pull request creation, run in CI with these environment variables:\n' + ' - CI=1\n' + ' - SOCKET_CLI_GITHUB_TOKEN=<your-github-token>\n' + ' - SOCKET_CLI_GIT_USER_NAME=<git-username>\n' + ' - SOCKET_CLI_GIT_USER_EMAIL=<git-email>';
3402
+ }
3403
+
3404
+ /**
3405
+ * Check which required CI environment variables are missing.
3406
+ * Returns lists of missing and present variables.
3407
+ */
3408
+ function checkCiEnvVars() {
3409
+ const {
3410
+ CI,
3411
+ SOCKET_CLI_GIT_USER_EMAIL,
3412
+ SOCKET_CLI_GIT_USER_NAME,
3413
+ SOCKET_CLI_GITHUB_TOKEN
3414
+ } = constants.default.ENV;
3415
+ const missing = [];
3416
+ const present = [];
3417
+ if (CI) {
3418
+ present.push('CI');
3419
+ } else {
3420
+ missing.push('CI');
3421
+ }
3422
+ if (SOCKET_CLI_GIT_USER_EMAIL) {
3423
+ present.push('SOCKET_CLI_GIT_USER_EMAIL');
3424
+ } else {
3425
+ missing.push('SOCKET_CLI_GIT_USER_EMAIL');
3426
+ }
3427
+ if (SOCKET_CLI_GIT_USER_NAME) {
3428
+ present.push('SOCKET_CLI_GIT_USER_NAME');
3429
+ } else {
3430
+ missing.push('SOCKET_CLI_GIT_USER_NAME');
3431
+ }
3432
+ if (SOCKET_CLI_GITHUB_TOKEN) {
3433
+ present.push('SOCKET_CLI_GITHUB_TOKEN');
3434
+ } else {
3435
+ missing.push('SOCKET_CLI_GITHUB_TOKEN (or GITHUB_TOKEN)');
3436
+ }
3437
+ return {
3438
+ missing,
3439
+ present
3440
+ };
3441
+ }
3398
3442
  async function getFixEnv() {
3399
3443
  const baseBranch = await utils.getBaseBranch();
3400
3444
  const gitEmail = constants.default.ENV.SOCKET_CLI_GIT_USER_EMAIL;
3401
3445
  const gitUser = constants.default.ENV.SOCKET_CLI_GIT_USER_NAME;
3402
3446
  const githubToken = constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN;
3403
3447
  const isCi = !!(constants.default.ENV.CI && gitEmail && gitUser && githubToken);
3404
- if (
3405
- // If isCi is false,
3406
- !isCi && (
3407
- // but some CI checks are passing,
3408
- constants.default.ENV.CI || gitEmail || gitUser || githubToken) &&
3448
+ const envCheck = checkCiEnvVars();
3449
+
3450
+ // Provide clear feedback about missing environment variables.
3451
+ if (constants.default.ENV.CI && envCheck.missing.length > 1) {
3452
+ // CI is set but other required vars are missing.
3453
+ const missingExceptCi = envCheck.missing.filter(v => v !== 'CI');
3454
+ if (missingExceptCi.length) {
3455
+ logger.logger.warn(`CI mode detected, but pull request creation is disabled due to missing environment variables:\n` + ` Missing: ${arrays.joinAnd(missingExceptCi)}\n` + ` Set these variables to enable automatic pull request creation.`);
3456
+ }
3457
+ } else if (
3458
+ // If not in CI but some CI-related env vars are set.
3459
+ !constants.default.ENV.CI && envCheck.present.length &&
3409
3460
  // then log about it when in debug mode.
3410
3461
  require$$9.isDebug('notice')) {
3411
- const envVars = [...(constants.default.ENV.CI ? [] : ['process.env.CI']), ...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']), ...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']), ...(githubToken ? [] : ['process.env.GITHUB_TOKEN'])];
3412
- require$$9.debugFn('notice', `miss: fixEnv.isCi is false, expected ${arrays.joinAnd(envVars)} to be set`);
3462
+ require$$9.debugFn('notice', `miss: fixEnv.isCi is false, expected ${arrays.joinAnd(envCheck.missing)} to be set`);
3413
3463
  }
3414
3464
  let repoInfo;
3415
3465
  if (isCi) {
@@ -3441,6 +3491,7 @@ async function coanaFix(fixConfig) {
3441
3491
  autopilot,
3442
3492
  cwd,
3443
3493
  ghsas,
3494
+ glob,
3444
3495
  limit,
3445
3496
  onlyCompute,
3446
3497
  orgSlug,
@@ -3486,6 +3537,19 @@ async function coanaFix(fixConfig) {
3486
3537
  const isAll = !ghsas.length || ghsas.length === 1 && (ghsas[0] === 'all' || ghsas[0] === 'auto');
3487
3538
  const shouldOpenPrs = fixEnv.isCi && fixEnv.repoInfo;
3488
3539
  if (!shouldOpenPrs) {
3540
+ // Inform user about local mode when fixes will be applied.
3541
+ if (!onlyCompute && ghsas.length) {
3542
+ const envCheck = checkCiEnvVars();
3543
+ if (envCheck.present.length) {
3544
+ // Some CI vars are set but not all - show what's missing.
3545
+ if (envCheck.missing.length) {
3546
+ logger.logger.info('Running in local mode - fixes will be applied directly to your working directory.\n' + `Missing environment variables for PR creation: ${arrays.joinAnd(envCheck.missing)}`);
3547
+ }
3548
+ } else {
3549
+ // No CI vars are present - show general local mode message.
3550
+ logger.logger.info('Running in local mode - fixes will be applied directly to your working directory.\n' + getCiEnvInstructions());
3551
+ }
3552
+ }
3489
3553
  const ids = isAll ? ['all'] : ghsas.slice(0, limit);
3490
3554
  if (!ids.length) {
3491
3555
  spinner?.stop();
@@ -3496,7 +3560,7 @@ async function coanaFix(fixConfig) {
3496
3560
  }
3497
3561
  };
3498
3562
  }
3499
- const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...(isAll ? ['all'] : ghsas), ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags, ...(onlyCompute ? ['--dry-run'] : []), ...(outputFile ? ['--output-file', outputFile] : [])], fixConfig.orgSlug, {
3563
+ const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...(isAll ? ['all'] : ghsas), ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(glob ? ['--glob', glob] : []), ...(onlyCompute ? ['--dry-run'] : []), ...(outputFile ? ['--output-file', outputFile] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3500
3564
  cwd,
3501
3565
  spinner,
3502
3566
  stdio: 'inherit'
@@ -3533,7 +3597,7 @@ async function coanaFix(fixConfig) {
3533
3597
  const shouldSpawnCoana = adjustedLimit > 0;
3534
3598
  let ids;
3535
3599
  if (shouldSpawnCoana && isAll) {
3536
- const foundCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3600
+ const foundCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(glob ? ['--glob', glob] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3537
3601
  cwd,
3538
3602
  spinner
3539
3603
  });
@@ -3575,7 +3639,7 @@ async function coanaFix(fixConfig) {
3575
3639
 
3576
3640
  // Apply fix for single GHSA ID.
3577
3641
  // eslint-disable-next-line no-await-in-loop
3578
- const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ghsaId, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3642
+ const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ghsaId, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(glob ? ['--glob', glob] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3579
3643
  cwd,
3580
3644
  spinner,
3581
3645
  stdio: 'inherit'
@@ -3630,6 +3694,16 @@ async function coanaFix(fixConfig) {
3630
3694
  }
3631
3695
 
3632
3696
  // Set up git remote.
3697
+ if (!fixEnv.githubToken) {
3698
+ logger.logger.error('Cannot create pull request: SOCKET_CLI_GITHUB_TOKEN environment variable is not set.\n' + 'Set SOCKET_CLI_GITHUB_TOKEN or GITHUB_TOKEN to enable PR creation.');
3699
+ // eslint-disable-next-line no-await-in-loop
3700
+ await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
3701
+ // eslint-disable-next-line no-await-in-loop
3702
+ await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
3703
+ // eslint-disable-next-line no-await-in-loop
3704
+ await utils.gitDeleteBranch(branch, cwd);
3705
+ continue ghsaLoop;
3706
+ }
3633
3707
  // eslint-disable-next-line no-await-in-loop
3634
3708
  await utils.setGitRemoteGithubRepoUrl(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, fixEnv.githubToken, cwd);
3635
3709
 
@@ -3751,7 +3825,7 @@ async function convertIdsToGhsas(ids) {
3751
3825
  const conversionResult = await utils.convertPurlToGhsas(trimmedId);
3752
3826
  if (conversionResult.ok && conversionResult.data.length) {
3753
3827
  validGhsas.push(...conversionResult.data);
3754
- logger.logger.info(`Converted ${trimmedId} to ${conversionResult.data.length} GHSA(s): ${conversionResult.data.join(', ')}`);
3828
+ logger.logger.info(`Converted ${trimmedId} to ${conversionResult.data.length} GHSA(s): ${arrays.joinAnd(conversionResult.data)}`);
3755
3829
  } else {
3756
3830
  errors.push(`${trimmedId}: ${conversionResult.message || 'No GHSAs found'}`);
3757
3831
  }
@@ -3769,6 +3843,7 @@ async function handleFix({
3769
3843
  autopilot,
3770
3844
  cwd,
3771
3845
  ghsas,
3846
+ glob,
3772
3847
  limit,
3773
3848
  minSatisfying,
3774
3849
  onlyCompute,
@@ -3785,6 +3860,7 @@ async function handleFix({
3785
3860
  cwd,
3786
3861
  // Convert mixed CVE/GHSA/PURL inputs to GHSA IDs only
3787
3862
  ghsas: await convertIdsToGhsas(ghsas),
3863
+ glob,
3788
3864
  limit,
3789
3865
  orgSlug,
3790
3866
  rangeStyle,
@@ -3855,6 +3931,12 @@ const hiddenFlags = {
3855
3931
  ...generalFlags$2['id'],
3856
3932
  hidden: true
3857
3933
  },
3934
+ glob: {
3935
+ type: 'string',
3936
+ default: '',
3937
+ description: 'Glob pattern to pass to coana for filtering files',
3938
+ hidden: true
3939
+ },
3858
3940
  maxSatisfying: {
3859
3941
  type: 'boolean',
3860
3942
  default: true,
@@ -3917,8 +3999,15 @@ async function run$K(argv, importMeta, {
3917
3999
  Options
3918
4000
  ${utils.getFlagListOutput(config.flags)}
3919
4001
 
4002
+ Environment Variables (for CI/PR mode)
4003
+ CI Set to enable CI mode
4004
+ SOCKET_CLI_GITHUB_TOKEN GitHub token for PR creation (or GITHUB_TOKEN)
4005
+ SOCKET_CLI_GIT_USER_NAME Git username for commits
4006
+ SOCKET_CLI_GIT_USER_EMAIL Git email for commits
4007
+
3920
4008
  Examples
3921
4009
  $ ${command}
4010
+ $ ${command} --id CVE-2021-23337
3922
4011
  $ ${command} ./path/to/project --range-style pin
3923
4012
  `
3924
4013
  };
@@ -3931,6 +4020,7 @@ async function run$K(argv, importMeta, {
3931
4020
  });
3932
4021
  const {
3933
4022
  autopilot,
4023
+ glob,
3934
4024
  json,
3935
4025
  limit,
3936
4026
  markdown,
@@ -3966,7 +4056,7 @@ async function run$K(argv, importMeta, {
3966
4056
  const orgSlugCResult = await utils.getDefaultOrgSlug();
3967
4057
  if (!orgSlugCResult.ok) {
3968
4058
  process.exitCode = orgSlugCResult.code ?? 1;
3969
- logger.logger.fail('Unable to resolve a Socket account organization.\nEnsure a Socket API token is specified for the organization using the SOCKET_CLI_API_TOKEN environment variable.');
4059
+ logger.logger.fail(`${constants.ERROR_UNABLE_RESOLVE_ORG}.\nEnsure a Socket API token is specified for the organization using the SOCKET_CLI_API_TOKEN environment variable.`);
3970
4060
  return;
3971
4061
  }
3972
4062
  const orgSlug = orgSlugCResult.data;
@@ -3982,6 +4072,7 @@ async function run$K(argv, importMeta, {
3982
4072
  autopilot,
3983
4073
  cwd,
3984
4074
  ghsas,
4075
+ glob,
3985
4076
  limit,
3986
4077
  minSatisfying,
3987
4078
  prCheck,
@@ -4250,15 +4341,15 @@ async function run$I(argv, importMeta, {
4250
4341
  }
4251
4342
 
4252
4343
  function applyLogin(apiToken, enforcedOrgs, apiBaseUrl, apiProxy) {
4253
- utils.updateConfigValue('enforcedOrgs', enforcedOrgs);
4254
- utils.updateConfigValue('apiToken', apiToken);
4255
- utils.updateConfigValue('apiBaseUrl', apiBaseUrl);
4256
- utils.updateConfigValue('apiProxy', apiProxy);
4344
+ utils.updateConfigValue(constants.CONFIG_KEY_ENFORCED_ORGS, enforcedOrgs);
4345
+ utils.updateConfigValue(constants.CONFIG_KEY_API_TOKEN, apiToken);
4346
+ utils.updateConfigValue(constants.CONFIG_KEY_API_BASE_URL, apiBaseUrl);
4347
+ utils.updateConfigValue(constants.CONFIG_KEY_API_PROXY, apiProxy);
4257
4348
  }
4258
4349
 
4259
4350
  async function attemptLogin(apiBaseUrl, apiProxy) {
4260
- apiBaseUrl ??= utils.getConfigValueOrUndef('apiBaseUrl') ?? undefined;
4261
- apiProxy ??= utils.getConfigValueOrUndef('apiProxy') ?? undefined;
4351
+ apiBaseUrl ??= utils.getConfigValueOrUndef(constants.CONFIG_KEY_API_BASE_URL) ?? undefined;
4352
+ apiProxy ??= utils.getConfigValueOrUndef(constants.CONFIG_KEY_API_PROXY) ?? undefined;
4262
4353
  const apiTokenInput = await prompts.password({
4263
4354
  message: `Enter your ${vendor.terminalLinkExports('Socket.dev API token', 'https://docs.socket.dev/docs/api-keys')} (leave blank to use a limited public token)`
4264
4355
  });
@@ -4372,8 +4463,8 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
4372
4463
  logger.logger.fail('Failed to install tab completion script. Try `socket install completion` later.');
4373
4464
  }
4374
4465
  }
4375
- utils.updateConfigValue('defaultOrg', orgSlugs[0]);
4376
- const previousPersistedToken = utils.getConfigValueOrUndef('apiToken');
4466
+ utils.updateConfigValue(constants.CONFIG_KEY_DEFAULT_ORG, orgSlugs[0]);
4467
+ const previousPersistedToken = utils.getConfigValueOrUndef(constants.CONFIG_KEY_API_TOKEN);
4377
4468
  try {
4378
4469
  applyLogin(apiToken, enforcedOrgs, apiBaseUrl, apiProxy);
4379
4470
  logger.logger.success(`API credentials ${previousPersistedToken === apiToken ? 'refreshed' : previousPersistedToken ? 'updated' : 'set'}`);
@@ -4454,10 +4545,10 @@ async function run$H(argv, importMeta, {
4454
4545
  }
4455
4546
 
4456
4547
  function applyLogout() {
4457
- utils.updateConfigValue('apiToken', null);
4458
- utils.updateConfigValue('apiBaseUrl', null);
4459
- utils.updateConfigValue('apiProxy', null);
4460
- utils.updateConfigValue('enforcedOrgs', null);
4548
+ utils.updateConfigValue(constants.CONFIG_KEY_API_TOKEN, null);
4549
+ utils.updateConfigValue(constants.CONFIG_KEY_API_BASE_URL, null);
4550
+ utils.updateConfigValue(constants.CONFIG_KEY_API_PROXY, null);
4551
+ utils.updateConfigValue(constants.CONFIG_KEY_ENFORCED_ORGS, null);
4461
4552
  }
4462
4553
 
4463
4554
  function attemptLogout() {
@@ -4512,11 +4603,9 @@ async function run$G(argv, importMeta, {
4512
4603
  attemptLogout();
4513
4604
  }
4514
4605
 
4515
- const require$6 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
4516
4606
  const {
4517
4607
  PACKAGE_LOCK_JSON,
4518
4608
  PNPM_LOCK_YAML,
4519
- YARN,
4520
4609
  YARN_LOCK
4521
4610
  } = constants.default;
4522
4611
  const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', constants.NPM, constants.PNPM, 'ts', 'tsx', 'typescript']);
@@ -4578,30 +4667,20 @@ async function runCdxgen(argvObj) {
4578
4667
  const yarnLockPath = pnpmLockPath || npmLockPath ? undefined : await utils.findUp(YARN_LOCK, {
4579
4668
  onlyFiles: true
4580
4669
  });
4670
+ const agent = pnpmLockPath ? constants.PNPM : yarnLockPath && utils.isYarnBerry() ? constants.YARN : constants.NPM;
4581
4671
  let cleanupPackageLock = false;
4582
- if (argvMutable['type'] !== YARN && nodejsPlatformTypes.has(argvMutable['type']) && yarnLockPath) {
4672
+ if (argvMutable['type'] !== constants.YARN && nodejsPlatformTypes.has(argvMutable['type']) && yarnLockPath) {
4583
4673
  if (npmLockPath) {
4584
4674
  argvMutable['type'] = constants.NPM;
4585
4675
  } else {
4586
4676
  // Use synp to create a package-lock.json from the yarn.lock,
4587
4677
  // based on the node_modules folder, for a more accurate SBOM.
4588
4678
  try {
4589
- const useYarnBerry = utils.isYarnBerry();
4590
- let args;
4591
- let synpPromise;
4592
- if (pnpmLockPath) {
4593
- args = ['dlx', `synp@${constants.default.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`];
4594
- const shadowPnpmBin = /*@__PURE__*/require$6(constants.default.shadowPnpmBinPath);
4595
- synpPromise = (await shadowPnpmBin(args, shadowOpts)).spawnPromise;
4596
- } else if (useYarnBerry) {
4597
- args = ['dlx', `synp@${constants.default.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`];
4598
- const shadowYarnBin = /*@__PURE__*/require$6(constants.default.shadowYarnBinPath);
4599
- synpPromise = (await shadowYarnBin(args, shadowOpts)).spawnPromise;
4600
- } else {
4601
- args = ['exec', '--yes', `synp@${constants.default.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`];
4602
- synpPromise = (await shadowNpmBin('npm', args, shadowOpts)).spawnPromise;
4603
- }
4604
- await synpPromise;
4679
+ const synpResult = await utils.spawnSynpDlx(['--source-file', `./${YARN_LOCK}`], {
4680
+ ...shadowOpts,
4681
+ agent
4682
+ });
4683
+ await synpResult.spawnPromise;
4605
4684
  argvMutable['type'] = constants.NPM;
4606
4685
  cleanupPackageLock = true;
4607
4686
  } catch {}
@@ -4609,19 +4688,15 @@ async function runCdxgen(argvObj) {
4609
4688
  }
4610
4689
 
4611
4690
  // Use appropriate package manager for cdxgen
4612
- let shadowResult;
4613
- if (pnpmLockPath) {
4614
- const shadowPnpmBin = /*@__PURE__*/require$6(constants.default.shadowPnpmBinPath);
4615
- shadowResult = await shadowPnpmBin(['dlx', '--silent', `@cyclonedx/cdxgen@${constants.default.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
4616
- } else if (yarnLockPath && utils.isYarnBerry()) {
4617
- const shadowYarnBin = /*@__PURE__*/require$6(constants.default.shadowYarnBinPath);
4618
- shadowResult = await shadowYarnBin(['dlx', '--quiet', `@cyclonedx/cdxgen@${constants.default.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
4619
- } else {
4620
- shadowResult = await shadowNpmBin('npm', ['exec', '--silent', '--yes', `@cyclonedx/cdxgen@${constants.default.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, '--', ...argvToArray(argvMutable)], shadowOpts);
4621
- }
4691
+ const shadowResult = await utils.spawnCdxgenDlx(argvToArray(argvMutable), {
4692
+ ...shadowOpts,
4693
+ agent
4694
+ });
4622
4695
  shadowResult.spawnPromise.process.on('exit', () => {
4623
4696
  if (cleanupPackageLock) {
4624
4697
  try {
4698
+ // TODO: Consider using trash instead of rmSync for safer deletion.
4699
+ // This removes the temporary package-lock.json we created for cdxgen.
4625
4700
  fs$1.rmSync(`./${PACKAGE_LOCK_JSON}`);
4626
4701
  } catch {}
4627
4702
  }
@@ -4887,7 +4962,7 @@ async function run$F(argv, importMeta, context) {
4887
4962
  // options or missing arguments.
4888
4963
  // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
4889
4964
  process.exitCode = 2;
4890
- logger.logger.fail(`Unknown ${words.pluralize('argument', unknownsCount)}: ${unknowns.join(', ')}`);
4965
+ logger.logger.fail(`Unknown ${words.pluralize('argument', unknownsCount)}: ${arrays.joinAnd(unknowns)}`);
4891
4966
  return;
4892
4967
  }
4893
4968
  if (dryRun) {
@@ -6234,7 +6309,7 @@ async function run$x(argv, importMeta, context) {
6234
6309
  const argsToForward = utils.filterFlags(argv, {
6235
6310
  ...flags.commonFlags,
6236
6311
  ...flags.outputFlags
6237
- }, ['--json']);
6312
+ }, [constants.FLAG_JSON]);
6238
6313
  const {
6239
6314
  spawnPromise
6240
6315
  } = await shadowBin(constants.NPM, argsToForward, {
@@ -8413,7 +8488,7 @@ async function fetchPurlsShallowScore(purls, options) {
8413
8488
  return sockSdkCResult;
8414
8489
  }
8415
8490
  const sockSdk = sockSdkCResult.data;
8416
- logger.logger.info(`Requesting shallow score data for ${purls.length} package urls (purl): ${purls.join(', ')}`);
8491
+ logger.logger.info(`Requesting shallow score data for ${purls.length} package urls (purl): ${arrays.joinAnd(purls)}`);
8417
8492
  const batchPackageCResult = await utils.handleApiCall(sockSdk.batchPackageFetch({
8418
8493
  components: purls.map(purl => ({
8419
8494
  purl
@@ -13971,7 +14046,7 @@ async function run$3(argv, importMeta, {
13971
14046
  }
13972
14047
  });
13973
14048
  if (argSet.size) {
13974
- logger.logger.info(`Warning: ignoring these excessive args: ${Array.from(argSet).join(', ')}`);
14049
+ logger.logger.info(`Warning: ignoring these excessive args: ${arrays.joinAnd(Array.from(argSet))}`);
13975
14050
  }
13976
14051
  const hasApiToken = utils.hasDefaultApiToken();
13977
14052
  const {
@@ -14660,5 +14735,5 @@ void (async () => {
14660
14735
  await utils.captureException(e);
14661
14736
  }
14662
14737
  })();
14663
- //# debugId=5d651596-3967-43af-9860-99f4bc7ab867
14738
+ //# debugId=243906f3-caec-435c-aaca-fe5ec4aeb381
14664
14739
  //# sourceMappingURL=cli.js.map