socket 0.14.40-alpha.9 → 0.14.41
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/README.md +1 -1
- package/bin/cli.js +2 -0
- package/dist/{module-sync/constants.d.ts → constants.d.ts} +9 -2
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +16 -12
- package/dist/module-sync/cli.js +321 -326
- package/dist/module-sync/debug.d.ts +3 -0
- package/dist/module-sync/errors.d.ts +3 -1
- package/dist/module-sync/logging.d.ts +16 -0
- package/dist/module-sync/npm-injection.js +990 -955
- package/dist/module-sync/path-resolve.d.ts +1 -1
- package/dist/module-sync/path-resolve.js +49 -1
- package/dist/module-sync/settings.d.ts +6 -1
- package/dist/module-sync/shadow-bin.d.ts +2 -2
- package/dist/module-sync/shadow-bin.js +10 -7
- package/dist/module-sync/socket-url.d.ts +40 -0
- package/dist/module-sync/socket-url.js +301 -0
- package/dist/require/cli.js +321 -324
- package/dist/require/npm-injection.js +2 -1500
- package/dist/require/path-resolve.js +2 -197
- package/dist/require/shadow-bin.js +2 -82
- package/dist/require/socket-url.js +3 -0
- package/dist/require/vendor.js +53 -400
- package/package.json +32 -26
- package/dist/module-sync/color-or-markdown.d.ts +0 -23
- package/dist/module-sync/constants.d.ts.map +0 -1
- package/dist/module-sync/sdk.d.ts +0 -8
- package/dist/module-sync/sdk.js +0 -214
- package/dist/require/constants.d.ts.map +0 -1
- package/dist/require/sdk.js +0 -212
package/dist/require/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ function _socketInterop(e) {
|
|
|
10
10
|
return c ? e.default : e
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
var process$1 = require('node:process');
|
|
13
14
|
var require$$0 = require('node:url');
|
|
14
15
|
var ponyCause = _socketInterop(require('pony-cause'));
|
|
15
16
|
var vendor = require('./vendor.js');
|
|
@@ -22,30 +23,33 @@ var words = require('@socketsecurity/registry/lib/words');
|
|
|
22
23
|
var constants = require('./constants.js');
|
|
23
24
|
var spinner = require('@socketsecurity/registry/lib/spinner');
|
|
24
25
|
var spawn = _socketInterop(require('@npmcli/promise-spawn'));
|
|
25
|
-
var
|
|
26
|
+
var objects = require('@socketsecurity/registry/lib/objects');
|
|
27
|
+
var pathResolve = require('./path-resolve.js');
|
|
28
|
+
var registryConstants = require('@socketsecurity/registry/lib/constants');
|
|
29
|
+
var socketUrl = require('./socket-url.js');
|
|
30
|
+
var terminalLink = _socketInterop(require('terminal-link'));
|
|
31
|
+
var isInteractive = require('@socketregistry/is-interactive/index.cjs');
|
|
26
32
|
var prompts = require('@socketsecurity/registry/lib/prompts');
|
|
27
|
-
var fs$1 = require('node:fs/promises');
|
|
28
33
|
var npa = _socketInterop(require('npm-package-arg'));
|
|
29
34
|
var semver = _socketInterop(require('semver'));
|
|
30
35
|
var tinyglobby = _socketInterop(require('tinyglobby'));
|
|
31
36
|
var yaml = _socketInterop(require('yaml'));
|
|
32
37
|
var registry = require('@socketsecurity/registry');
|
|
33
|
-
var objects = require('@socketsecurity/registry/lib/objects');
|
|
34
38
|
var packages = require('@socketsecurity/registry/lib/packages');
|
|
35
39
|
var promises = require('@socketsecurity/registry/lib/promises');
|
|
36
40
|
var regexps = require('@socketsecurity/registry/lib/regexps');
|
|
37
41
|
var strings = require('@socketsecurity/registry/lib/strings');
|
|
38
42
|
var browserslist = _socketInterop(require('browserslist'));
|
|
39
43
|
var which = _socketInterop(require('which'));
|
|
40
|
-
var
|
|
41
|
-
var
|
|
44
|
+
var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
|
|
45
|
+
var sorts = require('@socketsecurity/registry/lib/sorts');
|
|
42
46
|
var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
|
|
43
47
|
var config = require('@socketsecurity/config');
|
|
44
48
|
var os = require('node:os');
|
|
45
49
|
var readline = require('node:readline');
|
|
46
|
-
var process$1 = require('node:process');
|
|
47
50
|
var readline$1 = require('node:readline/promises');
|
|
48
51
|
var chalkTable = _socketInterop(require('chalk-table'));
|
|
52
|
+
var fs$1 = require('node:fs/promises');
|
|
49
53
|
var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
|
|
50
54
|
var GridLayout = _socketInterop(require('blessed-contrib/lib/layout/grid'));
|
|
51
55
|
var BarChart = _socketInterop(require('blessed-contrib/lib/widget/charts/bar'));
|
|
@@ -54,7 +58,7 @@ var require$$0$1 = require('node:util');
|
|
|
54
58
|
var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
|
|
55
59
|
|
|
56
60
|
const {
|
|
57
|
-
NPM: NPM$
|
|
61
|
+
NPM: NPM$5,
|
|
58
62
|
PNPM: PNPM$2,
|
|
59
63
|
cdxgenBinPath,
|
|
60
64
|
synpBinPath
|
|
@@ -65,10 +69,10 @@ const {
|
|
|
65
69
|
SBOM_SIGN_PRIVATE_KEY,
|
|
66
70
|
// Location to the RSA private key
|
|
67
71
|
SBOM_SIGN_PUBLIC_KEY // Optional. Location to the RSA public key
|
|
68
|
-
} = process.env;
|
|
72
|
+
} = process$1.env;
|
|
69
73
|
const toLower = arg => arg.toLowerCase();
|
|
70
74
|
const arrayToLower = arg => arg.map(toLower);
|
|
71
|
-
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$
|
|
75
|
+
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$5, PNPM$2, 'ts', 'tsx', 'typescript']);
|
|
72
76
|
const yargsConfig = {
|
|
73
77
|
configuration: {
|
|
74
78
|
'camel-case-expansion': false,
|
|
@@ -172,20 +176,20 @@ const cdxgen = {
|
|
|
172
176
|
length: unknownLength
|
|
173
177
|
} = unknown;
|
|
174
178
|
if (unknownLength) {
|
|
175
|
-
process.exitCode = 1;
|
|
179
|
+
process$1.exitCode = 1;
|
|
176
180
|
console.error(`Unknown ${words.pluralize('argument', unknownLength)}: ${yargv._.join(', ')}`);
|
|
177
181
|
return;
|
|
178
182
|
}
|
|
179
183
|
let cleanupPackageLock = false;
|
|
180
184
|
if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && fs.existsSync('./yarn.lock')) {
|
|
181
185
|
if (fs.existsSync('./package-lock.json')) {
|
|
182
|
-
yargv.type = NPM$
|
|
186
|
+
yargv.type = NPM$5;
|
|
183
187
|
} else {
|
|
184
188
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
185
189
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
186
190
|
try {
|
|
187
191
|
await npm$1.runBin(await fs.promises.realpath(synpBinPath), ['--source-file', './yarn.lock']);
|
|
188
|
-
yargv.type = NPM$
|
|
192
|
+
yargv.type = NPM$5;
|
|
189
193
|
cleanupPackageLock = true;
|
|
190
194
|
} catch {}
|
|
191
195
|
}
|
|
@@ -207,7 +211,7 @@ const cdxgen = {
|
|
|
207
211
|
await fs.promises.rm('./package-lock.json');
|
|
208
212
|
} catch {}
|
|
209
213
|
}
|
|
210
|
-
const fullOutputPath = path.join(process.cwd(), yargv.output);
|
|
214
|
+
const fullOutputPath = path.join(process$1.cwd(), yargv.output);
|
|
211
215
|
if (fs.existsSync(fullOutputPath)) {
|
|
212
216
|
console.log(colors.cyanBright(`${yargv.output} created!`));
|
|
213
217
|
}
|
|
@@ -217,45 +221,62 @@ const cdxgen = {
|
|
|
217
221
|
const {
|
|
218
222
|
abortSignal: abortSignal$3
|
|
219
223
|
} = constants;
|
|
220
|
-
|
|
224
|
+
function shadowNpmInstall(opts) {
|
|
221
225
|
const {
|
|
222
226
|
flags = [],
|
|
227
|
+
ipc,
|
|
223
228
|
...spawnOptions
|
|
224
229
|
} = {
|
|
225
230
|
__proto__: null,
|
|
226
231
|
...opts
|
|
227
232
|
};
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
} = constants.ENV;
|
|
232
|
-
return await spawn(
|
|
233
|
+
const useIpc = objects.isObject(ipc);
|
|
234
|
+
const useDebug = pathResolve.isDebug();
|
|
235
|
+
const promise = spawn(
|
|
233
236
|
// Lazily access constants.execPath.
|
|
234
237
|
constants.execPath, [
|
|
235
238
|
// Lazily access constants.rootBinPath.
|
|
236
|
-
path.join(constants.rootBinPath, 'npm-cli.js'), 'install',
|
|
239
|
+
path.join(constants.rootBinPath, 'npm-cli.js'), 'install',
|
|
240
|
+
// Even though the '--silent' flag is passed npm will still run through
|
|
241
|
+
// code paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
|
|
242
|
+
// flags are passed.
|
|
243
|
+
...(useDebug ? ['--no-audit', '--no-fund'] : ['--silent', '--no-audit', '--no-fund']), ...flags], {
|
|
237
244
|
signal: abortSignal$3,
|
|
238
|
-
//
|
|
239
|
-
|
|
245
|
+
// Set stdio to include 'ipc'.
|
|
246
|
+
// See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
|
|
247
|
+
// and https://github.com/nodejs/node/blob/v23.6.0/lib/internal/child_process.js#L238.
|
|
248
|
+
stdio: useDebug ?
|
|
249
|
+
// 'inherit'
|
|
250
|
+
useIpc ? [0, 1, 2, 'ipc'] : 'inherit' :
|
|
251
|
+
// 'ignore'
|
|
252
|
+
useIpc ? ['ignore', 'ignore', 'ignore', 'ipc'] : 'ignore',
|
|
240
253
|
...spawnOptions,
|
|
241
254
|
env: {
|
|
242
|
-
...process.env,
|
|
255
|
+
...process$1.env,
|
|
243
256
|
...spawnOptions.env
|
|
244
257
|
}
|
|
245
258
|
});
|
|
259
|
+
if (useIpc) {
|
|
260
|
+
promise.process.send(ipc);
|
|
261
|
+
}
|
|
262
|
+
return promise;
|
|
246
263
|
}
|
|
247
264
|
|
|
248
265
|
const {
|
|
249
|
-
SOCKET_CLI_FIX_PACKAGE_LOCK_FILE
|
|
266
|
+
SOCKET_CLI_FIX_PACKAGE_LOCK_FILE,
|
|
267
|
+
SOCKET_IPC_HANDSHAKE: SOCKET_IPC_HANDSHAKE$1
|
|
250
268
|
} = constants;
|
|
251
269
|
const fix = {
|
|
252
270
|
description: 'Fix "fixable" Socket alerts',
|
|
271
|
+
hidden: true,
|
|
253
272
|
async run() {
|
|
254
273
|
const spinner$1 = new spinner.Spinner().start();
|
|
255
274
|
try {
|
|
256
275
|
await shadowNpmInstall({
|
|
257
|
-
|
|
258
|
-
[
|
|
276
|
+
ipc: {
|
|
277
|
+
[SOCKET_IPC_HANDSHAKE$1]: {
|
|
278
|
+
[SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]: true
|
|
279
|
+
}
|
|
259
280
|
}
|
|
260
281
|
});
|
|
261
282
|
} catch (e) {
|
|
@@ -313,47 +334,6 @@ const validationFlags = {
|
|
|
313
334
|
}
|
|
314
335
|
};
|
|
315
336
|
|
|
316
|
-
const {
|
|
317
|
-
API_V0_URL
|
|
318
|
-
} = constants;
|
|
319
|
-
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
320
|
-
// SocketSdkErrorType['error'] is not typed.
|
|
321
|
-
const resultErrorMessage = result.error?.message;
|
|
322
|
-
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
323
|
-
if (result.status === 401 || result.status === 403) {
|
|
324
|
-
spinner.stop();
|
|
325
|
-
throw new sdk.AuthError(message);
|
|
326
|
-
}
|
|
327
|
-
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
328
|
-
process.exit(1);
|
|
329
|
-
}
|
|
330
|
-
async function handleApiCall(value, description) {
|
|
331
|
-
let result;
|
|
332
|
-
try {
|
|
333
|
-
result = await value;
|
|
334
|
-
} catch (cause) {
|
|
335
|
-
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
336
|
-
cause
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
return result;
|
|
340
|
-
}
|
|
341
|
-
async function handleAPIError(code) {
|
|
342
|
-
if (code === 400) {
|
|
343
|
-
return 'One of the options passed might be incorrect.';
|
|
344
|
-
} else if (code === 403) {
|
|
345
|
-
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
async function queryAPI(path, apiKey) {
|
|
349
|
-
return await fetch(`${API_V0_URL}/${path}`, {
|
|
350
|
-
method: 'GET',
|
|
351
|
-
headers: {
|
|
352
|
-
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
|
|
357
337
|
function objectSome(obj) {
|
|
358
338
|
for (const key in obj) {
|
|
359
339
|
if (obj[key]) {
|
|
@@ -370,6 +350,22 @@ function pick(input, keys) {
|
|
|
370
350
|
return result;
|
|
371
351
|
}
|
|
372
352
|
|
|
353
|
+
function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
|
|
354
|
+
const values = list.filter(Boolean);
|
|
355
|
+
const {
|
|
356
|
+
length
|
|
357
|
+
} = values;
|
|
358
|
+
if (!length) {
|
|
359
|
+
return '';
|
|
360
|
+
}
|
|
361
|
+
if (length === 1) {
|
|
362
|
+
return values[0];
|
|
363
|
+
}
|
|
364
|
+
const finalValue = values.pop();
|
|
365
|
+
return `${values.join(', ')}${separator}${finalValue}`;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// Ordered from most severe to least.
|
|
373
369
|
const SEVERITIES_BY_ORDER = ['critical', 'high', 'middle', 'low'];
|
|
374
370
|
function getDesiredSeverities(lowestToInclude) {
|
|
375
371
|
const result = [];
|
|
@@ -388,7 +384,7 @@ function formatSeverityCount(severityCount) {
|
|
|
388
384
|
summary.push(`${severityCount[severity]} ${severity}`);
|
|
389
385
|
}
|
|
390
386
|
}
|
|
391
|
-
return
|
|
387
|
+
return stringJoinWithSeparateFinalSeparator(summary);
|
|
392
388
|
}
|
|
393
389
|
function getSeverityCount(issues, lowestToInclude) {
|
|
394
390
|
const severityCount = pick({
|
|
@@ -398,7 +394,9 @@ function getSeverityCount(issues, lowestToInclude) {
|
|
|
398
394
|
critical: 0
|
|
399
395
|
}, getDesiredSeverities(lowestToInclude));
|
|
400
396
|
for (const issue of issues) {
|
|
401
|
-
const
|
|
397
|
+
const {
|
|
398
|
+
value
|
|
399
|
+
} = issue;
|
|
402
400
|
if (!value) {
|
|
403
401
|
continue;
|
|
404
402
|
}
|
|
@@ -409,18 +407,59 @@ function getSeverityCount(issues, lowestToInclude) {
|
|
|
409
407
|
return severityCount;
|
|
410
408
|
}
|
|
411
409
|
|
|
412
|
-
|
|
410
|
+
const {
|
|
411
|
+
API_V0_URL
|
|
412
|
+
} = constants;
|
|
413
|
+
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
414
|
+
// SocketSdkErrorType['error'] is not typed.
|
|
415
|
+
const resultErrorMessage = result.error?.message;
|
|
416
|
+
const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
|
|
417
|
+
if (result.status === 401 || result.status === 403) {
|
|
418
|
+
spinner.stop();
|
|
419
|
+
throw new socketUrl.AuthError(message);
|
|
420
|
+
}
|
|
421
|
+
spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
|
|
422
|
+
process$1.exit(1);
|
|
423
|
+
}
|
|
424
|
+
async function handleApiCall(value, description) {
|
|
425
|
+
let result;
|
|
426
|
+
try {
|
|
427
|
+
result = await value;
|
|
428
|
+
} catch (cause) {
|
|
429
|
+
throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
|
|
430
|
+
cause
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
return result;
|
|
434
|
+
}
|
|
435
|
+
async function handleAPIError(code) {
|
|
436
|
+
if (code === 400) {
|
|
437
|
+
return 'One of the options passed might be incorrect.';
|
|
438
|
+
} else if (code === 403) {
|
|
439
|
+
return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async function queryAPI(path, apiKey) {
|
|
443
|
+
return await fetch(`${API_V0_URL}/${path}`, {
|
|
444
|
+
method: 'GET',
|
|
445
|
+
headers: {
|
|
446
|
+
Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function getFlagListOutput(list, indent, {
|
|
413
452
|
keyPrefix = '--',
|
|
414
453
|
padName
|
|
415
454
|
} = {}) {
|
|
416
|
-
return
|
|
455
|
+
return getHelpListOutput({
|
|
417
456
|
...list
|
|
418
457
|
}, indent, {
|
|
419
458
|
keyPrefix,
|
|
420
459
|
padName
|
|
421
460
|
});
|
|
422
461
|
}
|
|
423
|
-
function
|
|
462
|
+
function getHelpListOutput(list, indent, {
|
|
424
463
|
keyPrefix = '',
|
|
425
464
|
padName = 18
|
|
426
465
|
} = {}) {
|
|
@@ -435,8 +474,8 @@ function printHelpList(list, indent, {
|
|
|
435
474
|
}
|
|
436
475
|
|
|
437
476
|
const {
|
|
438
|
-
|
|
439
|
-
} =
|
|
477
|
+
NPM: NPM$4
|
|
478
|
+
} = registryConstants;
|
|
440
479
|
const info = {
|
|
441
480
|
description: 'Look up info regarding a package',
|
|
442
481
|
async run(argv, importMeta, {
|
|
@@ -473,7 +512,7 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
473
512
|
$ ${name} <name>
|
|
474
513
|
|
|
475
514
|
Options
|
|
476
|
-
${
|
|
515
|
+
${getFlagListOutput(flags, 6)}
|
|
477
516
|
|
|
478
517
|
Examples
|
|
479
518
|
$ ${name} webtorrent
|
|
@@ -485,7 +524,7 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
485
524
|
flags
|
|
486
525
|
});
|
|
487
526
|
if (cli.input.length > 1) {
|
|
488
|
-
throw new
|
|
527
|
+
throw new socketUrl.InputError('Only one package lookup supported at once');
|
|
489
528
|
}
|
|
490
529
|
const {
|
|
491
530
|
0: rawPkgName = ''
|
|
@@ -513,7 +552,7 @@ function setupCommand$m(name, description, argv, importMeta) {
|
|
|
513
552
|
async function fetchPackageData(pkgName, pkgVersion, {
|
|
514
553
|
includeAllIssues
|
|
515
554
|
}, spinner) {
|
|
516
|
-
const socketSdk = await
|
|
555
|
+
const socketSdk = await socketUrl.setupSdk(socketUrl.getPublicToken());
|
|
517
556
|
const result = await handleApiCall(socketSdk.getIssuesByNPMPackage(pkgName, pkgVersion), 'looking up package');
|
|
518
557
|
const scoreResult = await handleApiCall(socketSdk.getScoreByNPMPackage(pkgName, pkgVersion), 'looking up package score');
|
|
519
558
|
if (result.success === false) {
|
|
@@ -560,8 +599,8 @@ function formatPackageDataOutput({
|
|
|
560
599
|
} else {
|
|
561
600
|
spinner.success('Package has no issues');
|
|
562
601
|
}
|
|
563
|
-
const format = new
|
|
564
|
-
const url =
|
|
602
|
+
const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
|
|
603
|
+
const url = socketUrl.getSocketDevPackageOverviewUrl(NPM$4, pkgName, pkgVersion);
|
|
565
604
|
console.log('\n');
|
|
566
605
|
if (pkgVersion === 'latest') {
|
|
567
606
|
console.log(`Detailed info on socket.dev: ${format.hyperlink(`${pkgName}`, url, {
|
|
@@ -577,7 +616,7 @@ function formatPackageDataOutput({
|
|
|
577
616
|
}
|
|
578
617
|
}
|
|
579
618
|
if (strict && objectSome(severityCount)) {
|
|
580
|
-
process.exit(1);
|
|
619
|
+
process$1.exit(1);
|
|
581
620
|
}
|
|
582
621
|
}
|
|
583
622
|
function formatPackageIssuesDetails(packageData, outputMarkdown) {
|
|
@@ -598,9 +637,9 @@ function formatPackageIssuesDetails(packageData, outputMarkdown) {
|
|
|
598
637
|
}
|
|
599
638
|
return acc;
|
|
600
639
|
}, {});
|
|
601
|
-
const format = new
|
|
640
|
+
const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
|
|
602
641
|
for (const issue of Object.keys(uniqueIssues)) {
|
|
603
|
-
const issueWithLink = format.hyperlink(`${uniqueIssues[issue]?.label}`,
|
|
642
|
+
const issueWithLink = format.hyperlink(`${uniqueIssues[issue]?.label}`, socketUrl.getSocketDevAlertUrl(issue), {
|
|
604
643
|
fallbackToUrl: true
|
|
605
644
|
});
|
|
606
645
|
if (uniqueIssues[issue]?.count === 1) {
|
|
@@ -620,7 +659,7 @@ function formatScore(score) {
|
|
|
620
659
|
}
|
|
621
660
|
|
|
622
661
|
const {
|
|
623
|
-
|
|
662
|
+
SOCKET_PUBLIC_API_TOKEN
|
|
624
663
|
} = constants;
|
|
625
664
|
const description$5 = 'Socket API login';
|
|
626
665
|
const flags = {
|
|
@@ -649,7 +688,7 @@ const login = {
|
|
|
649
688
|
Logs into the Socket API by prompting for an API key
|
|
650
689
|
|
|
651
690
|
Options
|
|
652
|
-
${
|
|
691
|
+
${getFlagListOutput({
|
|
653
692
|
'api-base-url': flags['apiBaseUrl'].description,
|
|
654
693
|
'api-proxy': flags['apiProxy'].description
|
|
655
694
|
}, 8)}
|
|
@@ -670,25 +709,25 @@ const login = {
|
|
|
670
709
|
cli.showHelp();
|
|
671
710
|
return;
|
|
672
711
|
}
|
|
673
|
-
if (!
|
|
674
|
-
throw new
|
|
712
|
+
if (!isInteractive()) {
|
|
713
|
+
throw new socketUrl.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
675
714
|
}
|
|
676
|
-
const
|
|
677
|
-
message: `Enter your ${
|
|
678
|
-
})) ||
|
|
715
|
+
const apiToken = (await prompts.password({
|
|
716
|
+
message: `Enter your ${terminalLink('Socket.dev API key', 'https://docs.socket.dev/docs/api-keys')} (leave blank for a public key)`
|
|
717
|
+
})) || SOCKET_PUBLIC_API_TOKEN;
|
|
679
718
|
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
680
|
-
apiBaseUrl ??=
|
|
719
|
+
apiBaseUrl ??= socketUrl.getSetting('apiBaseUrl') ?? undefined;
|
|
681
720
|
let apiProxy = cli.flags['apiProxy'];
|
|
682
|
-
apiProxy ??=
|
|
721
|
+
apiProxy ??= socketUrl.getSetting('apiProxy') ?? undefined;
|
|
683
722
|
const spinner$1 = new spinner.Spinner({
|
|
684
723
|
text: 'Verifying API key...'
|
|
685
724
|
}).start();
|
|
686
725
|
let orgs;
|
|
687
726
|
try {
|
|
688
|
-
const sdk
|
|
689
|
-
const result = await sdk
|
|
727
|
+
const sdk = await socketUrl.setupSdk(apiToken, apiBaseUrl, apiProxy);
|
|
728
|
+
const result = await sdk.getOrganizations();
|
|
690
729
|
if (!result.success) {
|
|
691
|
-
throw new
|
|
730
|
+
throw new socketUrl.AuthError();
|
|
692
731
|
}
|
|
693
732
|
orgs = result.data;
|
|
694
733
|
spinner$1.success('API key verified');
|
|
@@ -725,12 +764,13 @@ const login = {
|
|
|
725
764
|
}
|
|
726
765
|
}
|
|
727
766
|
}
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
767
|
+
socketUrl.updateSetting('enforcedOrgs', enforcedOrgs);
|
|
768
|
+
// TODO: Rename the 'apiKey' setting to 'apiToken'.
|
|
769
|
+
const oldToken = socketUrl.getSetting('apiKey');
|
|
770
|
+
socketUrl.updateSetting('apiKey', apiToken);
|
|
771
|
+
socketUrl.updateSetting('apiBaseUrl', apiBaseUrl);
|
|
772
|
+
socketUrl.updateSetting('apiProxy', apiProxy);
|
|
773
|
+
spinner$1.success(`API credentials ${oldToken ? 'updated' : 'set'}`);
|
|
734
774
|
}
|
|
735
775
|
};
|
|
736
776
|
|
|
@@ -762,10 +802,10 @@ const logout = {
|
|
|
762
802
|
cli.showHelp();
|
|
763
803
|
return;
|
|
764
804
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
805
|
+
socketUrl.updateSetting('apiKey', null);
|
|
806
|
+
socketUrl.updateSetting('apiBaseUrl', null);
|
|
807
|
+
socketUrl.updateSetting('apiProxy', null);
|
|
808
|
+
socketUrl.updateSetting('enforcedOrgs', null);
|
|
769
809
|
new spinner.Spinner().success('Successfully logged out');
|
|
770
810
|
}
|
|
771
811
|
};
|
|
@@ -794,48 +834,6 @@ const npx = {
|
|
|
794
834
|
}
|
|
795
835
|
};
|
|
796
836
|
|
|
797
|
-
function existsSync(filepath) {
|
|
798
|
-
try {
|
|
799
|
-
return filepath ? fs.existsSync(filepath) : false;
|
|
800
|
-
} catch {}
|
|
801
|
-
return false;
|
|
802
|
-
}
|
|
803
|
-
async function findUp(name, {
|
|
804
|
-
cwd = process.cwd()
|
|
805
|
-
}) {
|
|
806
|
-
let dir = path.resolve(cwd);
|
|
807
|
-
const {
|
|
808
|
-
root
|
|
809
|
-
} = path.parse(dir);
|
|
810
|
-
const names = [name].flat();
|
|
811
|
-
while (dir && dir !== root) {
|
|
812
|
-
for (const name of names) {
|
|
813
|
-
const filePath = path.join(dir, name);
|
|
814
|
-
try {
|
|
815
|
-
// eslint-disable-next-line no-await-in-loop
|
|
816
|
-
const stats = await fs.promises.stat(filePath);
|
|
817
|
-
if (stats.isFile()) {
|
|
818
|
-
return filePath;
|
|
819
|
-
}
|
|
820
|
-
} catch {}
|
|
821
|
-
}
|
|
822
|
-
dir = path.dirname(dir);
|
|
823
|
-
}
|
|
824
|
-
return undefined;
|
|
825
|
-
}
|
|
826
|
-
async function readFileBinary(filepath, options) {
|
|
827
|
-
return await fs.promises.readFile(filepath, {
|
|
828
|
-
...options,
|
|
829
|
-
encoding: 'binary'
|
|
830
|
-
});
|
|
831
|
-
}
|
|
832
|
-
async function readFileUtf8(filepath, options) {
|
|
833
|
-
return await fs.promises.readFile(filepath, {
|
|
834
|
-
...options,
|
|
835
|
-
encoding: 'utf8'
|
|
836
|
-
});
|
|
837
|
-
}
|
|
838
|
-
|
|
839
837
|
const {
|
|
840
838
|
BINARY_LOCK_EXT,
|
|
841
839
|
BUN: BUN$1,
|
|
@@ -843,20 +841,25 @@ const {
|
|
|
843
841
|
NPM: NPM$2,
|
|
844
842
|
PNPM: PNPM$1,
|
|
845
843
|
VLT: VLT$1,
|
|
844
|
+
YARN,
|
|
846
845
|
YARN_BERRY: YARN_BERRY$1,
|
|
847
846
|
YARN_CLASSIC: YARN_CLASSIC$1
|
|
848
847
|
} = constants;
|
|
849
848
|
const AGENTS = [BUN$1, NPM$2, PNPM$1, YARN_BERRY$1, YARN_CLASSIC$1, VLT$1];
|
|
850
|
-
const {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
849
|
+
const binByAgent = {
|
|
850
|
+
__proto__: null,
|
|
851
|
+
[BUN$1]: BUN$1,
|
|
852
|
+
[NPM$2]: NPM$2,
|
|
853
|
+
[PNPM$1]: PNPM$1,
|
|
854
|
+
[YARN_BERRY$1]: YARN,
|
|
855
|
+
[YARN_CLASSIC$1]: YARN,
|
|
856
|
+
[VLT$1]: VLT$1
|
|
857
|
+
};
|
|
856
858
|
async function getAgentExecPath(agent) {
|
|
857
|
-
|
|
859
|
+
const binName = binByAgent[agent];
|
|
860
|
+
return (await which(binName, {
|
|
858
861
|
nothrow: true
|
|
859
|
-
})) ??
|
|
862
|
+
})) ?? binName;
|
|
860
863
|
}
|
|
861
864
|
async function getAgentVersion(agentExecPath, cwd) {
|
|
862
865
|
let result;
|
|
@@ -900,8 +903,8 @@ const readLockFileByAgent = (() => {
|
|
|
900
903
|
return undefined;
|
|
901
904
|
};
|
|
902
905
|
}
|
|
903
|
-
const binaryReader = wrapReader(readFileBinary);
|
|
904
|
-
const defaultReader = wrapReader(async lockPath => await readFileUtf8(lockPath));
|
|
906
|
+
const binaryReader = wrapReader(socketUrl.readFileBinary);
|
|
907
|
+
const defaultReader = wrapReader(async lockPath => await socketUrl.readFileUtf8(lockPath));
|
|
905
908
|
return {
|
|
906
909
|
[BUN$1]: wrapReader(async (lockPath, agentExecPath) => {
|
|
907
910
|
const ext = path.extname(lockPath);
|
|
@@ -912,7 +915,7 @@ const readLockFileByAgent = (() => {
|
|
|
912
915
|
const lockBuffer = await binaryReader(lockPath);
|
|
913
916
|
if (lockBuffer) {
|
|
914
917
|
try {
|
|
915
|
-
return
|
|
918
|
+
return index_cjs.parse(lockBuffer);
|
|
916
919
|
} catch {}
|
|
917
920
|
}
|
|
918
921
|
// To print a Yarn lockfile to your console without writing it to disk
|
|
@@ -930,18 +933,18 @@ const readLockFileByAgent = (() => {
|
|
|
930
933
|
};
|
|
931
934
|
})();
|
|
932
935
|
async function detect({
|
|
933
|
-
cwd = process.cwd(),
|
|
936
|
+
cwd = process$1.cwd(),
|
|
934
937
|
onUnknown
|
|
935
938
|
} = {}) {
|
|
936
|
-
let lockPath = await findUp(Object.keys(LOCKS), {
|
|
939
|
+
let lockPath = await socketUrl.findUp(Object.keys(LOCKS), {
|
|
937
940
|
cwd
|
|
938
941
|
});
|
|
939
942
|
let lockBasename = lockPath ? path.basename(lockPath) : undefined;
|
|
940
943
|
const isHiddenLockFile = lockBasename === '.package-lock.json';
|
|
941
|
-
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await findUp('package.json', {
|
|
944
|
+
const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await socketUrl.findUp('package.json', {
|
|
942
945
|
cwd
|
|
943
946
|
});
|
|
944
|
-
const pkgPath = existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
947
|
+
const pkgPath = pkgJsonPath && fs.existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
|
|
945
948
|
const editablePkgJson = pkgPath ? await packages.readPackageJson(pkgPath, {
|
|
946
949
|
editable: true
|
|
947
950
|
}) : undefined;
|
|
@@ -998,7 +1001,7 @@ async function detect({
|
|
|
998
1001
|
}
|
|
999
1002
|
const browserslistQuery = pkgJson['browserslist'];
|
|
1000
1003
|
if (Array.isArray(browserslistQuery)) {
|
|
1001
|
-
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(
|
|
1004
|
+
const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(sorts.naturalCompare);
|
|
1002
1005
|
const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
|
|
1003
1006
|
if (!targets.browser && browserslistTargets.length) {
|
|
1004
1007
|
targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
|
|
@@ -1041,6 +1044,7 @@ const {
|
|
|
1041
1044
|
PNPM,
|
|
1042
1045
|
RESOLUTIONS,
|
|
1043
1046
|
SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE,
|
|
1047
|
+
SOCKET_IPC_HANDSHAKE,
|
|
1044
1048
|
VLT,
|
|
1045
1049
|
YARN_BERRY,
|
|
1046
1050
|
YARN_CLASSIC,
|
|
@@ -1052,6 +1056,7 @@ const PNPM_FIELD_NAME = PNPM;
|
|
|
1052
1056
|
const PNPM_WORKSPACE = `${PNPM}-workspace`;
|
|
1053
1057
|
const manifestNpmOverrides = registry.getManifestData(NPM$1);
|
|
1054
1058
|
const getOverridesDataByAgent = {
|
|
1059
|
+
__proto__: null,
|
|
1055
1060
|
[BUN](pkgJson) {
|
|
1056
1061
|
const overrides = pkgJson?.[RESOLUTIONS] ?? {};
|
|
1057
1062
|
return {
|
|
@@ -1120,6 +1125,7 @@ const lockIncludesByAgent = (() => {
|
|
|
1120
1125
|
`(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
|
|
1121
1126
|
}
|
|
1122
1127
|
return {
|
|
1128
|
+
__proto__: null,
|
|
1123
1129
|
[BUN](lockSrc, name, lockBasename) {
|
|
1124
1130
|
// This is a bit counterintuitive. When lockBasename ends with a .lockb
|
|
1125
1131
|
// we treat it as a yarn.lock. When lockBasename ends with a .lock we
|
|
@@ -1242,6 +1248,7 @@ const updateManifestByAgent = (() => {
|
|
|
1242
1248
|
updatePkgJson(editablePkgJson, RESOLUTIONS, overrides);
|
|
1243
1249
|
}
|
|
1244
1250
|
return {
|
|
1251
|
+
__proto__: null,
|
|
1245
1252
|
[BUN]: updateResolutions,
|
|
1246
1253
|
[NPM$1]: updateOverrides,
|
|
1247
1254
|
[PNPM](editablePkgJson, overrides) {
|
|
@@ -1303,6 +1310,7 @@ const lsByAgent = (() => {
|
|
|
1303
1310
|
return cleanupQueryStdout(stdout);
|
|
1304
1311
|
}
|
|
1305
1312
|
return {
|
|
1313
|
+
__proto__: null,
|
|
1306
1314
|
async [BUN](agentExecPath, cwd) {
|
|
1307
1315
|
try {
|
|
1308
1316
|
// Bun does not support filtering by production packages yet.
|
|
@@ -1380,6 +1388,7 @@ const depsIncludesByAgent = (() => {
|
|
|
1380
1388
|
return stdout.includes(`"${name}"`);
|
|
1381
1389
|
}
|
|
1382
1390
|
return {
|
|
1391
|
+
__proto__: null,
|
|
1383
1392
|
[BUN]: matchHumanStdout,
|
|
1384
1393
|
[NPM$1]: matchQueryStdout,
|
|
1385
1394
|
[PNPM]: matchQueryStdout,
|
|
@@ -1418,11 +1427,11 @@ async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
|
|
|
1418
1427
|
let workspacePatterns;
|
|
1419
1428
|
if (agent === PNPM) {
|
|
1420
1429
|
for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
|
|
1421
|
-
|
|
1430
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1431
|
+
const yml = await socketUrl.safeReadFile(workspacePath, 'utf8');
|
|
1432
|
+
if (yml) {
|
|
1422
1433
|
try {
|
|
1423
|
-
workspacePatterns = yaml.parse(
|
|
1424
|
-
// eslint-disable-next-line no-await-in-loop
|
|
1425
|
-
await fs$1.readFile(workspacePath, 'utf8'))?.packages;
|
|
1434
|
+
workspacePatterns = yaml.parse(yml)?.packages;
|
|
1426
1435
|
} catch {}
|
|
1427
1436
|
if (workspacePatterns) {
|
|
1428
1437
|
break;
|
|
@@ -1562,7 +1571,7 @@ async function addOverrides({
|
|
|
1562
1571
|
const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
|
|
1563
1572
|
const depAlias = depAliasMap.get(origPkgName);
|
|
1564
1573
|
const regSpecStartsLike = `${NPM$1}:${regPkgName}@`;
|
|
1565
|
-
let newSpec = `${regSpecStartsLike}
|
|
1574
|
+
let newSpec = `${regSpecStartsLike}${pin ? version : `^${major}`}`;
|
|
1566
1575
|
let thisVersion = version;
|
|
1567
1576
|
if (depAlias && type === NPM$1) {
|
|
1568
1577
|
// With npm one may not set an override for a package that one directly
|
|
@@ -1579,7 +1588,7 @@ async function addOverrides({
|
|
|
1579
1588
|
if (pin) {
|
|
1580
1589
|
thisVersion = semver.major(semver.coerce(npa(thisSpec).rawSpec)?.version ?? version) === major ? version : (await packages.fetchPackageManifest(thisSpec))?.version ?? version;
|
|
1581
1590
|
}
|
|
1582
|
-
newSpec = `${regSpecStartsLike}
|
|
1591
|
+
newSpec = `${regSpecStartsLike}${pin ? thisVersion : `^${semver.major(thisVersion)}`}`;
|
|
1583
1592
|
} else {
|
|
1584
1593
|
newSpec = oldSpec;
|
|
1585
1594
|
}
|
|
@@ -1647,7 +1656,7 @@ const optimize = {
|
|
|
1647
1656
|
pin,
|
|
1648
1657
|
prod
|
|
1649
1658
|
} = commandContext;
|
|
1650
|
-
const cwd = process.cwd();
|
|
1659
|
+
const cwd = process$1.cwd();
|
|
1651
1660
|
const {
|
|
1652
1661
|
agent,
|
|
1653
1662
|
agentExecPath,
|
|
@@ -1739,19 +1748,20 @@ const optimize = {
|
|
|
1739
1748
|
spinner$1.start(`Updating ${lockName}...`);
|
|
1740
1749
|
try {
|
|
1741
1750
|
if (isNpm) {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
[SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]:
|
|
1751
|
+
const ipc = {
|
|
1752
|
+
[SOCKET_IPC_HANDSHAKE]: {
|
|
1753
|
+
[SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: true
|
|
1745
1754
|
}
|
|
1755
|
+
};
|
|
1756
|
+
await shadowNpmInstall({
|
|
1757
|
+
ipc
|
|
1746
1758
|
});
|
|
1747
1759
|
// TODO: This is a temporary workaround for a `npm ci` bug where it
|
|
1748
1760
|
// will error out after Socket Optimize generates a lock file. More
|
|
1749
1761
|
// investigation is needed.
|
|
1750
1762
|
await shadowNpmInstall({
|
|
1751
1763
|
flags: ['--ignore-scripts', '--package-lock-only'],
|
|
1752
|
-
|
|
1753
|
-
[SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
|
|
1754
|
-
}
|
|
1764
|
+
ipc
|
|
1755
1765
|
});
|
|
1756
1766
|
} else {
|
|
1757
1767
|
// All package managers support the "install" command.
|
|
@@ -1793,7 +1803,7 @@ function setupCommand$l(name, description, argv, importMeta) {
|
|
|
1793
1803
|
$ ${name}
|
|
1794
1804
|
|
|
1795
1805
|
Options
|
|
1796
|
-
${
|
|
1806
|
+
${getFlagListOutput(flags, 6)}
|
|
1797
1807
|
|
|
1798
1808
|
Examples
|
|
1799
1809
|
$ ${name}
|
|
@@ -1841,14 +1851,14 @@ function setupCommand$k(name, description, argv, importMeta) {
|
|
|
1841
1851
|
});
|
|
1842
1852
|
}
|
|
1843
1853
|
async function fetchOrganizations() {
|
|
1844
|
-
const apiKey =
|
|
1854
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
1845
1855
|
if (!apiKey) {
|
|
1846
|
-
throw new
|
|
1856
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
1847
1857
|
}
|
|
1848
1858
|
const spinner$1 = new spinner.Spinner({
|
|
1849
1859
|
text: 'Fetching organizations...'
|
|
1850
1860
|
}).start();
|
|
1851
|
-
const socketSdk = await
|
|
1861
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
1852
1862
|
const result = await handleApiCall(socketSdk.getOrganizations(), 'looking up organizations');
|
|
1853
1863
|
if (result.success === false) {
|
|
1854
1864
|
handleUnsuccessfulApiResponse('getOrganizations', result, spinner$1);
|
|
@@ -1888,7 +1898,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1888
1898
|
$ ${name} <${binName$1} command>
|
|
1889
1899
|
|
|
1890
1900
|
Options
|
|
1891
|
-
${
|
|
1901
|
+
${getFlagListOutput(flags, 6)}
|
|
1892
1902
|
|
|
1893
1903
|
Examples
|
|
1894
1904
|
$ ${name} install
|
|
@@ -1913,7 +1923,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1913
1923
|
// The exit code 127 indicates that the command or binary being executed
|
|
1914
1924
|
// could not be found.
|
|
1915
1925
|
console.error(`Socket unable to locate ${binName$1}; ensure it is available in the PATH environment variable.`);
|
|
1916
|
-
process.exit(127);
|
|
1926
|
+
process$1.exit(127);
|
|
1917
1927
|
}
|
|
1918
1928
|
const spawnPromise = spawn(binPath, argv, {
|
|
1919
1929
|
signal: abortSignal$1,
|
|
@@ -1925,9 +1935,9 @@ async function setupCommand$j(name, description, argv, importMeta) {
|
|
|
1925
1935
|
return;
|
|
1926
1936
|
}
|
|
1927
1937
|
if (signalName) {
|
|
1928
|
-
process.kill(process.pid, signalName);
|
|
1938
|
+
process$1.kill(process$1.pid, signalName);
|
|
1929
1939
|
} else if (code !== null) {
|
|
1930
|
-
process.exit(code);
|
|
1940
|
+
process$1.exit(code);
|
|
1931
1941
|
}
|
|
1932
1942
|
});
|
|
1933
1943
|
await spawnPromise;
|
|
@@ -1956,7 +1966,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1956
1966
|
$ ${name} <${binName} command>
|
|
1957
1967
|
|
|
1958
1968
|
Options
|
|
1959
|
-
${
|
|
1969
|
+
${getFlagListOutput(flags, 6)}
|
|
1960
1970
|
|
|
1961
1971
|
Examples
|
|
1962
1972
|
$ ${name} install
|
|
@@ -1981,7 +1991,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1981
1991
|
// The exit code 127 indicates that the command or binary being executed
|
|
1982
1992
|
// could not be found.
|
|
1983
1993
|
console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable.`);
|
|
1984
|
-
process.exit(127);
|
|
1994
|
+
process$1.exit(127);
|
|
1985
1995
|
}
|
|
1986
1996
|
const spawnPromise = spawn(binPath, argv, {
|
|
1987
1997
|
signal: abortSignal,
|
|
@@ -1993,9 +2003,9 @@ async function setupCommand$i(name, description, argv, importMeta) {
|
|
|
1993
2003
|
return;
|
|
1994
2004
|
}
|
|
1995
2005
|
if (signalName) {
|
|
1996
|
-
process.kill(process.pid, signalName);
|
|
2006
|
+
process$1.kill(process$1.pid, signalName);
|
|
1997
2007
|
} else if (code !== null) {
|
|
1998
|
-
process.exit(code);
|
|
2008
|
+
process$1.exit(code);
|
|
1999
2009
|
}
|
|
2000
2010
|
});
|
|
2001
2011
|
await spawnPromise;
|
|
@@ -2031,7 +2041,7 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
2031
2041
|
$ ${name} <report-identifier>
|
|
2032
2042
|
|
|
2033
2043
|
Options
|
|
2034
|
-
${
|
|
2044
|
+
${getFlagListOutput(flags, 6)}
|
|
2035
2045
|
|
|
2036
2046
|
Examples
|
|
2037
2047
|
$ ${name} QXU8PmK7LfH608RAwfIKdbcHgwEd_ZeWJ9QEGv05FJUQ
|
|
@@ -2053,7 +2063,7 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
2053
2063
|
}
|
|
2054
2064
|
// Validate the input.
|
|
2055
2065
|
if (extraInput.length) {
|
|
2056
|
-
throw new
|
|
2066
|
+
throw new socketUrl.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
|
|
2057
2067
|
}
|
|
2058
2068
|
return {
|
|
2059
2069
|
includeAllIssues: cli.flags['all'],
|
|
@@ -2069,7 +2079,7 @@ async function fetchReportData(reportId, {
|
|
|
2069
2079
|
strict
|
|
2070
2080
|
}) {
|
|
2071
2081
|
// Do the API call
|
|
2072
|
-
const socketSdk = await
|
|
2082
|
+
const socketSdk = await socketUrl.setupSdk();
|
|
2073
2083
|
const spinner$1 = new spinner.Spinner({
|
|
2074
2084
|
text: `Fetching report with ID ${reportId} (this could take a while)`
|
|
2075
2085
|
}).start();
|
|
@@ -2115,7 +2125,7 @@ function formatReportDataOutput(data, {
|
|
|
2115
2125
|
if (outputJson) {
|
|
2116
2126
|
console.log(JSON.stringify(data, undefined, 2));
|
|
2117
2127
|
} else {
|
|
2118
|
-
const format = new
|
|
2128
|
+
const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
|
|
2119
2129
|
console.log('\nDetailed info on socket.dev: ' + format.hyperlink(reportId, data.url, {
|
|
2120
2130
|
fallbackToUrl: true
|
|
2121
2131
|
}));
|
|
@@ -2124,7 +2134,7 @@ function formatReportDataOutput(data, {
|
|
|
2124
2134
|
}
|
|
2125
2135
|
}
|
|
2126
2136
|
if (strict && data.healthy === false) {
|
|
2127
|
-
process.exit(1);
|
|
2137
|
+
process$1.exit(1);
|
|
2128
2138
|
}
|
|
2129
2139
|
}
|
|
2130
2140
|
|
|
@@ -2139,7 +2149,6 @@ const create$2 = {
|
|
|
2139
2149
|
const {
|
|
2140
2150
|
config,
|
|
2141
2151
|
cwd,
|
|
2142
|
-
debugLog,
|
|
2143
2152
|
dryRun,
|
|
2144
2153
|
includeAllIssues,
|
|
2145
2154
|
outputJson,
|
|
@@ -2151,7 +2160,6 @@ const create$2 = {
|
|
|
2151
2160
|
const result = input && (await createReport(packagePaths, {
|
|
2152
2161
|
config,
|
|
2153
2162
|
cwd,
|
|
2154
|
-
debugLog,
|
|
2155
2163
|
dryRun
|
|
2156
2164
|
}));
|
|
2157
2165
|
if (result && view) {
|
|
@@ -2187,12 +2195,6 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2187
2195
|
...commonFlags,
|
|
2188
2196
|
...outputFlags,
|
|
2189
2197
|
...validationFlags,
|
|
2190
|
-
debug: {
|
|
2191
|
-
type: 'boolean',
|
|
2192
|
-
shortFlag: 'd',
|
|
2193
|
-
default: false,
|
|
2194
|
-
description: 'Output debug information'
|
|
2195
|
-
},
|
|
2196
2198
|
dryRun: {
|
|
2197
2199
|
type: 'boolean',
|
|
2198
2200
|
default: false,
|
|
@@ -2219,9 +2221,8 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2219
2221
|
default ignores from the "ignore-by-default" module.
|
|
2220
2222
|
|
|
2221
2223
|
Options
|
|
2222
|
-
${
|
|
2224
|
+
${getFlagListOutput({
|
|
2223
2225
|
all: 'Include all issues',
|
|
2224
|
-
debug: 'Output debug information',
|
|
2225
2226
|
'dry-run': 'Only output what will be done without actually doing it',
|
|
2226
2227
|
json: 'Output result as json',
|
|
2227
2228
|
markdown: 'Output result as markdown',
|
|
@@ -2251,10 +2252,9 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2251
2252
|
const {
|
|
2252
2253
|
dryRun
|
|
2253
2254
|
} = cli.flags;
|
|
2254
|
-
const debugLog = sdk.createDebugLogger(!dryRun || cli.flags['debug']);
|
|
2255
2255
|
|
|
2256
2256
|
// TODO: Allow setting a custom cwd and/or configFile path?
|
|
2257
|
-
const cwd = process.cwd();
|
|
2257
|
+
const cwd = process$1.cwd();
|
|
2258
2258
|
const absoluteConfigPath = path.join(cwd, 'socket.yml');
|
|
2259
2259
|
const config$1 = await config.readSocketConfig(absoluteConfigPath).catch(cause => {
|
|
2260
2260
|
if (cause && typeof cause === 'object' && cause instanceof config.SocketValidationError) {
|
|
@@ -2266,14 +2266,14 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2266
2266
|
errors: cause.validationErrors,
|
|
2267
2267
|
schema: cause.schema
|
|
2268
2268
|
});
|
|
2269
|
-
throw new
|
|
2269
|
+
throw new socketUrl.InputError('The socket.yml config is not valid', betterErrors.map(err => `[${err.path}] ${err.message}.${err.suggestion ? err.suggestion : ''}`).join('\n'));
|
|
2270
2270
|
} else {
|
|
2271
2271
|
throw new ponyCause.ErrorWithCause('Failed to read socket.yml config', {
|
|
2272
2272
|
cause
|
|
2273
2273
|
});
|
|
2274
2274
|
}
|
|
2275
2275
|
});
|
|
2276
|
-
const socketSdk = await
|
|
2276
|
+
const socketSdk = await socketUrl.setupSdk();
|
|
2277
2277
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
2278
2278
|
if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
|
|
2279
2279
|
return res.data;
|
|
@@ -2282,11 +2282,10 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2282
2282
|
cause
|
|
2283
2283
|
});
|
|
2284
2284
|
});
|
|
2285
|
-
const packagePaths = await pathResolve.getPackageFiles(cwd, cli.input, config$1, supportedFiles
|
|
2285
|
+
const packagePaths = await pathResolve.getPackageFiles(cwd, cli.input, config$1, supportedFiles);
|
|
2286
2286
|
return {
|
|
2287
2287
|
config: config$1,
|
|
2288
2288
|
cwd,
|
|
2289
|
-
debugLog,
|
|
2290
2289
|
dryRun,
|
|
2291
2290
|
includeAllIssues: cli.flags['all'],
|
|
2292
2291
|
outputJson: cli.flags['json'],
|
|
@@ -2299,14 +2298,13 @@ async function setupCommand$g(name, description, argv, importMeta) {
|
|
|
2299
2298
|
async function createReport(packagePaths, {
|
|
2300
2299
|
config,
|
|
2301
2300
|
cwd,
|
|
2302
|
-
debugLog,
|
|
2303
2301
|
dryRun
|
|
2304
2302
|
}) {
|
|
2305
|
-
debugLog('Uploading:', packagePaths.join(`\n${
|
|
2303
|
+
pathResolve.debugLog('Uploading:', packagePaths.join(`\n${pathResolve.logSymbols.info} Uploading: `));
|
|
2306
2304
|
if (dryRun) {
|
|
2307
2305
|
return;
|
|
2308
2306
|
}
|
|
2309
|
-
const socketSdk = await
|
|
2307
|
+
const socketSdk = await socketUrl.setupSdk();
|
|
2310
2308
|
const spinner$1 = new spinner.Spinner({
|
|
2311
2309
|
text: `Creating report with ${packagePaths.length} package files`
|
|
2312
2310
|
}).start();
|
|
@@ -2327,7 +2325,7 @@ function formatReportCreationOutput(data, {
|
|
|
2327
2325
|
console.log(JSON.stringify(data, undefined, 2));
|
|
2328
2326
|
return;
|
|
2329
2327
|
}
|
|
2330
|
-
const format = new
|
|
2328
|
+
const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
|
|
2331
2329
|
console.log(`New report: ${format.hyperlink(data.id, data.url, {
|
|
2332
2330
|
fallbackToUrl: true
|
|
2333
2331
|
})}`);
|
|
@@ -2369,13 +2367,13 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
2369
2367
|
$ ${name} <command>
|
|
2370
2368
|
|
|
2371
2369
|
Commands
|
|
2372
|
-
${
|
|
2373
|
-
...objects.toSortedObject(subcommands),
|
|
2374
|
-
...objects.toSortedObject(aliases)
|
|
2370
|
+
${getHelpListOutput({
|
|
2371
|
+
...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(entry => !entry[1].hidden))),
|
|
2372
|
+
...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(entry => !subcommands[entry[1]?.argv[0]]?.hidden)))
|
|
2375
2373
|
}, 6)}
|
|
2376
2374
|
|
|
2377
2375
|
Options
|
|
2378
|
-
${
|
|
2376
|
+
${getFlagListOutput(flags, 6)}
|
|
2379
2377
|
|
|
2380
2378
|
Examples
|
|
2381
2379
|
$ ${name} --help
|
|
@@ -2406,8 +2404,9 @@ const report = {
|
|
|
2406
2404
|
}
|
|
2407
2405
|
};
|
|
2408
2406
|
|
|
2409
|
-
const
|
|
2410
|
-
const
|
|
2407
|
+
const HOME_DIR = os.homedir();
|
|
2408
|
+
const BASH_FILE = `${HOME_DIR}/.bashrc`;
|
|
2409
|
+
const ZSH_BASH_FILE = `${HOME_DIR}/.zshrc`;
|
|
2411
2410
|
const wrapper = {
|
|
2412
2411
|
description: 'Enable or disable the Socket npm/npx wrapper',
|
|
2413
2412
|
async run(argv, importMeta, {
|
|
@@ -2423,7 +2422,7 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2423
2422
|
$ ${name} <flag>
|
|
2424
2423
|
|
|
2425
2424
|
Options
|
|
2426
|
-
${
|
|
2425
|
+
${getFlagListOutput(flags, 6)}
|
|
2427
2426
|
|
|
2428
2427
|
Examples
|
|
2429
2428
|
$ ${name} --enable
|
|
@@ -2478,21 +2477,18 @@ function setupCommand$f(name, description, argv, importMeta) {
|
|
|
2478
2477
|
console.error('There was an issue setting up the alias in your bash profile');
|
|
2479
2478
|
}
|
|
2480
2479
|
}
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2480
|
+
function addAlias(file) {
|
|
2481
|
+
return fs.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
|
|
2482
|
+
if (err) {
|
|
2483
|
+
return new Error(`There was an error setting up the alias: ${err}`);
|
|
2484
|
+
}
|
|
2485
|
+
console.log(`
|
|
2486
|
+
The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
|
|
2487
|
+
If you want to disable it at any time, run \`socket wrapper --disable\`
|
|
2488
2488
|
`);
|
|
2489
|
-
const rl = readline.createInterface({
|
|
2490
|
-
input: process.stdin,
|
|
2491
|
-
output: process.stdout
|
|
2492
2489
|
});
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
const askQuestion = (rl, query) => {
|
|
2490
|
+
}
|
|
2491
|
+
function askQuestion(rl, query) {
|
|
2496
2492
|
rl.question(query, ans => {
|
|
2497
2493
|
if (ans.toLowerCase() === 'y') {
|
|
2498
2494
|
try {
|
|
@@ -2512,19 +2508,31 @@ const askQuestion = (rl, query) => {
|
|
|
2512
2508
|
rl.close();
|
|
2513
2509
|
}
|
|
2514
2510
|
});
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2511
|
+
}
|
|
2512
|
+
function checkSocketWrapperAlreadySetup(file) {
|
|
2513
|
+
const fileContent = fs.readFileSync(file, 'utf8');
|
|
2514
|
+
const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
|
|
2515
|
+
if (linesWithSocketAlias.length) {
|
|
2516
|
+
console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
|
|
2517
|
+
return true;
|
|
2518
|
+
}
|
|
2519
|
+
return false;
|
|
2520
|
+
}
|
|
2521
|
+
function installSafeNpm(query) {
|
|
2522
|
+
console.log(`
|
|
2523
|
+
_____ _ _
|
|
2524
|
+
| __|___ ___| |_ ___| |_
|
|
2525
|
+
|__ | . | _| '_| -_| _|
|
|
2526
|
+
|_____|___|___|_,_|___|_|
|
|
2527
|
+
|
|
2524
2528
|
`);
|
|
2529
|
+
const rl = readline.createInterface({
|
|
2530
|
+
input: process$1.stdin,
|
|
2531
|
+
output: process$1.stdout
|
|
2525
2532
|
});
|
|
2526
|
-
|
|
2527
|
-
|
|
2533
|
+
return askQuestion(rl, query);
|
|
2534
|
+
}
|
|
2535
|
+
function removeAlias(file) {
|
|
2528
2536
|
return fs.readFile(file, 'utf8', function (err, data) {
|
|
2529
2537
|
if (err) {
|
|
2530
2538
|
console.error(`There was an error removing the alias: ${err}`);
|
|
@@ -2541,16 +2549,7 @@ const removeAlias = file => {
|
|
|
2541
2549
|
}
|
|
2542
2550
|
});
|
|
2543
2551
|
});
|
|
2544
|
-
}
|
|
2545
|
-
const checkSocketWrapperAlreadySetup = file => {
|
|
2546
|
-
const fileContent = fs.readFileSync(file, 'utf8');
|
|
2547
|
-
const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
|
|
2548
|
-
if (linesWithSocketAlias.length) {
|
|
2549
|
-
console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
|
|
2550
|
-
return true;
|
|
2551
|
-
}
|
|
2552
|
-
return false;
|
|
2553
|
-
};
|
|
2552
|
+
}
|
|
2554
2553
|
|
|
2555
2554
|
const create$1 = {
|
|
2556
2555
|
description: 'Create a scan',
|
|
@@ -2560,9 +2559,9 @@ const create$1 = {
|
|
|
2560
2559
|
const name = `${parentName} create`;
|
|
2561
2560
|
const input = await setupCommand$e(name, create$1.description, argv, importMeta);
|
|
2562
2561
|
if (input) {
|
|
2563
|
-
const apiKey =
|
|
2562
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
2564
2563
|
if (!apiKey) {
|
|
2565
|
-
throw new
|
|
2564
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
2566
2565
|
}
|
|
2567
2566
|
const spinnerText = 'Creating a scan... \n';
|
|
2568
2567
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -2639,7 +2638,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2639
2638
|
$ ${name} [...options]
|
|
2640
2639
|
|
|
2641
2640
|
Options
|
|
2642
|
-
${
|
|
2641
|
+
${getFlagListOutput(flags, 6)}
|
|
2643
2642
|
|
|
2644
2643
|
Examples
|
|
2645
2644
|
$ ${name} --org=FakeOrg --repo=test-repo --branch=main ./package.json
|
|
@@ -2660,8 +2659,8 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2660
2659
|
const {
|
|
2661
2660
|
0: orgSlug = ''
|
|
2662
2661
|
} = cli.input;
|
|
2663
|
-
const cwd = process.cwd();
|
|
2664
|
-
const socketSdk = await
|
|
2662
|
+
const cwd = process$1.cwd();
|
|
2663
|
+
const socketSdk = await socketUrl.setupSdk();
|
|
2665
2664
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
2666
2665
|
if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
|
|
2667
2666
|
return res.data;
|
|
@@ -2671,8 +2670,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2671
2670
|
cause
|
|
2672
2671
|
});
|
|
2673
2672
|
});
|
|
2674
|
-
const
|
|
2675
|
-
const packagePaths = await pathResolve.getPackageFilesFullScans(cwd, cli.input, supportedFiles, debugLog);
|
|
2673
|
+
const packagePaths = await pathResolve.getPackageFilesFullScans(cwd, cli.input, supportedFiles);
|
|
2676
2674
|
const {
|
|
2677
2675
|
branch: branchName,
|
|
2678
2676
|
repo: repoName
|
|
@@ -2703,7 +2701,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
|
|
|
2703
2701
|
};
|
|
2704
2702
|
}
|
|
2705
2703
|
async function createFullScan(input, spinner, apiKey) {
|
|
2706
|
-
const socketSdk = await
|
|
2704
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
2707
2705
|
const {
|
|
2708
2706
|
branchName,
|
|
2709
2707
|
commitMessage,
|
|
@@ -2748,9 +2746,9 @@ const del$1 = {
|
|
|
2748
2746
|
const name = `${parentName} del`;
|
|
2749
2747
|
const input = setupCommand$d(name, del$1.description, argv, importMeta);
|
|
2750
2748
|
if (input) {
|
|
2751
|
-
const apiKey =
|
|
2749
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
2752
2750
|
if (!apiKey) {
|
|
2753
|
-
throw new
|
|
2751
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
2754
2752
|
}
|
|
2755
2753
|
const spinnerText = 'Deleting scan...';
|
|
2756
2754
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -2773,7 +2771,7 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2773
2771
|
$ ${name} <org slug> <scan ID>
|
|
2774
2772
|
|
|
2775
2773
|
Options
|
|
2776
|
-
${
|
|
2774
|
+
${getFlagListOutput(flags, 6)}
|
|
2777
2775
|
|
|
2778
2776
|
Examples
|
|
2779
2777
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -2804,7 +2802,7 @@ function setupCommand$d(name, description, argv, importMeta) {
|
|
|
2804
2802
|
};
|
|
2805
2803
|
}
|
|
2806
2804
|
async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
2807
|
-
const socketSdk = await
|
|
2805
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
2808
2806
|
const result = await handleApiCall(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting scan');
|
|
2809
2807
|
if (result.success) {
|
|
2810
2808
|
spinner.success('Scan deleted successfully');
|
|
@@ -2822,9 +2820,9 @@ const list$1 = {
|
|
|
2822
2820
|
const name = `${parentName} list`;
|
|
2823
2821
|
const input = setupCommand$c(name, list$1.description, argv, importMeta);
|
|
2824
2822
|
if (input) {
|
|
2825
|
-
const apiKey =
|
|
2823
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
2826
2824
|
if (!apiKey) {
|
|
2827
|
-
throw new
|
|
2825
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
2828
2826
|
}
|
|
2829
2827
|
const spinnerText = 'Listing scans... \n';
|
|
2830
2828
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -2886,7 +2884,7 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2886
2884
|
$ ${name} <org slug>
|
|
2887
2885
|
|
|
2888
2886
|
Options
|
|
2889
|
-
${
|
|
2887
|
+
${getFlagListOutput(flags, 6)}
|
|
2890
2888
|
|
|
2891
2889
|
Examples
|
|
2892
2890
|
$ ${name} FakeOrg
|
|
@@ -2921,7 +2919,7 @@ function setupCommand$c(name, description, argv, importMeta) {
|
|
|
2921
2919
|
};
|
|
2922
2920
|
}
|
|
2923
2921
|
async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
2924
|
-
const socketSdk = await
|
|
2922
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
2925
2923
|
const result = await handleApiCall(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing scans');
|
|
2926
2924
|
if (!result.success) {
|
|
2927
2925
|
handleUnsuccessfulApiResponse('getOrgFullScanList', result, spinner);
|
|
@@ -2966,9 +2964,9 @@ const metadata = {
|
|
|
2966
2964
|
const name = `${parentName} metadata`;
|
|
2967
2965
|
const input = setupCommand$b(name, metadata.description, argv, importMeta);
|
|
2968
2966
|
if (input) {
|
|
2969
|
-
const apiKey =
|
|
2967
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
2970
2968
|
if (!apiKey) {
|
|
2971
|
-
throw new
|
|
2969
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
2972
2970
|
}
|
|
2973
2971
|
const spinnerText = "Getting scan's metadata... \n";
|
|
2974
2972
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -2991,7 +2989,7 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
2991
2989
|
$ ${name} <org slug> <scan id>
|
|
2992
2990
|
|
|
2993
2991
|
Options
|
|
2994
|
-
${
|
|
2992
|
+
${getFlagListOutput(flags, 6)}
|
|
2995
2993
|
|
|
2996
2994
|
Examples
|
|
2997
2995
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -3022,7 +3020,7 @@ function setupCommand$b(name, description, argv, importMeta) {
|
|
|
3022
3020
|
};
|
|
3023
3021
|
}
|
|
3024
3022
|
async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
|
|
3025
|
-
const socketSdk = await
|
|
3023
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3026
3024
|
const result = await handleApiCall(socketSdk.getOrgFullScanMetadata(orgSlug, scanId), 'Listing scans');
|
|
3027
3025
|
if (!result.success) {
|
|
3028
3026
|
handleUnsuccessfulApiResponse('getOrgFullScanMetadata', result, spinner);
|
|
@@ -3040,9 +3038,9 @@ const stream = {
|
|
|
3040
3038
|
const name = `${parentName} stream`;
|
|
3041
3039
|
const input = setupCommand$a(name, stream.description, argv, importMeta);
|
|
3042
3040
|
if (input) {
|
|
3043
|
-
const apiKey =
|
|
3041
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3044
3042
|
if (!apiKey) {
|
|
3045
|
-
throw new
|
|
3043
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3046
3044
|
}
|
|
3047
3045
|
const spinner$1 = new spinner.Spinner({
|
|
3048
3046
|
text: 'Streaming scan...'
|
|
@@ -3069,7 +3067,7 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
3069
3067
|
$ ${name} <org slug> <scan ID> <path to output file>
|
|
3070
3068
|
|
|
3071
3069
|
Options
|
|
3072
|
-
${
|
|
3070
|
+
${getFlagListOutput(flags, 6)}
|
|
3073
3071
|
|
|
3074
3072
|
Examples
|
|
3075
3073
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
|
|
@@ -3102,7 +3100,7 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
3102
3100
|
};
|
|
3103
3101
|
}
|
|
3104
3102
|
async function getOrgFullScan(orgSlug, fullScanId, file, apiKey) {
|
|
3105
|
-
const socketSdk = await
|
|
3103
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3106
3104
|
return await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a scan');
|
|
3107
3105
|
}
|
|
3108
3106
|
|
|
@@ -3135,9 +3133,9 @@ const auditLog = {
|
|
|
3135
3133
|
const name = parentName + ' audit-log';
|
|
3136
3134
|
const input = setupCommand$9(name, auditLog.description, argv, importMeta);
|
|
3137
3135
|
if (input) {
|
|
3138
|
-
const apiKey =
|
|
3136
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3139
3137
|
if (!apiKey) {
|
|
3140
|
-
throw new
|
|
3138
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3141
3139
|
}
|
|
3142
3140
|
const spinner$1 = new spinner.Spinner({
|
|
3143
3141
|
text: `Looking up audit log for ${input.orgSlug}\n`
|
|
@@ -3180,7 +3178,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
3180
3178
|
$ ${name} <org slug>
|
|
3181
3179
|
|
|
3182
3180
|
Options
|
|
3183
|
-
${
|
|
3181
|
+
${getFlagListOutput(flags, 6)}
|
|
3184
3182
|
|
|
3185
3183
|
Examples
|
|
3186
3184
|
$ ${name} FakeOrg
|
|
@@ -3219,7 +3217,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
3219
3217
|
};
|
|
3220
3218
|
}
|
|
3221
3219
|
async function fetchOrgAuditLog(orgSlug, input, spinner, apiKey) {
|
|
3222
|
-
const socketSdk = await
|
|
3220
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3223
3221
|
const result = await handleApiCall(socketSdk.getAuditLogEvents(orgSlug, input), `Looking up audit log for ${orgSlug}\n`);
|
|
3224
3222
|
if (!result.success) {
|
|
3225
3223
|
handleUnsuccessfulApiResponse('getAuditLogEvents', result, spinner);
|
|
@@ -3259,9 +3257,9 @@ const create = {
|
|
|
3259
3257
|
const name = `${parentName} create`;
|
|
3260
3258
|
const input = setupCommand$8(name, create.description, argv, importMeta);
|
|
3261
3259
|
if (input) {
|
|
3262
|
-
const apiKey =
|
|
3260
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3263
3261
|
if (!apiKey) {
|
|
3264
|
-
throw new
|
|
3262
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3265
3263
|
}
|
|
3266
3264
|
const spinnerText = 'Creating repository... \n';
|
|
3267
3265
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -3317,7 +3315,7 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
3317
3315
|
$ ${name} <org slug>
|
|
3318
3316
|
|
|
3319
3317
|
Options
|
|
3320
|
-
${
|
|
3318
|
+
${getFlagListOutput(flags, 6)}
|
|
3321
3319
|
|
|
3322
3320
|
Examples
|
|
3323
3321
|
$ ${name} FakeOrg --repoName=test-repo
|
|
@@ -3355,7 +3353,7 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
3355
3353
|
};
|
|
3356
3354
|
}
|
|
3357
3355
|
async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
3358
|
-
const socketSdk = await
|
|
3356
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3359
3357
|
const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'creating repository');
|
|
3360
3358
|
if (result.success) {
|
|
3361
3359
|
spinner.success('Repository created successfully');
|
|
@@ -3372,9 +3370,9 @@ const del = {
|
|
|
3372
3370
|
const name = `${parentName} del`;
|
|
3373
3371
|
const input = setupCommand$7(name, del.description, argv, importMeta);
|
|
3374
3372
|
if (input) {
|
|
3375
|
-
const apiKey =
|
|
3373
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3376
3374
|
if (!apiKey) {
|
|
3377
|
-
throw new
|
|
3375
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3378
3376
|
}
|
|
3379
3377
|
const spinnerText = 'Deleting repository... \n';
|
|
3380
3378
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -3418,7 +3416,7 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
3418
3416
|
};
|
|
3419
3417
|
}
|
|
3420
3418
|
async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
|
|
3421
|
-
const socketSdk = await
|
|
3419
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3422
3420
|
const result = await handleApiCall(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository');
|
|
3423
3421
|
if (result.success) {
|
|
3424
3422
|
spinner.success('Repository deleted successfully');
|
|
@@ -3436,9 +3434,9 @@ const list = {
|
|
|
3436
3434
|
const name = `${parentName} list`;
|
|
3437
3435
|
const input = setupCommand$6(name, list.description, argv, importMeta);
|
|
3438
3436
|
if (input) {
|
|
3439
|
-
const apiKey =
|
|
3437
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3440
3438
|
if (!apiKey) {
|
|
3441
|
-
throw new
|
|
3439
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3442
3440
|
}
|
|
3443
3441
|
const spinnerText = 'Listing repositories... \n';
|
|
3444
3442
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -3487,7 +3485,7 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3487
3485
|
$ ${name} <org slug>
|
|
3488
3486
|
|
|
3489
3487
|
Options
|
|
3490
|
-
${
|
|
3488
|
+
${getFlagListOutput(flags, 6)}
|
|
3491
3489
|
|
|
3492
3490
|
Examples
|
|
3493
3491
|
$ ${name} FakeOrg
|
|
@@ -3520,7 +3518,7 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
3520
3518
|
};
|
|
3521
3519
|
}
|
|
3522
3520
|
async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
3523
|
-
const socketSdk = await
|
|
3521
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3524
3522
|
const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories');
|
|
3525
3523
|
if (!result.success) {
|
|
3526
3524
|
handleUnsuccessfulApiResponse('getOrgRepoList', result, spinner);
|
|
@@ -3555,9 +3553,9 @@ const update = {
|
|
|
3555
3553
|
const name = `${parentName} update`;
|
|
3556
3554
|
const input = setupCommand$5(name, update.description, argv, importMeta);
|
|
3557
3555
|
if (input) {
|
|
3558
|
-
const apiKey =
|
|
3556
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3559
3557
|
if (!apiKey) {
|
|
3560
|
-
throw new
|
|
3558
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3561
3559
|
}
|
|
3562
3560
|
const spinnerText = 'Updating repository... \n';
|
|
3563
3561
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -3613,7 +3611,7 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
3613
3611
|
$ ${name} <org slug>
|
|
3614
3612
|
|
|
3615
3613
|
Options
|
|
3616
|
-
${
|
|
3614
|
+
${getFlagListOutput(flags, 6)}
|
|
3617
3615
|
|
|
3618
3616
|
Examples
|
|
3619
3617
|
$ ${name} FakeOrg
|
|
@@ -3651,7 +3649,7 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
3651
3649
|
};
|
|
3652
3650
|
}
|
|
3653
3651
|
async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
3654
|
-
const socketSdk = await
|
|
3652
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3655
3653
|
const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository');
|
|
3656
3654
|
if (result.success) {
|
|
3657
3655
|
spinner.success('Repository updated successfully');
|
|
@@ -3669,9 +3667,9 @@ const view = {
|
|
|
3669
3667
|
const name = `${parentName} view`;
|
|
3670
3668
|
const input = setupCommand$4(name, view.description, argv, importMeta);
|
|
3671
3669
|
if (input) {
|
|
3672
|
-
const apiKey =
|
|
3670
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3673
3671
|
if (!apiKey) {
|
|
3674
|
-
throw new
|
|
3672
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3675
3673
|
}
|
|
3676
3674
|
const spinnerText = 'Fetching repository... \n';
|
|
3677
3675
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -3694,7 +3692,7 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3694
3692
|
$ ${name} <org slug>
|
|
3695
3693
|
|
|
3696
3694
|
Options
|
|
3697
|
-
${
|
|
3695
|
+
${getFlagListOutput(flags, 6)}
|
|
3698
3696
|
|
|
3699
3697
|
Examples
|
|
3700
3698
|
$ ${name} FakeOrg
|
|
@@ -3725,7 +3723,7 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
3725
3723
|
};
|
|
3726
3724
|
}
|
|
3727
3725
|
async function viewRepository(orgSlug, repoName, spinner, apiKey) {
|
|
3728
|
-
const socketSdk = await
|
|
3726
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3729
3727
|
const result = await handleApiCall(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository');
|
|
3730
3728
|
if (!result.success) {
|
|
3731
3729
|
handleUnsuccessfulApiResponse('getOrgRepo', result, spinner);
|
|
@@ -3820,7 +3818,7 @@ function setupCommand$3(name, description, argv, importMeta) {
|
|
|
3820
3818
|
$ ${name}
|
|
3821
3819
|
|
|
3822
3820
|
Options
|
|
3823
|
-
${
|
|
3821
|
+
${getFlagListOutput(flags, 6)}
|
|
3824
3822
|
|
|
3825
3823
|
Examples
|
|
3826
3824
|
$ ${name}
|
|
@@ -3848,14 +3846,14 @@ async function searchDeps({
|
|
|
3848
3846
|
offset,
|
|
3849
3847
|
outputJson
|
|
3850
3848
|
}) {
|
|
3851
|
-
const apiKey =
|
|
3849
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3852
3850
|
if (!apiKey) {
|
|
3853
|
-
throw new
|
|
3851
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3854
3852
|
}
|
|
3855
3853
|
const spinner$1 = new spinner.Spinner({
|
|
3856
3854
|
text: 'Searching dependencies...'
|
|
3857
3855
|
}).start();
|
|
3858
|
-
const socketSdk = await
|
|
3856
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
3859
3857
|
const result = await handleApiCall(socketSdk.searchDependencies({
|
|
3860
3858
|
limit,
|
|
3861
3859
|
offset
|
|
@@ -3905,9 +3903,9 @@ const analytics = {
|
|
|
3905
3903
|
const name = parentName + ' analytics';
|
|
3906
3904
|
const input = setupCommand$2(name, analytics.description, argv, importMeta);
|
|
3907
3905
|
if (input) {
|
|
3908
|
-
const apiKey =
|
|
3906
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
3909
3907
|
if (!apiKey) {
|
|
3910
|
-
throw new
|
|
3908
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
3911
3909
|
}
|
|
3912
3910
|
const spinner$1 = new spinner.Spinner({
|
|
3913
3911
|
text: 'Fetching analytics data'
|
|
@@ -3962,7 +3960,7 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3962
3960
|
$ ${name} --scope=<scope> --time=<time filter>
|
|
3963
3961
|
|
|
3964
3962
|
Options
|
|
3965
|
-
${
|
|
3963
|
+
${getFlagListOutput(flags, 6)}
|
|
3966
3964
|
|
|
3967
3965
|
Examples
|
|
3968
3966
|
$ ${name} --scope=org --time=7
|
|
@@ -3980,10 +3978,10 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
3980
3978
|
time
|
|
3981
3979
|
} = cli.flags;
|
|
3982
3980
|
if (scope !== 'org' && scope !== 'repo') {
|
|
3983
|
-
throw new
|
|
3981
|
+
throw new socketUrl.InputError("The scope must either be 'org' or 'repo'");
|
|
3984
3982
|
}
|
|
3985
3983
|
if (time !== 7 && time !== 30 && time !== 90) {
|
|
3986
|
-
throw new
|
|
3984
|
+
throw new socketUrl.InputError('The time filter must either be 7, 30 or 90');
|
|
3987
3985
|
}
|
|
3988
3986
|
let showHelp = cli.flags['help'];
|
|
3989
3987
|
if (scope === 'repo' && !repo) {
|
|
@@ -4004,7 +4002,7 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
4004
4002
|
}
|
|
4005
4003
|
const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
|
|
4006
4004
|
async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath) {
|
|
4007
|
-
const socketSdk = await
|
|
4005
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
4008
4006
|
const result = await handleApiCall(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
|
|
4009
4007
|
if (result.success === false) {
|
|
4010
4008
|
return handleUnsuccessfulApiResponse('getOrgAnalytics', result, spinner);
|
|
@@ -4117,7 +4115,7 @@ const formatData = (data, scope) => {
|
|
|
4117
4115
|
};
|
|
4118
4116
|
};
|
|
4119
4117
|
async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, filePath) {
|
|
4120
|
-
const socketSdk = await
|
|
4118
|
+
const socketSdk = await socketUrl.setupSdk(apiKey);
|
|
4121
4119
|
const result = await handleApiCall(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
|
|
4122
4120
|
if (result.success === false) {
|
|
4123
4121
|
return handleUnsuccessfulApiResponse('getRepoAnalytics', result, spinner);
|
|
@@ -4205,9 +4203,9 @@ const get = {
|
|
|
4205
4203
|
const name = `${parentName} get`;
|
|
4206
4204
|
const input = setupCommand$1(name, get.description, argv, importMeta);
|
|
4207
4205
|
if (input) {
|
|
4208
|
-
const apiKey =
|
|
4206
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
4209
4207
|
if (!apiKey) {
|
|
4210
|
-
throw new
|
|
4208
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
4211
4209
|
}
|
|
4212
4210
|
const spinnerText = 'Getting diff scan... \n';
|
|
4213
4211
|
const spinner$1 = new spinner.Spinner({
|
|
@@ -4257,7 +4255,7 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
4257
4255
|
$ ${name} <org slug> --before=<before> --after=<after>
|
|
4258
4256
|
|
|
4259
4257
|
Options
|
|
4260
|
-
${
|
|
4258
|
+
${getFlagListOutput(flags, 6)}
|
|
4261
4259
|
|
|
4262
4260
|
Examples
|
|
4263
4261
|
$ ${name} FakeCorp --before=aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 --after=aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
|
|
@@ -4348,7 +4346,6 @@ const diffScan = {
|
|
|
4348
4346
|
}
|
|
4349
4347
|
};
|
|
4350
4348
|
|
|
4351
|
-
// @ts-ignore
|
|
4352
4349
|
const threatFeed = {
|
|
4353
4350
|
description: 'Look up the threat feed',
|
|
4354
4351
|
async run(argv, importMeta, {
|
|
@@ -4357,9 +4354,9 @@ const threatFeed = {
|
|
|
4357
4354
|
const name = `${parentName} threat-feed`;
|
|
4358
4355
|
const input = setupCommand(name, threatFeed.description, argv, importMeta);
|
|
4359
4356
|
{
|
|
4360
|
-
const apiKey =
|
|
4357
|
+
const apiKey = socketUrl.getDefaultToken();
|
|
4361
4358
|
if (!apiKey) {
|
|
4362
|
-
throw new
|
|
4359
|
+
throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
|
|
4363
4360
|
}
|
|
4364
4361
|
const spinner$1 = new spinner.Spinner({
|
|
4365
4362
|
text: 'Looking up the threat feed'
|
|
@@ -4408,7 +4405,7 @@ function setupCommand(name, description, argv, importMeta) {
|
|
|
4408
4405
|
$ ${name}
|
|
4409
4406
|
|
|
4410
4407
|
Options
|
|
4411
|
-
${
|
|
4408
|
+
${getFlagListOutput(flags, 6)}
|
|
4412
4409
|
|
|
4413
4410
|
Examples
|
|
4414
4411
|
$ ${name}
|
|
@@ -4484,7 +4481,7 @@ async function fetchThreatFeed({
|
|
|
4484
4481
|
data: formattedOutput
|
|
4485
4482
|
});
|
|
4486
4483
|
screen.render();
|
|
4487
|
-
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
4484
|
+
screen.key(['escape', 'q', 'C-c'], () => process$1.exit(0));
|
|
4488
4485
|
}
|
|
4489
4486
|
const formatResults = data => {
|
|
4490
4487
|
return data.map(d => {
|
|
@@ -4553,7 +4550,7 @@ void (async () => {
|
|
|
4553
4550
|
argv: ['report', 'create', '--view', '--strict']
|
|
4554
4551
|
}
|
|
4555
4552
|
},
|
|
4556
|
-
argv: process.argv.slice(2),
|
|
4553
|
+
argv: process$1.argv.slice(2),
|
|
4557
4554
|
name: 'socket',
|
|
4558
4555
|
importMeta: {
|
|
4559
4556
|
url: `${require$$0.pathToFileURL(__filename)}`
|
|
@@ -4563,10 +4560,10 @@ void (async () => {
|
|
|
4563
4560
|
let errorBody;
|
|
4564
4561
|
let errorTitle;
|
|
4565
4562
|
let errorMessage = '';
|
|
4566
|
-
if (err instanceof
|
|
4563
|
+
if (err instanceof socketUrl.AuthError) {
|
|
4567
4564
|
errorTitle = 'Authentication error';
|
|
4568
4565
|
errorMessage = err.message;
|
|
4569
|
-
} else if (err instanceof
|
|
4566
|
+
} else if (err instanceof socketUrl.InputError) {
|
|
4570
4567
|
errorTitle = 'Invalid input';
|
|
4571
4568
|
errorMessage = err.message;
|
|
4572
4569
|
errorBody = err.body;
|
|
@@ -4577,10 +4574,10 @@ void (async () => {
|
|
|
4577
4574
|
} else {
|
|
4578
4575
|
errorTitle = 'Unexpected error with no details';
|
|
4579
4576
|
}
|
|
4580
|
-
console.error(`${
|
|
4577
|
+
console.error(`${pathResolve.logSymbols.error} ${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`);
|
|
4581
4578
|
if (errorBody) {
|
|
4582
4579
|
console.error(`\n${errorBody}`);
|
|
4583
4580
|
}
|
|
4584
|
-
process.exit(1);
|
|
4581
|
+
process$1.exit(1);
|
|
4585
4582
|
}
|
|
4586
4583
|
})();
|