@socketsecurity/cli-with-sentry 1.0.65 → 1.0.66

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 (138) hide show
  1. package/dist/cli.js +522 -345
  2. package/dist/cli.js.map +1 -1
  3. package/dist/constants.js +3 -3
  4. package/dist/constants.js.map +1 -1
  5. package/dist/shadow-npm-inject.js +6 -6
  6. package/dist/shadow-npm-inject.js.map +1 -1
  7. package/dist/types/commands/analytics/fetch-org-analytics.d.mts +6 -2
  8. package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +1 -1
  9. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +6 -2
  10. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +1 -1
  11. package/dist/types/commands/analytics/output-analytics.d.mts +4 -4
  12. package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
  13. package/dist/types/commands/audit-log/fetch-audit-log.d.mts +10 -5
  14. package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +1 -1
  15. package/dist/types/commands/audit-log/handle-audit-log.d.mts +1 -1
  16. package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +1 -1
  17. package/dist/types/commands/audit-log/output-audit-log.d.mts +6 -6
  18. package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
  19. package/dist/types/commands/ci/fetch-default-org-slug.d.mts +1 -1
  20. package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +1 -1
  21. package/dist/types/commands/ci/handle-ci.d.mts +1 -1
  22. package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
  23. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  24. package/dist/types/commands/fix/handle-fix.d.mts +2 -1
  25. package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
  26. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  27. package/dist/types/commands/organization/fetch-dependencies.d.mts +8 -3
  28. package/dist/types/commands/organization/fetch-dependencies.d.mts.map +1 -1
  29. package/dist/types/commands/organization/fetch-license-policy.d.mts +6 -2
  30. package/dist/types/commands/organization/fetch-license-policy.d.mts.map +1 -1
  31. package/dist/types/commands/organization/fetch-organization-list.d.mts +6 -2
  32. package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
  33. package/dist/types/commands/organization/fetch-quota.d.mts +6 -2
  34. package/dist/types/commands/organization/fetch-quota.d.mts.map +1 -1
  35. package/dist/types/commands/organization/fetch-security-policy.d.mts +6 -2
  36. package/dist/types/commands/organization/fetch-security-policy.d.mts.map +1 -1
  37. package/dist/types/commands/organization/output-dependencies.d.mts +2 -2
  38. package/dist/types/commands/organization/output-dependencies.d.mts.map +1 -1
  39. package/dist/types/commands/organization/output-license-policy.d.mts +2 -2
  40. package/dist/types/commands/organization/output-license-policy.d.mts.map +1 -1
  41. package/dist/types/commands/organization/output-organization-list.d.mts +2 -2
  42. package/dist/types/commands/organization/output-organization-list.d.mts.map +1 -1
  43. package/dist/types/commands/organization/output-quota.d.mts +2 -2
  44. package/dist/types/commands/organization/output-quota.d.mts.map +1 -1
  45. package/dist/types/commands/organization/output-security-policy.d.mts +2 -2
  46. package/dist/types/commands/organization/output-security-policy.d.mts.map +1 -1
  47. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +6 -2
  48. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
  49. package/dist/types/commands/repository/fetch-create-repo.d.mts +11 -6
  50. package/dist/types/commands/repository/fetch-create-repo.d.mts.map +1 -1
  51. package/dist/types/commands/repository/fetch-delete-repo.d.mts +6 -2
  52. package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +1 -1
  53. package/dist/types/commands/repository/fetch-list-all-repos.d.mts +8 -6
  54. package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
  55. package/dist/types/commands/repository/fetch-list-repos.d.mts +9 -4
  56. package/dist/types/commands/repository/fetch-list-repos.d.mts.map +1 -1
  57. package/dist/types/commands/repository/fetch-update-repo.d.mts +11 -6
  58. package/dist/types/commands/repository/fetch-update-repo.d.mts.map +1 -1
  59. package/dist/types/commands/repository/fetch-view-repo.d.mts +6 -2
  60. package/dist/types/commands/repository/fetch-view-repo.d.mts.map +1 -1
  61. package/dist/types/commands/repository/handle-create-repo.d.mts +2 -2
  62. package/dist/types/commands/repository/handle-create-repo.d.mts.map +1 -1
  63. package/dist/types/commands/repository/handle-list-repos.d.mts +2 -2
  64. package/dist/types/commands/repository/handle-list-repos.d.mts.map +1 -1
  65. package/dist/types/commands/repository/handle-update-repo.d.mts +2 -2
  66. package/dist/types/commands/repository/handle-update-repo.d.mts.map +1 -1
  67. package/dist/types/commands/repository/output-create-repo.d.mts +2 -2
  68. package/dist/types/commands/repository/output-create-repo.d.mts.map +1 -1
  69. package/dist/types/commands/repository/output-delete-repo.d.mts +2 -2
  70. package/dist/types/commands/repository/output-delete-repo.d.mts.map +1 -1
  71. package/dist/types/commands/repository/output-list-repos.d.mts +2 -2
  72. package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -1
  73. package/dist/types/commands/repository/output-update-repo.d.mts +2 -2
  74. package/dist/types/commands/repository/output-update-repo.d.mts.map +1 -1
  75. package/dist/types/commands/repository/output-view-repo.d.mts +2 -2
  76. package/dist/types/commands/repository/output-view-repo.d.mts.map +1 -1
  77. package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
  78. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +12 -3
  79. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
  80. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +6 -2
  81. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +1 -1
  82. package/dist/types/commands/scan/fetch-diff-scan.d.mts +2 -2
  83. package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +1 -1
  84. package/dist/types/commands/scan/fetch-list-scans.d.mts +9 -4
  85. package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
  86. package/dist/types/commands/scan/fetch-report-data.d.mts +8 -3
  87. package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
  88. package/dist/types/commands/scan/fetch-scan-metadata.d.mts +6 -2
  89. package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +1 -1
  90. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +6 -2
  91. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +1 -1
  92. package/dist/types/commands/scan/generate-report.d.mts +2 -2
  93. package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
  94. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  95. package/dist/types/commands/scan/handle-list-scans.d.mts +2 -2
  96. package/dist/types/commands/scan/handle-list-scans.d.mts.map +1 -1
  97. package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
  98. package/dist/types/commands/scan/output-create-new-scan.d.mts +2 -2
  99. package/dist/types/commands/scan/output-create-new-scan.d.mts.map +1 -1
  100. package/dist/types/commands/scan/output-delete-scan.d.mts +2 -2
  101. package/dist/types/commands/scan/output-delete-scan.d.mts.map +1 -1
  102. package/dist/types/commands/scan/output-diff-scan.d.mts +2 -2
  103. package/dist/types/commands/scan/output-diff-scan.d.mts.map +1 -1
  104. package/dist/types/commands/scan/output-list-scans.d.mts +2 -2
  105. package/dist/types/commands/scan/output-list-scans.d.mts.map +1 -1
  106. package/dist/types/commands/scan/output-scan-metadata.d.mts +2 -2
  107. package/dist/types/commands/scan/output-scan-metadata.d.mts.map +1 -1
  108. package/dist/types/commands/scan/output-scan-report.d.mts +2 -2
  109. package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
  110. package/dist/types/commands/scan/stream-scan.d.mts +6 -1
  111. package/dist/types/commands/scan/stream-scan.d.mts.map +1 -1
  112. package/dist/types/commands/scan/suggest-org-slug.d.mts.map +1 -1
  113. package/dist/types/commands/scan/suggest-repo-slug.d.mts +5 -1
  114. package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +1 -1
  115. package/dist/types/utils/alert/severity.d.mts +2 -2
  116. package/dist/types/utils/alert/severity.d.mts.map +1 -1
  117. package/dist/types/utils/alerts-map.d.mts.map +1 -1
  118. package/dist/types/utils/api.d.mts +8 -3
  119. package/dist/types/utils/api.d.mts.map +1 -1
  120. package/dist/types/utils/coana.d.mts.map +1 -1
  121. package/dist/types/utils/glob.d.mts +4 -2
  122. package/dist/types/utils/glob.d.mts.map +1 -1
  123. package/dist/types/utils/path-resolve.d.mts +2 -2
  124. package/dist/types/utils/path-resolve.d.mts.map +1 -1
  125. package/dist/types/utils/sdk.d.mts +6 -1
  126. package/dist/types/utils/sdk.d.mts.map +1 -1
  127. package/dist/utils.js +208 -104
  128. package/dist/utils.js.map +1 -1
  129. package/dist/vendor.js +141 -61
  130. package/external/@socketsecurity/registry/external/@inquirer/select.js +14 -2
  131. package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +4 -4
  132. package/external/@socketsecurity/registry/external/libnpmpack.js +4 -4
  133. package/external/@socketsecurity/registry/external/npm-package-arg.js +4 -4
  134. package/external/@socketsecurity/registry/external/pacote.js +4 -4
  135. package/external/@socketsecurity/registry/external/validate-npm-package-name.js +4 -4
  136. package/external/@socketsecurity/registry/lib/regexps.js +1 -1
  137. package/external/@socketsecurity/registry/lib/spinner.js +15 -5
  138. package/package.json +12 -12
package/dist/utils.js CHANGED
@@ -5,22 +5,22 @@ var logger = require('../external/@socketsecurity/registry/lib/logger');
5
5
  var strings = require('../external/@socketsecurity/registry/lib/strings');
6
6
  var debug = require('../external/@socketsecurity/registry/lib/debug');
7
7
  var arrays = require('../external/@socketsecurity/registry/lib/arrays');
8
- var objects = require('../external/@socketsecurity/registry/lib/objects');
8
+ var require$$7 = require('../external/@socketsecurity/registry/lib/objects');
9
9
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
10
10
  var sorts = require('../external/@socketsecurity/registry/lib/sorts');
11
11
  var constants = require('./constants.js');
12
12
  var path = require('node:path');
13
13
  var regexps = require('../external/@socketsecurity/registry/lib/regexps');
14
14
  var prompts = require('../external/@socketsecurity/registry/lib/prompts');
15
- var promises = require('node:timers/promises');
16
15
  var spawn = require('../external/@socketsecurity/registry/lib/spawn');
17
16
  var fs = require('node:fs');
18
17
  var fs$1 = require('../external/@socketsecurity/registry/lib/fs');
19
- var require$$7 = require('../external/@socketsecurity/registry/lib/promises');
18
+ var require$$8 = require('../external/@socketsecurity/registry/lib/promises');
20
19
  var packages = require('../external/@socketsecurity/registry/lib/packages');
21
20
  var registry = require('../external/@socketsecurity/registry');
22
21
  var require$$5 = require('node:module');
23
22
  var npm = require('../external/@socketsecurity/registry/lib/npm');
23
+ var promises = require('node:timers/promises');
24
24
 
25
25
  const ignoredDirs = [
26
26
  // Taken from ignore-by-default:
@@ -128,7 +128,11 @@ function workspacePatternToGlobPattern(workspace) {
128
128
  // Things like "packages/a" or "packages/*"
129
129
  return `${workspace}/package.json`;
130
130
  }
131
- async function filterGlobResultToSupportedFiles(entries, supportedFiles) {
131
+ function filterBySupportedScanFiles(filepaths, supportedFiles) {
132
+ const patterns = getSupportedFilePatterns(supportedFiles);
133
+ return filepaths.filter(p => vendor.micromatchExports.some(p, patterns));
134
+ }
135
+ function getSupportedFilePatterns(supportedFiles) {
132
136
  const patterns = [];
133
137
  for (const key of Object.keys(supportedFiles)) {
134
138
  const supported = supportedFiles[key];
@@ -136,7 +140,7 @@ async function filterGlobResultToSupportedFiles(entries, supportedFiles) {
136
140
  patterns.push(...Object.values(supported).map(p => `**/${p.pattern}`));
137
141
  }
138
142
  }
139
- return entries.filter(p => vendor.micromatchExports.some(p, patterns));
143
+ return patterns;
140
144
  }
141
145
  async function globWithGitIgnore(patterns, options) {
142
146
  const {
@@ -147,15 +151,16 @@ async function globWithGitIgnore(patterns, options) {
147
151
  __proto__: null,
148
152
  ...options
149
153
  };
150
- const projectIgnorePaths = socketConfig?.projectIgnorePaths;
151
154
  const ignoreFiles = await vendor.distExports.glob(['**/.gitignore'], {
152
155
  absolute: true,
153
156
  cwd,
154
157
  expandDirectories: true
155
158
  });
159
+ const projectIgnorePaths = socketConfig?.projectIgnorePaths;
156
160
  const ignores = [...ignoredDirPatterns, ...(Array.isArray(projectIgnorePaths) ? ignoreFileLinesToGlobPatterns(projectIgnorePaths, path.join(cwd, '.gitignore'), cwd) : []), ...(await Promise.all(ignoreFiles.map(async filepath => ignoreFileToGlobPatterns((await safeReadFile(filepath)) ?? '', filepath, cwd)))).flat()];
157
161
  const hasNegatedPattern = ignores.some(p => p.charCodeAt(0) === 33 /*'!'*/);
158
162
  const globOptions = {
163
+ __proto__: null,
159
164
  absolute: true,
160
165
  cwd,
161
166
  dot: true,
@@ -167,14 +172,11 @@ async function globWithGitIgnore(patterns, options) {
167
172
  if (!hasNegatedPattern) {
168
173
  return result;
169
174
  }
170
- const {
171
- absolute
172
- } = globOptions;
173
175
 
174
176
  // Note: the input files must be INSIDE the cwd. If you get strange looking
175
177
  // relative path errors here, most likely your path is outside the given cwd.
176
- const filtered = vendor.ignoreExports().add(ignores).filter(absolute ? result.map(p => path.relative(cwd, p)) : result);
177
- return absolute ? filtered.map(p => path.resolve(cwd, p)) : filtered;
178
+ const filtered = vendor.ignoreExports().add(ignores).filter(globOptions.absolute ? result.map(p => path.relative(cwd, p)) : result);
179
+ return globOptions.absolute ? filtered.map(p => path.resolve(cwd, p)) : filtered;
178
180
  }
179
181
  async function globNodeModules(cwd = process.cwd()) {
180
182
  return await vendor.distExports.glob('**/node_modules', {
@@ -192,6 +194,10 @@ async function globWorkspace(agent, cwd = process.cwd()) {
192
194
  ignore: ['**/node_modules/**', '**/bower_components/**']
193
195
  }) : [];
194
196
  }
197
+ function isReportSupportedFile(filepath, supportedFiles) {
198
+ const patterns = getSupportedFilePatterns(supportedFiles);
199
+ return vendor.micromatchExports.some(filepath, patterns);
200
+ }
195
201
  function pathsToGlobPatterns(paths) {
196
202
  // TODO: Does not support `~/` paths.
197
203
  return paths.map(p => p === '.' || p === './' ? '**/*' : p);
@@ -199,7 +205,7 @@ function pathsToGlobPatterns(paths) {
199
205
 
200
206
  async function removeNodeModules(cwd = process.cwd()) {
201
207
  const nodeModulesPaths = await globNodeModules(cwd);
202
- await require$$7.pEach(nodeModulesPaths, 3, p => fs$1.remove(p, {
208
+ await require$$8.pEach(nodeModulesPaths, 3, p => fs$1.remove(p, {
203
209
  force: true,
204
210
  recursive: true
205
211
  }), {
@@ -597,7 +603,14 @@ function getPublicToken() {
597
603
  // Lazily access constants.SOCKET_PUBLIC_API_TOKEN.
598
604
  constants.SOCKET_PUBLIC_API_TOKEN;
599
605
  }
600
- async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApiBaseUrl$1(), proxy) {
606
+ async function setupSdk(options) {
607
+ const opts = {
608
+ __proto__: null,
609
+ ...options
610
+ };
611
+ let {
612
+ apiToken = getDefaultToken()
613
+ } = opts;
601
614
  if (typeof apiToken !== 'string' && vendor.isInteractiveExports()) {
602
615
  apiToken = await prompts.password({
603
616
  message: 'Enter your Socket.dev API key (not saved, use socket login to persist)'
@@ -611,15 +624,21 @@ async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApi
611
624
  cause: 'You need to provide an API Token. Run `socket login` first.'
612
625
  };
613
626
  }
614
- if (!isUrl(proxy)) {
615
- proxy = getDefaultProxyUrl();
627
+ let {
628
+ apiProxy
629
+ } = opts;
630
+ if (!isUrl(apiProxy)) {
631
+ apiProxy = getDefaultProxyUrl();
616
632
  }
617
- const ProxyAgent = proxy?.startsWith('http:') ? vendor.HttpProxyAgent : vendor.HttpsProxyAgent;
633
+ const {
634
+ apiBaseUrl = getDefaultApiBaseUrl$1()
635
+ } = opts;
636
+ const ProxyAgent = apiProxy?.startsWith('http:') ? vendor.HttpProxyAgent : vendor.HttpsProxyAgent;
618
637
  return {
619
638
  ok: true,
620
639
  data: new vendor.distExports$2.SocketSdk(apiToken, {
621
- agent: proxy ? new ProxyAgent({
622
- proxy
640
+ agent: apiProxy ? new ProxyAgent({
641
+ proxy: apiProxy
623
642
  }) : undefined,
624
643
  baseUrl: apiBaseUrl,
625
644
  userAgent: vendor.distExports$2.createUserAgentFromPkgJson({
@@ -634,59 +653,79 @@ async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApi
634
653
  };
635
654
  }
636
655
 
637
- async function handleApiCall(value, fetchingDesc) {
638
- // Lazily access constants.spinner.
656
+ const NO_ERROR_MESSAGE = 'No error message returned';
657
+ async function handleApiCall(value, options) {
639
658
  const {
659
+ desc,
640
660
  spinner
641
- } = constants;
642
- spinner.start(`Requesting ${fetchingDesc} from API...`);
643
- let result;
661
+ } = {
662
+ __proto__: null,
663
+ ...options
664
+ };
665
+ if (desc) {
666
+ spinner?.start(`Requesting ${desc} from API...`);
667
+ } else {
668
+ spinner?.start();
669
+ }
670
+ let sdkResult;
644
671
  try {
645
- result = await value;
646
-
647
- // TODO: info, not success (looks weird when response is non-200)
648
- spinner.successAndStop(`Received API response (after requesting ${fetchingDesc}).`);
672
+ sdkResult = await value;
673
+ if (desc) {
674
+ // TODO: info, not success (looks weird when response is non-200)
675
+ spinner?.successAndStop(`Received API response (after requesting ${desc}).`);
676
+ } else {
677
+ spinner?.stop();
678
+ }
649
679
  } catch (e) {
650
- spinner.failAndStop(`An error was thrown while requesting ${fetchingDesc}`);
651
- const message = `${e || 'No error message returned'}`;
652
- const reason = `${e || 'No error message returned'}`;
653
- debug.debugFn('error', `caught: ${fetchingDesc} error`);
680
+ if (desc) {
681
+ spinner?.failAndStop(`An error was thrown while requesting ${desc}`);
682
+ debug.debugFn('error', `caught: ${desc} error`);
683
+ } else {
684
+ spinner?.stop();
685
+ debug.debugFn('error', `caught: error`);
686
+ }
654
687
  debug.debugDir('inspect', {
655
688
  error: e
656
689
  });
657
690
  return {
658
691
  ok: false,
659
692
  message: 'Socket API returned an error',
660
- cause: `${message}${reason ? ` ( Reason: ${reason} )` : ''}`
693
+ cause: vendor.messageWithCauses(e)
661
694
  };
662
695
  } finally {
663
- spinner.stop();
696
+ spinner?.stop();
664
697
  }
665
698
 
666
- // Note: TS can't narrow down the type of result due to generics
667
- if (result.success === false) {
668
- const error = result;
669
- const message = `${error.error || 'No error message returned'}`;
699
+ // Note: TS can't narrow down the type of result due to generics.
700
+ if (sdkResult.success === false) {
701
+ const errorResult = sdkResult;
702
+ const message = `${errorResult.error || NO_ERROR_MESSAGE}`;
670
703
  const {
671
704
  cause: reason
672
- } = error;
673
- debug.debugFn('error', `fail: ${fetchingDesc} bad response`);
705
+ } = errorResult;
706
+ if (desc) {
707
+ debug.debugFn('error', `fail: ${desc} bad response`);
708
+ } else {
709
+ debug.debugFn('error', 'fail: bad response');
710
+ }
674
711
  debug.debugDir('inspect', {
675
- error
712
+ sdkResult
676
713
  });
677
714
  return {
678
715
  ok: false,
679
716
  message: 'Socket API returned an error',
680
717
  cause: `${message}${reason ? ` ( Reason: ${reason} )` : ''}`,
681
718
  data: {
682
- code: result.status
719
+ code: sdkResult.status
683
720
  }
684
721
  };
685
722
  } else {
686
- const ok = result;
723
+ const {
724
+ data
725
+ } = sdkResult;
687
726
  return {
688
727
  ok: true,
689
- data: ok.data
728
+ data
690
729
  };
691
730
  }
692
731
  }
@@ -695,8 +734,8 @@ async function handleApiCallNoSpinner(value, description) {
695
734
  try {
696
735
  result = await value;
697
736
  } catch (e) {
698
- const message = `${e || 'No error message returned'}`;
699
- const reason = `${e || 'No error message returned'}`;
737
+ const message = `${e || NO_ERROR_MESSAGE}`;
738
+ const reason = `${e || NO_ERROR_MESSAGE}`;
700
739
  debug.debugFn('error', `caught: ${description} error`);
701
740
  debug.debugDir('inspect', {
702
741
  error: e
@@ -711,7 +750,7 @@ async function handleApiCallNoSpinner(value, description) {
711
750
  // Note: TS can't narrow down the type of result due to generics
712
751
  if (result.success === false) {
713
752
  const error = result;
714
- const message = `${error.error || 'No error message returned'}`;
753
+ const message = `${error.error || NO_ERROR_MESSAGE}`;
715
754
  debug.debugFn('error', `fail: ${description} bad response`);
716
755
  debug.debugDir('inspect', {
717
756
  error
@@ -1120,7 +1159,7 @@ function getHelpListOutput(list, options) {
1120
1159
  if (entry && 'hidden' in entry && entry?.hidden) {
1121
1160
  continue;
1122
1161
  }
1123
- const description = (objects.isObject(entry) ? entry.description : entry) || '';
1162
+ const description = (require$$7.isObject(entry) ? entry.description : entry) || '';
1124
1163
  result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
1125
1164
  }
1126
1165
  return result.trim() || '(none)';
@@ -1277,10 +1316,10 @@ async function meowWithSubcommands(subcommands, options) {
1277
1316
  function formatCommandsForHelp(isRootCommand) {
1278
1317
  if (!isRootCommand) {
1279
1318
  return getHelpListOutput({
1280
- ...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
1319
+ ...require$$7.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
1281
1320
  1: subcommand
1282
1321
  }) => !subcommand.hidden))),
1283
- ...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
1322
+ ...require$$7.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
1284
1323
  1: alias
1285
1324
  }) => {
1286
1325
  const {
@@ -1525,41 +1564,54 @@ function msAtHome(isoTimeStamp) {
1525
1564
  }
1526
1565
  }
1527
1566
 
1528
- async function suggestOrgSlug() {
1529
- const sockSdkCResult = await setupSdk();
1567
+ async function fetchOrganization(options) {
1568
+ const {
1569
+ sdkOptions
1570
+ } = {
1571
+ __proto__: null,
1572
+ ...options
1573
+ };
1574
+ const sockSdkCResult = await setupSdk(sdkOptions);
1530
1575
  if (!sockSdkCResult.ok) {
1531
- return;
1576
+ return sockSdkCResult;
1532
1577
  }
1533
1578
  const sockSdk = sockSdkCResult.data;
1534
- const result = await handleApiCall(sockSdk.getOrganizations(), 'list of organizations');
1579
+ return await handleApiCall(sockSdk.getOrganizations(), {
1580
+ desc: 'organization list'
1581
+ });
1582
+ }
1583
+
1584
+ async function suggestOrgSlug() {
1585
+ const orgsCResult = await fetchOrganization();
1586
+ if (!orgsCResult.ok) {
1587
+ logger.logger.fail('Failed to lookup organization list from API, unable to suggest');
1588
+ return undefined;
1589
+ }
1535
1590
 
1536
1591
  // Ignore a failed request here. It was not the primary goal of
1537
1592
  // running this command and reporting it only leads to end-user confusion.
1538
- if (result.ok) {
1539
- const proceed = await prompts.select({
1540
- message: 'Missing org name; do you want to use any of these orgs for this scan?',
1541
- choices: [...Object.values(result.data.organizations).map(org => {
1542
- const name = org.name ?? org.slug;
1543
- return {
1544
- name: `Yes [${name}]`,
1545
- value: name,
1546
- description: `Use "${name}" as the organization`
1547
- };
1548
- }), {
1549
- name: 'No',
1550
- value: '',
1551
- description: 'Do not use any of these organizations (will end in a no-op)'
1552
- }]
1553
- });
1554
- if (proceed === undefined) {
1555
- return undefined;
1556
- }
1557
- if (proceed) {
1558
- return proceed;
1559
- }
1560
- } else {
1561
- logger.logger.fail('Failed to lookup organization list from API, unable to suggest');
1593
+ const {
1594
+ organizations
1595
+ } = orgsCResult.data;
1596
+ const proceed = await prompts.select({
1597
+ message: 'Missing org name; do you want to use any of these orgs for this scan?',
1598
+ choices: [...Object.values(organizations).map(o => {
1599
+ const name = o.name ?? o.slug;
1600
+ return {
1601
+ name: `Yes [${name}]`,
1602
+ value: name,
1603
+ description: `Use "${name}" as the organization`
1604
+ };
1605
+ }), {
1606
+ name: 'No',
1607
+ value: '',
1608
+ description: 'Do not use any of these organizations (will end in a no-op)'
1609
+ }]
1610
+ });
1611
+ if (proceed) {
1612
+ return proceed;
1562
1613
  }
1614
+ return undefined;
1563
1615
  }
1564
1616
 
1565
1617
  async function suggestToPersistOrgSlug(orgSlug) {
@@ -1637,6 +1689,47 @@ async function determineOrgSlug(orgFlag, interactive, dryRun) {
1637
1689
  return [orgSlug, defaultOrgSlug];
1638
1690
  }
1639
1691
 
1692
+ // Use the config defaultOrg when set, otherwise discover from remote.
1693
+ async function getDefaultOrgSlug() {
1694
+ const defaultOrgResult = getConfigValueOrUndef('defaultOrg');
1695
+ if (defaultOrgResult) {
1696
+ debug.debugFn('notice', 'use: default org', defaultOrgResult);
1697
+ return {
1698
+ ok: true,
1699
+ data: defaultOrgResult
1700
+ };
1701
+ }
1702
+ const orgsCResult = await fetchOrganization();
1703
+ if (!orgsCResult.ok) {
1704
+ return orgsCResult;
1705
+ }
1706
+ const {
1707
+ organizations
1708
+ } = orgsCResult.data;
1709
+ const keys = Object.keys(organizations);
1710
+ if (!keys.length) {
1711
+ return {
1712
+ ok: false,
1713
+ message: 'Failed to establish identity',
1714
+ data: `API did not return any organization associated with the current API token. Unable to continue.`
1715
+ };
1716
+ }
1717
+ const slug = organizations[keys[0]]?.name ?? undefined;
1718
+ if (!slug) {
1719
+ return {
1720
+ ok: false,
1721
+ message: 'Failed to establish identity',
1722
+ data: `Was unable to determine the default organization for the current API token. Unable to continue.`
1723
+ };
1724
+ }
1725
+ debug.debugFn('notice', 'resolve: org', slug);
1726
+ return {
1727
+ ok: true,
1728
+ message: 'Retrieved default org from server',
1729
+ data: slug
1730
+ };
1731
+ }
1732
+
1640
1733
  async function getBaseBranch(cwd = process.cwd()) {
1641
1734
  // Lazily access constants.ENV properties.
1642
1735
  const {
@@ -2042,16 +2135,15 @@ function* walkNestedMap(map, keys = []) {
2042
2135
  }
2043
2136
  }
2044
2137
 
2045
- const {
2046
- NODE_MODULES: NODE_MODULES$1,
2047
- NPM: NPM$4,
2048
- shadowBinPath
2049
- } = constants;
2050
2138
  function findBinPathDetailsSync(binName) {
2051
2139
  const binPaths = vendor.libExports$1.sync(binName, {
2052
2140
  all: true,
2053
2141
  nothrow: true
2054
2142
  }) ?? [];
2143
+ // Lazily access constants.shadowBinPath.
2144
+ const {
2145
+ shadowBinPath
2146
+ } = constants;
2055
2147
  let shadowIndex = -1;
2056
2148
  let theBinPath;
2057
2149
  for (let i = 0, {
@@ -2079,7 +2171,7 @@ function findNpmPathSync(npmBinPath) {
2079
2171
  } = constants;
2080
2172
  let thePath = npmBinPath;
2081
2173
  while (true) {
2082
- const libNmNpmPath = path.join(thePath, 'lib', NODE_MODULES$1, NPM$4);
2174
+ const libNmNpmPath = path.join(thePath, 'lib/node_modules/npm');
2083
2175
  // mise puts its npm bin in a path like:
2084
2176
  // /Users/SomeUsername/.local/share/mise/installs/node/vX.X.X/bin/npm.
2085
2177
  // HOWEVER, the location of the npm install is:
@@ -2089,9 +2181,9 @@ function findNpmPathSync(npmBinPath) {
2089
2181
  // will throw an ENOTDIR error for paths like ./a-file-that-exists/a-directory-that-does-not.
2090
2182
  // See https://github.com/nodejs/node/issues/56993.
2091
2183
  fs.existsSync(libNmNpmPath) && safeStatsSync(libNmNpmPath)?.isDirectory()) {
2092
- thePath = path.join(libNmNpmPath, NPM$4);
2184
+ thePath = path.join(libNmNpmPath, 'npm');
2093
2185
  }
2094
- const nmPath = path.join(thePath, NODE_MODULES$1);
2186
+ const nmPath = path.join(thePath, 'node_modules');
2095
2187
  if (
2096
2188
  // npm bin paths may look like:
2097
2189
  // /usr/local/share/npm/bin/npm
@@ -2105,9 +2197,9 @@ function findNpmPathSync(npmBinPath) {
2105
2197
  // C:\Program Files\nodejs\node_modules
2106
2198
  fs.existsSync(nmPath) && safeStatsSync(nmPath)?.isDirectory() && (
2107
2199
  // Optimistically look for the default location.
2108
- path.basename(thePath) === NPM$4 ||
2200
+ path.basename(thePath) === 'npm' ||
2109
2201
  // Chocolatey installs npm bins in the same directory as node bins.
2110
- WIN32 && fs.existsSync(path.join(thePath, `${NPM$4}.cmd`)))) {
2202
+ WIN32 && fs.existsSync(path.join(thePath, 'npm.cmd')))) {
2111
2203
  return thePath;
2112
2204
  }
2113
2205
  const parent = path.dirname(thePath);
@@ -2125,11 +2217,11 @@ async function getPackageFilesForScan(inputPaths, supportedFiles, options) {
2125
2217
  __proto__: null,
2126
2218
  ...options
2127
2219
  };
2128
- const entries = await globWithGitIgnore(pathsToGlobPatterns(inputPaths), {
2220
+ const filepaths = await globWithGitIgnore(pathsToGlobPatterns(inputPaths), {
2129
2221
  cwd,
2130
2222
  socketConfig
2131
2223
  });
2132
- return await filterGlobResultToSupportedFiles(entries, supportedFiles);
2224
+ return filterBySupportedScanFiles(filepaths, supportedFiles);
2133
2225
  }
2134
2226
 
2135
2227
  async function readOrDefaultSocketJson(cwd) {
@@ -2566,7 +2658,7 @@ async function addArtifactToAlertsMap(artifact, alertsByPurl, options) {
2566
2658
  const fixableCve = fixType === ALERT_FIX_TYPE.cve;
2567
2659
  const fixableUpgrade = fixType === ALERT_FIX_TYPE.upgrade;
2568
2660
  const fixable = fixableCve || fixableUpgrade;
2569
- const upgradable = fixableUpgrade && !objects.hasOwn(overrides, name);
2661
+ const upgradable = fixableUpgrade && !require$$7.hasOwn(overrides, name);
2570
2662
  if (include.blocked && blocked || include.critical && critical || include.cve && cve || include.unfixable && !fixable || include.upgradable && upgradable) {
2571
2663
  sockPkgAlerts.push({
2572
2664
  name,
@@ -2931,7 +3023,7 @@ function parsePnpmLockfile(lockfileContent) {
2931
3023
  result = vendor.jsYaml.load(strings.stripBom(lockfileContent));
2932
3024
  } catch {}
2933
3025
  }
2934
- return objects.isObjectObject(result) ? result : null;
3026
+ return require$$7.isObjectObject(result) ? result : null;
2935
3027
  }
2936
3028
  function parsePnpmLockfileVersion(version) {
2937
3029
  try {
@@ -2992,7 +3084,9 @@ async function getAlertsMapFromPurls(purls, options) {
2992
3084
  } = opts;
2993
3085
  const getText = () => `Looking up data for ${remaining} packages`;
2994
3086
  spinner?.start(getText());
2995
- const sockSdkCResult = await setupSdk(getPublicToken());
3087
+ const sockSdkCResult = await setupSdk({
3088
+ apiToken: getPublicToken()
3089
+ });
2996
3090
  if (!sockSdkCResult.ok) {
2997
3091
  spinner?.stop();
2998
3092
  throw new Error('Auth error: Try to run `socket login` first');
@@ -3005,18 +3099,20 @@ async function getAlertsMapFromPurls(purls, options) {
3005
3099
  spinner
3006
3100
  };
3007
3101
  for await (const batchResult of sockSdk.batchPackageStream({
3008
- alerts: 'true',
3009
- compact: 'true',
3010
- ...(opts.include.actions ? {
3011
- actions: opts.include.actions.join(',')
3012
- } : {}),
3013
- ...(opts.include.unfixable ? {} : {
3014
- fixable: 'true'
3015
- })
3016
- }, {
3017
3102
  components: uniqPurls.map(purl => ({
3018
3103
  purl
3019
3104
  }))
3105
+ }, {
3106
+ queryParams: {
3107
+ alerts: 'true',
3108
+ compact: 'true',
3109
+ ...(opts.include.actions ? {
3110
+ actions: opts.include.actions.join(',')
3111
+ } : {}),
3112
+ ...(opts.include.unfixable ? {} : {
3113
+ fixable: 'true'
3114
+ })
3115
+ }
3020
3116
  })) {
3021
3117
  if (batchResult.success) {
3022
3118
  await addArtifactToAlertsMap(batchResult.data, alertsByPurl, alertsMapOptions);
@@ -3101,7 +3197,7 @@ function safeNpmInstall(options) {
3101
3197
  ...options
3102
3198
  };
3103
3199
  let stdio = spawnOptions.stdio;
3104
- const useIpc = objects.isObject(ipc);
3200
+ const useIpc = require$$7.isObject(ipc);
3105
3201
  // Include 'ipc' in the spawnOptions.stdio when an options.ipc object is provided.
3106
3202
  // See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
3107
3203
  // and https://github.com/nodejs/node/blob/v23.6.0/lib/internal/child_process.js#L238.
@@ -3260,6 +3356,9 @@ async function spawnCoana(args, options, extra) {
3260
3356
  __proto__: null,
3261
3357
  ...options
3262
3358
  };
3359
+ const orgSlugCResult = await getDefaultOrgSlug();
3360
+ const SOCKET_CLI_API_TOKEN = getDefaultToken();
3361
+ const SOCKET_ORG_SLUG = orgSlugCResult.ok ? orgSlugCResult.data : undefined;
3263
3362
  try {
3264
3363
  const output = await spawn.spawn(constants.execPath, [
3265
3364
  // Lazily access constants.nodeNoWarningsFlags.
@@ -3271,7 +3370,9 @@ async function spawnCoana(args, options, extra) {
3271
3370
  ...process.env,
3272
3371
  // Lazily access constants.processEnv.
3273
3372
  ...constants.processEnv,
3274
- SOCKET_CLI_API_TOKEN: getDefaultToken(),
3373
+ RUN_WITHOUT_DOCKER: 'true',
3374
+ SOCKET_CLI_API_TOKEN,
3375
+ SOCKET_ORG_SLUG,
3275
3376
  ...spawnEnv
3276
3377
  }
3277
3378
  }, extra);
@@ -3705,6 +3806,7 @@ exports.detectAndValidatePackageEnvironment = detectAndValidatePackageEnvironmen
3705
3806
  exports.determineOrgSlug = determineOrgSlug;
3706
3807
  exports.extractOverridesFromPnpmLockSrc = extractOverridesFromPnpmLockSrc;
3707
3808
  exports.failMsgWithBadge = failMsgWithBadge;
3809
+ exports.fetchOrganization = fetchOrganization;
3708
3810
  exports.getAlertsMapFromPnpmLockfile = getAlertsMapFromPnpmLockfile;
3709
3811
  exports.getAlertsMapFromPurls = getAlertsMapFromPurls;
3710
3812
  exports.getBaseBranch = getBaseBranch;
@@ -3712,6 +3814,7 @@ exports.getBashrcDetails = getBashrcDetails;
3712
3814
  exports.getConfigValue = getConfigValue;
3713
3815
  exports.getConfigValueOrUndef = getConfigValueOrUndef;
3714
3816
  exports.getCveInfoFromAlertsMap = getCveInfoFromAlertsMap;
3817
+ exports.getDefaultOrgSlug = getDefaultOrgSlug;
3715
3818
  exports.getFlagListOutput = getFlagListOutput;
3716
3819
  exports.getMajor = getMajor;
3717
3820
  exports.getMinVersion = getMinVersion;
@@ -3748,6 +3851,7 @@ exports.isHelpFlag = isHelpFlag;
3748
3851
  exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
3749
3852
  exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
3750
3853
  exports.isReadOnlyConfig = isReadOnlyConfig;
3854
+ exports.isReportSupportedFile = isReportSupportedFile;
3751
3855
  exports.isSensitiveConfigKey = isSensitiveConfigKey;
3752
3856
  exports.isSupportedConfigKey = isSupportedConfigKey;
3753
3857
  exports.logAlertsMap = logAlertsMap;
@@ -3780,5 +3884,5 @@ exports.tildify = tildify;
3780
3884
  exports.updateConfigValue = updateConfigValue;
3781
3885
  exports.walkNestedMap = walkNestedMap;
3782
3886
  exports.writeSocketJson = writeSocketJson;
3783
- //# debugId=1caec5a2-d540-4f7c-8084-bbec644574df
3887
+ //# debugId=eeb540f1-2cc9-44c6-8101-3926e319a1db
3784
3888
  //# sourceMappingURL=utils.js.map