@socketsecurity/cli-with-sentry 0.15.52 → 0.15.53
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 +245 -155
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan.d.mts.map +1 -1
- package/dist/types/flags.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/utils.js +19 -19
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -315,7 +315,7 @@ const config$T = {
|
|
|
315
315
|
file: {
|
|
316
316
|
type: 'string',
|
|
317
317
|
shortFlag: 'f',
|
|
318
|
-
description: 'Filepath to save output. Only valid with --json/--markdown.
|
|
318
|
+
description: 'Filepath to save output when given. Only valid with --json/--markdown.'
|
|
319
319
|
},
|
|
320
320
|
repo: {
|
|
321
321
|
type: 'string',
|
|
@@ -3222,7 +3222,7 @@ const description$9 = 'Commands related to the local CLI configuration';
|
|
|
3222
3222
|
const cmdConfig = {
|
|
3223
3223
|
description: description$9,
|
|
3224
3224
|
hidden: true,
|
|
3225
|
-
// [beta]
|
|
3225
|
+
// [beta]; isTestingV1
|
|
3226
3226
|
async run(argv, importMeta, {
|
|
3227
3227
|
parentName
|
|
3228
3228
|
}) {
|
|
@@ -4771,11 +4771,6 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4771
4771
|
isCi && repoInfo ? await getOpenSocketPrs(repoInfo.owner, repoInfo.repo, {
|
|
4772
4772
|
author: gitUser
|
|
4773
4773
|
}) : [];
|
|
4774
|
-
if (openPrs.length) {
|
|
4775
|
-
debug.debugFn(`found: ${openPrs.length} open PRs\n`, openPrs);
|
|
4776
|
-
} else {
|
|
4777
|
-
debug.debugFn('miss: 0 open PRs found');
|
|
4778
|
-
}
|
|
4779
4774
|
let count = 0;
|
|
4780
4775
|
let actualTree;
|
|
4781
4776
|
const lockfilePath = path.join(rootPath, 'pnpm-lock.yaml');
|
|
@@ -4825,9 +4820,9 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4825
4820
|
let alertsMap;
|
|
4826
4821
|
try {
|
|
4827
4822
|
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertsMapOptions({
|
|
4828
|
-
limit: limit
|
|
4823
|
+
limit: Math.max(limit, openPrs.length)
|
|
4829
4824
|
})) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getAlertsMapOptions({
|
|
4830
|
-
limit: limit
|
|
4825
|
+
limit: Math.max(limit, openPrs.length)
|
|
4831
4826
|
}));
|
|
4832
4827
|
} catch (e) {
|
|
4833
4828
|
spinner?.stop();
|
|
@@ -4839,7 +4834,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4839
4834
|
};
|
|
4840
4835
|
}
|
|
4841
4836
|
const infoByPartialPurl = utils.getCveInfoFromAlertsMap(alertsMap, {
|
|
4842
|
-
limit: limit
|
|
4837
|
+
limit: Math.max(limit, openPrs.length)
|
|
4843
4838
|
});
|
|
4844
4839
|
if (!infoByPartialPurl) {
|
|
4845
4840
|
spinner?.stop();
|
|
@@ -4921,6 +4916,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4921
4916
|
const pkgPath = path.dirname(pkgJsonPath);
|
|
4922
4917
|
const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
|
|
4923
4918
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
4919
|
+
const branchWorkspace = isCi ? getSocketBranchWorkspaceComponent(workspace) : '';
|
|
4924
4920
|
|
|
4925
4921
|
// actualTree may not be defined on the first iteration of pkgJsonPathsLoop.
|
|
4926
4922
|
if (!actualTree) {
|
|
@@ -4990,7 +4986,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4990
4986
|
continue infosLoop;
|
|
4991
4987
|
}
|
|
4992
4988
|
const newVersion = shadowInject.findBestPatchVersion(node, availableVersions, vulnerableVersionRange);
|
|
4993
|
-
if (activeBranches.find(b => b.newVersion === newVersion)) {
|
|
4989
|
+
if (activeBranches.find(b => b.workspace === branchWorkspace && b.newVersion === newVersion)) {
|
|
4994
4990
|
debug.debugFn(`skip: open PR found for ${name}@${newVersion}`);
|
|
4995
4991
|
if (++count >= limit) {
|
|
4996
4992
|
logger.logger.dedent();
|
|
@@ -5873,7 +5869,7 @@ const config$F = {
|
|
|
5873
5869
|
commandName: 'completion',
|
|
5874
5870
|
description: 'Install bash completion for Socket CLI',
|
|
5875
5871
|
hidden: true,
|
|
5876
|
-
// beta
|
|
5872
|
+
// beta; isTestingV1
|
|
5877
5873
|
flags: {
|
|
5878
5874
|
...utils.commonFlags
|
|
5879
5875
|
},
|
|
@@ -5932,7 +5928,7 @@ const description$7 = 'Setup the Socket CLI command in your environment';
|
|
|
5932
5928
|
const cmdInstall = {
|
|
5933
5929
|
description: description$7,
|
|
5934
5930
|
hidden: true,
|
|
5935
|
-
// beta
|
|
5931
|
+
// beta; isTestingV1
|
|
5936
5932
|
async run(argv, importMeta, {
|
|
5937
5933
|
parentName
|
|
5938
5934
|
}) {
|
|
@@ -8356,16 +8352,16 @@ async function run$s(argv, importMeta, {
|
|
|
8356
8352
|
});
|
|
8357
8353
|
}
|
|
8358
8354
|
|
|
8359
|
-
async function
|
|
8355
|
+
async function fetchLicensePolicy(orgSlug) {
|
|
8360
8356
|
const sockSdkResult = await utils.setupSdk();
|
|
8361
8357
|
if (!sockSdkResult.ok) {
|
|
8362
8358
|
return sockSdkResult;
|
|
8363
8359
|
}
|
|
8364
8360
|
const sockSdk = sockSdkResult.data;
|
|
8365
|
-
return await utils.handleApiCall(sockSdk.
|
|
8361
|
+
return await utils.handleApiCall(sockSdk.getOrgLicensePolicy(orgSlug), 'organization license policy');
|
|
8366
8362
|
}
|
|
8367
8363
|
|
|
8368
|
-
async function
|
|
8364
|
+
async function outputLicensePolicy(result, outputKind) {
|
|
8369
8365
|
if (!result.ok) {
|
|
8370
8366
|
process.exitCode = result.code ?? 1;
|
|
8371
8367
|
}
|
|
@@ -8377,73 +8373,66 @@ async function outputOrganizationList(result, outputKind = 'text') {
|
|
|
8377
8373
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8378
8374
|
return;
|
|
8379
8375
|
}
|
|
8380
|
-
|
|
8381
|
-
|
|
8382
|
-
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
let mw3 = 4;
|
|
8392
|
-
for (const o of organizations) {
|
|
8393
|
-
mw1 = Math.max(mw1, o.name?.length ?? 0);
|
|
8394
|
-
mw2 = Math.max(mw2, o.id.length);
|
|
8395
|
-
mw3 = Math.max(mw3, o.plan.length);
|
|
8396
|
-
}
|
|
8397
|
-
logger.logger.log('# Organizations\n');
|
|
8398
|
-
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8399
|
-
logger.logger.log(`| Name${' '.repeat(mw1 - 4)} | ID${' '.repeat(mw2 - 2)} | Plan${' '.repeat(mw3 - 4)} |`);
|
|
8400
|
-
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8401
|
-
for (const o of organizations) {
|
|
8402
|
-
logger.logger.log(`| ${(o.name || '').padEnd(mw1, ' ')} | ${(o.id || '').padEnd(mw2, ' ')} | ${(o.plan || '').padEnd(mw3, ' ')} |`);
|
|
8403
|
-
}
|
|
8404
|
-
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8405
|
-
return;
|
|
8406
|
-
}
|
|
8407
|
-
default:
|
|
8408
|
-
{
|
|
8409
|
-
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8410
|
-
// Just dump
|
|
8411
|
-
for (const o of organizations) {
|
|
8412
|
-
logger.logger.log(`- Name: ${vendor.yoctocolorsCjsExports.bold(o.name ?? 'undefined')}, ID: ${vendor.yoctocolorsCjsExports.bold(o.id)}, Plan: ${vendor.yoctocolorsCjsExports.bold(o.plan)}`);
|
|
8413
|
-
}
|
|
8414
|
-
}
|
|
8415
|
-
}
|
|
8376
|
+
logger.logger.info('Use --json to get the full result');
|
|
8377
|
+
logger.logger.log('# License policy');
|
|
8378
|
+
logger.logger.log('');
|
|
8379
|
+
logger.logger.log('This is the license policy for your organization:');
|
|
8380
|
+
logger.logger.log('');
|
|
8381
|
+
const rules = result.data['license_policy'];
|
|
8382
|
+
const entries = rules ? Object.entries(rules) : [];
|
|
8383
|
+
const mapped = entries.map(([key, value]) => [key, value?.['allowed'] ? ' yes' : ' no']);
|
|
8384
|
+
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8385
|
+
logger.logger.log(utils.mdTableOfPairs(mapped, ['License Name', 'Allowed']));
|
|
8386
|
+
logger.logger.log('');
|
|
8416
8387
|
}
|
|
8417
8388
|
|
|
8418
|
-
async function
|
|
8419
|
-
const data = await
|
|
8420
|
-
await
|
|
8389
|
+
async function handleLicensePolicy(orgSlug, outputKind) {
|
|
8390
|
+
const data = await fetchLicensePolicy(orgSlug);
|
|
8391
|
+
await outputLicensePolicy(data, outputKind);
|
|
8421
8392
|
}
|
|
8422
8393
|
|
|
8423
8394
|
const {
|
|
8424
8395
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$p
|
|
8425
8396
|
} = constants;
|
|
8397
|
+
|
|
8398
|
+
// TODO: secret toplevel alias `socket license policy`?
|
|
8426
8399
|
const config$r = {
|
|
8427
|
-
commandName: '
|
|
8428
|
-
description: '
|
|
8429
|
-
hidden:
|
|
8400
|
+
commandName: 'license',
|
|
8401
|
+
description: 'Retrieve the license policy of an organization',
|
|
8402
|
+
hidden: true,
|
|
8430
8403
|
flags: {
|
|
8431
8404
|
...utils.commonFlags,
|
|
8432
|
-
...utils.outputFlags
|
|
8405
|
+
...utils.outputFlags,
|
|
8406
|
+
interactive: {
|
|
8407
|
+
type: 'boolean',
|
|
8408
|
+
default: true,
|
|
8409
|
+
description: 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
8410
|
+
},
|
|
8411
|
+
org: {
|
|
8412
|
+
type: 'string',
|
|
8413
|
+
description: 'Force override the organization slug, overrides the default org from config'
|
|
8414
|
+
}
|
|
8433
8415
|
},
|
|
8434
8416
|
help: (command, _config) => `
|
|
8435
8417
|
Usage
|
|
8436
|
-
$ ${command}
|
|
8418
|
+
$ ${command}${utils.isTestingV1() ? '' : ' <org slug>'}
|
|
8437
8419
|
|
|
8438
8420
|
API Token Requirements
|
|
8439
8421
|
- Quota: 1 unit
|
|
8440
|
-
- Permissions:
|
|
8422
|
+
- Permissions: license-policy:read
|
|
8441
8423
|
|
|
8442
8424
|
Options
|
|
8443
8425
|
${utils.getFlagListOutput(config$r.flags, 6)}
|
|
8426
|
+
|
|
8427
|
+
Your API token will need the \`license-policy:read\` permission otherwise
|
|
8428
|
+
the request will fail with an authentication error.
|
|
8429
|
+
|
|
8430
|
+
Examples
|
|
8431
|
+
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'}
|
|
8432
|
+
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'} --json
|
|
8444
8433
|
`
|
|
8445
8434
|
};
|
|
8446
|
-
const
|
|
8435
|
+
const cmdOrganizationPolicyLicense = {
|
|
8447
8436
|
description: config$r.description,
|
|
8448
8437
|
hidden: config$r.hidden,
|
|
8449
8438
|
run: run$r
|
|
@@ -8458,17 +8447,27 @@ async function run$r(argv, importMeta, {
|
|
|
8458
8447
|
parentName
|
|
8459
8448
|
});
|
|
8460
8449
|
const {
|
|
8450
|
+
dryRun,
|
|
8451
|
+
interactive,
|
|
8461
8452
|
json,
|
|
8462
|
-
markdown
|
|
8453
|
+
markdown,
|
|
8454
|
+
org: orgFlag
|
|
8463
8455
|
} = cli.flags;
|
|
8464
8456
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
8457
|
+
const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', !!interactive, !!dryRun);
|
|
8465
8458
|
const hasApiToken = utils.hasDefaultToken();
|
|
8466
8459
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8460
|
+
nook: true,
|
|
8461
|
+
test: !!orgSlug,
|
|
8462
|
+
message: utils.isTestingV1() ? 'Org name by default setting, --org, or auto-discovered' : 'Org name must be the first argument',
|
|
8463
|
+
pass: 'ok',
|
|
8464
|
+
fail: 'missing'
|
|
8465
|
+
}, {
|
|
8467
8466
|
nook: true,
|
|
8468
8467
|
test: !json || !markdown,
|
|
8469
|
-
message: 'The
|
|
8468
|
+
message: 'The json and markdown flags cannot be both set, pick one',
|
|
8470
8469
|
pass: 'ok',
|
|
8471
|
-
fail: '
|
|
8470
|
+
fail: 'omit one'
|
|
8472
8471
|
}, {
|
|
8473
8472
|
nook: true,
|
|
8474
8473
|
test: hasApiToken,
|
|
@@ -8483,19 +8482,19 @@ async function run$r(argv, importMeta, {
|
|
|
8483
8482
|
logger.logger.log(DRY_RUN_BAILING_NOW$p);
|
|
8484
8483
|
return;
|
|
8485
8484
|
}
|
|
8486
|
-
await
|
|
8485
|
+
await handleLicensePolicy(orgSlug, outputKind);
|
|
8487
8486
|
}
|
|
8488
8487
|
|
|
8489
|
-
async function
|
|
8488
|
+
async function fetchSecurityPolicy(orgSlug) {
|
|
8490
8489
|
const sockSdkResult = await utils.setupSdk();
|
|
8491
8490
|
if (!sockSdkResult.ok) {
|
|
8492
8491
|
return sockSdkResult;
|
|
8493
8492
|
}
|
|
8494
8493
|
const sockSdk = sockSdkResult.data;
|
|
8495
|
-
return await utils.handleApiCall(sockSdk.
|
|
8494
|
+
return await utils.handleApiCall(sockSdk.getOrgSecurityPolicy(orgSlug), 'organization security policy');
|
|
8496
8495
|
}
|
|
8497
8496
|
|
|
8498
|
-
async function
|
|
8497
|
+
async function outputSecurityPolicy(result, outputKind) {
|
|
8499
8498
|
if (!result.ok) {
|
|
8500
8499
|
process.exitCode = result.code ?? 1;
|
|
8501
8500
|
}
|
|
@@ -8507,32 +8506,33 @@ async function outputLicensePolicy(result, outputKind) {
|
|
|
8507
8506
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8508
8507
|
return;
|
|
8509
8508
|
}
|
|
8510
|
-
logger.logger.
|
|
8511
|
-
logger.logger.log('# License policy');
|
|
8509
|
+
logger.logger.log('# Security policy');
|
|
8512
8510
|
logger.logger.log('');
|
|
8513
|
-
logger.logger.log(
|
|
8511
|
+
logger.logger.log(`The default security policy setting is: "${result.data.securityPolicyDefault}"`);
|
|
8514
8512
|
logger.logger.log('');
|
|
8515
|
-
|
|
8513
|
+
logger.logger.log('These are the security policies per setting for your organization:');
|
|
8514
|
+
logger.logger.log('');
|
|
8515
|
+
const rules = result.data.securityPolicyRules;
|
|
8516
8516
|
const entries = rules ? Object.entries(rules) : [];
|
|
8517
|
-
const mapped = entries.map(([key, value]) => [key, value
|
|
8517
|
+
const mapped = entries.map(([key, value]) => [key, value.action]);
|
|
8518
8518
|
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8519
|
-
logger.logger.log(utils.mdTableOfPairs(mapped, ['
|
|
8519
|
+
logger.logger.log(utils.mdTableOfPairs(mapped, ['name', 'action']));
|
|
8520
8520
|
logger.logger.log('');
|
|
8521
8521
|
}
|
|
8522
8522
|
|
|
8523
|
-
async function
|
|
8524
|
-
const data = await
|
|
8525
|
-
await
|
|
8523
|
+
async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
8524
|
+
const data = await fetchSecurityPolicy(orgSlug);
|
|
8525
|
+
await outputSecurityPolicy(data, outputKind);
|
|
8526
8526
|
}
|
|
8527
8527
|
|
|
8528
8528
|
const {
|
|
8529
8529
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$o
|
|
8530
8530
|
} = constants;
|
|
8531
8531
|
|
|
8532
|
-
// TODO: secret toplevel alias `socket
|
|
8532
|
+
// TODO: secret toplevel alias `socket security policy`?
|
|
8533
8533
|
const config$q = {
|
|
8534
|
-
commandName: '
|
|
8535
|
-
description: 'Retrieve the
|
|
8534
|
+
commandName: 'security',
|
|
8535
|
+
description: 'Retrieve the security policy of an organization',
|
|
8536
8536
|
hidden: true,
|
|
8537
8537
|
flags: {
|
|
8538
8538
|
...utils.commonFlags,
|
|
@@ -8553,12 +8553,12 @@ const config$q = {
|
|
|
8553
8553
|
|
|
8554
8554
|
API Token Requirements
|
|
8555
8555
|
- Quota: 1 unit
|
|
8556
|
-
- Permissions:
|
|
8556
|
+
- Permissions: security-policy:read
|
|
8557
8557
|
|
|
8558
8558
|
Options
|
|
8559
8559
|
${utils.getFlagListOutput(config$q.flags, 6)}
|
|
8560
8560
|
|
|
8561
|
-
Your API token will need the \`
|
|
8561
|
+
Your API token will need the \`security-policy:read\` permission otherwise
|
|
8562
8562
|
the request will fail with an authentication error.
|
|
8563
8563
|
|
|
8564
8564
|
Examples
|
|
@@ -8566,7 +8566,7 @@ const config$q = {
|
|
|
8566
8566
|
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'} --json
|
|
8567
8567
|
`
|
|
8568
8568
|
};
|
|
8569
|
-
const
|
|
8569
|
+
const cmdOrganizationPolicyPolicy = {
|
|
8570
8570
|
description: config$q.description,
|
|
8571
8571
|
hidden: config$q.hidden,
|
|
8572
8572
|
run: run$q
|
|
@@ -8593,7 +8593,7 @@ async function run$q(argv, importMeta, {
|
|
|
8593
8593
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8594
8594
|
nook: true,
|
|
8595
8595
|
test: !!orgSlug,
|
|
8596
|
-
message:
|
|
8596
|
+
message: 'Org name as the first argument',
|
|
8597
8597
|
pass: 'ok',
|
|
8598
8598
|
fail: 'missing'
|
|
8599
8599
|
}, {
|
|
@@ -8616,19 +8616,19 @@ async function run$q(argv, importMeta, {
|
|
|
8616
8616
|
logger.logger.log(DRY_RUN_BAILING_NOW$o);
|
|
8617
8617
|
return;
|
|
8618
8618
|
}
|
|
8619
|
-
await
|
|
8619
|
+
await handleSecurityPolicy(orgSlug, outputKind);
|
|
8620
8620
|
}
|
|
8621
8621
|
|
|
8622
|
-
async function
|
|
8622
|
+
async function fetchOrganization() {
|
|
8623
8623
|
const sockSdkResult = await utils.setupSdk();
|
|
8624
8624
|
if (!sockSdkResult.ok) {
|
|
8625
8625
|
return sockSdkResult;
|
|
8626
8626
|
}
|
|
8627
8627
|
const sockSdk = sockSdkResult.data;
|
|
8628
|
-
return await utils.handleApiCall(sockSdk.
|
|
8628
|
+
return await utils.handleApiCall(sockSdk.getOrganizations(), 'organization list');
|
|
8629
8629
|
}
|
|
8630
8630
|
|
|
8631
|
-
async function
|
|
8631
|
+
async function outputOrganizationList(result, outputKind = 'text') {
|
|
8632
8632
|
if (!result.ok) {
|
|
8633
8633
|
process.exitCode = result.code ?? 1;
|
|
8634
8634
|
}
|
|
@@ -8640,67 +8640,73 @@ async function outputSecurityPolicy(result, outputKind) {
|
|
|
8640
8640
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8641
8641
|
return;
|
|
8642
8642
|
}
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8643
|
+
const organizations = Object.values(result.data.organizations);
|
|
8644
|
+
const visibleTokenPrefix = utils.getVisibleTokenPrefix();
|
|
8645
|
+
switch (outputKind) {
|
|
8646
|
+
case 'markdown':
|
|
8647
|
+
{
|
|
8648
|
+
// | Syntax | Description |
|
|
8649
|
+
// | ----------- | ----------- |
|
|
8650
|
+
// | Header | Title |
|
|
8651
|
+
// | Paragraph | Text |
|
|
8652
|
+
let mw1 = 4;
|
|
8653
|
+
let mw2 = 2;
|
|
8654
|
+
let mw3 = 4;
|
|
8655
|
+
for (const o of organizations) {
|
|
8656
|
+
mw1 = Math.max(mw1, o.name?.length ?? 0);
|
|
8657
|
+
mw2 = Math.max(mw2, o.id.length);
|
|
8658
|
+
mw3 = Math.max(mw3, o.plan.length);
|
|
8659
|
+
}
|
|
8660
|
+
logger.logger.log('# Organizations\n');
|
|
8661
|
+
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8662
|
+
logger.logger.log(`| Name${' '.repeat(mw1 - 4)} | ID${' '.repeat(mw2 - 2)} | Plan${' '.repeat(mw3 - 4)} |`);
|
|
8663
|
+
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8664
|
+
for (const o of organizations) {
|
|
8665
|
+
logger.logger.log(`| ${(o.name || '').padEnd(mw1, ' ')} | ${(o.id || '').padEnd(mw2, ' ')} | ${(o.plan || '').padEnd(mw3, ' ')} |`);
|
|
8666
|
+
}
|
|
8667
|
+
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8668
|
+
return;
|
|
8669
|
+
}
|
|
8670
|
+
default:
|
|
8671
|
+
{
|
|
8672
|
+
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8673
|
+
// Just dump
|
|
8674
|
+
for (const o of organizations) {
|
|
8675
|
+
logger.logger.log(`- Name: ${vendor.yoctocolorsCjsExports.bold(o.name ?? 'undefined')}, ID: ${vendor.yoctocolorsCjsExports.bold(o.id)}, Plan: ${vendor.yoctocolorsCjsExports.bold(o.plan)}`);
|
|
8676
|
+
}
|
|
8677
|
+
}
|
|
8678
|
+
}
|
|
8655
8679
|
}
|
|
8656
8680
|
|
|
8657
|
-
async function
|
|
8658
|
-
const data = await
|
|
8659
|
-
await
|
|
8681
|
+
async function handleOrganizationList(outputKind = 'text') {
|
|
8682
|
+
const data = await fetchOrganization();
|
|
8683
|
+
await outputOrganizationList(data, outputKind);
|
|
8660
8684
|
}
|
|
8661
8685
|
|
|
8662
8686
|
const {
|
|
8663
8687
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$n
|
|
8664
8688
|
} = constants;
|
|
8665
|
-
|
|
8666
|
-
// TODO: secret toplevel alias `socket security policy`?
|
|
8667
8689
|
const config$p = {
|
|
8668
|
-
commandName: '
|
|
8669
|
-
description: '
|
|
8670
|
-
hidden:
|
|
8690
|
+
commandName: 'list',
|
|
8691
|
+
description: 'List organizations associated with the API key used',
|
|
8692
|
+
hidden: false,
|
|
8671
8693
|
flags: {
|
|
8672
8694
|
...utils.commonFlags,
|
|
8673
|
-
...utils.outputFlags
|
|
8674
|
-
interactive: {
|
|
8675
|
-
type: 'boolean',
|
|
8676
|
-
default: true,
|
|
8677
|
-
description: 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
8678
|
-
},
|
|
8679
|
-
org: {
|
|
8680
|
-
type: 'string',
|
|
8681
|
-
description: 'Force override the organization slug, overrides the default org from config'
|
|
8682
|
-
}
|
|
8695
|
+
...utils.outputFlags
|
|
8683
8696
|
},
|
|
8684
8697
|
help: (command, _config) => `
|
|
8685
8698
|
Usage
|
|
8686
|
-
$ ${command}
|
|
8699
|
+
$ ${command}
|
|
8687
8700
|
|
|
8688
8701
|
API Token Requirements
|
|
8689
8702
|
- Quota: 1 unit
|
|
8690
|
-
- Permissions:
|
|
8703
|
+
- Permissions: none (does need a token)
|
|
8691
8704
|
|
|
8692
8705
|
Options
|
|
8693
8706
|
${utils.getFlagListOutput(config$p.flags, 6)}
|
|
8694
|
-
|
|
8695
|
-
Your API token will need the \`security-policy:read\` permission otherwise
|
|
8696
|
-
the request will fail with an authentication error.
|
|
8697
|
-
|
|
8698
|
-
Examples
|
|
8699
|
-
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'}
|
|
8700
|
-
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'} --json
|
|
8701
8707
|
`
|
|
8702
8708
|
};
|
|
8703
|
-
const
|
|
8709
|
+
const cmdOrganizationList = {
|
|
8704
8710
|
description: config$p.description,
|
|
8705
8711
|
hidden: config$p.hidden,
|
|
8706
8712
|
run: run$p
|
|
@@ -8715,27 +8721,17 @@ async function run$p(argv, importMeta, {
|
|
|
8715
8721
|
parentName
|
|
8716
8722
|
});
|
|
8717
8723
|
const {
|
|
8718
|
-
dryRun,
|
|
8719
|
-
interactive,
|
|
8720
8724
|
json,
|
|
8721
|
-
markdown
|
|
8722
|
-
org: orgFlag
|
|
8725
|
+
markdown
|
|
8723
8726
|
} = cli.flags;
|
|
8724
8727
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
8725
|
-
const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', !!interactive, !!dryRun);
|
|
8726
8728
|
const hasApiToken = utils.hasDefaultToken();
|
|
8727
8729
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8728
|
-
nook: true,
|
|
8729
|
-
test: !!orgSlug,
|
|
8730
|
-
message: 'Org name as the first argument',
|
|
8731
|
-
pass: 'ok',
|
|
8732
|
-
fail: 'missing'
|
|
8733
|
-
}, {
|
|
8734
8730
|
nook: true,
|
|
8735
8731
|
test: !json || !markdown,
|
|
8736
|
-
message: 'The json and markdown flags
|
|
8732
|
+
message: 'The `--json` and `--markdown` flags can not be used at the same time',
|
|
8737
8733
|
pass: 'ok',
|
|
8738
|
-
fail: '
|
|
8734
|
+
fail: 'bad'
|
|
8739
8735
|
}, {
|
|
8740
8736
|
nook: true,
|
|
8741
8737
|
test: hasApiToken,
|
|
@@ -8750,7 +8746,7 @@ async function run$p(argv, importMeta, {
|
|
|
8750
8746
|
logger.logger.log(DRY_RUN_BAILING_NOW$n);
|
|
8751
8747
|
return;
|
|
8752
8748
|
}
|
|
8753
|
-
await
|
|
8749
|
+
await handleOrganizationList(outputKind);
|
|
8754
8750
|
}
|
|
8755
8751
|
|
|
8756
8752
|
const description$6 = 'Organization policy details';
|
|
@@ -8878,11 +8874,7 @@ async function run$o(argv, importMeta, {
|
|
|
8878
8874
|
const description$5 = 'Account details';
|
|
8879
8875
|
const cmdOrganization = {
|
|
8880
8876
|
description: description$5,
|
|
8881
|
-
|
|
8882
|
-
// and we're not sure if it's useful to anyone in its current state.
|
|
8883
|
-
// Until we do, we'll hide this to keep the help tidier.
|
|
8884
|
-
// And later, we may simply move this under `scan`, anyways.
|
|
8885
|
-
hidden: true,
|
|
8877
|
+
hidden: false,
|
|
8886
8878
|
async run(argv, importMeta, {
|
|
8887
8879
|
parentName
|
|
8888
8880
|
}) {
|
|
@@ -8891,6 +8883,18 @@ const cmdOrganization = {
|
|
|
8891
8883
|
quota: cmdOrganizationQuota,
|
|
8892
8884
|
policy: cmdOrganizationPolicy
|
|
8893
8885
|
}, {
|
|
8886
|
+
aliases: {
|
|
8887
|
+
license: {
|
|
8888
|
+
description: cmdOrganizationPolicyLicense.description,
|
|
8889
|
+
hidden: true,
|
|
8890
|
+
argv: ['policy', 'license']
|
|
8891
|
+
},
|
|
8892
|
+
security: {
|
|
8893
|
+
description: cmdOrganizationPolicyPolicy.description,
|
|
8894
|
+
hidden: true,
|
|
8895
|
+
argv: ['policy', 'security']
|
|
8896
|
+
}
|
|
8897
|
+
},
|
|
8894
8898
|
argv,
|
|
8895
8899
|
description: description$5,
|
|
8896
8900
|
defaultSub: 'list',
|
|
@@ -9121,7 +9125,7 @@ const {
|
|
|
9121
9125
|
} = constants;
|
|
9122
9126
|
const config$n = {
|
|
9123
9127
|
commandName: 'score',
|
|
9124
|
-
description: '
|
|
9128
|
+
description: 'Look up score for one package which reflects all of its transitive dependencies as well',
|
|
9125
9129
|
hidden: false,
|
|
9126
9130
|
flags: {
|
|
9127
9131
|
...utils.commonFlags,
|
|
@@ -9353,7 +9357,7 @@ const {
|
|
|
9353
9357
|
} = constants;
|
|
9354
9358
|
const config$m = {
|
|
9355
9359
|
commandName: 'shallow',
|
|
9356
|
-
description: '
|
|
9360
|
+
description: 'Look up info regarding one or more packages but not their transitives',
|
|
9357
9361
|
hidden: false,
|
|
9358
9362
|
flags: {
|
|
9359
9363
|
...utils.commonFlags,
|
|
@@ -13472,7 +13476,17 @@ const cmdScan = {
|
|
|
13472
13476
|
view: cmdScanView
|
|
13473
13477
|
}, {
|
|
13474
13478
|
aliases: {
|
|
13475
|
-
|
|
13479
|
+
meta: {
|
|
13480
|
+
description: cmdScanMetadata.description,
|
|
13481
|
+
hidden: true,
|
|
13482
|
+
argv: ['metadata']
|
|
13483
|
+
},
|
|
13484
|
+
reachability: {
|
|
13485
|
+
description: cmdScanReach.description,
|
|
13486
|
+
hidden: true,
|
|
13487
|
+
argv: ['reach']
|
|
13488
|
+
},
|
|
13489
|
+
// Backwards compat. TODO: Drop next major bump; isTestingV1
|
|
13476
13490
|
stream: {
|
|
13477
13491
|
description: cmdScanView.description,
|
|
13478
13492
|
hidden: true,
|
|
@@ -13896,7 +13910,7 @@ const config$1 = {
|
|
|
13896
13910
|
commandName: 'completion',
|
|
13897
13911
|
description: 'Uninstall bash completion for Socket CLI',
|
|
13898
13912
|
hidden: true,
|
|
13899
|
-
// beta
|
|
13913
|
+
// beta; isTestingV1
|
|
13900
13914
|
flags: {
|
|
13901
13915
|
...utils.commonFlags
|
|
13902
13916
|
},
|
|
@@ -13947,7 +13961,7 @@ const description = 'Teardown the Socket command from your environment';
|
|
|
13947
13961
|
const cmdUninstall = {
|
|
13948
13962
|
description,
|
|
13949
13963
|
hidden: true,
|
|
13950
|
-
// beta
|
|
13964
|
+
// beta; isTestingV1
|
|
13951
13965
|
async run(argv, importMeta, {
|
|
13952
13966
|
parentName
|
|
13953
13967
|
}) {
|
|
@@ -14247,7 +14261,83 @@ void (async () => {
|
|
|
14247
14261
|
manifest: cmdManifest,
|
|
14248
14262
|
uninstall: cmdUninstall
|
|
14249
14263
|
}, {
|
|
14250
|
-
aliases: {
|
|
14264
|
+
aliases: {
|
|
14265
|
+
audit: {
|
|
14266
|
+
description: cmdAuditLog.description,
|
|
14267
|
+
hidden: true,
|
|
14268
|
+
argv: ['audit-log']
|
|
14269
|
+
},
|
|
14270
|
+
auditLogs: {
|
|
14271
|
+
description: cmdAuditLog.description,
|
|
14272
|
+
hidden: true,
|
|
14273
|
+
argv: ['audit-log']
|
|
14274
|
+
},
|
|
14275
|
+
deps: {
|
|
14276
|
+
description: cmdScanCreate$1.description,
|
|
14277
|
+
hidden: true,
|
|
14278
|
+
argv: ['dependencies']
|
|
14279
|
+
},
|
|
14280
|
+
feed: {
|
|
14281
|
+
description: cmdThreatFeed.description,
|
|
14282
|
+
hidden: true,
|
|
14283
|
+
argv: ['threat-feed']
|
|
14284
|
+
},
|
|
14285
|
+
license: {
|
|
14286
|
+
description: cmdOrganizationPolicyLicense.description,
|
|
14287
|
+
hidden: true,
|
|
14288
|
+
argv: ['organization', 'policy', 'license']
|
|
14289
|
+
},
|
|
14290
|
+
org: {
|
|
14291
|
+
description: cmdOrganization.description,
|
|
14292
|
+
hidden: true,
|
|
14293
|
+
argv: ['organization']
|
|
14294
|
+
},
|
|
14295
|
+
orgs: {
|
|
14296
|
+
description: cmdOrganization.description,
|
|
14297
|
+
hidden: true,
|
|
14298
|
+
argv: ['organization']
|
|
14299
|
+
},
|
|
14300
|
+
organizations: {
|
|
14301
|
+
description: cmdOrganization.description,
|
|
14302
|
+
hidden: true,
|
|
14303
|
+
argv: ['organization']
|
|
14304
|
+
},
|
|
14305
|
+
organisation: {
|
|
14306
|
+
description: cmdOrganization.description,
|
|
14307
|
+
hidden: true,
|
|
14308
|
+
argv: ['organization']
|
|
14309
|
+
},
|
|
14310
|
+
organisations: {
|
|
14311
|
+
description: cmdOrganization.description,
|
|
14312
|
+
hidden: true,
|
|
14313
|
+
argv: ['organization']
|
|
14314
|
+
},
|
|
14315
|
+
pkg: {
|
|
14316
|
+
description: cmdPackage.description,
|
|
14317
|
+
hidden: true,
|
|
14318
|
+
argv: ['package']
|
|
14319
|
+
},
|
|
14320
|
+
repo: {
|
|
14321
|
+
description: cmdRepos.description,
|
|
14322
|
+
hidden: true,
|
|
14323
|
+
argv: ['repos']
|
|
14324
|
+
},
|
|
14325
|
+
repository: {
|
|
14326
|
+
description: cmdRepos.description,
|
|
14327
|
+
hidden: true,
|
|
14328
|
+
argv: ['repos']
|
|
14329
|
+
},
|
|
14330
|
+
repositories: {
|
|
14331
|
+
description: cmdRepos.description,
|
|
14332
|
+
hidden: true,
|
|
14333
|
+
argv: ['repos']
|
|
14334
|
+
},
|
|
14335
|
+
security: {
|
|
14336
|
+
description: cmdOrganizationPolicyPolicy.description,
|
|
14337
|
+
hidden: true,
|
|
14338
|
+
argv: ['organization', 'policy', 'security']
|
|
14339
|
+
}
|
|
14340
|
+
},
|
|
14251
14341
|
argv: process.argv.slice(2),
|
|
14252
14342
|
name: SOCKET_CLI_BIN_NAME,
|
|
14253
14343
|
importMeta: {
|
|
@@ -14282,5 +14372,5 @@ void (async () => {
|
|
|
14282
14372
|
await utils.captureException(e);
|
|
14283
14373
|
}
|
|
14284
14374
|
})();
|
|
14285
|
-
//# debugId=
|
|
14375
|
+
//# debugId=fc631456-d58c-4127-856d-214963966236
|
|
14286
14376
|
//# sourceMappingURL=cli.js.map
|