socket 1.1.24 → 1.1.26

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,11 @@ 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.26](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.26) - 2025-11-08
8
+
9
+ ### Added
10
+ - Debug logging of API requests/responses
11
+
7
12
  ## [1.1.23](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.23) - 2025-09-22
8
13
 
9
14
  ### Changed
package/dist/cli.js CHANGED
@@ -12,9 +12,9 @@ var constants = require('./constants.js');
12
12
  var flags = require('./flags.js');
13
13
  var path = require('node:path');
14
14
  var words = require('../external/@socketsecurity/registry/lib/words');
15
+ var fs$1 = require('node:fs');
15
16
  var arrays = require('../external/@socketsecurity/registry/lib/arrays');
16
17
  var prompts = require('../external/@socketsecurity/registry/lib/prompts');
17
- var fs$1 = require('node:fs');
18
18
  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');
@@ -907,6 +907,17 @@ async function fetchCreateOrgFullScan(packagePaths, orgSlug, config, options) {
907
907
  return sockSdkCResult;
908
908
  }
909
909
  const sockSdk = sockSdkCResult.data;
910
+ if (constants.default.ENV.SOCKET_CLI_DEBUG) {
911
+ const fileInfo = await Promise.all(packagePaths.map(async p => {
912
+ const absPath = path.resolve(process.cwd(), p);
913
+ const stat = await fs$1.promises.stat(absPath);
914
+ return {
915
+ path: absPath,
916
+ size: stat.size
917
+ };
918
+ }));
919
+ logger.logger.info(`[DEBUG] ${new Date().toISOString()} Uploading full scan manifests: ${JSON.stringify(fileInfo)}`);
920
+ }
910
921
  return await utils.handleApiCall(sockSdk.createOrgFullScan(orgSlug, packagePaths, cwd, {
911
922
  ...(branchName ? {
912
923
  branch: branchName
@@ -3547,12 +3558,14 @@ async function coanaFix(fixConfig) {
3547
3558
  applyFixes,
3548
3559
  autopilot,
3549
3560
  cwd,
3561
+ disableMajorUpdates,
3550
3562
  ghsas,
3551
3563
  glob,
3552
3564
  limit,
3553
3565
  minimumReleaseAge,
3554
3566
  orgSlug,
3555
3567
  outputFile,
3568
+ showAffectedDirectDependencies,
3556
3569
  spinner
3557
3570
  } = fixConfig;
3558
3571
  const fixEnv = await getFixEnv();
@@ -3617,7 +3630,7 @@ async function coanaFix(fixConfig) {
3617
3630
  }
3618
3631
  };
3619
3632
  }
3620
- 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] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...(!applyFixes ? [constants.FLAG_DRY_RUN] : []), ...(outputFile ? ['--output-file', outputFile] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3633
+ 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] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...(!applyFixes ? [constants.FLAG_DRY_RUN] : []), ...(outputFile ? ['--output-file', outputFile] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3621
3634
  cwd,
3622
3635
  spinner,
3623
3636
  stdio: 'inherit'
@@ -3652,7 +3665,7 @@ async function coanaFix(fixConfig) {
3652
3665
  const shouldSpawnCoana = adjustedLimit > 0;
3653
3666
  let ids;
3654
3667
  if (shouldSpawnCoana && isAll) {
3655
- const foundCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3668
+ const foundCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3656
3669
  cwd,
3657
3670
  spinner
3658
3671
  });
@@ -3694,7 +3707,7 @@ async function coanaFix(fixConfig) {
3694
3707
 
3695
3708
  // Apply fix for single GHSA ID.
3696
3709
  // eslint-disable-next-line no-await-in-loop
3697
- 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] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3710
+ 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] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(glob ? ['--glob', glob] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
3698
3711
  cwd,
3699
3712
  spinner,
3700
3713
  stdio: 'inherit'
@@ -3907,6 +3920,7 @@ async function handleFix({
3907
3920
  applyFixes,
3908
3921
  autopilot,
3909
3922
  cwd,
3923
+ disableMajorUpdates,
3910
3924
  ghsas,
3911
3925
  glob,
3912
3926
  limit,
@@ -3917,6 +3931,7 @@ async function handleFix({
3917
3931
  outputKind,
3918
3932
  prCheck,
3919
3933
  rangeStyle,
3934
+ showAffectedDirectDependencies,
3920
3935
  spinner,
3921
3936
  unknownFlags
3922
3937
  }) {
@@ -3924,6 +3939,7 @@ async function handleFix({
3924
3939
  require$$9.debugDir('inspect', {
3925
3940
  autopilot,
3926
3941
  cwd,
3942
+ disableMajorUpdates,
3927
3943
  ghsas,
3928
3944
  glob,
3929
3945
  limit,
@@ -3933,12 +3949,14 @@ async function handleFix({
3933
3949
  outputKind,
3934
3950
  prCheck,
3935
3951
  rangeStyle,
3952
+ showAffectedDirectDependencies,
3936
3953
  unknownFlags
3937
3954
  });
3938
3955
  await outputFixResult(await coanaFix({
3939
3956
  autopilot,
3940
3957
  applyFixes,
3941
3958
  cwd,
3959
+ disableMajorUpdates,
3942
3960
  // Convert mixed CVE/GHSA/PURL inputs to GHSA IDs only
3943
3961
  ghsas: await convertIdsToGhsas(ghsas),
3944
3962
  glob,
@@ -3946,6 +3964,7 @@ async function handleFix({
3946
3964
  minimumReleaseAge,
3947
3965
  orgSlug,
3948
3966
  rangeStyle,
3967
+ showAffectedDirectDependencies,
3949
3968
  spinner,
3950
3969
  unknownFlags,
3951
3970
  outputFile
@@ -3975,6 +3994,13 @@ const generalFlags$2 = {
3975
3994
  // Hidden to allow custom documenting of the negated `--no-apply-fixes` variant.
3976
3995
  hidden: true
3977
3996
  },
3997
+ majorUpdates: {
3998
+ type: 'boolean',
3999
+ default: true,
4000
+ description: 'Allow major version updates. Use --no-major-updates to disable.',
4001
+ // Hidden to allow custom documenting of the negated `--no-major-updates` variant.
4002
+ hidden: true
4003
+ },
3978
4004
  id: {
3979
4005
  type: 'string',
3980
4006
  default: [],
@@ -4009,6 +4035,11 @@ Available styles:
4009
4035
  type: 'string',
4010
4036
  default: '',
4011
4037
  description: 'Set a minimum age requirement for suggested upgrade versions (e.g., 1h, 2d, 3w). A higher age requirement reduces the risk of upgrading to malicious versions. For example, setting the value to 1 week (1w) gives ecosystem maintainers one week to remove potentially malicious versions.'
4038
+ },
4039
+ showAffectedDirectDependencies: {
4040
+ type: 'boolean',
4041
+ default: false,
4042
+ description: 'List the direct dependencies responsible for introducing transitive vulnerabilities and list the updates required to resolve the vulnerabilities'
4012
4043
  }
4013
4044
  };
4014
4045
  const hiddenFlags = {
@@ -4092,6 +4123,12 @@ async function run$K(argv, importMeta, {
4092
4123
  noApplyFixes: {
4093
4124
  ...config.flags['applyFixes'],
4094
4125
  hidden: false
4126
+ },
4127
+ // Explicitly document the negated --no-major-updates variant.
4128
+ noMajorUpdates: {
4129
+ ...config.flags['majorUpdates'],
4130
+ description: 'Do not suggest or apply fixes that require major version updates of direct or transitive dependencies',
4131
+ hidden: false
4095
4132
  }
4096
4133
  })}
4097
4134
 
@@ -4121,18 +4158,21 @@ async function run$K(argv, importMeta, {
4121
4158
  glob,
4122
4159
  json,
4123
4160
  limit,
4161
+ majorUpdates,
4124
4162
  markdown,
4125
4163
  maxSatisfying,
4126
4164
  minimumReleaseAge,
4127
4165
  outputFile,
4128
4166
  prCheck,
4129
4167
  rangeStyle,
4168
+ showAffectedDirectDependencies,
4130
4169
  // We patched in this feature with `npx custompatch meow` at
4131
4170
  // socket-cli/patches/meow#13.2.0.patch.
4132
4171
  unknownFlags = []
4133
4172
  } = cli.flags;
4134
4173
  const dryRun = !!cli.flags['dryRun'];
4135
4174
  const minSatisfying = cli.flags['minSatisfying'] || !maxSatisfying;
4175
+ const disableMajorUpdates = !majorUpdates;
4136
4176
  const outputKind = utils.getOutputKind(json, markdown);
4137
4177
  const wasValidInput = utils.checkCommandInput(outputKind, {
4138
4178
  test: utils.RangeStyles.includes(rangeStyle),
@@ -4170,6 +4210,7 @@ async function run$K(argv, importMeta, {
4170
4210
  autopilot,
4171
4211
  applyFixes,
4172
4212
  cwd,
4213
+ disableMajorUpdates,
4173
4214
  ghsas,
4174
4215
  glob,
4175
4216
  limit,
@@ -4179,6 +4220,7 @@ async function run$K(argv, importMeta, {
4179
4220
  orgSlug,
4180
4221
  outputKind,
4181
4222
  rangeStyle,
4223
+ showAffectedDirectDependencies,
4182
4224
  spinner,
4183
4225
  unknownFlags,
4184
4226
  outputFile
@@ -11938,12 +11980,20 @@ async function downloadManifestFile({
11938
11980
  require$$9.debugDir('inspect', {
11939
11981
  fileUrl
11940
11982
  });
11941
- const downloadUrlResponse = await fetch(fileUrl, {
11942
- method: 'GET',
11943
- headers: {
11944
- Authorization: `Bearer ${githubToken}`
11945
- }
11946
- });
11983
+ utils.debugApiRequest('GET', fileUrl);
11984
+ let downloadUrlResponse;
11985
+ try {
11986
+ downloadUrlResponse = await fetch(fileUrl, {
11987
+ method: 'GET',
11988
+ headers: {
11989
+ Authorization: `Bearer ${githubToken}`
11990
+ }
11991
+ });
11992
+ utils.debugApiResponse('GET', fileUrl, downloadUrlResponse.status);
11993
+ } catch (e) {
11994
+ utils.debugApiResponse('GET', fileUrl, undefined, e);
11995
+ throw e;
11996
+ }
11947
11997
  require$$9.debugFn('notice', 'complete: request');
11948
11998
  const downloadUrlText = await downloadUrlResponse.text();
11949
11999
  require$$9.debugFn('inspect', 'response: raw download url', downloadUrlText);
@@ -11980,7 +12030,9 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
11980
12030
  let response; // Declare response here to access it in catch if needed
11981
12031
 
11982
12032
  try {
12033
+ utils.debugApiRequest('GET', downloadUrl);
11983
12034
  response = await fetch(downloadUrl);
12035
+ utils.debugApiResponse('GET', downloadUrl, response.status);
11984
12036
  if (!response.ok) {
11985
12037
  const errorMsg = `Download failed due to bad server response: ${response.status} ${response.statusText} for ${downloadUrl}`;
11986
12038
  logger.logger.fail(errorMsg);
@@ -12019,6 +12071,9 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
12019
12071
  data: localPath
12020
12072
  };
12021
12073
  } catch (e) {
12074
+ if (!response) {
12075
+ utils.debugApiResponse('GET', downloadUrl, undefined, e);
12076
+ }
12022
12077
  logger.logger.fail('An error was thrown while trying to download a manifest file... url:', downloadUrl);
12023
12078
  require$$9.debugDir('error', e);
12024
12079
 
@@ -12060,11 +12115,19 @@ async function getLastCommitDetails({
12060
12115
  logger.logger.info(`Requesting last commit for default branch ${defaultBranch} for ${orgGithub}/${repoSlug}...`);
12061
12116
  const commitApiUrl = `${repoApiUrl}/commits?sha=${defaultBranch}&per_page=1`;
12062
12117
  require$$9.debugFn('inspect', 'url: commit', commitApiUrl);
12063
- const commitResponse = await fetch(commitApiUrl, {
12064
- headers: {
12065
- Authorization: `Bearer ${githubToken}`
12066
- }
12067
- });
12118
+ utils.debugApiRequest('GET', commitApiUrl);
12119
+ let commitResponse;
12120
+ try {
12121
+ commitResponse = await fetch(commitApiUrl, {
12122
+ headers: {
12123
+ Authorization: `Bearer ${githubToken}`
12124
+ }
12125
+ });
12126
+ utils.debugApiResponse('GET', commitApiUrl, commitResponse.status);
12127
+ } catch (e) {
12128
+ utils.debugApiResponse('GET', commitApiUrl, undefined, e);
12129
+ throw e;
12130
+ }
12068
12131
  const commitText = await commitResponse.text();
12069
12132
  require$$9.debugFn('inspect', 'response: commit', commitText);
12070
12133
  let lastCommit;
@@ -12156,12 +12219,20 @@ async function getRepoDetails({
12156
12219
  require$$9.debugDir('inspect', {
12157
12220
  repoApiUrl
12158
12221
  });
12159
- const repoDetailsResponse = await fetch(repoApiUrl, {
12160
- method: 'GET',
12161
- headers: {
12162
- Authorization: `Bearer ${githubToken}`
12163
- }
12164
- });
12222
+ let repoDetailsResponse;
12223
+ try {
12224
+ utils.debugApiRequest('GET', repoApiUrl);
12225
+ repoDetailsResponse = await fetch(repoApiUrl, {
12226
+ method: 'GET',
12227
+ headers: {
12228
+ Authorization: `Bearer ${githubToken}`
12229
+ }
12230
+ });
12231
+ utils.debugApiResponse('GET', repoApiUrl, repoDetailsResponse.status);
12232
+ } catch (e) {
12233
+ utils.debugApiResponse('GET', repoApiUrl, undefined, e);
12234
+ throw e;
12235
+ }
12165
12236
  logger.logger.success(`Request completed.`);
12166
12237
  const repoDetailsText = await repoDetailsResponse.text();
12167
12238
  require$$9.debugFn('inspect', 'response: repo', repoDetailsText);
@@ -12204,12 +12275,20 @@ async function getRepoBranchTree({
12204
12275
  logger.logger.info(`Requesting default branch file tree; branch \`${defaultBranch}\`, repo \`${orgGithub}/${repoSlug}\`...`);
12205
12276
  const treeApiUrl = `${repoApiUrl}/git/trees/${defaultBranch}?recursive=1`;
12206
12277
  require$$9.debugFn('inspect', 'url: tree', treeApiUrl);
12207
- const treeResponse = await fetch(treeApiUrl, {
12208
- method: 'GET',
12209
- headers: {
12210
- Authorization: `Bearer ${githubToken}`
12211
- }
12212
- });
12278
+ let treeResponse;
12279
+ try {
12280
+ utils.debugApiRequest('GET', treeApiUrl);
12281
+ treeResponse = await fetch(treeApiUrl, {
12282
+ method: 'GET',
12283
+ headers: {
12284
+ Authorization: `Bearer ${githubToken}`
12285
+ }
12286
+ });
12287
+ utils.debugApiResponse('GET', treeApiUrl, treeResponse.status);
12288
+ } catch (e) {
12289
+ utils.debugApiResponse('GET', treeApiUrl, undefined, e);
12290
+ throw e;
12291
+ }
12213
12292
  const treeText = await treeResponse.text();
12214
12293
  require$$9.debugFn('inspect', 'response: tree', treeText);
12215
12294
  let treeDetails;
@@ -14964,5 +15043,5 @@ void (async () => {
14964
15043
  await utils.captureException(e);
14965
15044
  }
14966
15045
  })();
14967
- //# debugId=a37ba0b8-5e27-487b-ba57-2d9a99bbccae
15046
+ //# debugId=6efb19e5-82e5-4a78-9747-dd32059707f5
14968
15047
  //# sourceMappingURL=cli.js.map