@socketsecurity/cli-with-sentry 0.15.52 → 0.15.54
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 +269 -171
- 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/npm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/commands/optimize/lockfile-includes-by-agent.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
|
}) {
|
|
@@ -4316,10 +4316,7 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4316
4316
|
isCi && repoInfo ? await getOpenSocketPrs(repoInfo.owner, repoInfo.repo, {
|
|
4317
4317
|
author: gitUser
|
|
4318
4318
|
}) : [];
|
|
4319
|
-
|
|
4320
|
-
debug.debugFn(`found: ${openPrs.length} open PRs`);
|
|
4321
|
-
}
|
|
4322
|
-
let count = isCi ? openPrs.length : 0;
|
|
4319
|
+
let count = 0;
|
|
4323
4320
|
const arb = new shadowInject.Arborist({
|
|
4324
4321
|
path: rootPath,
|
|
4325
4322
|
...shadowInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
@@ -4330,9 +4327,9 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4330
4327
|
let alertsMap;
|
|
4331
4328
|
try {
|
|
4332
4329
|
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertsMapOptions({
|
|
4333
|
-
limit: limit
|
|
4330
|
+
limit: Math.max(limit, openPrs.length)
|
|
4334
4331
|
})) : await shadowInject.getAlertsMapFromArborist(arb, getAlertsMapOptions({
|
|
4335
|
-
limit: limit
|
|
4332
|
+
limit: Math.max(limit, openPrs.length)
|
|
4336
4333
|
}));
|
|
4337
4334
|
} catch (e) {
|
|
4338
4335
|
spinner?.stop();
|
|
@@ -4344,7 +4341,7 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4344
4341
|
};
|
|
4345
4342
|
}
|
|
4346
4343
|
const infoByPartialPurl = utils.getCveInfoFromAlertsMap(alertsMap, {
|
|
4347
|
-
limit: limit
|
|
4344
|
+
limit: Math.max(limit, openPrs.length)
|
|
4348
4345
|
});
|
|
4349
4346
|
if (!infoByPartialPurl) {
|
|
4350
4347
|
spinner?.stop();
|
|
@@ -4381,11 +4378,14 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4381
4378
|
const infoEntry = sortedInfoEntries[i];
|
|
4382
4379
|
const partialPurlObj = utils.getPurlObject(infoEntry[0]);
|
|
4383
4380
|
const name = packages.resolvePackageName(partialPurlObj);
|
|
4384
|
-
|
|
4381
|
+
const infos = [...infoEntry[1].values()];
|
|
4382
|
+
if (!infos.length) {
|
|
4383
|
+
continue infoEntriesLoop;
|
|
4384
|
+
}
|
|
4385
|
+
const activeBranches = [];
|
|
4385
4386
|
if (isCi) {
|
|
4386
4387
|
const branchFullName = getSocketBranchFullNameComponent(partialPurlObj);
|
|
4387
4388
|
const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj);
|
|
4388
|
-
const activeBranches = [];
|
|
4389
4389
|
for (const pr of openPrs) {
|
|
4390
4390
|
const parsedBranch = branchParser(pr.headRefName);
|
|
4391
4391
|
if (branchPurlType === parsedBranch?.type && branchFullName === parsedBranch?.fullName) {
|
|
@@ -4397,10 +4397,6 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4397
4397
|
} else if (openPrs.length) {
|
|
4398
4398
|
debug.debugFn('miss: 0 active branches found');
|
|
4399
4399
|
}
|
|
4400
|
-
infos = infos.filter(info => !activeBranches.find(b => b.newVersion === info.firstPatchedVersionIdentifier));
|
|
4401
|
-
}
|
|
4402
|
-
if (!infos.length) {
|
|
4403
|
-
continue infoEntriesLoop;
|
|
4404
4400
|
}
|
|
4405
4401
|
logger.logger.log(`Processing vulns for ${name}:`);
|
|
4406
4402
|
logger.logger.indent();
|
|
@@ -4428,6 +4424,7 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4428
4424
|
const pkgPath = path.dirname(pkgJsonPath);
|
|
4429
4425
|
const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
|
|
4430
4426
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
4427
|
+
const branchWorkspace = isCi ? getSocketBranchWorkspaceComponent(workspace) : '';
|
|
4431
4428
|
const oldVersions = arrays.arrayUnique(shadowInject.findPackageNodes(actualTree, name).map(n => n.target?.version ?? n.version).filter(Boolean));
|
|
4432
4429
|
if (!oldVersions.length) {
|
|
4433
4430
|
debug.debugFn(`skip: ${name} not found\n`);
|
|
@@ -4467,6 +4464,15 @@ async function npmFix(pkgEnvDetails, {
|
|
|
4467
4464
|
continue infosLoop;
|
|
4468
4465
|
}
|
|
4469
4466
|
const newVersion = shadowInject.findBestPatchVersion(node, availableVersions, vulnerableVersionRange);
|
|
4467
|
+
if (activeBranches.find(b => b.workspace === branchWorkspace && b.newVersion === newVersion)) {
|
|
4468
|
+
debug.debugFn(`skip: open PR found for ${name}@${newVersion}`);
|
|
4469
|
+
if (++count >= limit) {
|
|
4470
|
+
logger.logger.dedent();
|
|
4471
|
+
spinner?.dedent();
|
|
4472
|
+
break infoEntriesLoop;
|
|
4473
|
+
}
|
|
4474
|
+
continue infosLoop;
|
|
4475
|
+
}
|
|
4470
4476
|
const newVersionPackument = newVersion ? packument.versions[newVersion] : undefined;
|
|
4471
4477
|
if (!(newVersion && newVersionPackument)) {
|
|
4472
4478
|
warningsForAfter.add(`${oldId} not updated: requires >=${firstPatchedVersionIdentifier}`);
|
|
@@ -4771,11 +4777,6 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4771
4777
|
isCi && repoInfo ? await getOpenSocketPrs(repoInfo.owner, repoInfo.repo, {
|
|
4772
4778
|
author: gitUser
|
|
4773
4779
|
}) : [];
|
|
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
4780
|
let count = 0;
|
|
4780
4781
|
let actualTree;
|
|
4781
4782
|
const lockfilePath = path.join(rootPath, 'pnpm-lock.yaml');
|
|
@@ -4825,9 +4826,9 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4825
4826
|
let alertsMap;
|
|
4826
4827
|
try {
|
|
4827
4828
|
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertsMapOptions({
|
|
4828
|
-
limit: limit
|
|
4829
|
+
limit: Math.max(limit, openPrs.length)
|
|
4829
4830
|
})) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getAlertsMapOptions({
|
|
4830
|
-
limit: limit
|
|
4831
|
+
limit: Math.max(limit, openPrs.length)
|
|
4831
4832
|
}));
|
|
4832
4833
|
} catch (e) {
|
|
4833
4834
|
spinner?.stop();
|
|
@@ -4839,7 +4840,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4839
4840
|
};
|
|
4840
4841
|
}
|
|
4841
4842
|
const infoByPartialPurl = utils.getCveInfoFromAlertsMap(alertsMap, {
|
|
4842
|
-
limit: limit
|
|
4843
|
+
limit: Math.max(limit, openPrs.length)
|
|
4843
4844
|
});
|
|
4844
4845
|
if (!infoByPartialPurl) {
|
|
4845
4846
|
spinner?.stop();
|
|
@@ -4921,6 +4922,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4921
4922
|
const pkgPath = path.dirname(pkgJsonPath);
|
|
4922
4923
|
const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
|
|
4923
4924
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
4925
|
+
const branchWorkspace = isCi ? getSocketBranchWorkspaceComponent(workspace) : '';
|
|
4924
4926
|
|
|
4925
4927
|
// actualTree may not be defined on the first iteration of pkgJsonPathsLoop.
|
|
4926
4928
|
if (!actualTree) {
|
|
@@ -4990,7 +4992,7 @@ async function pnpmFix(pkgEnvDetails, {
|
|
|
4990
4992
|
continue infosLoop;
|
|
4991
4993
|
}
|
|
4992
4994
|
const newVersion = shadowInject.findBestPatchVersion(node, availableVersions, vulnerableVersionRange);
|
|
4993
|
-
if (activeBranches.find(b => b.newVersion === newVersion)) {
|
|
4995
|
+
if (activeBranches.find(b => b.workspace === branchWorkspace && b.newVersion === newVersion)) {
|
|
4994
4996
|
debug.debugFn(`skip: open PR found for ${name}@${newVersion}`);
|
|
4995
4997
|
if (++count >= limit) {
|
|
4996
4998
|
logger.logger.dedent();
|
|
@@ -5873,7 +5875,7 @@ const config$F = {
|
|
|
5873
5875
|
commandName: 'completion',
|
|
5874
5876
|
description: 'Install bash completion for Socket CLI',
|
|
5875
5877
|
hidden: true,
|
|
5876
|
-
// beta
|
|
5878
|
+
// beta; isTestingV1
|
|
5877
5879
|
flags: {
|
|
5878
5880
|
...utils.commonFlags
|
|
5879
5881
|
},
|
|
@@ -5932,7 +5934,7 @@ const description$7 = 'Setup the Socket CLI command in your environment';
|
|
|
5932
5934
|
const cmdInstall = {
|
|
5933
5935
|
description: description$7,
|
|
5934
5936
|
hidden: true,
|
|
5935
|
-
// beta
|
|
5937
|
+
// beta; isTestingV1
|
|
5936
5938
|
async run(argv, importMeta, {
|
|
5937
5939
|
parentName
|
|
5938
5940
|
}) {
|
|
@@ -7680,12 +7682,14 @@ function includesBun(lockSrc, name, lockName) {
|
|
|
7680
7682
|
function includesPnpm(lockSrc, name) {
|
|
7681
7683
|
const escapedName = regexps.escapeRegExp(name);
|
|
7682
7684
|
return new RegExp(
|
|
7683
|
-
// Detects the package name
|
|
7684
|
-
//
|
|
7685
|
+
// Detects the package name.
|
|
7686
|
+
// v9.0 and v6.0 lockfile patterns:
|
|
7685
7687
|
// 'name'
|
|
7686
7688
|
// name:
|
|
7687
7689
|
// name@
|
|
7688
|
-
|
|
7690
|
+
// v6.0 lockfile patterns:
|
|
7691
|
+
// /name@
|
|
7692
|
+
`(?<=^\\s*)(?:'${escapedName}'|/?${escapedName}(?=[:@]))`, 'm').test(lockSrc);
|
|
7689
7693
|
}
|
|
7690
7694
|
function includesVlt(lockSrc, name) {
|
|
7691
7695
|
// Detects the package name in the following cases:
|
|
@@ -8356,16 +8360,16 @@ async function run$s(argv, importMeta, {
|
|
|
8356
8360
|
});
|
|
8357
8361
|
}
|
|
8358
8362
|
|
|
8359
|
-
async function
|
|
8363
|
+
async function fetchLicensePolicy(orgSlug) {
|
|
8360
8364
|
const sockSdkResult = await utils.setupSdk();
|
|
8361
8365
|
if (!sockSdkResult.ok) {
|
|
8362
8366
|
return sockSdkResult;
|
|
8363
8367
|
}
|
|
8364
8368
|
const sockSdk = sockSdkResult.data;
|
|
8365
|
-
return await utils.handleApiCall(sockSdk.
|
|
8369
|
+
return await utils.handleApiCall(sockSdk.getOrgLicensePolicy(orgSlug), 'organization license policy');
|
|
8366
8370
|
}
|
|
8367
8371
|
|
|
8368
|
-
async function
|
|
8372
|
+
async function outputLicensePolicy(result, outputKind) {
|
|
8369
8373
|
if (!result.ok) {
|
|
8370
8374
|
process.exitCode = result.code ?? 1;
|
|
8371
8375
|
}
|
|
@@ -8377,73 +8381,66 @@ async function outputOrganizationList(result, outputKind = 'text') {
|
|
|
8377
8381
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8378
8382
|
return;
|
|
8379
8383
|
}
|
|
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
|
-
}
|
|
8384
|
+
logger.logger.info('Use --json to get the full result');
|
|
8385
|
+
logger.logger.log('# License policy');
|
|
8386
|
+
logger.logger.log('');
|
|
8387
|
+
logger.logger.log('This is the license policy for your organization:');
|
|
8388
|
+
logger.logger.log('');
|
|
8389
|
+
const rules = result.data['license_policy'];
|
|
8390
|
+
const entries = rules ? Object.entries(rules) : [];
|
|
8391
|
+
const mapped = entries.map(([key, value]) => [key, value?.['allowed'] ? ' yes' : ' no']);
|
|
8392
|
+
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8393
|
+
logger.logger.log(utils.mdTableOfPairs(mapped, ['License Name', 'Allowed']));
|
|
8394
|
+
logger.logger.log('');
|
|
8416
8395
|
}
|
|
8417
8396
|
|
|
8418
|
-
async function
|
|
8419
|
-
const data = await
|
|
8420
|
-
await
|
|
8397
|
+
async function handleLicensePolicy(orgSlug, outputKind) {
|
|
8398
|
+
const data = await fetchLicensePolicy(orgSlug);
|
|
8399
|
+
await outputLicensePolicy(data, outputKind);
|
|
8421
8400
|
}
|
|
8422
8401
|
|
|
8423
8402
|
const {
|
|
8424
8403
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$p
|
|
8425
8404
|
} = constants;
|
|
8405
|
+
|
|
8406
|
+
// TODO: secret toplevel alias `socket license policy`?
|
|
8426
8407
|
const config$r = {
|
|
8427
|
-
commandName: '
|
|
8428
|
-
description: '
|
|
8429
|
-
hidden:
|
|
8408
|
+
commandName: 'license',
|
|
8409
|
+
description: 'Retrieve the license policy of an organization',
|
|
8410
|
+
hidden: true,
|
|
8430
8411
|
flags: {
|
|
8431
8412
|
...utils.commonFlags,
|
|
8432
|
-
...utils.outputFlags
|
|
8413
|
+
...utils.outputFlags,
|
|
8414
|
+
interactive: {
|
|
8415
|
+
type: 'boolean',
|
|
8416
|
+
default: true,
|
|
8417
|
+
description: 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
|
|
8418
|
+
},
|
|
8419
|
+
org: {
|
|
8420
|
+
type: 'string',
|
|
8421
|
+
description: 'Force override the organization slug, overrides the default org from config'
|
|
8422
|
+
}
|
|
8433
8423
|
},
|
|
8434
8424
|
help: (command, _config) => `
|
|
8435
8425
|
Usage
|
|
8436
|
-
$ ${command}
|
|
8426
|
+
$ ${command}${utils.isTestingV1() ? '' : ' <org slug>'}
|
|
8437
8427
|
|
|
8438
8428
|
API Token Requirements
|
|
8439
8429
|
- Quota: 1 unit
|
|
8440
|
-
- Permissions:
|
|
8430
|
+
- Permissions: license-policy:read
|
|
8441
8431
|
|
|
8442
8432
|
Options
|
|
8443
8433
|
${utils.getFlagListOutput(config$r.flags, 6)}
|
|
8434
|
+
|
|
8435
|
+
Your API token will need the \`license-policy:read\` permission otherwise
|
|
8436
|
+
the request will fail with an authentication error.
|
|
8437
|
+
|
|
8438
|
+
Examples
|
|
8439
|
+
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'}
|
|
8440
|
+
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'} --json
|
|
8444
8441
|
`
|
|
8445
8442
|
};
|
|
8446
|
-
const
|
|
8443
|
+
const cmdOrganizationPolicyLicense = {
|
|
8447
8444
|
description: config$r.description,
|
|
8448
8445
|
hidden: config$r.hidden,
|
|
8449
8446
|
run: run$r
|
|
@@ -8458,17 +8455,27 @@ async function run$r(argv, importMeta, {
|
|
|
8458
8455
|
parentName
|
|
8459
8456
|
});
|
|
8460
8457
|
const {
|
|
8458
|
+
dryRun,
|
|
8459
|
+
interactive,
|
|
8461
8460
|
json,
|
|
8462
|
-
markdown
|
|
8461
|
+
markdown,
|
|
8462
|
+
org: orgFlag
|
|
8463
8463
|
} = cli.flags;
|
|
8464
8464
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
8465
|
+
const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', !!interactive, !!dryRun);
|
|
8465
8466
|
const hasApiToken = utils.hasDefaultToken();
|
|
8466
8467
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8468
|
+
nook: true,
|
|
8469
|
+
test: !!orgSlug,
|
|
8470
|
+
message: utils.isTestingV1() ? 'Org name by default setting, --org, or auto-discovered' : 'Org name must be the first argument',
|
|
8471
|
+
pass: 'ok',
|
|
8472
|
+
fail: 'missing'
|
|
8473
|
+
}, {
|
|
8467
8474
|
nook: true,
|
|
8468
8475
|
test: !json || !markdown,
|
|
8469
|
-
message: 'The
|
|
8476
|
+
message: 'The json and markdown flags cannot be both set, pick one',
|
|
8470
8477
|
pass: 'ok',
|
|
8471
|
-
fail: '
|
|
8478
|
+
fail: 'omit one'
|
|
8472
8479
|
}, {
|
|
8473
8480
|
nook: true,
|
|
8474
8481
|
test: hasApiToken,
|
|
@@ -8483,19 +8490,19 @@ async function run$r(argv, importMeta, {
|
|
|
8483
8490
|
logger.logger.log(DRY_RUN_BAILING_NOW$p);
|
|
8484
8491
|
return;
|
|
8485
8492
|
}
|
|
8486
|
-
await
|
|
8493
|
+
await handleLicensePolicy(orgSlug, outputKind);
|
|
8487
8494
|
}
|
|
8488
8495
|
|
|
8489
|
-
async function
|
|
8496
|
+
async function fetchSecurityPolicy(orgSlug) {
|
|
8490
8497
|
const sockSdkResult = await utils.setupSdk();
|
|
8491
8498
|
if (!sockSdkResult.ok) {
|
|
8492
8499
|
return sockSdkResult;
|
|
8493
8500
|
}
|
|
8494
8501
|
const sockSdk = sockSdkResult.data;
|
|
8495
|
-
return await utils.handleApiCall(sockSdk.
|
|
8502
|
+
return await utils.handleApiCall(sockSdk.getOrgSecurityPolicy(orgSlug), 'organization security policy');
|
|
8496
8503
|
}
|
|
8497
8504
|
|
|
8498
|
-
async function
|
|
8505
|
+
async function outputSecurityPolicy(result, outputKind) {
|
|
8499
8506
|
if (!result.ok) {
|
|
8500
8507
|
process.exitCode = result.code ?? 1;
|
|
8501
8508
|
}
|
|
@@ -8507,32 +8514,33 @@ async function outputLicensePolicy(result, outputKind) {
|
|
|
8507
8514
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8508
8515
|
return;
|
|
8509
8516
|
}
|
|
8510
|
-
logger.logger.
|
|
8511
|
-
logger.logger.log('# License policy');
|
|
8517
|
+
logger.logger.log('# Security policy');
|
|
8512
8518
|
logger.logger.log('');
|
|
8513
|
-
logger.logger.log(
|
|
8519
|
+
logger.logger.log(`The default security policy setting is: "${result.data.securityPolicyDefault}"`);
|
|
8514
8520
|
logger.logger.log('');
|
|
8515
|
-
|
|
8521
|
+
logger.logger.log('These are the security policies per setting for your organization:');
|
|
8522
|
+
logger.logger.log('');
|
|
8523
|
+
const rules = result.data.securityPolicyRules;
|
|
8516
8524
|
const entries = rules ? Object.entries(rules) : [];
|
|
8517
|
-
const mapped = entries.map(([key, value]) => [key, value
|
|
8525
|
+
const mapped = entries.map(([key, value]) => [key, value.action]);
|
|
8518
8526
|
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8519
|
-
logger.logger.log(utils.mdTableOfPairs(mapped, ['
|
|
8527
|
+
logger.logger.log(utils.mdTableOfPairs(mapped, ['name', 'action']));
|
|
8520
8528
|
logger.logger.log('');
|
|
8521
8529
|
}
|
|
8522
8530
|
|
|
8523
|
-
async function
|
|
8524
|
-
const data = await
|
|
8525
|
-
await
|
|
8531
|
+
async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
8532
|
+
const data = await fetchSecurityPolicy(orgSlug);
|
|
8533
|
+
await outputSecurityPolicy(data, outputKind);
|
|
8526
8534
|
}
|
|
8527
8535
|
|
|
8528
8536
|
const {
|
|
8529
8537
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$o
|
|
8530
8538
|
} = constants;
|
|
8531
8539
|
|
|
8532
|
-
// TODO: secret toplevel alias `socket
|
|
8540
|
+
// TODO: secret toplevel alias `socket security policy`?
|
|
8533
8541
|
const config$q = {
|
|
8534
|
-
commandName: '
|
|
8535
|
-
description: 'Retrieve the
|
|
8542
|
+
commandName: 'security',
|
|
8543
|
+
description: 'Retrieve the security policy of an organization',
|
|
8536
8544
|
hidden: true,
|
|
8537
8545
|
flags: {
|
|
8538
8546
|
...utils.commonFlags,
|
|
@@ -8553,12 +8561,12 @@ const config$q = {
|
|
|
8553
8561
|
|
|
8554
8562
|
API Token Requirements
|
|
8555
8563
|
- Quota: 1 unit
|
|
8556
|
-
- Permissions:
|
|
8564
|
+
- Permissions: security-policy:read
|
|
8557
8565
|
|
|
8558
8566
|
Options
|
|
8559
8567
|
${utils.getFlagListOutput(config$q.flags, 6)}
|
|
8560
8568
|
|
|
8561
|
-
Your API token will need the \`
|
|
8569
|
+
Your API token will need the \`security-policy:read\` permission otherwise
|
|
8562
8570
|
the request will fail with an authentication error.
|
|
8563
8571
|
|
|
8564
8572
|
Examples
|
|
@@ -8566,7 +8574,7 @@ const config$q = {
|
|
|
8566
8574
|
$ ${command}${utils.isTestingV1() ? '' : ' mycorp'} --json
|
|
8567
8575
|
`
|
|
8568
8576
|
};
|
|
8569
|
-
const
|
|
8577
|
+
const cmdOrganizationPolicyPolicy = {
|
|
8570
8578
|
description: config$q.description,
|
|
8571
8579
|
hidden: config$q.hidden,
|
|
8572
8580
|
run: run$q
|
|
@@ -8593,7 +8601,7 @@ async function run$q(argv, importMeta, {
|
|
|
8593
8601
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
8594
8602
|
nook: true,
|
|
8595
8603
|
test: !!orgSlug,
|
|
8596
|
-
message:
|
|
8604
|
+
message: 'Org name as the first argument',
|
|
8597
8605
|
pass: 'ok',
|
|
8598
8606
|
fail: 'missing'
|
|
8599
8607
|
}, {
|
|
@@ -8616,19 +8624,19 @@ async function run$q(argv, importMeta, {
|
|
|
8616
8624
|
logger.logger.log(DRY_RUN_BAILING_NOW$o);
|
|
8617
8625
|
return;
|
|
8618
8626
|
}
|
|
8619
|
-
await
|
|
8627
|
+
await handleSecurityPolicy(orgSlug, outputKind);
|
|
8620
8628
|
}
|
|
8621
8629
|
|
|
8622
|
-
async function
|
|
8630
|
+
async function fetchOrganization() {
|
|
8623
8631
|
const sockSdkResult = await utils.setupSdk();
|
|
8624
8632
|
if (!sockSdkResult.ok) {
|
|
8625
8633
|
return sockSdkResult;
|
|
8626
8634
|
}
|
|
8627
8635
|
const sockSdk = sockSdkResult.data;
|
|
8628
|
-
return await utils.handleApiCall(sockSdk.
|
|
8636
|
+
return await utils.handleApiCall(sockSdk.getOrganizations(), 'organization list');
|
|
8629
8637
|
}
|
|
8630
8638
|
|
|
8631
|
-
async function
|
|
8639
|
+
async function outputOrganizationList(result, outputKind = 'text') {
|
|
8632
8640
|
if (!result.ok) {
|
|
8633
8641
|
process.exitCode = result.code ?? 1;
|
|
8634
8642
|
}
|
|
@@ -8640,67 +8648,73 @@ async function outputSecurityPolicy(result, outputKind) {
|
|
|
8640
8648
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
8641
8649
|
return;
|
|
8642
8650
|
}
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8651
|
+
const organizations = Object.values(result.data.organizations);
|
|
8652
|
+
const visibleTokenPrefix = utils.getVisibleTokenPrefix();
|
|
8653
|
+
switch (outputKind) {
|
|
8654
|
+
case 'markdown':
|
|
8655
|
+
{
|
|
8656
|
+
// | Syntax | Description |
|
|
8657
|
+
// | ----------- | ----------- |
|
|
8658
|
+
// | Header | Title |
|
|
8659
|
+
// | Paragraph | Text |
|
|
8660
|
+
let mw1 = 4;
|
|
8661
|
+
let mw2 = 2;
|
|
8662
|
+
let mw3 = 4;
|
|
8663
|
+
for (const o of organizations) {
|
|
8664
|
+
mw1 = Math.max(mw1, o.name?.length ?? 0);
|
|
8665
|
+
mw2 = Math.max(mw2, o.id.length);
|
|
8666
|
+
mw3 = Math.max(mw3, o.plan.length);
|
|
8667
|
+
}
|
|
8668
|
+
logger.logger.log('# Organizations\n');
|
|
8669
|
+
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8670
|
+
logger.logger.log(`| Name${' '.repeat(mw1 - 4)} | ID${' '.repeat(mw2 - 2)} | Plan${' '.repeat(mw3 - 4)} |`);
|
|
8671
|
+
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8672
|
+
for (const o of organizations) {
|
|
8673
|
+
logger.logger.log(`| ${(o.name || '').padEnd(mw1, ' ')} | ${(o.id || '').padEnd(mw2, ' ')} | ${(o.plan || '').padEnd(mw3, ' ')} |`);
|
|
8674
|
+
}
|
|
8675
|
+
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8676
|
+
return;
|
|
8677
|
+
}
|
|
8678
|
+
default:
|
|
8679
|
+
{
|
|
8680
|
+
logger.logger.log(`List of organizations associated with your API key, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8681
|
+
// Just dump
|
|
8682
|
+
for (const o of organizations) {
|
|
8683
|
+
logger.logger.log(`- Name: ${vendor.yoctocolorsCjsExports.bold(o.name ?? 'undefined')}, ID: ${vendor.yoctocolorsCjsExports.bold(o.id)}, Plan: ${vendor.yoctocolorsCjsExports.bold(o.plan)}`);
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8686
|
+
}
|
|
8655
8687
|
}
|
|
8656
8688
|
|
|
8657
|
-
async function
|
|
8658
|
-
const data = await
|
|
8659
|
-
await
|
|
8689
|
+
async function handleOrganizationList(outputKind = 'text') {
|
|
8690
|
+
const data = await fetchOrganization();
|
|
8691
|
+
await outputOrganizationList(data, outputKind);
|
|
8660
8692
|
}
|
|
8661
8693
|
|
|
8662
8694
|
const {
|
|
8663
8695
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$n
|
|
8664
8696
|
} = constants;
|
|
8665
|
-
|
|
8666
|
-
// TODO: secret toplevel alias `socket security policy`?
|
|
8667
8697
|
const config$p = {
|
|
8668
|
-
commandName: '
|
|
8669
|
-
description: '
|
|
8670
|
-
hidden:
|
|
8698
|
+
commandName: 'list',
|
|
8699
|
+
description: 'List organizations associated with the API key used',
|
|
8700
|
+
hidden: false,
|
|
8671
8701
|
flags: {
|
|
8672
8702
|
...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
|
-
}
|
|
8703
|
+
...utils.outputFlags
|
|
8683
8704
|
},
|
|
8684
8705
|
help: (command, _config) => `
|
|
8685
8706
|
Usage
|
|
8686
|
-
$ ${command}
|
|
8707
|
+
$ ${command}
|
|
8687
8708
|
|
|
8688
8709
|
API Token Requirements
|
|
8689
8710
|
- Quota: 1 unit
|
|
8690
|
-
- Permissions:
|
|
8711
|
+
- Permissions: none (does need a token)
|
|
8691
8712
|
|
|
8692
8713
|
Options
|
|
8693
8714
|
${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
8715
|
`
|
|
8702
8716
|
};
|
|
8703
|
-
const
|
|
8717
|
+
const cmdOrganizationList = {
|
|
8704
8718
|
description: config$p.description,
|
|
8705
8719
|
hidden: config$p.hidden,
|
|
8706
8720
|
run: run$p
|
|
@@ -8715,27 +8729,17 @@ async function run$p(argv, importMeta, {
|
|
|
8715
8729
|
parentName
|
|
8716
8730
|
});
|
|
8717
8731
|
const {
|
|
8718
|
-
dryRun,
|
|
8719
|
-
interactive,
|
|
8720
8732
|
json,
|
|
8721
|
-
markdown
|
|
8722
|
-
org: orgFlag
|
|
8733
|
+
markdown
|
|
8723
8734
|
} = cli.flags;
|
|
8724
8735
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
8725
|
-
const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', !!interactive, !!dryRun);
|
|
8726
8736
|
const hasApiToken = utils.hasDefaultToken();
|
|
8727
8737
|
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
8738
|
nook: true,
|
|
8735
8739
|
test: !json || !markdown,
|
|
8736
|
-
message: 'The json and markdown flags
|
|
8740
|
+
message: 'The `--json` and `--markdown` flags can not be used at the same time',
|
|
8737
8741
|
pass: 'ok',
|
|
8738
|
-
fail: '
|
|
8742
|
+
fail: 'bad'
|
|
8739
8743
|
}, {
|
|
8740
8744
|
nook: true,
|
|
8741
8745
|
test: hasApiToken,
|
|
@@ -8750,7 +8754,7 @@ async function run$p(argv, importMeta, {
|
|
|
8750
8754
|
logger.logger.log(DRY_RUN_BAILING_NOW$n);
|
|
8751
8755
|
return;
|
|
8752
8756
|
}
|
|
8753
|
-
await
|
|
8757
|
+
await handleOrganizationList(outputKind);
|
|
8754
8758
|
}
|
|
8755
8759
|
|
|
8756
8760
|
const description$6 = 'Organization policy details';
|
|
@@ -8878,11 +8882,7 @@ async function run$o(argv, importMeta, {
|
|
|
8878
8882
|
const description$5 = 'Account details';
|
|
8879
8883
|
const cmdOrganization = {
|
|
8880
8884
|
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,
|
|
8885
|
+
hidden: false,
|
|
8886
8886
|
async run(argv, importMeta, {
|
|
8887
8887
|
parentName
|
|
8888
8888
|
}) {
|
|
@@ -8891,6 +8891,18 @@ const cmdOrganization = {
|
|
|
8891
8891
|
quota: cmdOrganizationQuota,
|
|
8892
8892
|
policy: cmdOrganizationPolicy
|
|
8893
8893
|
}, {
|
|
8894
|
+
aliases: {
|
|
8895
|
+
license: {
|
|
8896
|
+
description: cmdOrganizationPolicyLicense.description,
|
|
8897
|
+
hidden: true,
|
|
8898
|
+
argv: ['policy', 'license']
|
|
8899
|
+
},
|
|
8900
|
+
security: {
|
|
8901
|
+
description: cmdOrganizationPolicyPolicy.description,
|
|
8902
|
+
hidden: true,
|
|
8903
|
+
argv: ['policy', 'security']
|
|
8904
|
+
}
|
|
8905
|
+
},
|
|
8894
8906
|
argv,
|
|
8895
8907
|
description: description$5,
|
|
8896
8908
|
defaultSub: 'list',
|
|
@@ -9121,7 +9133,7 @@ const {
|
|
|
9121
9133
|
} = constants;
|
|
9122
9134
|
const config$n = {
|
|
9123
9135
|
commandName: 'score',
|
|
9124
|
-
description: '
|
|
9136
|
+
description: 'Look up score for one package which reflects all of its transitive dependencies as well',
|
|
9125
9137
|
hidden: false,
|
|
9126
9138
|
flags: {
|
|
9127
9139
|
...utils.commonFlags,
|
|
@@ -9353,7 +9365,7 @@ const {
|
|
|
9353
9365
|
} = constants;
|
|
9354
9366
|
const config$m = {
|
|
9355
9367
|
commandName: 'shallow',
|
|
9356
|
-
description: '
|
|
9368
|
+
description: 'Look up info regarding one or more packages but not their transitives',
|
|
9357
9369
|
hidden: false,
|
|
9358
9370
|
flags: {
|
|
9359
9371
|
...utils.commonFlags,
|
|
@@ -13472,7 +13484,17 @@ const cmdScan = {
|
|
|
13472
13484
|
view: cmdScanView
|
|
13473
13485
|
}, {
|
|
13474
13486
|
aliases: {
|
|
13475
|
-
|
|
13487
|
+
meta: {
|
|
13488
|
+
description: cmdScanMetadata.description,
|
|
13489
|
+
hidden: true,
|
|
13490
|
+
argv: ['metadata']
|
|
13491
|
+
},
|
|
13492
|
+
reachability: {
|
|
13493
|
+
description: cmdScanReach.description,
|
|
13494
|
+
hidden: true,
|
|
13495
|
+
argv: ['reach']
|
|
13496
|
+
},
|
|
13497
|
+
// Backwards compat. TODO: Drop next major bump; isTestingV1
|
|
13476
13498
|
stream: {
|
|
13477
13499
|
description: cmdScanView.description,
|
|
13478
13500
|
hidden: true,
|
|
@@ -13896,7 +13918,7 @@ const config$1 = {
|
|
|
13896
13918
|
commandName: 'completion',
|
|
13897
13919
|
description: 'Uninstall bash completion for Socket CLI',
|
|
13898
13920
|
hidden: true,
|
|
13899
|
-
// beta
|
|
13921
|
+
// beta; isTestingV1
|
|
13900
13922
|
flags: {
|
|
13901
13923
|
...utils.commonFlags
|
|
13902
13924
|
},
|
|
@@ -13947,7 +13969,7 @@ const description = 'Teardown the Socket command from your environment';
|
|
|
13947
13969
|
const cmdUninstall = {
|
|
13948
13970
|
description,
|
|
13949
13971
|
hidden: true,
|
|
13950
|
-
// beta
|
|
13972
|
+
// beta; isTestingV1
|
|
13951
13973
|
async run(argv, importMeta, {
|
|
13952
13974
|
parentName
|
|
13953
13975
|
}) {
|
|
@@ -14247,7 +14269,83 @@ void (async () => {
|
|
|
14247
14269
|
manifest: cmdManifest,
|
|
14248
14270
|
uninstall: cmdUninstall
|
|
14249
14271
|
}, {
|
|
14250
|
-
aliases: {
|
|
14272
|
+
aliases: {
|
|
14273
|
+
audit: {
|
|
14274
|
+
description: cmdAuditLog.description,
|
|
14275
|
+
hidden: true,
|
|
14276
|
+
argv: ['audit-log']
|
|
14277
|
+
},
|
|
14278
|
+
auditLogs: {
|
|
14279
|
+
description: cmdAuditLog.description,
|
|
14280
|
+
hidden: true,
|
|
14281
|
+
argv: ['audit-log']
|
|
14282
|
+
},
|
|
14283
|
+
deps: {
|
|
14284
|
+
description: cmdScanCreate$1.description,
|
|
14285
|
+
hidden: true,
|
|
14286
|
+
argv: ['dependencies']
|
|
14287
|
+
},
|
|
14288
|
+
feed: {
|
|
14289
|
+
description: cmdThreatFeed.description,
|
|
14290
|
+
hidden: true,
|
|
14291
|
+
argv: ['threat-feed']
|
|
14292
|
+
},
|
|
14293
|
+
license: {
|
|
14294
|
+
description: cmdOrganizationPolicyLicense.description,
|
|
14295
|
+
hidden: true,
|
|
14296
|
+
argv: ['organization', 'policy', 'license']
|
|
14297
|
+
},
|
|
14298
|
+
org: {
|
|
14299
|
+
description: cmdOrganization.description,
|
|
14300
|
+
hidden: true,
|
|
14301
|
+
argv: ['organization']
|
|
14302
|
+
},
|
|
14303
|
+
orgs: {
|
|
14304
|
+
description: cmdOrganization.description,
|
|
14305
|
+
hidden: true,
|
|
14306
|
+
argv: ['organization']
|
|
14307
|
+
},
|
|
14308
|
+
organizations: {
|
|
14309
|
+
description: cmdOrganization.description,
|
|
14310
|
+
hidden: true,
|
|
14311
|
+
argv: ['organization']
|
|
14312
|
+
},
|
|
14313
|
+
organisation: {
|
|
14314
|
+
description: cmdOrganization.description,
|
|
14315
|
+
hidden: true,
|
|
14316
|
+
argv: ['organization']
|
|
14317
|
+
},
|
|
14318
|
+
organisations: {
|
|
14319
|
+
description: cmdOrganization.description,
|
|
14320
|
+
hidden: true,
|
|
14321
|
+
argv: ['organization']
|
|
14322
|
+
},
|
|
14323
|
+
pkg: {
|
|
14324
|
+
description: cmdPackage.description,
|
|
14325
|
+
hidden: true,
|
|
14326
|
+
argv: ['package']
|
|
14327
|
+
},
|
|
14328
|
+
repo: {
|
|
14329
|
+
description: cmdRepos.description,
|
|
14330
|
+
hidden: true,
|
|
14331
|
+
argv: ['repos']
|
|
14332
|
+
},
|
|
14333
|
+
repository: {
|
|
14334
|
+
description: cmdRepos.description,
|
|
14335
|
+
hidden: true,
|
|
14336
|
+
argv: ['repos']
|
|
14337
|
+
},
|
|
14338
|
+
repositories: {
|
|
14339
|
+
description: cmdRepos.description,
|
|
14340
|
+
hidden: true,
|
|
14341
|
+
argv: ['repos']
|
|
14342
|
+
},
|
|
14343
|
+
security: {
|
|
14344
|
+
description: cmdOrganizationPolicyPolicy.description,
|
|
14345
|
+
hidden: true,
|
|
14346
|
+
argv: ['organization', 'policy', 'security']
|
|
14347
|
+
}
|
|
14348
|
+
},
|
|
14251
14349
|
argv: process.argv.slice(2),
|
|
14252
14350
|
name: SOCKET_CLI_BIN_NAME,
|
|
14253
14351
|
importMeta: {
|
|
@@ -14282,5 +14380,5 @@ void (async () => {
|
|
|
14282
14380
|
await utils.captureException(e);
|
|
14283
14381
|
}
|
|
14284
14382
|
})();
|
|
14285
|
-
//# debugId=
|
|
14383
|
+
//# debugId=c367b9c2-15d4-4650-9e2f-c8866daf46cd
|
|
14286
14384
|
//# sourceMappingURL=cli.js.map
|