@socketsecurity/cli-with-sentry 0.15.63 → 1.0.0
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 +1855 -2180
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts +2 -2
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/cmd-ci.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-get.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-list.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-set.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +1 -1
- package/dist/types/commands/json/cmd-json.d.mts.map +1 -1
- package/dist/types/commands/login/attempt-login.d.mts +5 -1
- package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
- package/dist/types/commands/logout/cmd-logout.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-setup.d.mts.map +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
- package/dist/types/commands/npx/cmd-npx.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts +10 -0
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +1 -0
- package/dist/types/commands/organization/cmd-organization-list.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-policy-license.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts +1 -1
- package/dist/types/commands/organization/cmd-organization-policy-security.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-quota.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization.d.mts.map +1 -1
- package/dist/types/commands/{dependencies → organization}/fetch-dependencies.d.mts.map +1 -1
- package/dist/types/commands/{dependencies → organization}/handle-dependencies.d.mts.map +1 -1
- package/dist/types/commands/{dependencies → organization}/output-dependencies.d.mts.map +1 -1
- package/dist/types/commands/package/cmd-package-score.d.mts.map +1 -1
- package/dist/types/commands/package/cmd-package-shallow.d.mts.map +1 -1
- package/dist/types/commands/raw-npm/cmd-raw-npm.d.mts.map +1 -1
- package/dist/types/commands/raw-npx/cmd-raw-npx.d.mts.map +1 -1
- package/dist/types/commands/{diff-scan/cmd-diff-scan-get.d.mts → repository/cmd-repository-create.d.mts} +2 -2
- package/dist/types/commands/repository/cmd-repository-create.d.mts.map +1 -0
- package/dist/types/commands/{cdxgen/cmd-cdxgen.d.mts → repository/cmd-repository-del.d.mts} +2 -2
- package/dist/types/commands/repository/cmd-repository-del.d.mts.map +1 -0
- package/dist/types/commands/{dependencies/cmd-dependencies.d.mts → repository/cmd-repository-list.d.mts} +2 -2
- package/dist/types/commands/repository/cmd-repository-list.d.mts.map +1 -0
- package/dist/types/commands/repository/cmd-repository-update.d.mts +10 -0
- package/dist/types/commands/repository/cmd-repository-update.d.mts.map +1 -0
- package/dist/types/commands/{info/cmd-info.d.mts → repository/cmd-repository-view.d.mts} +2 -2
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -0
- package/dist/types/commands/repository/cmd-repository.d.mts +3 -0
- package/dist/types/commands/repository/cmd-repository.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-create-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-list-repos.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-update-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/fetch-view-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/handle-create-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/handle-delete-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +1 -0
- package/dist/types/commands/repository/handle-update-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/handle-view-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/output-create-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/output-delete-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -0
- package/dist/types/commands/repository/output-update-repo.d.mts.map +1 -0
- package/dist/types/commands/repository/output-view-repo.d.mts.map +1 -0
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-del.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-view.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/output-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/wrapper/cmd-wrapper.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts +1 -3
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/determine-org-slug.d.mts +1 -1
- package/dist/types/utils/determine-org-slug.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/ms-at-home.d.mts +2 -0
- package/dist/types/utils/ms-at-home.d.mts.map +1 -0
- package/dist/utils.js +212 -307
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +11871 -11855
- package/package.json +5 -5
- package/dist/types/commands/cdxgen/cmd-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/cdxgen/handle-cdxgen.d.mts +0 -4
- package/dist/types/commands/cdxgen/handle-cdxgen.d.mts.map +0 -1
- package/dist/types/commands/dependencies/cmd-dependencies.d.mts.map +0 -1
- package/dist/types/commands/diff-scan/cmd-diff-scan-get.d.mts.map +0 -1
- package/dist/types/commands/diff-scan/cmd-diff-scan.d.mts +0 -3
- package/dist/types/commands/diff-scan/cmd-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/diff-scan/fetch-diff-scan.d.mts +0 -8
- package/dist/types/commands/diff-scan/fetch-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/diff-scan/handle-diff-scan.d.mts +0 -10
- package/dist/types/commands/diff-scan/handle-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/diff-scan/output-diff-scan.d.mts +0 -8
- package/dist/types/commands/diff-scan/output-diff-scan.d.mts.map +0 -1
- package/dist/types/commands/info/cmd-info.d.mts.map +0 -1
- package/dist/types/commands/info/fetch-package-info.d.mts +0 -3
- package/dist/types/commands/info/fetch-package-info.d.mts.map +0 -1
- package/dist/types/commands/info/handle-package-info.d.mts +0 -17
- package/dist/types/commands/info/handle-package-info.d.mts.map +0 -1
- package/dist/types/commands/info/output-package-info.d.mts +0 -10
- package/dist/types/commands/info/output-package-info.d.mts.map +0 -1
- package/dist/types/commands/report/cmd-report-create.d.mts +0 -10
- package/dist/types/commands/report/cmd-report-create.d.mts.map +0 -1
- package/dist/types/commands/report/cmd-report-view.d.mts +0 -10
- package/dist/types/commands/report/cmd-report-view.d.mts.map +0 -1
- package/dist/types/commands/report/cmd-report.d.mts +0 -3
- package/dist/types/commands/report/cmd-report.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos-create.d.mts +0 -10
- package/dist/types/commands/repos/cmd-repos-create.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos-del.d.mts +0 -10
- package/dist/types/commands/repos/cmd-repos-del.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos-list.d.mts +0 -10
- package/dist/types/commands/repos/cmd-repos-list.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos-update.d.mts +0 -10
- package/dist/types/commands/repos/cmd-repos-update.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos-view.d.mts +0 -10
- package/dist/types/commands/repos/cmd-repos-view.d.mts.map +0 -1
- package/dist/types/commands/repos/cmd-repos.d.mts +0 -3
- package/dist/types/commands/repos/cmd-repos.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-list-all-repos.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/fetch-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/handle-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/handle-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/handle-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repos/handle-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/handle-view-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/output-create-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/output-delete-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/output-list-repos.d.mts.map +0 -1
- package/dist/types/commands/repos/output-update-repo.d.mts.map +0 -1
- package/dist/types/commands/repos/output-view-repo.d.mts.map +0 -1
- /package/dist/types/commands/{dependencies → organization}/fetch-dependencies.d.mts +0 -0
- /package/dist/types/commands/{dependencies → organization}/handle-dependencies.d.mts +0 -0
- /package/dist/types/commands/{dependencies → organization}/output-dependencies.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-create-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-delete-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-list-all-repos.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-list-repos.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-update-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/fetch-view-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/handle-create-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/handle-delete-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/handle-list-repos.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/handle-update-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/handle-view-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/output-create-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/output-delete-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/output-list-repos.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/output-update-repo.d.mts +0 -0
- /package/dist/types/commands/{repos → repository}/output-view-repo.d.mts +0 -0
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'], ['
|
|
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']]);
|
|
283
283
|
function getConfigValues() {
|
|
284
284
|
if (_cachedConfig === undefined) {
|
|
285
285
|
// Order: env var > --config flag > file
|
|
@@ -315,7 +315,8 @@ function getConfigValues() {
|
|
|
315
315
|
function normalizeConfigKey(key) {
|
|
316
316
|
// Note: apiKey was the old name of the token. When we load a config with
|
|
317
317
|
// property apiKey, we'll copy that to apiToken and delete the old property.
|
|
318
|
-
|
|
318
|
+
// We added `org` as a convenience alias for `defaultOrg`
|
|
319
|
+
const normalizedKey = key === 'apiKey' ? 'apiToken' : key === 'org' ? 'defaultOrg' : key;
|
|
319
320
|
if (!supportedConfigKeys.has(normalizedKey)) {
|
|
320
321
|
return {
|
|
321
322
|
ok: false,
|
|
@@ -325,7 +326,7 @@ function normalizeConfigKey(key) {
|
|
|
325
326
|
}
|
|
326
327
|
return {
|
|
327
328
|
ok: true,
|
|
328
|
-
data:
|
|
329
|
+
data: normalizedKey
|
|
329
330
|
};
|
|
330
331
|
}
|
|
331
332
|
function findSocketYmlSync(dir = process.cwd()) {
|
|
@@ -377,9 +378,6 @@ function getConfigValueOrUndef(key) {
|
|
|
377
378
|
function isReadOnlyConfig() {
|
|
378
379
|
return _readOnlyConfig;
|
|
379
380
|
}
|
|
380
|
-
function isTestingV1() {
|
|
381
|
-
return !!getConfigValueOrUndef('isTestingV1');
|
|
382
|
-
}
|
|
383
381
|
let _cachedConfig;
|
|
384
382
|
// When using --config or SOCKET_CLI_CONFIG, do not persist the config.
|
|
385
383
|
let _readOnlyConfig = false;
|
|
@@ -411,7 +409,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
411
409
|
_cachedConfig = config;
|
|
412
410
|
_readOnlyConfig = true;
|
|
413
411
|
|
|
414
|
-
// Normalize apiKey to apiToken
|
|
412
|
+
// Normalize apiKey to apiToken
|
|
415
413
|
if (_cachedConfig['apiKey']) {
|
|
416
414
|
if (_cachedConfig['apiToken']) {
|
|
417
415
|
logger.logger.warn('Note: The config override had both apiToken and apiKey. Using the apiToken value. Remove the apiKey to get rid of this message.');
|
|
@@ -447,7 +445,7 @@ function updateConfigValue(key, value) {
|
|
|
447
445
|
if (_readOnlyConfig) {
|
|
448
446
|
return {
|
|
449
447
|
ok: true,
|
|
450
|
-
message: `Config key '${
|
|
448
|
+
message: `Config key '${keyResult.data}' was updated`,
|
|
451
449
|
data: 'Change applied but not persisted; current config is overridden through env var or flag'
|
|
452
450
|
};
|
|
453
451
|
}
|
|
@@ -466,7 +464,7 @@ function updateConfigValue(key, value) {
|
|
|
466
464
|
}
|
|
467
465
|
return {
|
|
468
466
|
ok: true,
|
|
469
|
-
message: `Config key '${
|
|
467
|
+
message: `Config key '${keyResult.data}' was updated`,
|
|
470
468
|
data: undefined
|
|
471
469
|
};
|
|
472
470
|
}
|
|
@@ -587,21 +585,6 @@ async function setupSdk(apiToken = getDefaultToken(), apiBaseUrl = getDefaultApi
|
|
|
587
585
|
};
|
|
588
586
|
}
|
|
589
587
|
|
|
590
|
-
// TODO: this function is removed after v1.0.0
|
|
591
|
-
function handleUnsuccessfulApiResponse(_name, error, cause, status) {
|
|
592
|
-
const message = `${error || 'No error message returned'}${cause ? ` (reason: ${cause})` : ''}`;
|
|
593
|
-
if (status === 401 || status === 403) {
|
|
594
|
-
// Lazily access constants.spinner.
|
|
595
|
-
const {
|
|
596
|
-
spinner
|
|
597
|
-
} = constants;
|
|
598
|
-
spinner.stop();
|
|
599
|
-
throw new AuthError(message);
|
|
600
|
-
}
|
|
601
|
-
logger.logger.fail(failMsgWithBadge('Socket API returned an error', message));
|
|
602
|
-
// eslint-disable-next-line n/no-process-exit
|
|
603
|
-
process.exit(1);
|
|
604
|
-
}
|
|
605
588
|
async function handleApiCall(value, fetchingDesc) {
|
|
606
589
|
// Lazily access constants.spinner.
|
|
607
590
|
const {
|
|
@@ -992,18 +975,6 @@ const outputFlags = {
|
|
|
992
975
|
description: 'Output result as markdown'
|
|
993
976
|
}
|
|
994
977
|
};
|
|
995
|
-
const validationFlags = {
|
|
996
|
-
all: {
|
|
997
|
-
type: 'boolean',
|
|
998
|
-
default: false,
|
|
999
|
-
description: 'Include all issues'
|
|
1000
|
-
},
|
|
1001
|
-
strict: {
|
|
1002
|
-
type: 'boolean',
|
|
1003
|
-
default: false,
|
|
1004
|
-
description: 'Exits with an error code if any matching issues are found'
|
|
1005
|
-
}
|
|
1006
|
-
};
|
|
1007
978
|
|
|
1008
979
|
function checkCommandInput(outputKind, ...checks) {
|
|
1009
980
|
if (checks.every(d => d.test)) {
|
|
@@ -1231,13 +1202,8 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1231
1202
|
});
|
|
1232
1203
|
}
|
|
1233
1204
|
}
|
|
1234
|
-
if (isTestingV1()) {
|
|
1235
|
-
delete subcommands['diff-scan'];
|
|
1236
|
-
delete subcommands['info'];
|
|
1237
|
-
delete subcommands['report'];
|
|
1238
|
-
}
|
|
1239
1205
|
function formatCommandsForHelp(isRootCommand) {
|
|
1240
|
-
if (!isRootCommand
|
|
1206
|
+
if (!isRootCommand) {
|
|
1241
1207
|
return getHelpListOutput({
|
|
1242
1208
|
...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
|
|
1243
1209
|
1: subcommand
|
|
@@ -1256,7 +1222,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1256
1222
|
}
|
|
1257
1223
|
|
|
1258
1224
|
// "Bucket" some commands for easier usage.
|
|
1259
|
-
const commands = new Set(['analytics', 'audit-log', 'config', '
|
|
1225
|
+
const commands = new Set(['analytics', 'audit-log', 'config', 'fix', 'install', 'login', 'logout', 'manifest', 'npm', 'npx', 'optimize', 'organization', 'package', 'raw-npm', 'raw-npx', 'repos', 'scan', 'threat-feed', 'uninstall', 'wrapper']);
|
|
1260
1226
|
Object.entries(subcommands).filter(([_name, subcommand]) => !subcommand.hidden).map(([name]) => name).forEach(name => {
|
|
1261
1227
|
if (commands.has(name)) {
|
|
1262
1228
|
commands.delete(name);
|
|
@@ -1318,13 +1284,13 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1318
1284
|
Usage
|
|
1319
1285
|
$ ${name} <command>
|
|
1320
1286
|
|
|
1321
|
-
${isRootCommand
|
|
1287
|
+
${isRootCommand ? '' : ' Commands'}
|
|
1322
1288
|
${formatCommandsForHelp(isRootCommand)}
|
|
1323
1289
|
|
|
1324
|
-
${isRootCommand
|
|
1325
|
-
${getFlagListOutput(flags, 6,
|
|
1290
|
+
${isRootCommand ? ' Options' : ' Options'}${isRootCommand ? ' (Note: all CLI commands have these flags even when not displayed in their help)\n' : ''}
|
|
1291
|
+
${getFlagListOutput(flags, 6, {
|
|
1326
1292
|
padName: 25
|
|
1327
|
-
}
|
|
1293
|
+
})}
|
|
1328
1294
|
|
|
1329
1295
|
Examples
|
|
1330
1296
|
$ ${name} --help
|
|
@@ -1448,23 +1414,36 @@ function getAsciiHeader(command) {
|
|
|
1448
1414
|
const nodeVersion = redacting ? REDACTED : process.version;
|
|
1449
1415
|
const defaultOrg = getConfigValueOrUndef('defaultOrg');
|
|
1450
1416
|
const readOnlyConfig = isReadOnlyConfig() ? '*' : '.';
|
|
1451
|
-
const v1test = isTestingV1() ? ' (is testing v1)' : '';
|
|
1452
|
-
const feedback = isTestingV1() ? vendor.yoctocolorsCjsExports.green(' (Thank you for testing the v1 bump! Please send us any feedback you might have!)\n') : '';
|
|
1453
1417
|
const shownToken = redacting ? REDACTED : getVisibleTokenPrefix() || 'no';
|
|
1454
1418
|
const relCwd = redacting ? REDACTED : path$1.normalizePath(tildify(process.cwd()));
|
|
1455
|
-
let nodeVerWarn = '';
|
|
1456
|
-
if (vendor.semverExports.parse(constants.NODE_VERSION).major < 20) {
|
|
1457
|
-
nodeVerWarn += vendor.yoctocolorsCjsExports.bold(` ${vendor.yoctocolorsCjsExports.red('Warning:')} NodeJS version 19 and lower will be ${vendor.yoctocolorsCjsExports.red('unsupported')} after April 30th, 2025.`);
|
|
1458
|
-
nodeVerWarn += '\n';
|
|
1459
|
-
nodeVerWarn += ' Soon after the Socket CLI will require NodeJS version 20 or higher.';
|
|
1460
|
-
nodeVerWarn += '\n';
|
|
1461
|
-
}
|
|
1462
1419
|
const body = `
|
|
1463
1420
|
_____ _ _ /---------------
|
|
1464
|
-
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
1465
|
-
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `,
|
|
1421
|
+
| __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
|
|
1422
|
+
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}${defaultOrg ? `, org: ${redacting ? REDACTED : defaultOrg}` : ''}
|
|
1466
1423
|
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
|
|
1467
|
-
return ` ${body}
|
|
1424
|
+
return ` ${body}`; // Note: logger will auto-append a newline
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
function msAtHome(isoTimeStamp) {
|
|
1428
|
+
const timeStart = Date.parse(isoTimeStamp);
|
|
1429
|
+
const timeEnd = Date.now();
|
|
1430
|
+
const rtf = new Intl.RelativeTimeFormat('en', {
|
|
1431
|
+
numeric: 'always',
|
|
1432
|
+
style: 'short'
|
|
1433
|
+
});
|
|
1434
|
+
const delta = timeEnd - timeStart;
|
|
1435
|
+
if (delta < 60 * 60 * 1000) {
|
|
1436
|
+
return rtf.format(-Math.round(delta / (60 * 1000)), 'minute');
|
|
1437
|
+
// return Math.round(delta / (60 * 1000)) + ' min ago'
|
|
1438
|
+
} else if (delta < 24 * 60 * 60 * 1000) {
|
|
1439
|
+
return rtf.format(-(delta / (60 * 60 * 1000)).toFixed(1), 'hour');
|
|
1440
|
+
// return (delta / (60 * 60 * 1000)).toFixed(1) + ' hr ago'
|
|
1441
|
+
} else if (delta < 7 * 24 * 60 * 60 * 1000) {
|
|
1442
|
+
return rtf.format(-(delta / (24 * 60 * 60 * 1000)).toFixed(1), 'day');
|
|
1443
|
+
// return (delta / (24 * 60 * 60 * 1000)).toFixed(1) + ' day ago'
|
|
1444
|
+
} else {
|
|
1445
|
+
return isoTimeStamp.slice(0, 10);
|
|
1446
|
+
}
|
|
1468
1447
|
}
|
|
1469
1448
|
|
|
1470
1449
|
async function suggestOrgSlug() {
|
|
@@ -1501,28 +1480,70 @@ async function suggestOrgSlug() {
|
|
|
1501
1480
|
}
|
|
1502
1481
|
}
|
|
1503
1482
|
|
|
1504
|
-
async function determineOrgSlug(orgFlag,
|
|
1483
|
+
async function determineOrgSlug(orgFlag, interactive, dryRun) {
|
|
1505
1484
|
const defaultOrgSlug = getConfigValueOrUndef('defaultOrg');
|
|
1506
1485
|
let orgSlug = String(orgFlag || defaultOrgSlug || '');
|
|
1507
1486
|
if (!orgSlug) {
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
logger.logger.fail('Skipping auto-discovery of org when interactive = false');
|
|
1516
|
-
} else {
|
|
1517
|
-
orgSlug = (await suggestOrgSlug()) || '';
|
|
1518
|
-
}
|
|
1487
|
+
// ask from server
|
|
1488
|
+
logger.logger.warn('Missing the org slug and no --org flag set. Trying to auto-discover the org now...');
|
|
1489
|
+
logger.logger.info('Note: you can set the default org slug to prevent this issue. You can also override all that with the --org flag.');
|
|
1490
|
+
if (dryRun) {
|
|
1491
|
+
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');
|
|
1519
1494
|
} else {
|
|
1520
|
-
orgSlug =
|
|
1495
|
+
orgSlug = (await suggestOrgSlug()) || '';
|
|
1521
1496
|
}
|
|
1522
1497
|
}
|
|
1523
1498
|
return [orgSlug, defaultOrgSlug];
|
|
1524
1499
|
}
|
|
1525
1500
|
|
|
1501
|
+
function getPurlObject(purl) {
|
|
1502
|
+
return typeof purl === 'string' ? vendor.packageurlJsExports.PackageURL.fromString(purl) : purl;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
const {
|
|
1506
|
+
SOCKET_WEBSITE_URL
|
|
1507
|
+
} = constants;
|
|
1508
|
+
function getPkgFullNameFromPurl(purl) {
|
|
1509
|
+
const purlObj = getPurlObject(purl);
|
|
1510
|
+
const {
|
|
1511
|
+
name,
|
|
1512
|
+
namespace
|
|
1513
|
+
} = purlObj;
|
|
1514
|
+
return namespace ? `${namespace}${purlObj.type === 'maven' ? ':' : '/'}${name}` : name;
|
|
1515
|
+
}
|
|
1516
|
+
function getSocketDevPackageOverviewUrlFromPurl(purl) {
|
|
1517
|
+
const purlObj = getPurlObject(purl);
|
|
1518
|
+
const fullName = getPkgFullNameFromPurl(purlObj);
|
|
1519
|
+
return getSocketDevPackageOverviewUrl(purlObj.type, fullName, purlObj.version);
|
|
1520
|
+
}
|
|
1521
|
+
function getSocketDevPackageOverviewUrl(ecosystem, fullName, version) {
|
|
1522
|
+
const url = `${SOCKET_WEBSITE_URL}/${ecosystem}/package/${fullName}`;
|
|
1523
|
+
return ecosystem === 'golang' ? `${url}${version ? `?section=overview&version=${version}` : ''}` : `${url}${version ? `/overview/${version}` : ''}`;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Convert a Map<string, Map|string> to a nested object of similar shape.
|
|
1528
|
+
* The goal is to serialize it with JSON.stringify, which Map can't do.
|
|
1529
|
+
*/
|
|
1530
|
+
function mapToObject(map) {
|
|
1531
|
+
return Object.fromEntries(Array.from(map.entries()).map(([k, v]) => [k, v instanceof Map ? mapToObject(v) : v]));
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
function* walkNestedMap(map, keys = []) {
|
|
1535
|
+
for (const [key, value] of map.entries()) {
|
|
1536
|
+
if (value instanceof Map) {
|
|
1537
|
+
yield* walkNestedMap(value, keys.concat(key));
|
|
1538
|
+
} else {
|
|
1539
|
+
yield {
|
|
1540
|
+
keys: keys.concat(key),
|
|
1541
|
+
value: value
|
|
1542
|
+
};
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1526
1547
|
const {
|
|
1527
1548
|
NODE_MODULES: NODE_MODULES$1,
|
|
1528
1549
|
NPM: NPM$4,
|
|
@@ -1628,164 +1649,6 @@ async function getPackageFilesForScan(cwd, inputPaths, supportedFiles, config) {
|
|
|
1628
1649
|
return packageFiles;
|
|
1629
1650
|
}
|
|
1630
1651
|
|
|
1631
|
-
const {
|
|
1632
|
-
NODE_MODULES,
|
|
1633
|
-
NPM: NPM$3,
|
|
1634
|
-
NPX,
|
|
1635
|
-
SOCKET_CLI_ISSUES_URL
|
|
1636
|
-
} = constants;
|
|
1637
|
-
function exitWithBinPathError(binName) {
|
|
1638
|
-
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
1639
|
-
// The exit code 127 indicates that the command or binary being executed
|
|
1640
|
-
// could not be found.
|
|
1641
|
-
// eslint-disable-next-line n/no-process-exit
|
|
1642
|
-
process.exit(127);
|
|
1643
|
-
}
|
|
1644
|
-
let _npmBinPathDetails;
|
|
1645
|
-
function getNpmBinPathDetails() {
|
|
1646
|
-
if (_npmBinPathDetails === undefined) {
|
|
1647
|
-
_npmBinPathDetails = findBinPathDetailsSync(NPM$3);
|
|
1648
|
-
}
|
|
1649
|
-
return _npmBinPathDetails;
|
|
1650
|
-
}
|
|
1651
|
-
let _npxBinPathDetails;
|
|
1652
|
-
function getNpxBinPathDetails() {
|
|
1653
|
-
if (_npxBinPathDetails === undefined) {
|
|
1654
|
-
_npxBinPathDetails = findBinPathDetailsSync(NPX);
|
|
1655
|
-
}
|
|
1656
|
-
return _npxBinPathDetails;
|
|
1657
|
-
}
|
|
1658
|
-
function isNpmBinPathShadowed() {
|
|
1659
|
-
return getNpmBinPathDetails().shadowed;
|
|
1660
|
-
}
|
|
1661
|
-
function isNpxBinPathShadowed() {
|
|
1662
|
-
return getNpxBinPathDetails().shadowed;
|
|
1663
|
-
}
|
|
1664
|
-
let _npmBinPath;
|
|
1665
|
-
function getNpmBinPath() {
|
|
1666
|
-
if (_npmBinPath === undefined) {
|
|
1667
|
-
_npmBinPath = getNpmBinPathDetails().path;
|
|
1668
|
-
if (!_npmBinPath) {
|
|
1669
|
-
exitWithBinPathError(NPM$3);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
return _npmBinPath;
|
|
1673
|
-
}
|
|
1674
|
-
let _npmPath;
|
|
1675
|
-
function getNpmPath() {
|
|
1676
|
-
if (_npmPath === undefined) {
|
|
1677
|
-
const npmBinPath = getNpmBinPath();
|
|
1678
|
-
_npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined;
|
|
1679
|
-
if (!_npmPath) {
|
|
1680
|
-
let message = 'Unable to find npm CLI install directory.';
|
|
1681
|
-
if (npmBinPath) {
|
|
1682
|
-
message += `\nSearched parent directories of ${path.dirname(npmBinPath)}.`;
|
|
1683
|
-
}
|
|
1684
|
-
message += `\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`;
|
|
1685
|
-
logger.logger.fail(message);
|
|
1686
|
-
// The exit code 127 indicates that the command or binary being executed
|
|
1687
|
-
// could not be found.
|
|
1688
|
-
// eslint-disable-next-line n/no-process-exit
|
|
1689
|
-
process.exit(127);
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
return _npmPath;
|
|
1693
|
-
}
|
|
1694
|
-
let _npmRequire;
|
|
1695
|
-
function getNpmRequire() {
|
|
1696
|
-
if (_npmRequire === undefined) {
|
|
1697
|
-
const npmPath = getNpmPath();
|
|
1698
|
-
const npmNmPath = path.join(npmPath, NODE_MODULES, NPM$3);
|
|
1699
|
-
_npmRequire = Module.createRequire(path.join(fs.existsSync(npmNmPath) ? npmNmPath : npmPath, '<dummy-basename>'));
|
|
1700
|
-
}
|
|
1701
|
-
return _npmRequire;
|
|
1702
|
-
}
|
|
1703
|
-
let _npxBinPath;
|
|
1704
|
-
function getNpxBinPath() {
|
|
1705
|
-
if (_npxBinPath === undefined) {
|
|
1706
|
-
_npxBinPath = getNpxBinPathDetails().path;
|
|
1707
|
-
if (!_npxBinPath) {
|
|
1708
|
-
exitWithBinPathError(NPX);
|
|
1709
|
-
}
|
|
1710
|
-
}
|
|
1711
|
-
return _npxBinPath;
|
|
1712
|
-
}
|
|
1713
|
-
|
|
1714
|
-
const helpFlags = new Set(['--help', '-h']);
|
|
1715
|
-
function cmdFlagsToString(args) {
|
|
1716
|
-
const result = [];
|
|
1717
|
-
for (let i = 0, {
|
|
1718
|
-
length
|
|
1719
|
-
} = args; i < length; i += 1) {
|
|
1720
|
-
if (args[i].startsWith('--')) {
|
|
1721
|
-
// Check if the next item exists and is NOT another flag.
|
|
1722
|
-
if (i + 1 < length && !args[i + 1].startsWith('--')) {
|
|
1723
|
-
result.push(`${args[i]}=${args[i + 1]}`);
|
|
1724
|
-
i += 1;
|
|
1725
|
-
} else {
|
|
1726
|
-
result.push(args[i]);
|
|
1727
|
-
}
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
return result.join(' ');
|
|
1731
|
-
}
|
|
1732
|
-
function cmdPrefixMessage(cmdName, text) {
|
|
1733
|
-
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
1734
|
-
return `${cmdPrefix}${text}`;
|
|
1735
|
-
}
|
|
1736
|
-
function isHelpFlag(cmdArg) {
|
|
1737
|
-
return helpFlags.has(cmdArg);
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
function getPurlObject(purl) {
|
|
1741
|
-
return typeof purl === 'string' ? vendor.packageurlJsExports.PackageURL.fromString(purl) : purl;
|
|
1742
|
-
}
|
|
1743
|
-
|
|
1744
|
-
const {
|
|
1745
|
-
SOCKET_WEBSITE_URL
|
|
1746
|
-
} = constants;
|
|
1747
|
-
function getPkgFullNameFromPurl(purl) {
|
|
1748
|
-
const purlObj = getPurlObject(purl);
|
|
1749
|
-
const {
|
|
1750
|
-
name,
|
|
1751
|
-
namespace
|
|
1752
|
-
} = purlObj;
|
|
1753
|
-
return namespace ? `${namespace}${purlObj.type === 'maven' ? ':' : '/'}${name}` : name;
|
|
1754
|
-
}
|
|
1755
|
-
function getSocketDevAlertUrl(alertType) {
|
|
1756
|
-
return `${SOCKET_WEBSITE_URL}/alerts/${alertType}`;
|
|
1757
|
-
}
|
|
1758
|
-
function getSocketDevPackageOverviewUrlFromPurl(purl) {
|
|
1759
|
-
const purlObj = getPurlObject(purl);
|
|
1760
|
-
const fullName = getPkgFullNameFromPurl(purlObj);
|
|
1761
|
-
return getSocketDevPackageOverviewUrl(purlObj.type, fullName, purlObj.version);
|
|
1762
|
-
}
|
|
1763
|
-
function getSocketDevPackageOverviewUrl(ecosystem, fullName, version) {
|
|
1764
|
-
const url = `${SOCKET_WEBSITE_URL}/${ecosystem}/package/${fullName}`;
|
|
1765
|
-
return ecosystem === 'golang' ? `${url}${version ? `?section=overview&version=${version}` : ''}` : `${url}${version ? `/overview/${version}` : ''}`;
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
|
-
/**
|
|
1769
|
-
* Convert a Map<string, Map|string> to a nested object of similar shape.
|
|
1770
|
-
* The goal is to serialize it with JSON.stringify, which Map can't do.
|
|
1771
|
-
*/
|
|
1772
|
-
function mapToObject(map) {
|
|
1773
|
-
return Object.fromEntries(Array.from(map.entries()).map(([k, v]) => [k, v instanceof Map ? mapToObject(v) : v]));
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
function* walkNestedMap(map, keys = []) {
|
|
1777
|
-
for (const [key, value] of map.entries()) {
|
|
1778
|
-
if (value instanceof Map) {
|
|
1779
|
-
yield* walkNestedMap(value, keys.concat(key));
|
|
1780
|
-
} else {
|
|
1781
|
-
yield {
|
|
1782
|
-
keys: keys.concat(key),
|
|
1783
|
-
value: value
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
|
|
1789
1652
|
async function readOrDefaultSocketJson(cwd) {
|
|
1790
1653
|
const result = await readSocketJson(cwd, true);
|
|
1791
1654
|
if (result.ok) {
|
|
@@ -1891,6 +1754,89 @@ async function writeSocketJson(cwd, socketJson) {
|
|
|
1891
1754
|
};
|
|
1892
1755
|
}
|
|
1893
1756
|
|
|
1757
|
+
const {
|
|
1758
|
+
NODE_MODULES,
|
|
1759
|
+
NPM: NPM$3,
|
|
1760
|
+
NPX,
|
|
1761
|
+
SOCKET_CLI_ISSUES_URL
|
|
1762
|
+
} = constants;
|
|
1763
|
+
function exitWithBinPathError(binName) {
|
|
1764
|
+
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
1765
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
1766
|
+
// could not be found.
|
|
1767
|
+
// eslint-disable-next-line n/no-process-exit
|
|
1768
|
+
process.exit(127);
|
|
1769
|
+
}
|
|
1770
|
+
let _npmBinPathDetails;
|
|
1771
|
+
function getNpmBinPathDetails() {
|
|
1772
|
+
if (_npmBinPathDetails === undefined) {
|
|
1773
|
+
_npmBinPathDetails = findBinPathDetailsSync(NPM$3);
|
|
1774
|
+
}
|
|
1775
|
+
return _npmBinPathDetails;
|
|
1776
|
+
}
|
|
1777
|
+
let _npxBinPathDetails;
|
|
1778
|
+
function getNpxBinPathDetails() {
|
|
1779
|
+
if (_npxBinPathDetails === undefined) {
|
|
1780
|
+
_npxBinPathDetails = findBinPathDetailsSync(NPX);
|
|
1781
|
+
}
|
|
1782
|
+
return _npxBinPathDetails;
|
|
1783
|
+
}
|
|
1784
|
+
function isNpmBinPathShadowed() {
|
|
1785
|
+
return getNpmBinPathDetails().shadowed;
|
|
1786
|
+
}
|
|
1787
|
+
function isNpxBinPathShadowed() {
|
|
1788
|
+
return getNpxBinPathDetails().shadowed;
|
|
1789
|
+
}
|
|
1790
|
+
let _npmBinPath;
|
|
1791
|
+
function getNpmBinPath() {
|
|
1792
|
+
if (_npmBinPath === undefined) {
|
|
1793
|
+
_npmBinPath = getNpmBinPathDetails().path;
|
|
1794
|
+
if (!_npmBinPath) {
|
|
1795
|
+
exitWithBinPathError(NPM$3);
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return _npmBinPath;
|
|
1799
|
+
}
|
|
1800
|
+
let _npmPath;
|
|
1801
|
+
function getNpmPath() {
|
|
1802
|
+
if (_npmPath === undefined) {
|
|
1803
|
+
const npmBinPath = getNpmBinPath();
|
|
1804
|
+
_npmPath = npmBinPath ? findNpmPathSync(npmBinPath) : undefined;
|
|
1805
|
+
if (!_npmPath) {
|
|
1806
|
+
let message = 'Unable to find npm CLI install directory.';
|
|
1807
|
+
if (npmBinPath) {
|
|
1808
|
+
message += `\nSearched parent directories of ${path.dirname(npmBinPath)}.`;
|
|
1809
|
+
}
|
|
1810
|
+
message += `\n\nThis is may be a bug with socket-npm related to changes to the npm CLI.\nPlease report to ${SOCKET_CLI_ISSUES_URL}.`;
|
|
1811
|
+
logger.logger.fail(message);
|
|
1812
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
1813
|
+
// could not be found.
|
|
1814
|
+
// eslint-disable-next-line n/no-process-exit
|
|
1815
|
+
process.exit(127);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
return _npmPath;
|
|
1819
|
+
}
|
|
1820
|
+
let _npmRequire;
|
|
1821
|
+
function getNpmRequire() {
|
|
1822
|
+
if (_npmRequire === undefined) {
|
|
1823
|
+
const npmPath = getNpmPath();
|
|
1824
|
+
const npmNmPath = path.join(npmPath, NODE_MODULES, NPM$3);
|
|
1825
|
+
_npmRequire = Module.createRequire(path.join(fs.existsSync(npmNmPath) ? npmNmPath : npmPath, '<dummy-basename>'));
|
|
1826
|
+
}
|
|
1827
|
+
return _npmRequire;
|
|
1828
|
+
}
|
|
1829
|
+
let _npxBinPath;
|
|
1830
|
+
function getNpxBinPath() {
|
|
1831
|
+
if (_npxBinPath === undefined) {
|
|
1832
|
+
_npxBinPath = getNpxBinPathDetails().path;
|
|
1833
|
+
if (!_npxBinPath) {
|
|
1834
|
+
exitWithBinPathError(NPX);
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
return _npxBinPath;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1894
1840
|
const {
|
|
1895
1841
|
ALERT_TYPE_CRITICAL_CVE,
|
|
1896
1842
|
ALERT_TYPE_CVE,
|
|
@@ -1910,13 +1856,6 @@ function createEnum(obj) {
|
|
|
1910
1856
|
...obj
|
|
1911
1857
|
});
|
|
1912
1858
|
}
|
|
1913
|
-
function pick(input, keys) {
|
|
1914
|
-
const result = {};
|
|
1915
|
-
for (const key of keys) {
|
|
1916
|
-
result[key] = input[key];
|
|
1917
|
-
}
|
|
1918
|
-
return result;
|
|
1919
|
-
}
|
|
1920
1859
|
|
|
1921
1860
|
const ALERT_FIX_TYPE = createEnum({
|
|
1922
1861
|
cve: 'cve',
|
|
@@ -1924,71 +1863,12 @@ const ALERT_FIX_TYPE = createEnum({
|
|
|
1924
1863
|
upgrade: 'upgrade'
|
|
1925
1864
|
});
|
|
1926
1865
|
|
|
1927
|
-
function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
1928
|
-
const values = list.filter(Boolean);
|
|
1929
|
-
const {
|
|
1930
|
-
length
|
|
1931
|
-
} = values;
|
|
1932
|
-
if (!length) {
|
|
1933
|
-
return '';
|
|
1934
|
-
}
|
|
1935
|
-
if (length === 1) {
|
|
1936
|
-
return values[0];
|
|
1937
|
-
}
|
|
1938
|
-
const finalValue = values.pop();
|
|
1939
|
-
return `${values.join(', ')}${separator}${finalValue}`;
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
1866
|
const ALERT_SEVERITY = createEnum({
|
|
1943
1867
|
critical: 'critical',
|
|
1944
1868
|
high: 'high',
|
|
1945
1869
|
middle: 'middle',
|
|
1946
1870
|
low: 'low'
|
|
1947
1871
|
});
|
|
1948
|
-
// Ordered from most severe to least.
|
|
1949
|
-
const ALERT_SEVERITIES_SORTED = Object.freeze(['critical', 'high', 'middle', 'low']);
|
|
1950
|
-
function getDesiredSeverities(lowestToInclude) {
|
|
1951
|
-
const result = [];
|
|
1952
|
-
for (const severity of ALERT_SEVERITIES_SORTED) {
|
|
1953
|
-
result.push(severity);
|
|
1954
|
-
if (severity === lowestToInclude) {
|
|
1955
|
-
break;
|
|
1956
|
-
}
|
|
1957
|
-
}
|
|
1958
|
-
return result;
|
|
1959
|
-
}
|
|
1960
|
-
function formatSeverityCount(severityCount) {
|
|
1961
|
-
const summary = [];
|
|
1962
|
-
for (const severity of ALERT_SEVERITIES_SORTED) {
|
|
1963
|
-
if (severityCount[severity]) {
|
|
1964
|
-
summary.push(`${severityCount[severity]} ${severity}`);
|
|
1965
|
-
}
|
|
1966
|
-
}
|
|
1967
|
-
return stringJoinWithSeparateFinalSeparator(summary);
|
|
1968
|
-
}
|
|
1969
|
-
function getSeverityCount(issues, lowestToInclude) {
|
|
1970
|
-
const severityCount = pick({
|
|
1971
|
-
low: 0,
|
|
1972
|
-
middle: 0,
|
|
1973
|
-
high: 0,
|
|
1974
|
-
critical: 0
|
|
1975
|
-
}, getDesiredSeverities(lowestToInclude));
|
|
1976
|
-
for (const issue of issues) {
|
|
1977
|
-
const {
|
|
1978
|
-
value
|
|
1979
|
-
} = issue;
|
|
1980
|
-
if (!value) {
|
|
1981
|
-
continue;
|
|
1982
|
-
}
|
|
1983
|
-
const {
|
|
1984
|
-
severity
|
|
1985
|
-
} = value;
|
|
1986
|
-
if (severityCount[severity] !== undefined) {
|
|
1987
|
-
severityCount[severity] += 1;
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
return severityCount;
|
|
1991
|
-
}
|
|
1992
1872
|
|
|
1993
1873
|
class ColorOrMarkdown {
|
|
1994
1874
|
constructor(useMarkdown) {
|
|
@@ -2654,6 +2534,14 @@ async function getAlertsMapFromPurls(purls, options_) {
|
|
|
2654
2534
|
const statusCode = batchResult.status ?? 'unknown';
|
|
2655
2535
|
const statusMessage = batchResult.error ?? 'No status message';
|
|
2656
2536
|
throw new Error(`Socket API server error (${statusCode}): ${statusMessage}`);
|
|
2537
|
+
} else {
|
|
2538
|
+
const {
|
|
2539
|
+
spinner
|
|
2540
|
+
} = constants;
|
|
2541
|
+
spinner.stop();
|
|
2542
|
+
debug.debugFn('Received a result=false:', batchResult);
|
|
2543
|
+
logger.logger.fail(`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, batchResult.error, batchResult.cause ? `( ${batchResult.cause} )` : '');
|
|
2544
|
+
break;
|
|
2657
2545
|
}
|
|
2658
2546
|
remaining -= 1;
|
|
2659
2547
|
if (spinner && remaining > 0) {
|
|
@@ -2672,6 +2560,32 @@ function npa(...args) {
|
|
|
2672
2560
|
return null;
|
|
2673
2561
|
}
|
|
2674
2562
|
|
|
2563
|
+
const helpFlags = new Set(['--help', '-h']);
|
|
2564
|
+
function cmdFlagsToString(args) {
|
|
2565
|
+
const result = [];
|
|
2566
|
+
for (let i = 0, {
|
|
2567
|
+
length
|
|
2568
|
+
} = args; i < length; i += 1) {
|
|
2569
|
+
if (args[i].startsWith('--')) {
|
|
2570
|
+
// Check if the next item exists and is NOT another flag.
|
|
2571
|
+
if (i + 1 < length && !args[i + 1].startsWith('--')) {
|
|
2572
|
+
result.push(`${args[i]}=${args[i + 1]}`);
|
|
2573
|
+
i += 1;
|
|
2574
|
+
} else {
|
|
2575
|
+
result.push(args[i]);
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
}
|
|
2579
|
+
return result.join(' ');
|
|
2580
|
+
}
|
|
2581
|
+
function cmdPrefixMessage(cmdName, text) {
|
|
2582
|
+
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
2583
|
+
return `${cmdPrefix}${text}`;
|
|
2584
|
+
}
|
|
2585
|
+
function isHelpFlag(cmdArg) {
|
|
2586
|
+
return helpFlags.has(cmdArg);
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2675
2589
|
const {
|
|
2676
2590
|
NPM: NPM$2,
|
|
2677
2591
|
SOCKET_CLI_SAFE_BIN,
|
|
@@ -3188,10 +3102,8 @@ fi
|
|
|
3188
3102
|
};
|
|
3189
3103
|
}
|
|
3190
3104
|
|
|
3191
|
-
exports.ALERT_SEVERITY = ALERT_SEVERITY;
|
|
3192
3105
|
exports.AuthError = AuthError;
|
|
3193
3106
|
exports.COMPLETION_CMD_PREFIX = COMPLETION_CMD_PREFIX;
|
|
3194
|
-
exports.ColorOrMarkdown = ColorOrMarkdown;
|
|
3195
3107
|
exports.InputError = InputError;
|
|
3196
3108
|
exports.RangeStyles = RangeStyles;
|
|
3197
3109
|
exports.applyRange = applyRange;
|
|
@@ -3205,7 +3117,6 @@ exports.detectAndValidatePackageEnvironment = detectAndValidatePackageEnvironmen
|
|
|
3205
3117
|
exports.determineOrgSlug = determineOrgSlug;
|
|
3206
3118
|
exports.extractOverridesFromPnpmLockfileContent = extractOverridesFromPnpmLockfileContent;
|
|
3207
3119
|
exports.failMsgWithBadge = failMsgWithBadge;
|
|
3208
|
-
exports.formatSeverityCount = formatSeverityCount;
|
|
3209
3120
|
exports.getAlertsMapFromPnpmLockfile = getAlertsMapFromPnpmLockfile;
|
|
3210
3121
|
exports.getAlertsMapFromPurls = getAlertsMapFromPurls;
|
|
3211
3122
|
exports.getBashrcDetails = getBashrcDetails;
|
|
@@ -3222,17 +3133,12 @@ exports.getNpxBinPath = getNpxBinPath;
|
|
|
3222
3133
|
exports.getOutputKind = getOutputKind;
|
|
3223
3134
|
exports.getPackageFilesForScan = getPackageFilesForScan;
|
|
3224
3135
|
exports.getPkgFullNameFromPurl = getPkgFullNameFromPurl;
|
|
3225
|
-
exports.getPublicToken = getPublicToken;
|
|
3226
3136
|
exports.getPurlObject = getPurlObject;
|
|
3227
|
-
exports.getSeverityCount = getSeverityCount;
|
|
3228
|
-
exports.getSocketDevAlertUrl = getSocketDevAlertUrl;
|
|
3229
|
-
exports.getSocketDevPackageOverviewUrl = getSocketDevPackageOverviewUrl;
|
|
3230
3137
|
exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlFromPurl;
|
|
3231
3138
|
exports.getVisibleTokenPrefix = getVisibleTokenPrefix;
|
|
3232
3139
|
exports.globWorkspace = globWorkspace;
|
|
3233
3140
|
exports.handleApiCall = handleApiCall;
|
|
3234
3141
|
exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
|
|
3235
|
-
exports.handleUnsuccessfulApiResponse = handleUnsuccessfulApiResponse;
|
|
3236
3142
|
exports.hasDefaultToken = hasDefaultToken;
|
|
3237
3143
|
exports.idToNpmPurl = idToNpmPurl;
|
|
3238
3144
|
exports.idToPurl = idToPurl;
|
|
@@ -3240,7 +3146,6 @@ exports.isHelpFlag = isHelpFlag;
|
|
|
3240
3146
|
exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
|
|
3241
3147
|
exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
|
|
3242
3148
|
exports.isReadOnlyConfig = isReadOnlyConfig;
|
|
3243
|
-
exports.isTestingV1 = isTestingV1;
|
|
3244
3149
|
exports.logAlertsMap = logAlertsMap;
|
|
3245
3150
|
exports.mapToObject = mapToObject;
|
|
3246
3151
|
exports.mdTable = mdTable;
|
|
@@ -3248,6 +3153,7 @@ exports.mdTableOfPairs = mdTableOfPairs;
|
|
|
3248
3153
|
exports.mdTableStringNumber = mdTableStringNumber;
|
|
3249
3154
|
exports.meowOrExit = meowOrExit;
|
|
3250
3155
|
exports.meowWithSubcommands = meowWithSubcommands;
|
|
3156
|
+
exports.msAtHome = msAtHome;
|
|
3251
3157
|
exports.npa = npa;
|
|
3252
3158
|
exports.outputFlags = outputFlags;
|
|
3253
3159
|
exports.parsePnpmLockfile = parsePnpmLockfile;
|
|
@@ -3267,8 +3173,7 @@ exports.suggestOrgSlug = suggestOrgSlug;
|
|
|
3267
3173
|
exports.supportedConfigKeys = supportedConfigKeys;
|
|
3268
3174
|
exports.tildify = tildify;
|
|
3269
3175
|
exports.updateConfigValue = updateConfigValue;
|
|
3270
|
-
exports.validationFlags = validationFlags;
|
|
3271
3176
|
exports.walkNestedMap = walkNestedMap;
|
|
3272
3177
|
exports.writeSocketJson = writeSocketJson;
|
|
3273
|
-
//# debugId=
|
|
3178
|
+
//# debugId=94178b1d-85ee-4390-b193-3a3d369ed113
|
|
3274
3179
|
//# sourceMappingURL=utils.js.map
|