@socketsecurity/cli-with-sentry 0.14.149 → 0.14.150

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/dist/cli.js CHANGED
@@ -5,7 +5,6 @@ const require$$0 = require('node:url')
5
5
  const vendor = require('./vendor.js')
6
6
  const debug = require('../external/@socketsecurity/registry/lib/debug')
7
7
  const logger = require('../external/@socketsecurity/registry/lib/logger')
8
- const assert = require('node:assert')
9
8
  const fs = require('node:fs/promises')
10
9
  const strings = require('../external/@socketsecurity/registry/lib/strings')
11
10
  const shadowNpmInject = require('./shadow-npm-inject.js')
@@ -14,10 +13,10 @@ const path$1 = require('node:path')
14
13
  const objects = require('../external/@socketsecurity/registry/lib/objects')
15
14
  const path = require('../external/@socketsecurity/registry/lib/path')
16
15
  const regexps = require('../external/@socketsecurity/registry/lib/regexps')
16
+ const prompts = require('../external/@socketsecurity/registry/lib/prompts')
17
17
  const words = require('../external/@socketsecurity/registry/lib/words')
18
18
  const fs$1 = require('node:fs')
19
19
  const shadowBin = require('./shadow-bin.js')
20
- const prompts = require('../external/@socketsecurity/registry/lib/prompts')
21
20
  const shadowNpmPaths = require('./shadow-npm-paths.js')
22
21
  const util = require('node:util')
23
22
  const arrays = require('../external/@socketsecurity/registry/lib/arrays')
@@ -33,9 +32,8 @@ function failMsgWithBadge(badge, msg) {
33
32
  return `${vendor.yoctocolorsCjsExports.bgRed(vendor.yoctocolorsCjsExports.bold(vendor.yoctocolorsCjsExports.white(` ${badge}: `)))} ${vendor.yoctocolorsCjsExports.bold(msg)}`
34
33
  }
35
34
 
36
- function handleUnsuccessfulApiResponse(_name, sockSdkError) {
37
- const message = sockSdkError.error || 'No error message returned'
38
- const { status } = sockSdkError
35
+ function handleUnsuccessfulApiResponse(_name, { cause, error, status }) {
36
+ const message = `${error || 'No error message returned'}${cause ? ` (reason: ${cause})` : ''}`
39
37
  if (status === 401 || status === 403) {
40
38
  // Lazily access constants.spinner.
41
39
  const { spinner } = constants
@@ -904,7 +902,7 @@ function emitBanner(name) {
904
902
  logger.logger.error(getAsciiHeader(name))
905
903
  }
906
904
  function getAsciiHeader(command) {
907
- const cliVersion = '0.14.149:e5f0cba:2e3185e5:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
905
+ const cliVersion = '0.14.150:cc2913a:84ef72e1:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
908
906
  const nodeVersion = process$1.version
909
907
  const apiToken = shadowNpmInject.getDefaultToken()
910
908
  const defaultOrg = shadowNpmInject.getConfigValue('defaultOrg')
@@ -927,12 +925,22 @@ function getAsciiHeader(command) {
927
925
  '~/'
928
926
  )
929
927
  )
928
+ let nodeVerWarn = ''
929
+ if ((vendor.semverExports.parse(constants.NODE_VERSION)?.major ?? 0) < 20) {
930
+ nodeVerWarn += vendor.yoctocolorsCjsExports.bold(
931
+ ` ${vendor.yoctocolorsCjsExports.red('Warning:')} NodeJS version 19 and lower will be ${vendor.yoctocolorsCjsExports.red('unsupported')} after April 30th, 2025.`
932
+ )
933
+ nodeVerWarn += '\n'
934
+ nodeVerWarn +=
935
+ ' Soon after the Socket CLI will require NodeJS version 20 or higher.'
936
+ nodeVerWarn += '\n'
937
+ }
930
938
  const body = `
931
939
  _____ _ _ /---------------
932
940
  | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}${v1test}
933
941
  |__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, default org: ${defaultOrg}` : ''}
934
942
  |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart()
935
- return ` ${body}\n${feedback}`
943
+ return ` ${body}\n${nodeVerWarn}${feedback}`
936
944
  }
937
945
 
938
946
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$J } = constants
@@ -970,25 +978,34 @@ const config$M = {
970
978
  description: 'Time filter - either 7, 30 or 90, default: 7'
971
979
  }
972
980
  },
973
- help: (command, { flags }) => `
981
+ help: (command, { flags }) =>
982
+ `
974
983
  Usage
975
- $ ${command} --scope=<scope> --time=<time filter>
984
+ $ ${command} ${shadowNpmInject.isTestingV1() ? '[ org | repo <reponame>] [time]' : '--scope=<scope> --time=<time filter>'}
976
985
 
977
986
  API Token Requirements
978
987
  - Quota: 1 unit
979
988
  - Permissions: report:write
980
989
 
981
- Default parameters are set to show the organization-level analytics over the
982
- last 7 days.
990
+ ${shadowNpmInject.isTestingV1() ? '' : 'Default parameters are set to show the organization-level analytics over the'}
991
+ ${shadowNpmInject.isTestingV1() ? '' : 'last 7 days.'}
992
+
993
+ ${shadowNpmInject.isTestingV1() ? 'The scope is either org or repo level, defaults to org.' : ''}
994
+
995
+ ${shadowNpmInject.isTestingV1() ? 'When scope is repo, a repo slug must be given as well.' : ''}
996
+
997
+ ${shadowNpmInject.isTestingV1() ? 'The time argument must be number 7, 30, or 90 and defaults to 7.' : ''}
983
998
 
984
999
  Options
985
1000
  ${getFlagListOutput(flags, 6)}
986
1001
 
987
1002
  Examples
988
- $ ${command} --scope=org --time=7
989
- $ ${command} --scope=org --time=30
990
- $ ${command} --scope=repo --repo=test-repo --time=30
1003
+ $ ${command} ${shadowNpmInject.isTestingV1() ? 'org 7' : '--scope=org --time=7'}
1004
+ $ ${command} ${shadowNpmInject.isTestingV1() ? 'repo test-repo 30' : '--scope=org --time=30'}
1005
+ $ ${command} ${shadowNpmInject.isTestingV1() ? '90' : '--scope=repo --repo=test-repo --time=30'}
991
1006
  `
1007
+ // Drop consecutive empty lines. Temporarily necessary to deal with v1 prep.
1008
+ .replace(/\n(?: *\n)+/g, '\n\n')
992
1009
  }
993
1010
  const cmdAnalytics = {
994
1011
  description: config$M.description,
@@ -1002,28 +1019,87 @@ async function run$M(argv, importMeta, { parentName }) {
1002
1019
  importMeta,
1003
1020
  parentName
1004
1021
  })
1005
- const { file, json, markdown, repo, scope, time } = cli.flags
1022
+ const { file, json, markdown } = cli.flags
1023
+
1024
+ // In v1 mode support:
1025
+ // - [] (no args)
1026
+ // - ['org']
1027
+ // - ['org', '30']
1028
+ // - ['repo', 'name']
1029
+ // - ['repo', 'name', '30']
1030
+ // - ['30']
1031
+ // Validate final values in the next step
1032
+ let scope = 'org'
1033
+ let time = shadowNpmInject.isTestingV1() ? '7' : 7
1034
+ let repoName = ''
1035
+ if (shadowNpmInject.isTestingV1()) {
1036
+ if (cli.input[0] === 'org') {
1037
+ if (cli.input[1]) {
1038
+ time = cli.input[1]
1039
+ }
1040
+ } else if (cli.input[0] === 'repo') {
1041
+ scope = 'repo'
1042
+ if (cli.input[1]) {
1043
+ repoName = cli.input[1]
1044
+ }
1045
+ if (cli.input[2]) {
1046
+ time = cli.input[2]
1047
+ }
1048
+ } else if (cli.input[0]) {
1049
+ time = cli.input[0]
1050
+ }
1051
+ } else {
1052
+ if (cli.flags['scope']) {
1053
+ scope = String(cli.flags['scope'] || '')
1054
+ }
1055
+ if (scope === 'repo') {
1056
+ repoName = String(cli.flags['repoName'] || '')
1057
+ }
1058
+ if (cli.flags['time']) {
1059
+ time = Number(cli.flags['time'] || 7)
1060
+ }
1061
+ }
1006
1062
  const apiToken = shadowNpmInject.getDefaultToken()
1007
1063
  const wasBadInput = handleBadInput(
1008
1064
  {
1065
+ // In v1 this can't go wrong anymore since the unknown value goes to time
1066
+ nook: !shadowNpmInject.isTestingV1(),
1009
1067
  test: scope === 'org' || scope === 'repo',
1010
1068
  message: 'Scope must be "repo" or "org"',
1011
1069
  pass: 'ok',
1012
1070
  fail: 'bad'
1013
1071
  },
1014
1072
  {
1015
- test: time === 7 || time === 30 || time === 90,
1016
- message: 'The time filter must either be 7, 30 or 90',
1073
+ nook: true,
1074
+ test: scope === 'org' || !!repoName,
1075
+ message: shadowNpmInject.isTestingV1()
1076
+ ? 'When scope=repo, repo name should be the second argument'
1077
+ : 'When scope=repo, repo name should be set through --repo',
1017
1078
  pass: 'ok',
1018
- fail: 'bad'
1079
+ fail: 'missing'
1019
1080
  },
1020
1081
  {
1021
1082
  nook: true,
1022
- test: scope === 'org' || !!repo,
1023
- message: 'When scope=repo, repo name should be set through --repo',
1083
+ test:
1084
+ scope === 'org' ||
1085
+ (shadowNpmInject.isTestingV1() &&
1086
+ repoName !== '7' &&
1087
+ repoName !== '30' &&
1088
+ repoName !== '90'),
1089
+ message: 'Missing the repo name as second argument',
1024
1090
  pass: 'ok',
1025
1091
  fail: 'missing'
1026
1092
  },
1093
+ {
1094
+ test: shadowNpmInject.isTestingV1()
1095
+ ? time === '7' || time === '30' || time === '90'
1096
+ : time === 7 || time === 30 || time === 90,
1097
+ message: 'The time filter must either be 7, 30 or 90',
1098
+ pass: 'ok',
1099
+ fail: shadowNpmInject.isTestingV1()
1100
+ ? 'invalid range set, see --help for command arg details.'
1101
+ : 'bad'
1102
+ },
1027
1103
  {
1028
1104
  nook: true,
1029
1105
  test: file === '-' || !!json || !!markdown,
@@ -1056,22 +1132,14 @@ async function run$M(argv, importMeta, { parentName }) {
1056
1132
  logger.logger.log(DRY_RUN_BAIL_TEXT$J)
1057
1133
  return
1058
1134
  }
1059
- assert(assertScope(scope))
1060
- assert(assertTime(time))
1061
1135
  return await displayAnalytics({
1062
1136
  scope,
1063
- time,
1064
- repo: String(repo || ''),
1137
+ time: time === '90' ? 90 : time === '30' ? 30 : 7,
1138
+ repo: repoName,
1065
1139
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
1066
1140
  filePath: String(file || '')
1067
1141
  })
1068
1142
  }
1069
- function assertScope(scope) {
1070
- return scope === 'org' || scope === 'repo'
1071
- }
1072
- function assertTime(time) {
1073
- return time === 7 || time === 30 || time === 90
1074
- }
1075
1143
 
1076
1144
  async function fetchAuditLog({ logType, orgSlug, outputKind, page, perPage }) {
1077
1145
  const sockSdk = await shadowNpmInject.setupSdk()
@@ -1228,12 +1296,92 @@ async function handleAuditLog({ logType, orgSlug, outputKind, page, perPage }) {
1228
1296
  })
1229
1297
  }
1230
1298
 
1299
+ async function suggestOrgSlug() {
1300
+ const sockSdk = await shadowNpmInject.setupSdk()
1301
+ const result = await handleApiCall(
1302
+ sockSdk.getOrganizations(),
1303
+ 'looking up organizations'
1304
+ )
1305
+ // Ignore a failed request here. It was not the primary goal of
1306
+ // running this command and reporting it only leads to end-user confusion.
1307
+ if (result.success) {
1308
+ const proceed = await prompts.select({
1309
+ message:
1310
+ 'Missing org name; do you want to use any of these orgs for this scan?',
1311
+ choices: [
1312
+ ...Object.values(result.data.organizations).map(org => {
1313
+ const slug = org.name ?? 'undefined'
1314
+ return {
1315
+ name: `Yes [${slug}]`,
1316
+ value: slug,
1317
+ description: `Use "${slug}" as the organization`
1318
+ }
1319
+ }),
1320
+ {
1321
+ name: 'No',
1322
+ value: '',
1323
+ description:
1324
+ 'Do not use any of these organizations (will end in a no-op)'
1325
+ }
1326
+ ]
1327
+ })
1328
+ if (proceed) {
1329
+ return proceed
1330
+ }
1331
+ } else {
1332
+ logger.logger.fail(
1333
+ 'Failed to lookup organization list from API, unable to suggest'
1334
+ )
1335
+ }
1336
+ }
1337
+
1338
+ async function determineOrgSlug(orgFlag, firstArg, interactive, dryRun) {
1339
+ const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg') || ''
1340
+ let orgSlug = String(orgFlag || defaultOrgSlug || '')
1341
+ if (!orgSlug) {
1342
+ if (shadowNpmInject.isTestingV1()) {
1343
+ // ask from server
1344
+ logger.logger.error(
1345
+ 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
1346
+ )
1347
+ logger.logger.error(
1348
+ 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
1349
+ )
1350
+ if (dryRun) {
1351
+ logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
1352
+ } else if (!interactive) {
1353
+ logger.logger.fail(
1354
+ 'Skipping auto-discovery of org when interactive = false'
1355
+ )
1356
+ } else {
1357
+ orgSlug = (await suggestOrgSlug()) || ''
1358
+ }
1359
+ } else {
1360
+ orgSlug = firstArg || ''
1361
+ }
1362
+ }
1363
+ return [orgSlug, defaultOrgSlug]
1364
+ }
1365
+
1231
1366
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$I } = constants
1232
1367
  const config$L = {
1233
1368
  commandName: 'audit-log',
1234
1369
  description: 'Look up the audit log for an organization',
1235
1370
  hidden: false,
1236
1371
  flags: {
1372
+ ...commonFlags,
1373
+ ...outputFlags,
1374
+ interactive: {
1375
+ type: 'boolean',
1376
+ default: true,
1377
+ description:
1378
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
1379
+ },
1380
+ org: {
1381
+ type: 'string',
1382
+ description:
1383
+ 'Force override the organization slug, overrides the default org from config'
1384
+ },
1237
1385
  type: {
1238
1386
  type: 'string',
1239
1387
  shortFlag: 't',
@@ -1251,13 +1399,11 @@ const config$L = {
1251
1399
  shortFlag: 'p',
1252
1400
  default: 1,
1253
1401
  description: 'Page number - default is 1'
1254
- },
1255
- ...commonFlags,
1256
- ...outputFlags
1402
+ }
1257
1403
  },
1258
1404
  help: (command, config) => `
1259
1405
  Usage
1260
- $ ${command} <org slug>
1406
+ $ ${command} ${shadowNpmInject.isTestingV1() ? '<repo>' : '<org slug>'}
1261
1407
 
1262
1408
  API Token Requirements
1263
1409
  - Quota: 1 unit
@@ -1270,7 +1416,7 @@ const config$L = {
1270
1416
  ${getFlagListOutput(config.flags, 6)}
1271
1417
 
1272
1418
  Examples
1273
- $ ${command} FakeOrg
1419
+ $ ${command} ${shadowNpmInject.isTestingV1() ? '' : 'FakeOrg'}
1274
1420
  `
1275
1421
  }
1276
1422
  const cmdAuditLog = {
@@ -1285,15 +1431,31 @@ async function run$L(argv, importMeta, { parentName }) {
1285
1431
  importMeta,
1286
1432
  parentName
1287
1433
  })
1288
- const { json, markdown, page, perPage, type } = cli.flags
1434
+ const {
1435
+ dryRun,
1436
+ interactive,
1437
+ json,
1438
+ markdown,
1439
+ org: orgFlag,
1440
+ page,
1441
+ perPage,
1442
+ type
1443
+ } = cli.flags
1289
1444
  const logType = String(type || '')
1290
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
1291
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
1445
+ const [orgSlug] = await determineOrgSlug(
1446
+ String(orgFlag || ''),
1447
+ cli.input[0] || '',
1448
+ !!interactive,
1449
+ !!dryRun
1450
+ )
1292
1451
  const apiToken = shadowNpmInject.getDefaultToken()
1293
1452
  const wasBadInput = handleBadInput(
1294
1453
  {
1454
+ nook: true,
1295
1455
  test: !!orgSlug,
1296
- message: 'Org name should be the first arg',
1456
+ message: shadowNpmInject.isTestingV1()
1457
+ ? 'Org name by default setting, --org, or auto-discovered'
1458
+ : 'Org name must be the first argument',
1297
1459
  pass: 'ok',
1298
1460
  fail: 'missing'
1299
1461
  },
@@ -1381,7 +1543,7 @@ async function runCycloneDX(yargvWithYes) {
1381
1543
  await shadowBin(NPX$3, [
1382
1544
  ...yesArgs,
1383
1545
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
1384
- `@cyclonedx/cdxgen@${'11.2.5'}`,
1546
+ `@cyclonedx/cdxgen@${'11.2.6'}`,
1385
1547
  ...argvToArray(yargv)
1386
1548
  ])
1387
1549
  if (cleanupPackageLock) {
@@ -3604,7 +3766,13 @@ const config$C = {
3604
3766
  'Path to a local file where the output should be saved. Use `-` to force stdout.'
3605
3767
  }
3606
3768
  },
3607
- help: (command, config) => `
3769
+ help: (command, config) =>
3770
+ shadowNpmInject.isTestingV1()
3771
+ ? 'This command will be removed in v1'
3772
+ : `
3773
+ Note: This command is deprecated, to be dropped in the next major bump.
3774
+ Please see \`socket scan diff\`
3775
+
3608
3776
  Usage
3609
3777
  $ ${command} <org slug> --before=<before> --after=<after>
3610
3778
 
@@ -5462,7 +5630,10 @@ const config$A = {
5462
5630
  ...outputFlags,
5463
5631
  ...validationFlags
5464
5632
  },
5465
- help: (command, config) => `
5633
+ help: (command, config) =>
5634
+ shadowNpmInject.isTestingV1()
5635
+ ? 'This command will be removed in v1'
5636
+ : `
5466
5637
  Usage
5467
5638
  $ ${command} <name>
5468
5639
 
@@ -8065,11 +8236,22 @@ const config$m = {
8065
8236
  hidden: true,
8066
8237
  flags: {
8067
8238
  ...commonFlags,
8068
- ...outputFlags
8239
+ ...outputFlags,
8240
+ interactive: {
8241
+ type: 'boolean',
8242
+ default: true,
8243
+ description:
8244
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
8245
+ },
8246
+ org: {
8247
+ type: 'string',
8248
+ description:
8249
+ 'Force override the organization slug, overrides the default org from config'
8250
+ }
8069
8251
  },
8070
8252
  help: (command, _config) => `
8071
8253
  Usage
8072
- $ ${command} <org slug>
8254
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
8073
8255
 
8074
8256
  API Token Requirements
8075
8257
  - Quota: 1 unit
@@ -8082,8 +8264,8 @@ const config$m = {
8082
8264
  the request will fail with an authentication error.
8083
8265
 
8084
8266
  Examples
8085
- $ ${command} mycorp
8086
- $ ${command} mycorp --json
8267
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'}
8268
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'} --json
8087
8269
  `
8088
8270
  }
8089
8271
  const cmdOrganizationPolicyLicense = {
@@ -8098,16 +8280,21 @@ async function run$m(argv, importMeta, { parentName }) {
8098
8280
  importMeta,
8099
8281
  parentName
8100
8282
  })
8101
- const json = Boolean(cli.flags['json'])
8102
- const markdown = Boolean(cli.flags['markdown'])
8103
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
8104
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
8283
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
8284
+ const [orgSlug] = await determineOrgSlug(
8285
+ String(orgFlag || ''),
8286
+ cli.input[0] || '',
8287
+ !!interactive,
8288
+ !!dryRun
8289
+ )
8105
8290
  const apiToken = shadowNpmInject.getDefaultToken()
8106
8291
  const wasBadInput = handleBadInput(
8107
8292
  {
8108
8293
  nook: true,
8109
8294
  test: !!orgSlug,
8110
- message: 'Org name as the first argument',
8295
+ message: shadowNpmInject.isTestingV1()
8296
+ ? 'Org name by default setting, --org, or auto-discovered'
8297
+ : 'Org name must be the first argument',
8111
8298
  pass: 'ok',
8112
8299
  fail: 'missing'
8113
8300
  },
@@ -8207,11 +8394,22 @@ const config$l = {
8207
8394
  hidden: true,
8208
8395
  flags: {
8209
8396
  ...commonFlags,
8210
- ...outputFlags
8397
+ ...outputFlags,
8398
+ interactive: {
8399
+ type: 'boolean',
8400
+ default: true,
8401
+ description:
8402
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
8403
+ },
8404
+ org: {
8405
+ type: 'string',
8406
+ description:
8407
+ 'Force override the organization slug, overrides the default org from config'
8408
+ }
8211
8409
  },
8212
8410
  help: (command, _config) => `
8213
8411
  Usage
8214
- $ ${command} <org slug>
8412
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
8215
8413
 
8216
8414
  API Token Requirements
8217
8415
  - Quota: 1 unit
@@ -8224,8 +8422,8 @@ const config$l = {
8224
8422
  the request will fail with an authentication error.
8225
8423
 
8226
8424
  Examples
8227
- $ ${command} mycorp
8228
- $ ${command} mycorp --json
8425
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'}
8426
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'} --json
8229
8427
  `
8230
8428
  }
8231
8429
  const cmdOrganizationPolicyPolicy = {
@@ -8240,10 +8438,13 @@ async function run$l(argv, importMeta, { parentName }) {
8240
8438
  importMeta,
8241
8439
  parentName
8242
8440
  })
8243
- const json = Boolean(cli.flags['json'])
8244
- const markdown = Boolean(cli.flags['markdown'])
8245
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
8246
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
8441
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
8442
+ const [orgSlug] = await determineOrgSlug(
8443
+ String(orgFlag || ''),
8444
+ cli.input[0] || '',
8445
+ !!interactive,
8446
+ !!dryRun
8447
+ )
8247
8448
  const apiToken = shadowNpmInject.getDefaultToken()
8248
8449
  const wasBadInput = handleBadInput(
8249
8450
  {
@@ -9417,45 +9618,6 @@ async function handleCreateRepo({
9417
9618
  await outputCreateRepo()
9418
9619
  }
9419
9620
 
9420
- async function suggestOrgSlug() {
9421
- const sockSdk = await shadowNpmInject.setupSdk()
9422
- const result = await handleApiCall(
9423
- sockSdk.getOrganizations(),
9424
- 'looking up organizations'
9425
- )
9426
- // Ignore a failed request here. It was not the primary goal of
9427
- // running this command and reporting it only leads to end-user confusion.
9428
- if (result.success) {
9429
- const proceed = await prompts.select({
9430
- message:
9431
- 'Missing org name; do you want to use any of these orgs for this scan?',
9432
- choices: [
9433
- ...Object.values(result.data.organizations).map(org => {
9434
- const slug = org.name ?? 'undefined'
9435
- return {
9436
- name: `Yes [${slug}]`,
9437
- value: slug,
9438
- description: `Use "${slug}" as the organization`
9439
- }
9440
- }),
9441
- {
9442
- name: 'No',
9443
- value: '',
9444
- description:
9445
- 'Do not use any of these organizations (will end in a no-op)'
9446
- }
9447
- ]
9448
- })
9449
- if (proceed) {
9450
- return proceed
9451
- }
9452
- } else {
9453
- logger.logger.fail(
9454
- 'Failed to lookup organization list from API, unable to suggest'
9455
- )
9456
- }
9457
- }
9458
-
9459
9621
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
9460
9622
  const config$d = {
9461
9623
  commandName: 'create',
@@ -9532,33 +9694,18 @@ async function run$d(argv, importMeta, { parentName }) {
9532
9694
  importMeta,
9533
9695
  parentName
9534
9696
  })
9535
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9536
- const interactive = cli.flags['interactive']
9537
- const dryRun = cli.flags['dryRun']
9538
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9539
- if (!orgSlug) {
9540
- if (shadowNpmInject.isTestingV1()) {
9541
- // ask from server
9542
- logger.logger.error(
9543
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9544
- )
9545
- logger.logger.error(
9546
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9547
- )
9548
- if (dryRun) {
9549
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9550
- } else if (!interactive) {
9551
- logger.logger.fail(
9552
- 'Skipping auto-discovery of org when interactive = false'
9553
- )
9554
- } else {
9555
- orgSlug = (await suggestOrgSlug()) || ''
9556
- }
9557
- } else {
9558
- orgSlug = cli.input[0] || ''
9559
- }
9560
- }
9561
- const repoNameFlag = cli.flags['repoName']
9697
+ const {
9698
+ dryRun,
9699
+ interactive,
9700
+ org: orgFlag,
9701
+ repoName: repoNameFlag
9702
+ } = cli.flags
9703
+ const [orgSlug] = await determineOrgSlug(
9704
+ String(orgFlag || ''),
9705
+ cli.input[0] || '',
9706
+ !!interactive,
9707
+ !!dryRun
9708
+ )
9562
9709
  const repoName =
9563
9710
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
9564
9711
  const apiToken = shadowNpmInject.getDefaultToken()
@@ -9675,32 +9822,13 @@ async function run$c(argv, importMeta, { parentName }) {
9675
9822
  importMeta,
9676
9823
  parentName
9677
9824
  })
9678
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9679
- const interactive = cli.flags['interactive']
9680
- const dryRun = cli.flags['dryRun']
9681
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9682
- if (!orgSlug) {
9683
- if (shadowNpmInject.isTestingV1()) {
9684
- // ask from server
9685
- logger.logger.error(
9686
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9687
- )
9688
- logger.logger.error(
9689
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9690
- )
9691
- if (dryRun) {
9692
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9693
- } else if (!interactive) {
9694
- logger.logger.fail(
9695
- 'Skipping auto-discovery of org when interactive = false'
9696
- )
9697
- } else {
9698
- orgSlug = (await suggestOrgSlug()) || ''
9699
- }
9700
- } else {
9701
- orgSlug = cli.input[0] || ''
9702
- }
9703
- }
9825
+ const { dryRun, interactive, org: orgFlag } = cli.flags
9826
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
9827
+ String(orgFlag || ''),
9828
+ cli.input[0] || '',
9829
+ !!interactive,
9830
+ !!dryRun
9831
+ )
9704
9832
  const repoName =
9705
9833
  (defaultOrgSlug || shadowNpmInject.isTestingV1()
9706
9834
  ? cli.input[0]
@@ -9897,32 +10025,13 @@ async function run$b(argv, importMeta, { parentName }) {
9897
10025
  parentName
9898
10026
  })
9899
10027
  const { json, markdown } = cli.flags
9900
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9901
- const interactive = cli.flags['interactive']
9902
- const dryRun = cli.flags['dryRun']
9903
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9904
- if (!orgSlug) {
9905
- if (shadowNpmInject.isTestingV1()) {
9906
- // ask from server
9907
- logger.logger.error(
9908
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9909
- )
9910
- logger.logger.error(
9911
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9912
- )
9913
- if (dryRun) {
9914
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9915
- } else if (!interactive) {
9916
- logger.logger.fail(
9917
- 'Skipping auto-discovery of org when interactive = false'
9918
- )
9919
- } else {
9920
- orgSlug = (await suggestOrgSlug()) || ''
9921
- }
9922
- } else {
9923
- orgSlug = cli.input[0] || ''
9924
- }
9925
- }
10028
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10029
+ const [orgSlug] = await determineOrgSlug(
10030
+ String(orgFlag || ''),
10031
+ cli.input[0] || '',
10032
+ !!interactive,
10033
+ !!dryRun
10034
+ )
9926
10035
  const apiToken = shadowNpmInject.getDefaultToken()
9927
10036
  const wasBadInput = handleBadInput(
9928
10037
  {
@@ -10101,32 +10210,13 @@ async function run$a(argv, importMeta, { parentName }) {
10101
10210
  importMeta,
10102
10211
  parentName
10103
10212
  })
10104
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10105
- const interactive = cli.flags['interactive']
10106
- const dryRun = cli.flags['dryRun']
10107
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
10108
- if (!orgSlug) {
10109
- if (shadowNpmInject.isTestingV1()) {
10110
- // ask from server
10111
- logger.logger.error(
10112
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
10113
- )
10114
- logger.logger.error(
10115
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
10116
- )
10117
- if (dryRun) {
10118
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
10119
- } else if (!interactive) {
10120
- logger.logger.fail(
10121
- 'Skipping auto-discovery of org when interactive = false'
10122
- )
10123
- } else {
10124
- orgSlug = (await suggestOrgSlug()) || ''
10125
- }
10126
- } else {
10127
- orgSlug = cli.input[0] || ''
10128
- }
10129
- }
10213
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10214
+ const [orgSlug] = await determineOrgSlug(
10215
+ String(orgFlag || ''),
10216
+ cli.input[0] || '',
10217
+ !!interactive,
10218
+ !!dryRun
10219
+ )
10130
10220
  const repoNameFlag = cli.flags['repoName']
10131
10221
  const repoName =
10132
10222
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
@@ -10323,34 +10413,20 @@ async function run$9(argv, importMeta, { parentName }) {
10323
10413
  importMeta,
10324
10414
  parentName
10325
10415
  })
10326
- const { json, markdown } = cli.flags
10327
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10328
- const interactive = cli.flags['interactive']
10329
- const dryRun = cli.flags['dryRun']
10330
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
10331
- if (!orgSlug) {
10332
- if (shadowNpmInject.isTestingV1()) {
10333
- // ask from server
10334
- logger.logger.error(
10335
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
10336
- )
10337
- logger.logger.error(
10338
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
10339
- )
10340
- if (dryRun) {
10341
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
10342
- } else if (!interactive) {
10343
- logger.logger.fail(
10344
- 'Skipping auto-discovery of org when interactive = false'
10345
- )
10346
- } else {
10347
- orgSlug = (await suggestOrgSlug()) || ''
10348
- }
10349
- } else {
10350
- orgSlug = cli.input[0] || ''
10351
- }
10352
- }
10353
- const repoNameFlag = cli.flags['repoName']
10416
+ const {
10417
+ dryRun,
10418
+ interactive,
10419
+ json,
10420
+ markdown,
10421
+ org: orgFlag,
10422
+ repoName: repoNameFlag
10423
+ } = cli.flags
10424
+ const [orgSlug] = await determineOrgSlug(
10425
+ String(orgFlag || ''),
10426
+ cli.input[0] || '',
10427
+ !!interactive,
10428
+ !!dryRun
10429
+ )
10354
10430
  const repoName =
10355
10431
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
10356
10432
  const apiToken = shadowNpmInject.getDefaultToken()
@@ -10515,6 +10591,11 @@ const config$8 = {
10515
10591
  shortFlag: 'pr',
10516
10592
  description: 'Commit hash'
10517
10593
  },
10594
+ org: {
10595
+ type: 'string',
10596
+ description:
10597
+ 'Force override the organization slug, overrides the default org from config'
10598
+ },
10518
10599
  readOnly: {
10519
10600
  type: 'boolean',
10520
10601
  default: false,
@@ -10544,7 +10625,7 @@ const config$8 = {
10544
10625
  // TODO: your project's "socket.yml" file's "projectIgnorePaths"
10545
10626
  help: (command, config) => `
10546
10627
  Usage
10547
- $ ${command} [...options] <org> <TARGET> [TARGET...]
10628
+ $ ${command} [...options]${shadowNpmInject.isTestingV1() ? '' : ' <org>'} <TARGET> [TARGET...]
10548
10629
 
10549
10630
  API Token Requirements
10550
10631
  - Quota: 1 unit
@@ -10577,7 +10658,8 @@ const config$8 = {
10577
10658
  ${getFlagListOutput(config.flags, 6)}
10578
10659
 
10579
10660
  Examples
10580
- $ ${command} --repo=test-repo --branch=main FakeOrg ./package.json
10661
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} .
10662
+ $ ${command} --repo=test-repo --branch=main${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} ./package.json
10581
10663
  `
10582
10664
  }
10583
10665
  const cmdScanCreate = {
@@ -10599,10 +10681,11 @@ async function run$8(argv, importMeta, { parentName }) {
10599
10681
  committers,
10600
10682
  cwd: cwdOverride,
10601
10683
  defaultBranch,
10602
- dryRun,
10684
+ dryRun = false,
10603
10685
  interactive = true,
10604
10686
  json,
10605
10687
  markdown,
10688
+ org: orgFlag,
10606
10689
  pendingHead,
10607
10690
  pullRequest,
10608
10691
  readOnly,
@@ -10610,9 +10693,19 @@ async function run$8(argv, importMeta, { parentName }) {
10610
10693
  report,
10611
10694
  tmp
10612
10695
  } = cli.flags
10613
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10614
- let orgSlug = defaultOrgSlug || cli.input[0] || ''
10615
- let targets = cli.input.slice(defaultOrgSlug ? 0 : 1)
10696
+ let [orgSlug, defaultOrgSlug] = await determineOrgSlug(
10697
+ String(orgFlag || ''),
10698
+ cli.input[0] || '',
10699
+ interactive,
10700
+ dryRun
10701
+ )
10702
+ if (!defaultOrgSlug) {
10703
+ // Tmp. just for TS. will drop this later.
10704
+ defaultOrgSlug = ''
10705
+ }
10706
+ let targets = cli.input.slice(
10707
+ shadowNpmInject.isTestingV1() || defaultOrgSlug ? 0 : 1
10708
+ )
10616
10709
  const cwd =
10617
10710
  cwdOverride && cwdOverride !== 'process.cwd()'
10618
10711
  ? String(cwdOverride)
@@ -10656,9 +10749,11 @@ async function run$8(argv, importMeta, { parentName }) {
10656
10749
  }
10657
10750
  const wasBadInput = handleBadInput(
10658
10751
  {
10659
- nook: !!defaultOrgSlug,
10752
+ nook: !shadowNpmInject.isTestingV1() && !!defaultOrgSlug,
10660
10753
  test: !!orgSlug && orgSlug !== '.',
10661
- message: 'Org name as the first argument',
10754
+ message: shadowNpmInject.isTestingV1()
10755
+ ? 'Org name by default setting, --org, or auto-discovered'
10756
+ : 'Org name must be the first argument',
10662
10757
  pass: 'ok',
10663
10758
  fail:
10664
10759
  orgSlug === '.'
@@ -10772,11 +10867,22 @@ const config$7 = {
10772
10867
  hidden: false,
10773
10868
  flags: {
10774
10869
  ...commonFlags,
10775
- ...outputFlags
10870
+ ...outputFlags,
10871
+ interactive: {
10872
+ type: 'boolean',
10873
+ default: true,
10874
+ description:
10875
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
10876
+ },
10877
+ org: {
10878
+ type: 'string',
10879
+ description:
10880
+ 'Force override the organization slug, overrides the default org from config'
10881
+ }
10776
10882
  },
10777
10883
  help: (command, config) => `
10778
10884
  Usage
10779
- $ ${command} <org slug> <scan ID>
10885
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID>
10780
10886
 
10781
10887
  API Token Requirements
10782
10888
  - Quota: 1 unit
@@ -10786,7 +10892,7 @@ const config$7 = {
10786
10892
  ${getFlagListOutput(config.flags, 6)}
10787
10893
 
10788
10894
  Examples
10789
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
10895
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0
10790
10896
  `
10791
10897
  }
10792
10898
  const cmdScanDel = {
@@ -10801,15 +10907,25 @@ async function run$7(argv, importMeta, { parentName }) {
10801
10907
  importMeta,
10802
10908
  parentName
10803
10909
  })
10804
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10805
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
10806
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
10910
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10911
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
10912
+ String(orgFlag || ''),
10913
+ cli.input[0] || '',
10914
+ !!interactive,
10915
+ !!dryRun
10916
+ )
10917
+ const scanId =
10918
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
10919
+ ? cli.input[0]
10920
+ : cli.input[1]) || ''
10807
10921
  const apiToken = shadowNpmInject.getDefaultToken()
10808
10922
  const wasBadInput = handleBadInput(
10809
10923
  {
10810
10924
  nook: !!defaultOrgSlug,
10811
10925
  test: !!orgSlug && orgSlug !== '.',
10812
- message: 'Org name as the first argument',
10926
+ message: shadowNpmInject.isTestingV1()
10927
+ ? 'Org name by default setting, --org, or auto-discovered'
10928
+ : 'Org name must be the first argument',
10813
10929
  pass: 'ok',
10814
10930
  fail:
10815
10931
  orgSlug === '.'
@@ -11094,11 +11210,22 @@ const config$6 = {
11094
11210
  default: '',
11095
11211
  description:
11096
11212
  'Path to a local file where the output should be saved. Use `-` to force stdout.'
11213
+ },
11214
+ interactive: {
11215
+ type: 'boolean',
11216
+ default: true,
11217
+ description:
11218
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11219
+ },
11220
+ org: {
11221
+ type: 'string',
11222
+ description:
11223
+ 'Force override the organization slug, overrides the default org from config'
11097
11224
  }
11098
11225
  },
11099
11226
  help: (command, config) => `
11100
11227
  Usage
11101
- $ ${command} <org slug> <ID1> <ID2>
11228
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <ID1> <ID2>
11102
11229
 
11103
11230
  API Token Requirements
11104
11231
  - Quota: 1 unit
@@ -11115,8 +11242,8 @@ const config$6 = {
11115
11242
  ${getFlagListOutput(config.flags, 6)}
11116
11243
 
11117
11244
  Examples
11118
- $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
11119
- $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
11245
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
11246
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
11120
11247
  `
11121
11248
  }
11122
11249
  const cmdScanDiff = {
@@ -11131,9 +11258,21 @@ async function run$6(argv, importMeta, { parentName }) {
11131
11258
  importMeta,
11132
11259
  parentName
11133
11260
  })
11134
- const { depth, file, json, markdown } = cli.flags
11135
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11136
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11261
+ const {
11262
+ depth,
11263
+ dryRun,
11264
+ file,
11265
+ interactive,
11266
+ json,
11267
+ markdown,
11268
+ org: orgFlag
11269
+ } = cli.flags
11270
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11271
+ String(orgFlag || ''),
11272
+ cli.input[0] || '',
11273
+ !!interactive,
11274
+ !!dryRun
11275
+ )
11137
11276
  let id1 = cli.input[defaultOrgSlug ? 0 : 1] || ''
11138
11277
  let id2 = cli.input[defaultOrgSlug ? 1 : 2] || ''
11139
11278
  if (id1.startsWith(SOCKET_SBOM_URL_PREFIX)) {
@@ -11159,7 +11298,9 @@ async function run$6(argv, importMeta, { parentName }) {
11159
11298
  {
11160
11299
  test: !!orgSlug,
11161
11300
  nook: true,
11162
- message: 'Org name as the first argument',
11301
+ message: shadowNpmInject.isTestingV1()
11302
+ ? 'Org name by default setting, --org, or auto-discovered'
11303
+ : 'Org name must be the first argument',
11163
11304
  pass: 'ok',
11164
11305
  fail: 'missing'
11165
11306
  },
@@ -11340,6 +11481,12 @@ const config$5 = {
11340
11481
  default: '',
11341
11482
  description: 'From time - as a unix timestamp'
11342
11483
  },
11484
+ interactive: {
11485
+ type: 'boolean',
11486
+ default: true,
11487
+ description:
11488
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11489
+ },
11343
11490
  page: {
11344
11491
  type: 'number',
11345
11492
  shortFlag: 'p',
@@ -11352,6 +11499,11 @@ const config$5 = {
11352
11499
  default: 30,
11353
11500
  description: 'Results per page - Default is 30'
11354
11501
  },
11502
+ org: {
11503
+ type: 'string',
11504
+ description:
11505
+ 'Force override the organization slug, overrides the default org from config'
11506
+ },
11355
11507
  repo: {
11356
11508
  type: 'string',
11357
11509
  description: 'Filter to show only scans with this repository name'
@@ -11372,7 +11524,7 @@ const config$5 = {
11372
11524
  },
11373
11525
  help: (command, config) => `
11374
11526
  Usage
11375
- $ ${command} <org slug>
11527
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
11376
11528
 
11377
11529
  API Token Requirements
11378
11530
  - Quota: 1 unit
@@ -11382,7 +11534,7 @@ const config$5 = {
11382
11534
  ${getFlagListOutput(config.flags, 6)}
11383
11535
 
11384
11536
  Examples
11385
- $ ${command} FakeOrg
11537
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'}
11386
11538
  `
11387
11539
  }
11388
11540
  const cmdScanList = {
@@ -11397,15 +11549,29 @@ async function run$5(argv, importMeta, { parentName }) {
11397
11549
  importMeta,
11398
11550
  parentName
11399
11551
  })
11400
- const { branch, json, markdown, repo } = cli.flags
11401
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11402
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11552
+ const {
11553
+ branch,
11554
+ dryRun,
11555
+ interactive,
11556
+ json,
11557
+ markdown,
11558
+ org: orgFlag,
11559
+ repo
11560
+ } = cli.flags
11561
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11562
+ String(orgFlag || ''),
11563
+ cli.input[0] || '',
11564
+ !!interactive,
11565
+ !!dryRun
11566
+ )
11403
11567
  const apiToken = shadowNpmInject.getDefaultToken()
11404
11568
  const wasBadInput = handleBadInput(
11405
11569
  {
11406
11570
  nook: !!defaultOrgSlug,
11407
11571
  test: !!orgSlug && orgSlug !== '.',
11408
- message: 'Org name as the first argument',
11572
+ message: shadowNpmInject.isTestingV1()
11573
+ ? 'Org name by default setting, --org, or auto-discovered'
11574
+ : 'Org name must be the first argument',
11409
11575
  pass: 'ok',
11410
11576
  fail:
11411
11577
  orgSlug === '.'
@@ -11516,11 +11682,22 @@ const config$4 = {
11516
11682
  hidden: false,
11517
11683
  flags: {
11518
11684
  ...commonFlags,
11519
- ...outputFlags
11685
+ ...outputFlags,
11686
+ interactive: {
11687
+ type: 'boolean',
11688
+ default: true,
11689
+ description:
11690
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11691
+ },
11692
+ org: {
11693
+ type: 'string',
11694
+ description:
11695
+ 'Force override the organization slug, overrides the default org from config'
11696
+ }
11520
11697
  },
11521
11698
  help: (command, config) => `
11522
11699
  Usage
11523
- $ ${command} <org slug> <scan ID>
11700
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID>
11524
11701
 
11525
11702
  API Token Requirements
11526
11703
  - Quota: 1 unit
@@ -11530,7 +11707,7 @@ const config$4 = {
11530
11707
  ${getFlagListOutput(config.flags, 6)}
11531
11708
 
11532
11709
  Examples
11533
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
11710
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0
11534
11711
  `
11535
11712
  }
11536
11713
  const cmdScanMetadata = {
@@ -11545,16 +11722,25 @@ async function run$4(argv, importMeta, { parentName }) {
11545
11722
  importMeta,
11546
11723
  parentName
11547
11724
  })
11548
- const { json, markdown } = cli.flags
11549
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11550
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11551
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11725
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
11726
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11727
+ String(orgFlag || ''),
11728
+ cli.input[0] || '',
11729
+ !!interactive,
11730
+ !!dryRun
11731
+ )
11732
+ const scanId =
11733
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11734
+ ? cli.input[0]
11735
+ : cli.input[1]) || ''
11552
11736
  const apiToken = shadowNpmInject.getDefaultToken()
11553
11737
  const wasBadInput = handleBadInput(
11554
11738
  {
11555
11739
  nook: !!defaultOrgSlug,
11556
11740
  test: !!orgSlug && orgSlug !== '.',
11557
- message: 'Org name as the first argument',
11741
+ message: shadowNpmInject.isTestingV1()
11742
+ ? 'Org name by default setting, --org, or auto-discovered'
11743
+ : 'Org name must be the first argument',
11558
11744
  pass: 'ok',
11559
11745
  fail:
11560
11746
  orgSlug === '.'
@@ -11611,6 +11797,17 @@ const config$3 = {
11611
11797
  default: 'none',
11612
11798
  description: 'Fold reported alerts to some degree'
11613
11799
  },
11800
+ interactive: {
11801
+ type: 'boolean',
11802
+ default: true,
11803
+ description:
11804
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11805
+ },
11806
+ org: {
11807
+ type: 'string',
11808
+ description:
11809
+ 'Force override the organization slug, overrides the default org from config'
11810
+ },
11614
11811
  reportLevel: {
11615
11812
  type: 'string',
11616
11813
  default: 'warn',
@@ -11629,7 +11826,7 @@ const config$3 = {
11629
11826
  },
11630
11827
  help: (command, config) => `
11631
11828
  Usage
11632
- $ ${command} <org slug> <scan ID> [path to output file]
11829
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID> [path to output file]
11633
11830
 
11634
11831
  API Token Requirements
11635
11832
  - Quota: 2 units
@@ -11648,8 +11845,8 @@ const config$3 = {
11648
11845
  Short responses: JSON: \`{healthy:bool}\`, markdown: \`healthy = bool\`, text: \`OK/ERR\`
11649
11846
 
11650
11847
  Examples
11651
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 --json --fold=version
11652
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 --license --markdown --short
11848
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 --json --fold=version
11849
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 --license --markdown --short
11653
11850
  `
11654
11851
  }
11655
11852
  const cmdScanReport = {
@@ -11671,16 +11868,29 @@ async function run$3(argv, importMeta, { parentName }) {
11671
11868
  markdown,
11672
11869
  reportLevel = 'warn'
11673
11870
  } = cli.flags
11674
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11675
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11676
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11677
- const file = (defaultOrgSlug ? cli.input[1] : cli.input[2]) || '-'
11871
+ const { dryRun, interactive, org: orgFlag } = cli.flags
11872
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11873
+ String(orgFlag || ''),
11874
+ cli.input[0] || '',
11875
+ !!interactive,
11876
+ !!dryRun
11877
+ )
11878
+ const scanId =
11879
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11880
+ ? cli.input[0]
11881
+ : cli.input[1]) || ''
11882
+ const file =
11883
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11884
+ ? cli.input[1]
11885
+ : cli.input[2]) || '-'
11678
11886
  const apiToken = shadowNpmInject.getDefaultToken()
11679
11887
  const wasBadInput = handleBadInput(
11680
11888
  {
11681
11889
  nook: !!defaultOrgSlug,
11682
11890
  test: !!orgSlug && orgSlug !== '.',
11683
- message: 'Org name as the first argument',
11891
+ message: shadowNpmInject.isTestingV1()
11892
+ ? 'Org name by default setting, --org, or auto-discovered'
11893
+ : 'Org name must be the first argument',
11684
11894
  pass: 'ok',
11685
11895
  fail:
11686
11896
  orgSlug === '.'
@@ -11839,11 +12049,22 @@ const config$2 = {
11839
12049
  hidden: false,
11840
12050
  flags: {
11841
12051
  ...commonFlags,
11842
- ...outputFlags
12052
+ ...outputFlags,
12053
+ interactive: {
12054
+ type: 'boolean',
12055
+ default: true,
12056
+ description:
12057
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
12058
+ },
12059
+ org: {
12060
+ type: 'string',
12061
+ description:
12062
+ 'Force override the organization slug, overrides the default org from config'
12063
+ }
11843
12064
  },
11844
12065
  help: (command, config) => `
11845
12066
  Usage
11846
- $ ${command} <org slug> <scan ID> [path to output file]
12067
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID> [path to output file]
11847
12068
 
11848
12069
  API Token Requirements
11849
12070
  - Quota: 1 unit
@@ -11855,7 +12076,7 @@ const config$2 = {
11855
12076
  ${getFlagListOutput(config.flags, 6)}
11856
12077
 
11857
12078
  Examples
11858
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
12079
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
11859
12080
  `
11860
12081
  }
11861
12082
  const cmdScanView = {
@@ -11870,17 +12091,29 @@ async function run$2(argv, importMeta, { parentName }) {
11870
12091
  importMeta,
11871
12092
  parentName
11872
12093
  })
11873
- const { json, markdown } = cli.flags
11874
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11875
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11876
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11877
- const file = (defaultOrgSlug ? cli.input[1] : cli.input[2]) || '-'
12094
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
12095
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
12096
+ String(orgFlag || ''),
12097
+ cli.input[0] || '',
12098
+ !!interactive,
12099
+ !!dryRun
12100
+ )
12101
+ const scanId =
12102
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
12103
+ ? cli.input[0]
12104
+ : cli.input[1]) || ''
12105
+ const file =
12106
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
12107
+ ? cli.input[1]
12108
+ : cli.input[2]) || '-'
11878
12109
  const apiToken = shadowNpmInject.getDefaultToken()
11879
12110
  const wasBadInput = handleBadInput(
11880
12111
  {
11881
12112
  nook: !!defaultOrgSlug,
11882
12113
  test: !!orgSlug && orgSlug !== '.',
11883
- message: 'Org name as the first argument',
12114
+ message: shadowNpmInject.isTestingV1()
12115
+ ? 'Org name by default setting, --org, or auto-discovered'
12116
+ : 'Org name must be the first argument',
11884
12117
  pass: 'ok',
11885
12118
  fail:
11886
12119
  orgSlug === '.'
@@ -12168,6 +12401,17 @@ const config$1 = {
12168
12401
  flags: {
12169
12402
  ...commonFlags,
12170
12403
  ...outputFlags,
12404
+ interactive: {
12405
+ type: 'boolean',
12406
+ default: true,
12407
+ description:
12408
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
12409
+ },
12410
+ org: {
12411
+ type: 'string',
12412
+ description:
12413
+ 'Force override the organization slug, overrides the default org from config'
12414
+ },
12171
12415
  perPage: {
12172
12416
  type: 'number',
12173
12417
  shortFlag: 'pp',
@@ -12201,7 +12445,7 @@ const config$1 = {
12201
12445
  },
12202
12446
  help: (command, config) => `
12203
12447
  Usage
12204
- $ ${command}
12448
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
12205
12449
 
12206
12450
  API Token Requirements
12207
12451
  - Quota: 1 unit
@@ -12238,8 +12482,8 @@ const config$1 = {
12238
12482
  - pypi
12239
12483
 
12240
12484
  Examples
12241
- $ ${command}
12242
- $ ${command} --perPage=5 --page=2 --direction=asc --filter=joke
12485
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'}
12486
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} --perPage=5 --page=2 --direction=asc --filter=joke
12243
12487
  `
12244
12488
  }
12245
12489
  const cmdThreatFeed = {
@@ -12254,9 +12498,13 @@ async function run$1(argv, importMeta, { parentName }) {
12254
12498
  importMeta,
12255
12499
  parentName
12256
12500
  })
12257
- const { json, markdown } = cli.flags
12258
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
12259
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
12501
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
12502
+ const [orgSlug] = await determineOrgSlug(
12503
+ String(orgFlag || ''),
12504
+ cli.input[0] || '',
12505
+ !!interactive,
12506
+ !!dryRun
12507
+ )
12260
12508
  const apiToken = shadowNpmInject.getDefaultToken()
12261
12509
  const wasBadInput = handleBadInput(
12262
12510
  {
@@ -12508,7 +12756,7 @@ void (async () => {
12508
12756
  await vendor.updater({
12509
12757
  name: SOCKET_CLI_BIN_NAME,
12510
12758
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
12511
- version: '0.14.149',
12759
+ version: '0.14.150',
12512
12760
  ttl: 86_400_000 /* 24 hours in milliseconds */
12513
12761
  })
12514
12762
  try {
@@ -12576,5 +12824,5 @@ void (async () => {
12576
12824
  await shadowNpmInject.captureException(e)
12577
12825
  }
12578
12826
  })()
12579
- //# debugId=b16c9682-c6cb-499e-9433-037f8e571bc1
12827
+ //# debugId=835d04cb-7542-4f21-978b-70fe4fe52a4e
12580
12828
  //# sourceMappingURL=cli.js.map