@socketsecurity/cli-with-sentry 1.0.0 → 1.0.2
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 +618 -887
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-inject.js +1 -61
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/types/cli.d.mts +1 -0
- package/dist/types/commands/fix/agent-fix.d.mts +36 -0
- package/dist/types/commands/fix/agent-fix.d.mts.map +1 -0
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/get-actual-tree.d.mts +3 -0
- package/dist/types/commands/fix/get-actual-tree.d.mts.map +1 -0
- package/dist/types/commands/fix/handle-fix.d.mts +2 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/npm-fix.d.mts +2 -10
- package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts +2 -10
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts.map +1 -1
- package/dist/types/commands/optimize/add-overrides.d.mts.map +1 -1
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts +36 -3
- package/dist/types/commands/optimize/get-overrides-by-agent.d.mts.map +1 -1
- package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-github-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-github.d.mts +3 -0
- package/dist/types/commands/scan/output-scan-github.d.mts.map +1 -0
- package/dist/types/commands/scan/scan-reachability.d.mts.map +1 -1
- package/dist/types/commands/scan/suggest-org-slug.d.mts.map +1 -1
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts +2 -0
- package/dist/types/commands/scan/suggest-to-persist-orgslug.d.mts.map +1 -0
- package/dist/types/utils/cmd.d.mts +1 -0
- package/dist/types/utils/cmd.d.mts.map +1 -1
- package/dist/types/utils/coana.d.mts +4 -0
- package/dist/types/utils/coana.d.mts.map +1 -0
- package/dist/types/utils/config.d.mts +2 -1
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/determine-org-slug.d.mts.map +1 -1
- package/dist/types/utils/lockfile.d.mts +2 -0
- package/dist/types/utils/lockfile.d.mts.map +1 -0
- package/dist/types/utils/meow-with-subcommands.d.mts +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts +11 -11
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/pnpm.d.mts +1 -1
- package/dist/types/utils/pnpm.d.mts.map +1 -1
- package/dist/types/utils/semver.d.mts.map +1 -1
- package/dist/utils.js +160 -30
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +8021 -7993
- package/external/@coana-tech/cli/cli.mjs +14035 -3820
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +7 -7
- package/external/@socketsecurity/registry/external/@socketregistry/packageurl-js.js +12 -8
- package/external/@socketsecurity/registry/external/browserslist.js +374 -347
- package/external/@socketsecurity/registry/external/cacache.js +6 -6
- package/external/@socketsecurity/registry/external/libnpmpack.js +47 -45
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +37 -36
- package/external/@socketsecurity/registry/external/pacote.js +45 -44
- package/external/@socketsecurity/registry/lib/spawn.js +11 -2
- package/external/@socketsecurity/registry/manifest.json +2 -2
- package/external/blessed-contrib/lib/widget/charts/bar.js +6 -3
- package/external/blessed-contrib/lib/widget/charts/line.js +6 -3
- package/package.json +31 -31
- package/dist/types/commands/fix/run-fix.d.mts +0 -12
- package/dist/types/commands/fix/run-fix.d.mts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -279,7 +279,7 @@ function safeReadFileSync(filepath, options) {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
const sensitiveConfigKeys = new Set(['apiToken']);
|
|
282
|
-
const supportedConfigKeys = new Map([['apiBaseUrl', 'Base URL of the API endpoint'], ['apiProxy', 'A proxy through which to access the API'], ['apiToken', 'The API token required to access most API endpoints'], ['defaultOrg', 'The default org slug to use; usually the org your API token has access to. When set, all orgSlug arguments are implied to be this value.'], ['enforcedOrgs', 'Orgs in this list have their security policies enforced on this machine'], ['org', 'Alias for defaultOrg']]);
|
|
282
|
+
const supportedConfigKeys = new Map([['apiBaseUrl', 'Base URL of the API endpoint'], ['apiProxy', 'A proxy through which to access the API'], ['apiToken', 'The API token required to access most API endpoints'], ['defaultOrg', 'The default org slug to use; usually the org your API token has access to. When set, all orgSlug arguments are implied to be this value.'], ['enforcedOrgs', 'Orgs in this list have their security policies enforced on this machine'], ['skipAskToPersistDefaultOrg', 'This flag prevents the CLI from asking you to persist the org slug when you selected one interactively'], ['org', 'Alias for defaultOrg']]);
|
|
283
283
|
function getConfigValues() {
|
|
284
284
|
if (_cachedConfig === undefined) {
|
|
285
285
|
// Order: env var > --config flag > file
|
|
@@ -435,17 +435,31 @@ function overrideConfigApiToken(apiToken) {
|
|
|
435
435
|
_readOnlyConfig = true;
|
|
436
436
|
}
|
|
437
437
|
let _pendingSave = false;
|
|
438
|
-
function updateConfigValue(
|
|
438
|
+
function updateConfigValue(configKey, value) {
|
|
439
439
|
const localConfig = getConfigValues();
|
|
440
|
-
const keyResult = normalizeConfigKey(
|
|
440
|
+
const keyResult = normalizeConfigKey(configKey);
|
|
441
441
|
if (!keyResult.ok) {
|
|
442
442
|
return keyResult;
|
|
443
443
|
}
|
|
444
|
-
|
|
444
|
+
const key = keyResult.data;
|
|
445
|
+
let wasDeleted = value === undefined; // implicitly when serializing
|
|
446
|
+
if (key === 'skipAskToPersistDefaultOrg') {
|
|
447
|
+
if (value === 'true' || value === 'false') {
|
|
448
|
+
localConfig['skipAskToPersistDefaultOrg'] = value === 'true';
|
|
449
|
+
} else {
|
|
450
|
+
delete localConfig['skipAskToPersistDefaultOrg'];
|
|
451
|
+
wasDeleted = true;
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
if (value === 'undefined' || value === 'true' || value === 'false') {
|
|
455
|
+
logger.logger.warn(`Note: The value is set to "${value}", as a string (!). Use \`socket config unset\` to reset a key.`);
|
|
456
|
+
}
|
|
457
|
+
localConfig[key] = value;
|
|
458
|
+
}
|
|
445
459
|
if (_readOnlyConfig) {
|
|
446
460
|
return {
|
|
447
461
|
ok: true,
|
|
448
|
-
message: `Config key '${
|
|
462
|
+
message: `Config key '${key}' was ${wasDeleted ? 'deleted' : `updated`}`,
|
|
449
463
|
data: 'Change applied but not persisted; current config is overridden through env var or flag'
|
|
450
464
|
};
|
|
451
465
|
}
|
|
@@ -464,7 +478,7 @@ function updateConfigValue(key, value) {
|
|
|
464
478
|
}
|
|
465
479
|
return {
|
|
466
480
|
ok: true,
|
|
467
|
-
message: `Config key '${
|
|
481
|
+
message: `Config key '${key}' was ${wasDeleted ? 'deleted' : `updated`}`,
|
|
468
482
|
data: undefined
|
|
469
483
|
};
|
|
470
484
|
}
|
|
@@ -1153,6 +1167,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1153
1167
|
// Plus, if we allow this then meow() can just exit here.
|
|
1154
1168
|
autoHelp: false
|
|
1155
1169
|
});
|
|
1170
|
+
const orgFlag = String(cli1.flags['org'] || '') || undefined;
|
|
1156
1171
|
|
|
1157
1172
|
// Hard override the config if instructed to do so.
|
|
1158
1173
|
// The env var overrides the --flag, which overrides the persisted config
|
|
@@ -1182,7 +1197,8 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1182
1197
|
}
|
|
1183
1198
|
}
|
|
1184
1199
|
if (configOverrideResult?.ok === false) {
|
|
1185
|
-
emitBanner(name);
|
|
1200
|
+
emitBanner(name, orgFlag);
|
|
1201
|
+
logger.logger.error(''); // spacing in stderr
|
|
1186
1202
|
logger.logger.fail(configOverrideResult.message);
|
|
1187
1203
|
process.exitCode = 2;
|
|
1188
1204
|
return;
|
|
@@ -1283,8 +1299,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1283
1299
|
const cli2 = vendor.meow(`
|
|
1284
1300
|
Usage
|
|
1285
1301
|
$ ${name} <command>
|
|
1286
|
-
|
|
1287
|
-
${isRootCommand ? '' : ' Commands'}
|
|
1302
|
+
${isRootCommand ? '' : '\n Commands'}
|
|
1288
1303
|
${formatCommandsForHelp(isRootCommand)}
|
|
1289
1304
|
|
|
1290
1305
|
${isRootCommand ? ' Options' : ' Options'}${isRootCommand ? ' (Note: all CLI commands have these flags even when not displayed in their help)\n' : ''}
|
|
@@ -1310,7 +1325,8 @@ ${isRootCommand ? ` $ ${name} scan create --json` : ''}${isRootCommand ? `\
|
|
|
1310
1325
|
|
|
1311
1326
|
// ...else we provide basic instructions and help.
|
|
1312
1327
|
if (!cli2.flags['nobanner']) {
|
|
1313
|
-
emitBanner(name);
|
|
1328
|
+
emitBanner(name, orgFlag);
|
|
1329
|
+
// meow will add newline so don't add stderr spacing here
|
|
1314
1330
|
}
|
|
1315
1331
|
if (!cli2.flags['help'] && cli2.flags['dryRun']) {
|
|
1316
1332
|
process.exitCode = 0;
|
|
@@ -1349,7 +1365,9 @@ function meowOrExit({
|
|
|
1349
1365
|
autoHelp: false // meow will exit(0) before printing the banner
|
|
1350
1366
|
});
|
|
1351
1367
|
if (!cli.flags['nobanner']) {
|
|
1352
|
-
emitBanner(command);
|
|
1368
|
+
emitBanner(command, String(cli.flags['org'] || '') || undefined);
|
|
1369
|
+
// Add spacing in stderr. meow.help adds a newline too so we do it here
|
|
1370
|
+
logger.logger.error('');
|
|
1353
1371
|
}
|
|
1354
1372
|
|
|
1355
1373
|
// As per https://github.com/sindresorhus/meow/issues/178
|
|
@@ -1390,7 +1408,7 @@ function meowOrExit({
|
|
|
1390
1408
|
process.exitCode = 0;
|
|
1391
1409
|
return cli;
|
|
1392
1410
|
}
|
|
1393
|
-
function emitBanner(name) {
|
|
1411
|
+
function emitBanner(name, orgFlag) {
|
|
1394
1412
|
// Print a banner at the top of each command.
|
|
1395
1413
|
// This helps with brand recognition and marketing.
|
|
1396
1414
|
// It also helps with debugging since it contains version and command details.
|
|
@@ -1399,9 +1417,9 @@ function emitBanner(name) {
|
|
|
1399
1417
|
// and pipe the result to other tools. By emitting the banner over stderr
|
|
1400
1418
|
// you can do something like `socket scan view xyz | jq | process`.
|
|
1401
1419
|
// The spinner also emits over stderr for example.
|
|
1402
|
-
logger.logger.error(getAsciiHeader(name));
|
|
1420
|
+
logger.logger.error(getAsciiHeader(name, orgFlag));
|
|
1403
1421
|
}
|
|
1404
|
-
function getAsciiHeader(command) {
|
|
1422
|
+
function getAsciiHeader(command, orgFlag) {
|
|
1405
1423
|
// Note: In tests we return <redacted> because otherwise snapshots will fail.
|
|
1406
1424
|
const {
|
|
1407
1425
|
REDACTED
|
|
@@ -1414,13 +1432,19 @@ function getAsciiHeader(command) {
|
|
|
1414
1432
|
const nodeVersion = redacting ? REDACTED : process.version;
|
|
1415
1433
|
const defaultOrg = getConfigValueOrUndef('defaultOrg');
|
|
1416
1434
|
const readOnlyConfig = isReadOnlyConfig() ? '*' : '.';
|
|
1417
|
-
const shownToken = redacting ? REDACTED : getVisibleTokenPrefix() || '
|
|
1435
|
+
const shownToken = redacting ? REDACTED : getVisibleTokenPrefix() || '(not set)';
|
|
1418
1436
|
const relCwd = redacting ? REDACTED : path$1.normalizePath(tildify(process.cwd()));
|
|
1437
|
+
// Note: we must redact org when creating snapshots because dev machine probably
|
|
1438
|
+
// has a default org set but CI won't. Showing --org is fine either way.
|
|
1439
|
+
const orgPart = orgFlag ? `--org: ${orgFlag}` : redacting ? 'org: <redacted>' : defaultOrg ? `default org: ${defaultOrg}` : '(org not set)';
|
|
1440
|
+
// Note: We could draw these with ascii box art instead but I worry about
|
|
1441
|
+
// portability and paste-ability. "simple" ascii chars just work.
|
|
1419
1442
|
const body = `
|
|
1420
1443
|
_____ _ _ /---------------
|
|
1421
1444
|
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
1422
|
-
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token
|
|
1423
|
-
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}
|
|
1445
|
+
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token: ${shownToken}, ${orgPart}
|
|
1446
|
+
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}
|
|
1447
|
+
`.trim();
|
|
1424
1448
|
return ` ${body}`; // Note: logger will auto-append a newline
|
|
1425
1449
|
}
|
|
1426
1450
|
|
|
@@ -1472,6 +1496,9 @@ async function suggestOrgSlug() {
|
|
|
1472
1496
|
description: 'Do not use any of these organizations (will end in a no-op)'
|
|
1473
1497
|
}]
|
|
1474
1498
|
});
|
|
1499
|
+
if (proceed === undefined) {
|
|
1500
|
+
return undefined;
|
|
1501
|
+
}
|
|
1475
1502
|
if (proceed) {
|
|
1476
1503
|
return proceed;
|
|
1477
1504
|
}
|
|
@@ -1480,19 +1507,76 @@ async function suggestOrgSlug() {
|
|
|
1480
1507
|
}
|
|
1481
1508
|
}
|
|
1482
1509
|
|
|
1510
|
+
async function suggestToPersistOrgSlug(orgSlug) {
|
|
1511
|
+
const skipAsk = getConfigValue('skipAskToPersistDefaultOrg');
|
|
1512
|
+
if (!skipAsk.ok || skipAsk.data) {
|
|
1513
|
+
// Don't ask to store it when disabled before, or when reading config fails.
|
|
1514
|
+
return;
|
|
1515
|
+
}
|
|
1516
|
+
const result = await prompts.select({
|
|
1517
|
+
message: `Would you like to use this org (${orgSlug}) as the default org for future calls?`,
|
|
1518
|
+
choices: [{
|
|
1519
|
+
name: 'Yes',
|
|
1520
|
+
value: 'yes',
|
|
1521
|
+
description: 'Stores it in your config'
|
|
1522
|
+
}, {
|
|
1523
|
+
name: 'No',
|
|
1524
|
+
value: 'no',
|
|
1525
|
+
description: 'Do not persist this org as default org'
|
|
1526
|
+
}, {
|
|
1527
|
+
name: "No and don't ask again",
|
|
1528
|
+
value: 'sush',
|
|
1529
|
+
description: 'Do not store as default org and do not ask again to persist it'
|
|
1530
|
+
}]
|
|
1531
|
+
});
|
|
1532
|
+
if (result === 'yes') {
|
|
1533
|
+
const updateResult = updateConfigValue('defaultOrg', orgSlug);
|
|
1534
|
+
if (updateResult.ok) {
|
|
1535
|
+
logger.logger.success('Updated default org config to:', orgSlug);
|
|
1536
|
+
} else {
|
|
1537
|
+
logger.logger.fail('(Non blocking) Failed to update default org in config:', updateResult.cause);
|
|
1538
|
+
}
|
|
1539
|
+
} else if (result === 'sush') {
|
|
1540
|
+
const updateResult = updateConfigValue('skipAskToPersistDefaultOrg', true);
|
|
1541
|
+
if (updateResult.ok) {
|
|
1542
|
+
logger.logger.info('Default org not changed. Will not ask to persist again.');
|
|
1543
|
+
} else {
|
|
1544
|
+
logger.logger.fail(`(Non blocking) Failed to store preference; will ask to persist again next time. Reason: ${updateResult.cause}`);
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1483
1549
|
async function determineOrgSlug(orgFlag, interactive, dryRun) {
|
|
1484
1550
|
const defaultOrgSlug = getConfigValueOrUndef('defaultOrg');
|
|
1485
1551
|
let orgSlug = String(orgFlag || defaultOrgSlug || '');
|
|
1486
1552
|
if (!orgSlug) {
|
|
1553
|
+
if (!interactive) {
|
|
1554
|
+
logger.logger.warn('Note: This command requires an org slug because the remote API endpoint does.');
|
|
1555
|
+
logger.logger.warn('');
|
|
1556
|
+
logger.logger.warn('It seems no default org was setup and the `--org` flag was not used.');
|
|
1557
|
+
logger.logger.warn("Additionally, `--no-interactive` was set so we can't ask for it.");
|
|
1558
|
+
logger.logger.warn('Since v1.0.0 the org _argument_ for all commands was dropped in favor of an');
|
|
1559
|
+
logger.logger.warn('implicit default org setting, which will be setup when you run `socket login`.');
|
|
1560
|
+
logger.logger.warn('');
|
|
1561
|
+
logger.logger.warn('Note: When running in CI, you probably want to set the `--org` flag.');
|
|
1562
|
+
logger.logger.warn('');
|
|
1563
|
+
logger.logger.warn('For details, see: https://docs.socket.dev/docs/v1-migration-guide');
|
|
1564
|
+
logger.logger.warn('');
|
|
1565
|
+
logger.logger.warn('This command will exit now because the org slug is required to proceed.');
|
|
1566
|
+
return ['', undefined];
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1487
1569
|
// ask from server
|
|
1488
|
-
logger.logger.warn('
|
|
1489
|
-
logger.logger.info('Note: you can
|
|
1570
|
+
logger.logger.warn('Unable to determine the target org. Trying to auto-discover it now...');
|
|
1571
|
+
logger.logger.info('Note: you can run `socket login` to set a default org. You can also override it with the --org flag.');
|
|
1572
|
+
logger.logger.error(''); // spacing in stderr
|
|
1490
1573
|
if (dryRun) {
|
|
1491
1574
|
logger.logger.fail('Skipping auto-discovery of org in dry-run mode');
|
|
1492
|
-
} else if (!interactive) {
|
|
1493
|
-
logger.logger.fail('Skipping auto-discovery of org when interactive = false');
|
|
1494
1575
|
} else {
|
|
1495
1576
|
orgSlug = (await suggestOrgSlug()) || '';
|
|
1577
|
+
if (orgSlug) {
|
|
1578
|
+
await suggestToPersistOrgSlug(orgSlug);
|
|
1579
|
+
}
|
|
1496
1580
|
}
|
|
1497
1581
|
}
|
|
1498
1582
|
return [orgSlug, defaultOrgSlug];
|
|
@@ -1906,7 +1990,7 @@ class ColorOrMarkdown {
|
|
|
1906
1990
|
}
|
|
1907
1991
|
}
|
|
1908
1992
|
|
|
1909
|
-
const RangeStyles = ['caret', 'gt', 'lt', 'pin', 'preserve', 'tilde'];
|
|
1993
|
+
const RangeStyles = ['caret', 'gt', 'gte', 'lt', 'lte', 'pin', 'preserve', 'tilde'];
|
|
1910
1994
|
function applyRange(refRange, version, style = 'preserve') {
|
|
1911
1995
|
switch (style) {
|
|
1912
1996
|
case 'caret':
|
|
@@ -2400,7 +2484,7 @@ function idToPurl(id, type) {
|
|
|
2400
2484
|
return `pkg:${type}/${id}`;
|
|
2401
2485
|
}
|
|
2402
2486
|
|
|
2403
|
-
function
|
|
2487
|
+
function extractOverridesFromPnpmLockSrc(lockfileContent) {
|
|
2404
2488
|
return typeof lockfileContent === 'string' ? /^overrides:(\r?\n {2}.+)+(?:\r?\n)*/m.exec(lockfileContent)?.[0] ?? '' : '';
|
|
2405
2489
|
}
|
|
2406
2490
|
async function extractPurlsFromPnpmLockfile(lockfile) {
|
|
@@ -2450,9 +2534,6 @@ function parsePnpmLockfileVersion(version) {
|
|
|
2450
2534
|
} catch {}
|
|
2451
2535
|
return null;
|
|
2452
2536
|
}
|
|
2453
|
-
async function readPnpmLockfile(lockfilePath) {
|
|
2454
|
-
return fs.existsSync(lockfilePath) ? await readFileUtf8(lockfilePath) : null;
|
|
2455
|
-
}
|
|
2456
2537
|
function stripLeadingPnpmDepPathSlash(depPath) {
|
|
2457
2538
|
return isPnpmDepPath(depPath) ? depPath.slice(1) : depPath;
|
|
2458
2539
|
}
|
|
@@ -2560,6 +2641,10 @@ function npa(...args) {
|
|
|
2560
2641
|
return null;
|
|
2561
2642
|
}
|
|
2562
2643
|
|
|
2644
|
+
async function readLockfile(lockfilePath) {
|
|
2645
|
+
return fs.existsSync(lockfilePath) ? await readFileUtf8(lockfilePath) : null;
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2563
2648
|
const helpFlags = new Set(['--help', '-h']);
|
|
2564
2649
|
function cmdFlagsToString(args) {
|
|
2565
2650
|
const result = [];
|
|
@@ -2578,6 +2663,15 @@ function cmdFlagsToString(args) {
|
|
|
2578
2663
|
}
|
|
2579
2664
|
return result.join(' ');
|
|
2580
2665
|
}
|
|
2666
|
+
function cmdFlagValueToArray(flagValue) {
|
|
2667
|
+
if (typeof flagValue === 'string') {
|
|
2668
|
+
return flagValue.trim().split(/, */);
|
|
2669
|
+
}
|
|
2670
|
+
if (Array.isArray(flagValue)) {
|
|
2671
|
+
return flagValue.flatMap(v => v.split(/, */));
|
|
2672
|
+
}
|
|
2673
|
+
return [];
|
|
2674
|
+
}
|
|
2581
2675
|
function cmdPrefixMessage(cmdName, text) {
|
|
2582
2676
|
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
2583
2677
|
return `${cmdPrefix}${text}`;
|
|
@@ -2711,6 +2805,41 @@ function runAgentInstall(pkgEnvDetails, options) {
|
|
|
2711
2805
|
});
|
|
2712
2806
|
}
|
|
2713
2807
|
|
|
2808
|
+
async function spawnCoana(args, options, extra) {
|
|
2809
|
+
const {
|
|
2810
|
+
env: optionsEnv
|
|
2811
|
+
} = {
|
|
2812
|
+
__proto__: null,
|
|
2813
|
+
...options
|
|
2814
|
+
};
|
|
2815
|
+
try {
|
|
2816
|
+
const output = await spawn.spawn(constants.execPath, [
|
|
2817
|
+
// Lazily access constants.nodeNoWarningsFlags.
|
|
2818
|
+
...constants.nodeNoWarningsFlags,
|
|
2819
|
+
// Lazily access constants.coanaBinPath.
|
|
2820
|
+
constants.coanaBinPath, ...args], {
|
|
2821
|
+
...options,
|
|
2822
|
+
env: {
|
|
2823
|
+
...process.env,
|
|
2824
|
+
...optionsEnv,
|
|
2825
|
+
SOCKET_CLI_API_BASE_URL: constants.ENV.SOCKET_CLI_API_BASE_URL || undefined,
|
|
2826
|
+
SOCKET_CLI_API_TOKEN: getDefaultToken()
|
|
2827
|
+
}
|
|
2828
|
+
}, extra);
|
|
2829
|
+
return {
|
|
2830
|
+
ok: true,
|
|
2831
|
+
data: output.stdout.trim()
|
|
2832
|
+
};
|
|
2833
|
+
} catch (e) {
|
|
2834
|
+
const message = e?.stdout ?? e?.message;
|
|
2835
|
+
return {
|
|
2836
|
+
ok: false,
|
|
2837
|
+
data: e,
|
|
2838
|
+
message
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
|
|
2714
2843
|
const {
|
|
2715
2844
|
BINARY_LOCK_EXT,
|
|
2716
2845
|
BUN,
|
|
@@ -3109,13 +3238,14 @@ exports.RangeStyles = RangeStyles;
|
|
|
3109
3238
|
exports.applyRange = applyRange;
|
|
3110
3239
|
exports.captureException = captureException;
|
|
3111
3240
|
exports.checkCommandInput = checkCommandInput;
|
|
3241
|
+
exports.cmdFlagValueToArray = cmdFlagValueToArray;
|
|
3112
3242
|
exports.cmdFlagsToString = cmdFlagsToString;
|
|
3113
3243
|
exports.cmdPrefixMessage = cmdPrefixMessage;
|
|
3114
3244
|
exports.commonFlags = commonFlags;
|
|
3115
3245
|
exports.createEnum = createEnum;
|
|
3116
3246
|
exports.detectAndValidatePackageEnvironment = detectAndValidatePackageEnvironment;
|
|
3117
3247
|
exports.determineOrgSlug = determineOrgSlug;
|
|
3118
|
-
exports.
|
|
3248
|
+
exports.extractOverridesFromPnpmLockSrc = extractOverridesFromPnpmLockSrc;
|
|
3119
3249
|
exports.failMsgWithBadge = failMsgWithBadge;
|
|
3120
3250
|
exports.getAlertsMapFromPnpmLockfile = getAlertsMapFromPnpmLockfile;
|
|
3121
3251
|
exports.getAlertsMapFromPurls = getAlertsMapFromPurls;
|
|
@@ -3123,7 +3253,6 @@ exports.getBashrcDetails = getBashrcDetails;
|
|
|
3123
3253
|
exports.getConfigValue = getConfigValue;
|
|
3124
3254
|
exports.getConfigValueOrUndef = getConfigValueOrUndef;
|
|
3125
3255
|
exports.getCveInfoFromAlertsMap = getCveInfoFromAlertsMap;
|
|
3126
|
-
exports.getDefaultToken = getDefaultToken;
|
|
3127
3256
|
exports.getFlagListOutput = getFlagListOutput;
|
|
3128
3257
|
exports.getMajor = getMajor;
|
|
3129
3258
|
exports.getMinVersion = getMinVersion;
|
|
@@ -3160,8 +3289,8 @@ exports.parsePnpmLockfile = parsePnpmLockfile;
|
|
|
3160
3289
|
exports.parsePnpmLockfileVersion = parsePnpmLockfileVersion;
|
|
3161
3290
|
exports.queryApiSafeJson = queryApiSafeJson;
|
|
3162
3291
|
exports.queryApiSafeText = queryApiSafeText;
|
|
3292
|
+
exports.readLockfile = readLockfile;
|
|
3163
3293
|
exports.readOrDefaultSocketJson = readOrDefaultSocketJson;
|
|
3164
|
-
exports.readPnpmLockfile = readPnpmLockfile;
|
|
3165
3294
|
exports.readSocketJson = readSocketJson;
|
|
3166
3295
|
exports.removeNodeModules = removeNodeModules;
|
|
3167
3296
|
exports.runAgentInstall = runAgentInstall;
|
|
@@ -3169,11 +3298,12 @@ exports.safeReadFile = safeReadFile;
|
|
|
3169
3298
|
exports.sensitiveConfigKeys = sensitiveConfigKeys;
|
|
3170
3299
|
exports.serializeResultJson = serializeResultJson;
|
|
3171
3300
|
exports.setupSdk = setupSdk;
|
|
3301
|
+
exports.spawnCoana = spawnCoana;
|
|
3172
3302
|
exports.suggestOrgSlug = suggestOrgSlug;
|
|
3173
3303
|
exports.supportedConfigKeys = supportedConfigKeys;
|
|
3174
3304
|
exports.tildify = tildify;
|
|
3175
3305
|
exports.updateConfigValue = updateConfigValue;
|
|
3176
3306
|
exports.walkNestedMap = walkNestedMap;
|
|
3177
3307
|
exports.writeSocketJson = writeSocketJson;
|
|
3178
|
-
//# debugId=
|
|
3308
|
+
//# debugId=88d9d91b-8101-48d8-a336-71d3fbea0f10
|
|
3179
3309
|
//# sourceMappingURL=utils.js.map
|