@socketsecurity/cli-with-sentry 1.0.94 → 1.0.96

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 (81) hide show
  1. package/README.md +2 -1
  2. package/dist/cli.js +133 -102
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +7 -3
  5. package/dist/constants.js.map +1 -1
  6. package/dist/tsconfig.dts.tsbuildinfo +1 -1
  7. package/dist/types/commands/analytics/fetch-org-analytics.d.mts +1 -1
  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 +1 -1
  10. package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +1 -1
  11. package/dist/types/commands/audit-log/fetch-audit-log.d.mts +1 -1
  12. package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +1 -1
  13. package/dist/types/commands/config/discover-config-value.d.mts.map +1 -1
  14. package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
  15. package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
  16. package/dist/types/commands/organization/fetch-dependencies.d.mts +1 -1
  17. package/dist/types/commands/organization/fetch-dependencies.d.mts.map +1 -1
  18. package/dist/types/commands/organization/fetch-license-policy.d.mts +1 -1
  19. package/dist/types/commands/organization/fetch-license-policy.d.mts.map +1 -1
  20. package/dist/types/commands/organization/fetch-organization-list.d.mts +15 -3
  21. package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
  22. package/dist/types/commands/organization/fetch-quota.d.mts +1 -1
  23. package/dist/types/commands/organization/fetch-quota.d.mts.map +1 -1
  24. package/dist/types/commands/organization/fetch-security-policy.d.mts +1 -1
  25. package/dist/types/commands/organization/fetch-security-policy.d.mts.map +1 -1
  26. package/dist/types/commands/organization/output-organization-list.d.mts +3 -3
  27. package/dist/types/commands/organization/output-organization-list.d.mts.map +1 -1
  28. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +1 -1
  29. package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
  30. package/dist/types/commands/repository/fetch-create-repo.d.mts +1 -1
  31. package/dist/types/commands/repository/fetch-create-repo.d.mts.map +1 -1
  32. package/dist/types/commands/repository/fetch-delete-repo.d.mts +1 -1
  33. package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +1 -1
  34. package/dist/types/commands/repository/fetch-list-all-repos.d.mts +1 -1
  35. package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
  36. package/dist/types/commands/repository/fetch-list-repos.d.mts +1 -1
  37. package/dist/types/commands/repository/fetch-list-repos.d.mts.map +1 -1
  38. package/dist/types/commands/repository/fetch-update-repo.d.mts +1 -1
  39. package/dist/types/commands/repository/fetch-update-repo.d.mts.map +1 -1
  40. package/dist/types/commands/repository/fetch-view-repo.d.mts +1 -1
  41. package/dist/types/commands/repository/fetch-view-repo.d.mts.map +1 -1
  42. package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
  43. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +1 -1
  44. package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
  45. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +1 -1
  46. package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +1 -1
  47. package/dist/types/commands/scan/fetch-list-scans.d.mts +1 -1
  48. package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
  49. package/dist/types/commands/scan/fetch-report-data.d.mts +1 -1
  50. package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
  51. package/dist/types/commands/scan/fetch-scan-metadata.d.mts +1 -1
  52. package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +1 -1
  53. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +1 -1
  54. package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +1 -1
  55. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  56. package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
  57. package/dist/types/commands/scan/stream-scan.d.mts +1 -1
  58. package/dist/types/commands/scan/stream-scan.d.mts.map +1 -1
  59. package/dist/types/commands/scan/suggest-repo-slug.d.mts +1 -1
  60. package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +1 -1
  61. package/dist/types/constants.d.mts +1 -0
  62. package/dist/types/constants.d.mts.map +1 -1
  63. package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
  64. package/dist/types/utils/organization.d.mts +5 -0
  65. package/dist/types/utils/organization.d.mts.map +1 -0
  66. package/dist/types/utils/sdk.d.mts.map +1 -1
  67. package/dist/types/utils/serialize-result-json.d.mts.map +1 -1
  68. package/dist/utils.js +55 -29
  69. package/dist/utils.js.map +1 -1
  70. package/dist/vendor.js +12 -4
  71. package/external/@coana-tech/cli/README.md +5 -0
  72. package/external/@coana-tech/cli/cli.mjs +2 -2
  73. package/external/@coana-tech/cli/repos/coana-tech/alucard/alucard.jar +0 -0
  74. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
  75. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
  76. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
  77. package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
  78. package/external/@socketsecurity/registry/README.md +9 -0
  79. package/external/@socketsecurity/registry/lib/env.js +11 -0
  80. package/external/blessed/README.md +2421 -0
  81. package/package.json +7 -7
package/dist/utils.js CHANGED
@@ -4,8 +4,8 @@ var vendor = require('./vendor.js');
4
4
  var logger = require('../external/@socketsecurity/registry/lib/logger');
5
5
  var strings = require('../external/@socketsecurity/registry/lib/strings');
6
6
  var require$$6 = require('../external/@socketsecurity/registry/lib/debug');
7
- var arrays = require('../external/@socketsecurity/registry/lib/arrays');
8
7
  var require$$7 = require('../external/@socketsecurity/registry/lib/objects');
8
+ var arrays = require('../external/@socketsecurity/registry/lib/arrays');
9
9
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
10
10
  var sorts = require('../external/@socketsecurity/registry/lib/sorts');
11
11
  var words = require('../external/@socketsecurity/registry/lib/words');
@@ -251,9 +251,8 @@ function updateConfigValue(configKey, value) {
251
251
  }
252
252
 
253
253
  const TOKEN_PREFIX = 'sktsec_';
254
- const {
255
- length: TOKEN_PREFIX_LENGTH
256
- } = TOKEN_PREFIX;
254
+ const TOKEN_PREFIX_LENGTH = TOKEN_PREFIX.length;
255
+ const TOKEN_VISIBLE_LENGTH = 5;
257
256
 
258
257
  // The Socket API server that should be used for operations.
259
258
  function getDefaultApiBaseUrl$1() {
@@ -297,7 +296,7 @@ function getDefaultToken() {
297
296
  }
298
297
  function getVisibleTokenPrefix() {
299
298
  const apiToken = getDefaultToken();
300
- return apiToken ? apiToken.slice(TOKEN_PREFIX_LENGTH, TOKEN_PREFIX_LENGTH + 5) : '';
299
+ return apiToken ? apiToken.slice(TOKEN_PREFIX_LENGTH, TOKEN_PREFIX_LENGTH + TOKEN_VISIBLE_LENGTH) : '';
301
300
  }
302
301
  function hasDefaultToken() {
303
302
  return !!getDefaultToken();
@@ -347,6 +346,8 @@ async function setupSdk(options) {
347
346
  proxy: apiProxy
348
347
  }) : undefined,
349
348
  baseUrl: apiBaseUrl,
349
+ // Lazily access constants.ENV.SOCKET_CLI_API_TIMEOUT.
350
+ timeout: constants.ENV.SOCKET_CLI_API_TIMEOUT,
350
351
  userAgent: vendor.distExports.createUserAgentFromPkgJson({
351
352
  // Lazily access constants.ENV.INLINED_SOCKET_CLI_NAME.
352
353
  name: constants.ENV.INLINED_SOCKET_CLI_NAME,
@@ -780,38 +781,36 @@ cols) {
780
781
  // Serialize the final result object before printing it
781
782
  // All commands that support the --json flag should call this before printing
782
783
  function serializeResultJson(data) {
783
- if (typeof data !== 'object' || !data) {
784
+ if (!require$$7.isObject(data)) {
784
785
  process.exitCode = 1;
785
- require$$6.debugFn('inspect', 'typeof data=', typeof data);
786
- if (typeof data !== 'object' && data) {
787
- require$$6.debugFn('inspect', 'data:\n', data);
788
- }
786
+ require$$6.debugFn('inspect', {
787
+ data
788
+ });
789
789
 
790
790
  // We should not allow the JSON value to be "null", or a boolean/number/string,
791
791
  // even if they are valid "json".
792
- const message = 'There was a problem converting the data set to JSON. The JSON was not an object. Please try again without --json';
793
- return JSON.stringify({
792
+ return `${JSON.stringify({
794
793
  ok: false,
795
794
  message: 'Unable to serialize JSON',
796
- cause: message
797
- }).trim() + '\n';
795
+ cause: 'There was a problem converting the data set to JSON. The JSON was not an object. Please try again without --json'
796
+ }).trim()}\n`;
798
797
  }
799
798
  try {
800
- return JSON.stringify(data, null, 2).trim() + '\n';
799
+ return `${JSON.stringify(data, null, 2).trim()}\n`;
801
800
  } catch (e) {
802
801
  process.exitCode = 1;
803
-
804
- // This could be caused by circular references, which is an "us" problem
805
802
  const message = 'There was a problem converting the data set to JSON. Please try again without --json';
806
803
  logger.logger.fail(message);
807
804
  require$$6.debugDir('inspect', {
808
805
  error: e
809
806
  });
810
- return JSON.stringify({
807
+
808
+ // This could be caused by circular references, which is an "us" problem.
809
+ return `${JSON.stringify({
811
810
  ok: false,
812
811
  message: 'Unable to serialize JSON',
813
812
  cause: message
814
- }).trim() + '\n';
813
+ }).trim()}\n`;
815
814
  }
816
815
  }
817
816
 
@@ -1240,7 +1239,7 @@ async function meowWithSubcommands(subcommands, options) {
1240
1239
  padName: HELP_PAD_NAME
1241
1240
  })}`);
1242
1241
  if (isRootCommand) {
1243
- 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 https://api.socket.dev/v0/', ' SOCKET_CLI_API_PROXY Set the proxy all 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_DEBUG Enable debug logging in Socket CLI', ` DEBUG Enable debug logging based on the ${vendor.terminalLinkExports('debug', 'https://socket.dev/npm/package/debug')} package`);
1242
+ 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 https://api.socket.dev/v0/', ' 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', 'https://socket.dev/npm/package/debug')} package`);
1244
1243
  }
1245
1244
 
1246
1245
  // Parse it again. Config overrides should now be applied (may affect help).
@@ -1428,19 +1427,33 @@ function msAtHome(isoTimeStamp) {
1428
1427
 
1429
1428
  async function fetchOrganization(options) {
1430
1429
  const {
1431
- sdkOptions
1430
+ desc = 'organization list',
1431
+ sdk,
1432
+ sdkOpts
1432
1433
  } = {
1433
1434
  __proto__: null,
1434
1435
  ...options
1435
1436
  };
1436
- const sockSdkCResult = await setupSdk(sdkOptions);
1437
- if (!sockSdkCResult.ok) {
1438
- return sockSdkCResult;
1437
+ let sockSdk = sdk;
1438
+ if (!sockSdk) {
1439
+ const sockSdkCResult = await setupSdk(sdkOpts);
1440
+ if (!sockSdkCResult.ok) {
1441
+ return sockSdkCResult;
1442
+ }
1443
+ sockSdk = sockSdkCResult.data;
1439
1444
  }
1440
- const sockSdk = sockSdkCResult.data;
1441
- return await handleApiCall(sockSdk.getOrganizations(), {
1442
- desc: 'organization list'
1445
+ const orgsCResult = await handleApiCall(sockSdk.getOrganizations(), {
1446
+ desc
1443
1447
  });
1448
+ if (!orgsCResult.ok) {
1449
+ return orgsCResult;
1450
+ }
1451
+ return {
1452
+ ...orgsCResult,
1453
+ data: {
1454
+ organizations: Object.values(orgsCResult.data.organizations)
1455
+ }
1456
+ };
1444
1457
  }
1445
1458
 
1446
1459
  async function suggestOrgSlug() {
@@ -1457,7 +1470,7 @@ async function suggestOrgSlug() {
1457
1470
  } = orgsCResult.data;
1458
1471
  const proceed = await prompts.select({
1459
1472
  message: 'Missing org name; do you want to use any of these orgs for this scan?',
1460
- choices: [...Object.values(organizations).map(o => {
1473
+ choices: [...organizations.map(o => {
1461
1474
  const name = o.name ?? o.slug;
1462
1475
  return {
1463
1476
  name: `Yes [${name}]`,
@@ -2171,6 +2184,16 @@ async function spawnCoana(args, orgSlug, options, extra) {
2171
2184
  }
2172
2185
  }
2173
2186
 
2187
+ function getEnterpriseOrgs(orgs) {
2188
+ return orgs.filter(o => o.plan === 'enterprise');
2189
+ }
2190
+ function getOrgSlugs(orgs) {
2191
+ return orgs.map(o => o.slug);
2192
+ }
2193
+ function hasEnterpriseOrgPlan(orgs) {
2194
+ return orgs.some(o => o.plan === 'enterprise');
2195
+ }
2196
+
2174
2197
  const DEFAULT_IGNORE_FOR_GIT_IGNORE = globs.defaultIgnore.filter(p => !p.endsWith('.gitignore'));
2175
2198
  const IGNORED_DIRS = [
2176
2199
  // Taken from ignore-by-default:
@@ -4100,6 +4123,7 @@ exports.getConfigValueOrUndef = getConfigValueOrUndef;
4100
4123
  exports.getCveInfoFromAlertsMap = getCveInfoFromAlertsMap;
4101
4124
  exports.getDefaultOrgSlug = getDefaultOrgSlug;
4102
4125
  exports.getEcosystemChoicesForMeow = getEcosystemChoicesForMeow;
4126
+ exports.getEnterpriseOrgs = getEnterpriseOrgs;
4103
4127
  exports.getFlagApiRequirementsOutput = getFlagApiRequirementsOutput;
4104
4128
  exports.getFlagListOutput = getFlagListOutput;
4105
4129
  exports.getMajor = getMajor;
@@ -4108,6 +4132,7 @@ exports.getNpmBinPath = getNpmBinPath;
4108
4132
  exports.getNpmConfig = getNpmConfig;
4109
4133
  exports.getNpmRequire = getNpmRequire;
4110
4134
  exports.getNpxBinPath = getNpxBinPath;
4135
+ exports.getOrgSlugs = getOrgSlugs;
4111
4136
  exports.getOutputKind = getOutputKind;
4112
4137
  exports.getPackageFilesForScan = getPackageFilesForScan;
4113
4138
  exports.getPkgFullNameFromPurl = getPkgFullNameFromPurl;
@@ -4131,6 +4156,7 @@ exports.globWorkspace = globWorkspace;
4131
4156
  exports.handleApiCall = handleApiCall;
4132
4157
  exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
4133
4158
  exports.hasDefaultToken = hasDefaultToken;
4159
+ exports.hasEnterpriseOrgPlan = hasEnterpriseOrgPlan;
4134
4160
  exports.idToNpmPurl = idToNpmPurl;
4135
4161
  exports.idToPurl = idToPurl;
4136
4162
  exports.isHelpFlag = isHelpFlag;
@@ -4167,5 +4193,5 @@ exports.tildify = tildify;
4167
4193
  exports.updateConfigValue = updateConfigValue;
4168
4194
  exports.walkNestedMap = walkNestedMap;
4169
4195
  exports.writeSocketJson = writeSocketJson;
4170
- //# debugId=68b89be0-ee10-410b-b0e6-2f5b40be33c2
4196
+ //# debugId=5b3d9fc5-fd9d-410c-9fa5-fb1634dc1cb6
4171
4197
  //# sourceMappingURL=utils.js.map