socket 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:5a035429:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
905
+ const cliVersion = '0.14.150:cc2913a:aa0fe20d: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
 
@@ -5458,7 +5626,10 @@ const config$A = {
5458
5626
  ...outputFlags,
5459
5627
  ...validationFlags
5460
5628
  },
5461
- help: (command, config) => `
5629
+ help: (command, config) =>
5630
+ shadowNpmInject.isTestingV1()
5631
+ ? 'This command will be removed in v1'
5632
+ : `
5462
5633
  Usage
5463
5634
  $ ${command} <name>
5464
5635
 
@@ -8061,11 +8232,22 @@ const config$m = {
8061
8232
  hidden: true,
8062
8233
  flags: {
8063
8234
  ...commonFlags,
8064
- ...outputFlags
8235
+ ...outputFlags,
8236
+ interactive: {
8237
+ type: 'boolean',
8238
+ default: true,
8239
+ description:
8240
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
8241
+ },
8242
+ org: {
8243
+ type: 'string',
8244
+ description:
8245
+ 'Force override the organization slug, overrides the default org from config'
8246
+ }
8065
8247
  },
8066
8248
  help: (command, _config) => `
8067
8249
  Usage
8068
- $ ${command} <org slug>
8250
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
8069
8251
 
8070
8252
  API Token Requirements
8071
8253
  - Quota: 1 unit
@@ -8078,8 +8260,8 @@ const config$m = {
8078
8260
  the request will fail with an authentication error.
8079
8261
 
8080
8262
  Examples
8081
- $ ${command} mycorp
8082
- $ ${command} mycorp --json
8263
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'}
8264
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'} --json
8083
8265
  `
8084
8266
  }
8085
8267
  const cmdOrganizationPolicyLicense = {
@@ -8094,16 +8276,21 @@ async function run$m(argv, importMeta, { parentName }) {
8094
8276
  importMeta,
8095
8277
  parentName
8096
8278
  })
8097
- const json = Boolean(cli.flags['json'])
8098
- const markdown = Boolean(cli.flags['markdown'])
8099
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
8100
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
8279
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
8280
+ const [orgSlug] = await determineOrgSlug(
8281
+ String(orgFlag || ''),
8282
+ cli.input[0] || '',
8283
+ !!interactive,
8284
+ !!dryRun
8285
+ )
8101
8286
  const apiToken = shadowNpmInject.getDefaultToken()
8102
8287
  const wasBadInput = handleBadInput(
8103
8288
  {
8104
8289
  nook: true,
8105
8290
  test: !!orgSlug,
8106
- message: 'Org name as the first argument',
8291
+ message: shadowNpmInject.isTestingV1()
8292
+ ? 'Org name by default setting, --org, or auto-discovered'
8293
+ : 'Org name must be the first argument',
8107
8294
  pass: 'ok',
8108
8295
  fail: 'missing'
8109
8296
  },
@@ -8203,11 +8390,22 @@ const config$l = {
8203
8390
  hidden: true,
8204
8391
  flags: {
8205
8392
  ...commonFlags,
8206
- ...outputFlags
8393
+ ...outputFlags,
8394
+ interactive: {
8395
+ type: 'boolean',
8396
+ default: true,
8397
+ description:
8398
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
8399
+ },
8400
+ org: {
8401
+ type: 'string',
8402
+ description:
8403
+ 'Force override the organization slug, overrides the default org from config'
8404
+ }
8207
8405
  },
8208
8406
  help: (command, _config) => `
8209
8407
  Usage
8210
- $ ${command} <org slug>
8408
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
8211
8409
 
8212
8410
  API Token Requirements
8213
8411
  - Quota: 1 unit
@@ -8220,8 +8418,8 @@ const config$l = {
8220
8418
  the request will fail with an authentication error.
8221
8419
 
8222
8420
  Examples
8223
- $ ${command} mycorp
8224
- $ ${command} mycorp --json
8421
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'}
8422
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' mycorp'} --json
8225
8423
  `
8226
8424
  }
8227
8425
  const cmdOrganizationPolicyPolicy = {
@@ -8236,10 +8434,13 @@ async function run$l(argv, importMeta, { parentName }) {
8236
8434
  importMeta,
8237
8435
  parentName
8238
8436
  })
8239
- const json = Boolean(cli.flags['json'])
8240
- const markdown = Boolean(cli.flags['markdown'])
8241
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
8242
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
8437
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
8438
+ const [orgSlug] = await determineOrgSlug(
8439
+ String(orgFlag || ''),
8440
+ cli.input[0] || '',
8441
+ !!interactive,
8442
+ !!dryRun
8443
+ )
8243
8444
  const apiToken = shadowNpmInject.getDefaultToken()
8244
8445
  const wasBadInput = handleBadInput(
8245
8446
  {
@@ -9413,45 +9614,6 @@ async function handleCreateRepo({
9413
9614
  await outputCreateRepo()
9414
9615
  }
9415
9616
 
9416
- async function suggestOrgSlug() {
9417
- const sockSdk = await shadowNpmInject.setupSdk()
9418
- const result = await handleApiCall(
9419
- sockSdk.getOrganizations(),
9420
- 'looking up organizations'
9421
- )
9422
- // Ignore a failed request here. It was not the primary goal of
9423
- // running this command and reporting it only leads to end-user confusion.
9424
- if (result.success) {
9425
- const proceed = await prompts.select({
9426
- message:
9427
- 'Missing org name; do you want to use any of these orgs for this scan?',
9428
- choices: [
9429
- ...Object.values(result.data.organizations).map(org => {
9430
- const slug = org.name ?? 'undefined'
9431
- return {
9432
- name: `Yes [${slug}]`,
9433
- value: slug,
9434
- description: `Use "${slug}" as the organization`
9435
- }
9436
- }),
9437
- {
9438
- name: 'No',
9439
- value: '',
9440
- description:
9441
- 'Do not use any of these organizations (will end in a no-op)'
9442
- }
9443
- ]
9444
- })
9445
- if (proceed) {
9446
- return proceed
9447
- }
9448
- } else {
9449
- logger.logger.fail(
9450
- 'Failed to lookup organization list from API, unable to suggest'
9451
- )
9452
- }
9453
- }
9454
-
9455
9617
  const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$d } = constants
9456
9618
  const config$d = {
9457
9619
  commandName: 'create',
@@ -9528,33 +9690,18 @@ async function run$d(argv, importMeta, { parentName }) {
9528
9690
  importMeta,
9529
9691
  parentName
9530
9692
  })
9531
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9532
- const interactive = cli.flags['interactive']
9533
- const dryRun = cli.flags['dryRun']
9534
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9535
- if (!orgSlug) {
9536
- if (shadowNpmInject.isTestingV1()) {
9537
- // ask from server
9538
- logger.logger.error(
9539
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9540
- )
9541
- logger.logger.error(
9542
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9543
- )
9544
- if (dryRun) {
9545
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9546
- } else if (!interactive) {
9547
- logger.logger.fail(
9548
- 'Skipping auto-discovery of org when interactive = false'
9549
- )
9550
- } else {
9551
- orgSlug = (await suggestOrgSlug()) || ''
9552
- }
9553
- } else {
9554
- orgSlug = cli.input[0] || ''
9555
- }
9556
- }
9557
- const repoNameFlag = cli.flags['repoName']
9693
+ const {
9694
+ dryRun,
9695
+ interactive,
9696
+ org: orgFlag,
9697
+ repoName: repoNameFlag
9698
+ } = cli.flags
9699
+ const [orgSlug] = await determineOrgSlug(
9700
+ String(orgFlag || ''),
9701
+ cli.input[0] || '',
9702
+ !!interactive,
9703
+ !!dryRun
9704
+ )
9558
9705
  const repoName =
9559
9706
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
9560
9707
  const apiToken = shadowNpmInject.getDefaultToken()
@@ -9671,32 +9818,13 @@ async function run$c(argv, importMeta, { parentName }) {
9671
9818
  importMeta,
9672
9819
  parentName
9673
9820
  })
9674
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9675
- const interactive = cli.flags['interactive']
9676
- const dryRun = cli.flags['dryRun']
9677
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9678
- if (!orgSlug) {
9679
- if (shadowNpmInject.isTestingV1()) {
9680
- // ask from server
9681
- logger.logger.error(
9682
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9683
- )
9684
- logger.logger.error(
9685
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9686
- )
9687
- if (dryRun) {
9688
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9689
- } else if (!interactive) {
9690
- logger.logger.fail(
9691
- 'Skipping auto-discovery of org when interactive = false'
9692
- )
9693
- } else {
9694
- orgSlug = (await suggestOrgSlug()) || ''
9695
- }
9696
- } else {
9697
- orgSlug = cli.input[0] || ''
9698
- }
9699
- }
9821
+ const { dryRun, interactive, org: orgFlag } = cli.flags
9822
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
9823
+ String(orgFlag || ''),
9824
+ cli.input[0] || '',
9825
+ !!interactive,
9826
+ !!dryRun
9827
+ )
9700
9828
  const repoName =
9701
9829
  (defaultOrgSlug || shadowNpmInject.isTestingV1()
9702
9830
  ? cli.input[0]
@@ -9893,32 +10021,13 @@ async function run$b(argv, importMeta, { parentName }) {
9893
10021
  parentName
9894
10022
  })
9895
10023
  const { json, markdown } = cli.flags
9896
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
9897
- const interactive = cli.flags['interactive']
9898
- const dryRun = cli.flags['dryRun']
9899
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
9900
- if (!orgSlug) {
9901
- if (shadowNpmInject.isTestingV1()) {
9902
- // ask from server
9903
- logger.logger.error(
9904
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
9905
- )
9906
- logger.logger.error(
9907
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
9908
- )
9909
- if (dryRun) {
9910
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
9911
- } else if (!interactive) {
9912
- logger.logger.fail(
9913
- 'Skipping auto-discovery of org when interactive = false'
9914
- )
9915
- } else {
9916
- orgSlug = (await suggestOrgSlug()) || ''
9917
- }
9918
- } else {
9919
- orgSlug = cli.input[0] || ''
9920
- }
9921
- }
10024
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10025
+ const [orgSlug] = await determineOrgSlug(
10026
+ String(orgFlag || ''),
10027
+ cli.input[0] || '',
10028
+ !!interactive,
10029
+ !!dryRun
10030
+ )
9922
10031
  const apiToken = shadowNpmInject.getDefaultToken()
9923
10032
  const wasBadInput = handleBadInput(
9924
10033
  {
@@ -10097,32 +10206,13 @@ async function run$a(argv, importMeta, { parentName }) {
10097
10206
  importMeta,
10098
10207
  parentName
10099
10208
  })
10100
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10101
- const interactive = cli.flags['interactive']
10102
- const dryRun = cli.flags['dryRun']
10103
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
10104
- if (!orgSlug) {
10105
- if (shadowNpmInject.isTestingV1()) {
10106
- // ask from server
10107
- logger.logger.error(
10108
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
10109
- )
10110
- logger.logger.error(
10111
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
10112
- )
10113
- if (dryRun) {
10114
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
10115
- } else if (!interactive) {
10116
- logger.logger.fail(
10117
- 'Skipping auto-discovery of org when interactive = false'
10118
- )
10119
- } else {
10120
- orgSlug = (await suggestOrgSlug()) || ''
10121
- }
10122
- } else {
10123
- orgSlug = cli.input[0] || ''
10124
- }
10125
- }
10209
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10210
+ const [orgSlug] = await determineOrgSlug(
10211
+ String(orgFlag || ''),
10212
+ cli.input[0] || '',
10213
+ !!interactive,
10214
+ !!dryRun
10215
+ )
10126
10216
  const repoNameFlag = cli.flags['repoName']
10127
10217
  const repoName =
10128
10218
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
@@ -10319,34 +10409,20 @@ async function run$9(argv, importMeta, { parentName }) {
10319
10409
  importMeta,
10320
10410
  parentName
10321
10411
  })
10322
- const { json, markdown } = cli.flags
10323
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10324
- const interactive = cli.flags['interactive']
10325
- const dryRun = cli.flags['dryRun']
10326
- let orgSlug = String(cli.flags['org'] || defaultOrgSlug || '')
10327
- if (!orgSlug) {
10328
- if (shadowNpmInject.isTestingV1()) {
10329
- // ask from server
10330
- logger.logger.error(
10331
- 'Missing the org slug and no --org flag set. Trying to auto-discover the org now...'
10332
- )
10333
- logger.logger.error(
10334
- 'Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.'
10335
- )
10336
- if (dryRun) {
10337
- logger.logger.fail('Skipping auto-discovery of org in dry-run mode')
10338
- } else if (!interactive) {
10339
- logger.logger.fail(
10340
- 'Skipping auto-discovery of org when interactive = false'
10341
- )
10342
- } else {
10343
- orgSlug = (await suggestOrgSlug()) || ''
10344
- }
10345
- } else {
10346
- orgSlug = cli.input[0] || ''
10347
- }
10348
- }
10349
- const repoNameFlag = cli.flags['repoName']
10412
+ const {
10413
+ dryRun,
10414
+ interactive,
10415
+ json,
10416
+ markdown,
10417
+ org: orgFlag,
10418
+ repoName: repoNameFlag
10419
+ } = cli.flags
10420
+ const [orgSlug] = await determineOrgSlug(
10421
+ String(orgFlag || ''),
10422
+ cli.input[0] || '',
10423
+ !!interactive,
10424
+ !!dryRun
10425
+ )
10350
10426
  const repoName =
10351
10427
  (shadowNpmInject.isTestingV1() ? cli.input[0] : repoNameFlag) || ''
10352
10428
  const apiToken = shadowNpmInject.getDefaultToken()
@@ -10511,6 +10587,11 @@ const config$8 = {
10511
10587
  shortFlag: 'pr',
10512
10588
  description: 'Commit hash'
10513
10589
  },
10590
+ org: {
10591
+ type: 'string',
10592
+ description:
10593
+ 'Force override the organization slug, overrides the default org from config'
10594
+ },
10514
10595
  readOnly: {
10515
10596
  type: 'boolean',
10516
10597
  default: false,
@@ -10540,7 +10621,7 @@ const config$8 = {
10540
10621
  // TODO: your project's "socket.yml" file's "projectIgnorePaths"
10541
10622
  help: (command, config) => `
10542
10623
  Usage
10543
- $ ${command} [...options] <org> <TARGET> [TARGET...]
10624
+ $ ${command} [...options]${shadowNpmInject.isTestingV1() ? '' : ' <org>'} <TARGET> [TARGET...]
10544
10625
 
10545
10626
  API Token Requirements
10546
10627
  - Quota: 1 unit
@@ -10573,7 +10654,8 @@ const config$8 = {
10573
10654
  ${getFlagListOutput(config.flags, 6)}
10574
10655
 
10575
10656
  Examples
10576
- $ ${command} --repo=test-repo --branch=main FakeOrg ./package.json
10657
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} .
10658
+ $ ${command} --repo=test-repo --branch=main${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} ./package.json
10577
10659
  `
10578
10660
  }
10579
10661
  const cmdScanCreate = {
@@ -10595,10 +10677,11 @@ async function run$8(argv, importMeta, { parentName }) {
10595
10677
  committers,
10596
10678
  cwd: cwdOverride,
10597
10679
  defaultBranch,
10598
- dryRun,
10680
+ dryRun = false,
10599
10681
  interactive = true,
10600
10682
  json,
10601
10683
  markdown,
10684
+ org: orgFlag,
10602
10685
  pendingHead,
10603
10686
  pullRequest,
10604
10687
  readOnly,
@@ -10606,9 +10689,19 @@ async function run$8(argv, importMeta, { parentName }) {
10606
10689
  report,
10607
10690
  tmp
10608
10691
  } = cli.flags
10609
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10610
- let orgSlug = defaultOrgSlug || cli.input[0] || ''
10611
- let targets = cli.input.slice(defaultOrgSlug ? 0 : 1)
10692
+ let [orgSlug, defaultOrgSlug] = await determineOrgSlug(
10693
+ String(orgFlag || ''),
10694
+ cli.input[0] || '',
10695
+ interactive,
10696
+ dryRun
10697
+ )
10698
+ if (!defaultOrgSlug) {
10699
+ // Tmp. just for TS. will drop this later.
10700
+ defaultOrgSlug = ''
10701
+ }
10702
+ let targets = cli.input.slice(
10703
+ shadowNpmInject.isTestingV1() || defaultOrgSlug ? 0 : 1
10704
+ )
10612
10705
  const cwd =
10613
10706
  cwdOverride && cwdOverride !== 'process.cwd()'
10614
10707
  ? String(cwdOverride)
@@ -10652,9 +10745,11 @@ async function run$8(argv, importMeta, { parentName }) {
10652
10745
  }
10653
10746
  const wasBadInput = handleBadInput(
10654
10747
  {
10655
- nook: !!defaultOrgSlug,
10748
+ nook: !shadowNpmInject.isTestingV1() && !!defaultOrgSlug,
10656
10749
  test: !!orgSlug && orgSlug !== '.',
10657
- message: 'Org name as the first argument',
10750
+ message: shadowNpmInject.isTestingV1()
10751
+ ? 'Org name by default setting, --org, or auto-discovered'
10752
+ : 'Org name must be the first argument',
10658
10753
  pass: 'ok',
10659
10754
  fail:
10660
10755
  orgSlug === '.'
@@ -10768,11 +10863,22 @@ const config$7 = {
10768
10863
  hidden: false,
10769
10864
  flags: {
10770
10865
  ...commonFlags,
10771
- ...outputFlags
10866
+ ...outputFlags,
10867
+ interactive: {
10868
+ type: 'boolean',
10869
+ default: true,
10870
+ description:
10871
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
10872
+ },
10873
+ org: {
10874
+ type: 'string',
10875
+ description:
10876
+ 'Force override the organization slug, overrides the default org from config'
10877
+ }
10772
10878
  },
10773
10879
  help: (command, config) => `
10774
10880
  Usage
10775
- $ ${command} <org slug> <scan ID>
10881
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID>
10776
10882
 
10777
10883
  API Token Requirements
10778
10884
  - Quota: 1 unit
@@ -10782,7 +10888,7 @@ const config$7 = {
10782
10888
  ${getFlagListOutput(config.flags, 6)}
10783
10889
 
10784
10890
  Examples
10785
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
10891
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0
10786
10892
  `
10787
10893
  }
10788
10894
  const cmdScanDel = {
@@ -10797,15 +10903,25 @@ async function run$7(argv, importMeta, { parentName }) {
10797
10903
  importMeta,
10798
10904
  parentName
10799
10905
  })
10800
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
10801
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
10802
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
10906
+ const { dryRun, interactive, org: orgFlag } = cli.flags
10907
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
10908
+ String(orgFlag || ''),
10909
+ cli.input[0] || '',
10910
+ !!interactive,
10911
+ !!dryRun
10912
+ )
10913
+ const scanId =
10914
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
10915
+ ? cli.input[0]
10916
+ : cli.input[1]) || ''
10803
10917
  const apiToken = shadowNpmInject.getDefaultToken()
10804
10918
  const wasBadInput = handleBadInput(
10805
10919
  {
10806
10920
  nook: !!defaultOrgSlug,
10807
10921
  test: !!orgSlug && orgSlug !== '.',
10808
- message: 'Org name as the first argument',
10922
+ message: shadowNpmInject.isTestingV1()
10923
+ ? 'Org name by default setting, --org, or auto-discovered'
10924
+ : 'Org name must be the first argument',
10809
10925
  pass: 'ok',
10810
10926
  fail:
10811
10927
  orgSlug === '.'
@@ -11090,11 +11206,22 @@ const config$6 = {
11090
11206
  default: '',
11091
11207
  description:
11092
11208
  'Path to a local file where the output should be saved. Use `-` to force stdout.'
11209
+ },
11210
+ interactive: {
11211
+ type: 'boolean',
11212
+ default: true,
11213
+ description:
11214
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11215
+ },
11216
+ org: {
11217
+ type: 'string',
11218
+ description:
11219
+ 'Force override the organization slug, overrides the default org from config'
11093
11220
  }
11094
11221
  },
11095
11222
  help: (command, config) => `
11096
11223
  Usage
11097
- $ ${command} <org slug> <ID1> <ID2>
11224
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <ID1> <ID2>
11098
11225
 
11099
11226
  API Token Requirements
11100
11227
  - Quota: 1 unit
@@ -11111,8 +11238,8 @@ const config$6 = {
11111
11238
  ${getFlagListOutput(config.flags, 6)}
11112
11239
 
11113
11240
  Examples
11114
- $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
11115
- $ ${command} FakeCorp aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
11241
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
11242
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1 --json
11116
11243
  `
11117
11244
  }
11118
11245
  const cmdScanDiff = {
@@ -11127,9 +11254,21 @@ async function run$6(argv, importMeta, { parentName }) {
11127
11254
  importMeta,
11128
11255
  parentName
11129
11256
  })
11130
- const { depth, file, json, markdown } = cli.flags
11131
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11132
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11257
+ const {
11258
+ depth,
11259
+ dryRun,
11260
+ file,
11261
+ interactive,
11262
+ json,
11263
+ markdown,
11264
+ org: orgFlag
11265
+ } = cli.flags
11266
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11267
+ String(orgFlag || ''),
11268
+ cli.input[0] || '',
11269
+ !!interactive,
11270
+ !!dryRun
11271
+ )
11133
11272
  let id1 = cli.input[defaultOrgSlug ? 0 : 1] || ''
11134
11273
  let id2 = cli.input[defaultOrgSlug ? 1 : 2] || ''
11135
11274
  if (id1.startsWith(SOCKET_SBOM_URL_PREFIX)) {
@@ -11155,7 +11294,9 @@ async function run$6(argv, importMeta, { parentName }) {
11155
11294
  {
11156
11295
  test: !!orgSlug,
11157
11296
  nook: true,
11158
- message: 'Org name as the first argument',
11297
+ message: shadowNpmInject.isTestingV1()
11298
+ ? 'Org name by default setting, --org, or auto-discovered'
11299
+ : 'Org name must be the first argument',
11159
11300
  pass: 'ok',
11160
11301
  fail: 'missing'
11161
11302
  },
@@ -11336,6 +11477,12 @@ const config$5 = {
11336
11477
  default: '',
11337
11478
  description: 'From time - as a unix timestamp'
11338
11479
  },
11480
+ interactive: {
11481
+ type: 'boolean',
11482
+ default: true,
11483
+ description:
11484
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11485
+ },
11339
11486
  page: {
11340
11487
  type: 'number',
11341
11488
  shortFlag: 'p',
@@ -11348,6 +11495,11 @@ const config$5 = {
11348
11495
  default: 30,
11349
11496
  description: 'Results per page - Default is 30'
11350
11497
  },
11498
+ org: {
11499
+ type: 'string',
11500
+ description:
11501
+ 'Force override the organization slug, overrides the default org from config'
11502
+ },
11351
11503
  repo: {
11352
11504
  type: 'string',
11353
11505
  description: 'Filter to show only scans with this repository name'
@@ -11368,7 +11520,7 @@ const config$5 = {
11368
11520
  },
11369
11521
  help: (command, config) => `
11370
11522
  Usage
11371
- $ ${command} <org slug>
11523
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
11372
11524
 
11373
11525
  API Token Requirements
11374
11526
  - Quota: 1 unit
@@ -11378,7 +11530,7 @@ const config$5 = {
11378
11530
  ${getFlagListOutput(config.flags, 6)}
11379
11531
 
11380
11532
  Examples
11381
- $ ${command} FakeOrg
11533
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'}
11382
11534
  `
11383
11535
  }
11384
11536
  const cmdScanList = {
@@ -11393,15 +11545,29 @@ async function run$5(argv, importMeta, { parentName }) {
11393
11545
  importMeta,
11394
11546
  parentName
11395
11547
  })
11396
- const { branch, json, markdown, repo } = cli.flags
11397
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11398
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11548
+ const {
11549
+ branch,
11550
+ dryRun,
11551
+ interactive,
11552
+ json,
11553
+ markdown,
11554
+ org: orgFlag,
11555
+ repo
11556
+ } = cli.flags
11557
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11558
+ String(orgFlag || ''),
11559
+ cli.input[0] || '',
11560
+ !!interactive,
11561
+ !!dryRun
11562
+ )
11399
11563
  const apiToken = shadowNpmInject.getDefaultToken()
11400
11564
  const wasBadInput = handleBadInput(
11401
11565
  {
11402
11566
  nook: !!defaultOrgSlug,
11403
11567
  test: !!orgSlug && orgSlug !== '.',
11404
- message: 'Org name as the first argument',
11568
+ message: shadowNpmInject.isTestingV1()
11569
+ ? 'Org name by default setting, --org, or auto-discovered'
11570
+ : 'Org name must be the first argument',
11405
11571
  pass: 'ok',
11406
11572
  fail:
11407
11573
  orgSlug === '.'
@@ -11512,11 +11678,22 @@ const config$4 = {
11512
11678
  hidden: false,
11513
11679
  flags: {
11514
11680
  ...commonFlags,
11515
- ...outputFlags
11681
+ ...outputFlags,
11682
+ interactive: {
11683
+ type: 'boolean',
11684
+ default: true,
11685
+ description:
11686
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11687
+ },
11688
+ org: {
11689
+ type: 'string',
11690
+ description:
11691
+ 'Force override the organization slug, overrides the default org from config'
11692
+ }
11516
11693
  },
11517
11694
  help: (command, config) => `
11518
11695
  Usage
11519
- $ ${command} <org slug> <scan ID>
11696
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID>
11520
11697
 
11521
11698
  API Token Requirements
11522
11699
  - Quota: 1 unit
@@ -11526,7 +11703,7 @@ const config$4 = {
11526
11703
  ${getFlagListOutput(config.flags, 6)}
11527
11704
 
11528
11705
  Examples
11529
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
11706
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0
11530
11707
  `
11531
11708
  }
11532
11709
  const cmdScanMetadata = {
@@ -11541,16 +11718,25 @@ async function run$4(argv, importMeta, { parentName }) {
11541
11718
  importMeta,
11542
11719
  parentName
11543
11720
  })
11544
- const { json, markdown } = cli.flags
11545
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11546
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11547
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11721
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
11722
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11723
+ String(orgFlag || ''),
11724
+ cli.input[0] || '',
11725
+ !!interactive,
11726
+ !!dryRun
11727
+ )
11728
+ const scanId =
11729
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11730
+ ? cli.input[0]
11731
+ : cli.input[1]) || ''
11548
11732
  const apiToken = shadowNpmInject.getDefaultToken()
11549
11733
  const wasBadInput = handleBadInput(
11550
11734
  {
11551
11735
  nook: !!defaultOrgSlug,
11552
11736
  test: !!orgSlug && orgSlug !== '.',
11553
- message: 'Org name as the first argument',
11737
+ message: shadowNpmInject.isTestingV1()
11738
+ ? 'Org name by default setting, --org, or auto-discovered'
11739
+ : 'Org name must be the first argument',
11554
11740
  pass: 'ok',
11555
11741
  fail:
11556
11742
  orgSlug === '.'
@@ -11607,6 +11793,17 @@ const config$3 = {
11607
11793
  default: 'none',
11608
11794
  description: 'Fold reported alerts to some degree'
11609
11795
  },
11796
+ interactive: {
11797
+ type: 'boolean',
11798
+ default: true,
11799
+ description:
11800
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
11801
+ },
11802
+ org: {
11803
+ type: 'string',
11804
+ description:
11805
+ 'Force override the organization slug, overrides the default org from config'
11806
+ },
11610
11807
  reportLevel: {
11611
11808
  type: 'string',
11612
11809
  default: 'warn',
@@ -11625,7 +11822,7 @@ const config$3 = {
11625
11822
  },
11626
11823
  help: (command, config) => `
11627
11824
  Usage
11628
- $ ${command} <org slug> <scan ID> [path to output file]
11825
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID> [path to output file]
11629
11826
 
11630
11827
  API Token Requirements
11631
11828
  - Quota: 2 units
@@ -11644,8 +11841,8 @@ const config$3 = {
11644
11841
  Short responses: JSON: \`{healthy:bool}\`, markdown: \`healthy = bool\`, text: \`OK/ERR\`
11645
11842
 
11646
11843
  Examples
11647
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 --json --fold=version
11648
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 --license --markdown --short
11844
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 --json --fold=version
11845
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 --license --markdown --short
11649
11846
  `
11650
11847
  }
11651
11848
  const cmdScanReport = {
@@ -11667,16 +11864,29 @@ async function run$3(argv, importMeta, { parentName }) {
11667
11864
  markdown,
11668
11865
  reportLevel = 'warn'
11669
11866
  } = cli.flags
11670
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11671
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11672
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11673
- const file = (defaultOrgSlug ? cli.input[1] : cli.input[2]) || '-'
11867
+ const { dryRun, interactive, org: orgFlag } = cli.flags
11868
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
11869
+ String(orgFlag || ''),
11870
+ cli.input[0] || '',
11871
+ !!interactive,
11872
+ !!dryRun
11873
+ )
11874
+ const scanId =
11875
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11876
+ ? cli.input[0]
11877
+ : cli.input[1]) || ''
11878
+ const file =
11879
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
11880
+ ? cli.input[1]
11881
+ : cli.input[2]) || '-'
11674
11882
  const apiToken = shadowNpmInject.getDefaultToken()
11675
11883
  const wasBadInput = handleBadInput(
11676
11884
  {
11677
11885
  nook: !!defaultOrgSlug,
11678
11886
  test: !!orgSlug && orgSlug !== '.',
11679
- message: 'Org name as the first argument',
11887
+ message: shadowNpmInject.isTestingV1()
11888
+ ? 'Org name by default setting, --org, or auto-discovered'
11889
+ : 'Org name must be the first argument',
11680
11890
  pass: 'ok',
11681
11891
  fail:
11682
11892
  orgSlug === '.'
@@ -11835,11 +12045,22 @@ const config$2 = {
11835
12045
  hidden: false,
11836
12046
  flags: {
11837
12047
  ...commonFlags,
11838
- ...outputFlags
12048
+ ...outputFlags,
12049
+ interactive: {
12050
+ type: 'boolean',
12051
+ default: true,
12052
+ description:
12053
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
12054
+ },
12055
+ org: {
12056
+ type: 'string',
12057
+ description:
12058
+ 'Force override the organization slug, overrides the default org from config'
12059
+ }
11839
12060
  },
11840
12061
  help: (command, config) => `
11841
12062
  Usage
11842
- $ ${command} <org slug> <scan ID> [path to output file]
12063
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'} <scan ID> [path to output file]
11843
12064
 
11844
12065
  API Token Requirements
11845
12066
  - Quota: 1 unit
@@ -11851,7 +12072,7 @@ const config$2 = {
11851
12072
  ${getFlagListOutput(config.flags, 6)}
11852
12073
 
11853
12074
  Examples
11854
- $ ${command} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
12075
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
11855
12076
  `
11856
12077
  }
11857
12078
  const cmdScanView = {
@@ -11866,17 +12087,29 @@ async function run$2(argv, importMeta, { parentName }) {
11866
12087
  importMeta,
11867
12088
  parentName
11868
12089
  })
11869
- const { json, markdown } = cli.flags
11870
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
11871
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
11872
- const scanId = (defaultOrgSlug ? cli.input[0] : cli.input[1]) || ''
11873
- const file = (defaultOrgSlug ? cli.input[1] : cli.input[2]) || '-'
12090
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
12091
+ const [orgSlug, defaultOrgSlug] = await determineOrgSlug(
12092
+ String(orgFlag || ''),
12093
+ cli.input[0] || '',
12094
+ !!interactive,
12095
+ !!dryRun
12096
+ )
12097
+ const scanId =
12098
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
12099
+ ? cli.input[0]
12100
+ : cli.input[1]) || ''
12101
+ const file =
12102
+ (shadowNpmInject.isTestingV1() || defaultOrgSlug
12103
+ ? cli.input[1]
12104
+ : cli.input[2]) || '-'
11874
12105
  const apiToken = shadowNpmInject.getDefaultToken()
11875
12106
  const wasBadInput = handleBadInput(
11876
12107
  {
11877
12108
  nook: !!defaultOrgSlug,
11878
12109
  test: !!orgSlug && orgSlug !== '.',
11879
- message: 'Org name as the first argument',
12110
+ message: shadowNpmInject.isTestingV1()
12111
+ ? 'Org name by default setting, --org, or auto-discovered'
12112
+ : 'Org name must be the first argument',
11880
12113
  pass: 'ok',
11881
12114
  fail:
11882
12115
  orgSlug === '.'
@@ -12164,6 +12397,17 @@ const config$1 = {
12164
12397
  flags: {
12165
12398
  ...commonFlags,
12166
12399
  ...outputFlags,
12400
+ interactive: {
12401
+ type: 'boolean',
12402
+ default: true,
12403
+ description:
12404
+ 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
12405
+ },
12406
+ org: {
12407
+ type: 'string',
12408
+ description:
12409
+ 'Force override the organization slug, overrides the default org from config'
12410
+ },
12167
12411
  perPage: {
12168
12412
  type: 'number',
12169
12413
  shortFlag: 'pp',
@@ -12197,7 +12441,7 @@ const config$1 = {
12197
12441
  },
12198
12442
  help: (command, config) => `
12199
12443
  Usage
12200
- $ ${command}
12444
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' <org slug>'}
12201
12445
 
12202
12446
  API Token Requirements
12203
12447
  - Quota: 1 unit
@@ -12234,8 +12478,8 @@ const config$1 = {
12234
12478
  - pypi
12235
12479
 
12236
12480
  Examples
12237
- $ ${command}
12238
- $ ${command} --perPage=5 --page=2 --direction=asc --filter=joke
12481
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'}
12482
+ $ ${command}${shadowNpmInject.isTestingV1() ? '' : ' FakeOrg'} --perPage=5 --page=2 --direction=asc --filter=joke
12239
12483
  `
12240
12484
  }
12241
12485
  const cmdThreatFeed = {
@@ -12250,9 +12494,13 @@ async function run$1(argv, importMeta, { parentName }) {
12250
12494
  importMeta,
12251
12495
  parentName
12252
12496
  })
12253
- const { json, markdown } = cli.flags
12254
- const defaultOrgSlug = shadowNpmInject.getConfigValue('defaultOrg')
12255
- const orgSlug = defaultOrgSlug || cli.input[0] || ''
12497
+ const { dryRun, interactive, json, markdown, org: orgFlag } = cli.flags
12498
+ const [orgSlug] = await determineOrgSlug(
12499
+ String(orgFlag || ''),
12500
+ cli.input[0] || '',
12501
+ !!interactive,
12502
+ !!dryRun
12503
+ )
12256
12504
  const apiToken = shadowNpmInject.getDefaultToken()
12257
12505
  const wasBadInput = handleBadInput(
12258
12506
  {
@@ -12504,7 +12752,7 @@ void (async () => {
12504
12752
  await vendor.updater({
12505
12753
  name: SOCKET_CLI_BIN_NAME,
12506
12754
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
12507
- version: '0.14.149',
12755
+ version: '0.14.150',
12508
12756
  ttl: 86_400_000 /* 24 hours in milliseconds */
12509
12757
  })
12510
12758
  try {
@@ -12572,5 +12820,5 @@ void (async () => {
12572
12820
  await shadowNpmInject.captureException(e)
12573
12821
  }
12574
12822
  })()
12575
- //# debugId=f345cafe-75b2-4c4f-8efd-1c13139d9917
12823
+ //# debugId=f9eb8bc8-da58-4963-a26b-58b7c8dc44b6
12576
12824
  //# sourceMappingURL=cli.js.map