@socketsecurity/cli 0.11.1 → 0.13.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.d.ts.map +1 -1
- package/dist/cli.js +1188 -474
- package/dist/vendor.js +223 -249
- package/package.json +9 -4
package/dist/cli.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
var vendor = require('./vendor.js');
|
|
5
5
|
var require$$0 = require('node:fs');
|
|
6
6
|
var require$$1 = require('node:path');
|
|
7
|
-
var require$$2$
|
|
7
|
+
var require$$2$4 = require('node:url');
|
|
8
8
|
var require$$6 = require('pony-cause');
|
|
9
9
|
var require$$5 = require('yargs-parser');
|
|
10
10
|
var sdk = require('./sdk.js');
|
|
@@ -18,6 +18,9 @@ var require$$3$1 = require('node:readline');
|
|
|
18
18
|
var require$$0$3 = require('node:process');
|
|
19
19
|
var require$$2$1 = require('node:readline/promises');
|
|
20
20
|
var require$$2$2 = require('chalk-table');
|
|
21
|
+
var require$$1$2 = require('blessed');
|
|
22
|
+
var require$$2$3 = require('blessed-contrib');
|
|
23
|
+
var require$$0$4 = require('node:util');
|
|
21
24
|
|
|
22
25
|
var cli$1 = {};
|
|
23
26
|
|
|
@@ -27,14 +30,14 @@ var commands = {};
|
|
|
27
30
|
|
|
28
31
|
var cdxgen = {};
|
|
29
32
|
|
|
30
|
-
var _interopRequireDefault$
|
|
33
|
+
var _interopRequireDefault$r = vendor.interopRequireDefault.default;
|
|
31
34
|
Object.defineProperty(cdxgen, "__esModule", {
|
|
32
35
|
value: true
|
|
33
36
|
});
|
|
34
37
|
cdxgen.cdxgen = void 0;
|
|
35
38
|
var _nodeFs$2 = require$$0;
|
|
36
39
|
var _nodePath$4 = require$$1;
|
|
37
|
-
var _chalk$
|
|
40
|
+
var _chalk$j = _interopRequireDefault$r(vendor.source);
|
|
38
41
|
var _execa = vendor.execa;
|
|
39
42
|
var _yargsParser = require$$5;
|
|
40
43
|
const distPath$3 = __dirname;
|
|
@@ -192,7 +195,7 @@ cdxgen.cdxgen = {
|
|
|
192
195
|
}
|
|
193
196
|
const fullOutputPath = _nodePath$4.join(process.cwd(), yargv.output);
|
|
194
197
|
if ((0, _nodeFs$2.existsSync)(fullOutputPath)) {
|
|
195
|
-
console.log(_chalk$
|
|
198
|
+
console.log(_chalk$j.default.cyanBright(`${yargv.output} created!`));
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
};
|
|
@@ -246,23 +249,26 @@ flags.validationFlags = {
|
|
|
246
249
|
|
|
247
250
|
var apiHelpers = {};
|
|
248
251
|
|
|
249
|
-
var _interopRequireDefault$
|
|
252
|
+
var _interopRequireDefault$q = vendor.interopRequireDefault.default;
|
|
250
253
|
Object.defineProperty(apiHelpers, "__esModule", {
|
|
251
254
|
value: true
|
|
252
255
|
});
|
|
256
|
+
apiHelpers.handleAPIError = handleAPIError;
|
|
253
257
|
apiHelpers.handleApiCall = handleApiCall;
|
|
254
258
|
apiHelpers.handleUnsuccessfulApiResponse = handleUnsuccessfulApiResponse;
|
|
255
|
-
|
|
259
|
+
apiHelpers.queryAPI = queryAPI;
|
|
260
|
+
apiHelpers.queryOrgsAPI = queryOrgsAPI;
|
|
261
|
+
var _chalk$i = _interopRequireDefault$q(vendor.source);
|
|
256
262
|
var _ponyCause$4 = require$$6;
|
|
257
|
-
var _errors$
|
|
263
|
+
var _errors$l = sdk.errors;
|
|
258
264
|
function handleUnsuccessfulApiResponse(_name, result, spinner) {
|
|
259
265
|
const resultError = 'error' in result && result.error && typeof result.error === 'object' ? result.error : {};
|
|
260
266
|
const message = 'message' in resultError && typeof resultError.message === 'string' ? resultError.message : 'No error message returned';
|
|
261
267
|
if (result.status === 401 || result.status === 403) {
|
|
262
268
|
spinner.stop();
|
|
263
|
-
throw new _errors$
|
|
269
|
+
throw new _errors$l.AuthError(message);
|
|
264
270
|
}
|
|
265
|
-
spinner.fail(_chalk$
|
|
271
|
+
spinner.fail(_chalk$i.default.white.bgRed('API returned an error:') + ' ' + message);
|
|
266
272
|
process.exit(1);
|
|
267
273
|
}
|
|
268
274
|
async function handleApiCall(value, description) {
|
|
@@ -276,6 +282,30 @@ async function handleApiCall(value, description) {
|
|
|
276
282
|
}
|
|
277
283
|
return result;
|
|
278
284
|
}
|
|
285
|
+
async function handleAPIError(code) {
|
|
286
|
+
if (code === 400) {
|
|
287
|
+
return `One of the options passed might be incorrect.`;
|
|
288
|
+
} else if (code === 403) {
|
|
289
|
+
return `You might be trying to access an organization that is not linked to the API key you are logged in with.`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const API_V0_URL = 'https://api.socket.dev/v0';
|
|
293
|
+
async function queryOrgsAPI(path, apiKey) {
|
|
294
|
+
return await fetch(`${API_V0_URL}/orgs/${path}`, {
|
|
295
|
+
method: 'GET',
|
|
296
|
+
headers: {
|
|
297
|
+
'Authorization': 'Basic ' + btoa(`${apiKey}:${apiKey}`)
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
async function queryAPI(path, apiKey) {
|
|
302
|
+
return await fetch(`${API_V0_URL}/${path}`, {
|
|
303
|
+
method: 'GET',
|
|
304
|
+
headers: {
|
|
305
|
+
'Authorization': 'Basic ' + btoa(`${apiKey}:${apiKey}`)
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
279
309
|
|
|
280
310
|
var formatIssues = {};
|
|
281
311
|
|
|
@@ -395,32 +425,32 @@ function printFlagList(list, indent, {
|
|
|
395
425
|
});
|
|
396
426
|
}
|
|
397
427
|
|
|
398
|
-
var _interopRequireDefault$
|
|
428
|
+
var _interopRequireDefault$p = vendor.interopRequireDefault.default;
|
|
399
429
|
Object.defineProperty(info$1, "__esModule", {
|
|
400
430
|
value: true
|
|
401
431
|
});
|
|
402
432
|
info$1.info = void 0;
|
|
403
|
-
var _chalk$
|
|
404
|
-
var _meow$
|
|
405
|
-
var _ora$
|
|
406
|
-
var _flags$
|
|
407
|
-
var _apiHelpers$
|
|
433
|
+
var _chalk$h = _interopRequireDefault$p(vendor.source);
|
|
434
|
+
var _meow$o = _interopRequireDefault$p(vendor.build);
|
|
435
|
+
var _ora$k = _interopRequireDefault$p(vendor.ora);
|
|
436
|
+
var _flags$i = flags;
|
|
437
|
+
var _apiHelpers$i = apiHelpers;
|
|
408
438
|
var _chalkMarkdown$3 = sdk.chalkMarkdown;
|
|
409
|
-
var _errors$
|
|
439
|
+
var _errors$k = sdk.errors;
|
|
410
440
|
var _formatIssues$1 = formatIssues;
|
|
411
|
-
var _formatting$
|
|
441
|
+
var _formatting$l = formatting;
|
|
412
442
|
var _misc$2 = misc;
|
|
413
|
-
var _sdk$
|
|
443
|
+
var _sdk$j = sdk.sdk;
|
|
414
444
|
const info = info$1.info = {
|
|
415
445
|
description: 'Look up info regarding a package',
|
|
416
446
|
async run(argv, importMeta, {
|
|
417
447
|
parentName
|
|
418
448
|
}) {
|
|
419
449
|
const name = parentName + ' info';
|
|
420
|
-
const input = setupCommand$
|
|
450
|
+
const input = setupCommand$l(name, info.description, argv, importMeta);
|
|
421
451
|
if (input) {
|
|
422
452
|
const spinnerText = input.pkgVersion === 'latest' ? `Looking up data for the latest version of ${input.pkgName}\n` : `Looking up data for version ${input.pkgVersion} of ${input.pkgName}\n`;
|
|
423
|
-
const spinner = (0, _ora$
|
|
453
|
+
const spinner = (0, _ora$k.default)(spinnerText).start();
|
|
424
454
|
const packageData = await fetchPackageData(input.pkgName, input.pkgVersion, input, spinner);
|
|
425
455
|
if (packageData) {
|
|
426
456
|
formatPackageDataOutput(packageData, {
|
|
@@ -434,17 +464,17 @@ const info = info$1.info = {
|
|
|
434
464
|
|
|
435
465
|
// Internal functions
|
|
436
466
|
|
|
437
|
-
function setupCommand$
|
|
467
|
+
function setupCommand$l(name, description, argv, importMeta) {
|
|
438
468
|
const flags = {
|
|
439
|
-
..._flags$
|
|
440
|
-
..._flags$
|
|
469
|
+
..._flags$i.outputFlags,
|
|
470
|
+
..._flags$i.validationFlags
|
|
441
471
|
};
|
|
442
|
-
const cli = (0, _meow$
|
|
472
|
+
const cli = (0, _meow$o.default)(`
|
|
443
473
|
Usage
|
|
444
474
|
$ ${name} <name>
|
|
445
475
|
|
|
446
476
|
Options
|
|
447
|
-
${(0, _formatting$
|
|
477
|
+
${(0, _formatting$l.printFlagList)(flags, 6)}
|
|
448
478
|
|
|
449
479
|
Examples
|
|
450
480
|
$ ${name} webtorrent
|
|
@@ -462,7 +492,7 @@ function setupCommand$i(name, description, argv, importMeta) {
|
|
|
462
492
|
strict
|
|
463
493
|
} = cli.flags;
|
|
464
494
|
if (cli.input.length > 1) {
|
|
465
|
-
throw new _errors$
|
|
495
|
+
throw new _errors$k.InputError('Only one package lookup supported at once');
|
|
466
496
|
}
|
|
467
497
|
const [rawPkgName = ''] = cli.input;
|
|
468
498
|
if (!rawPkgName) {
|
|
@@ -484,14 +514,14 @@ function setupCommand$i(name, description, argv, importMeta) {
|
|
|
484
514
|
async function fetchPackageData(pkgName, pkgVersion, {
|
|
485
515
|
includeAllIssues
|
|
486
516
|
}, spinner) {
|
|
487
|
-
const socketSdk = await (0, _sdk$
|
|
488
|
-
const result = await (0, _apiHelpers$
|
|
489
|
-
const scoreResult = await (0, _apiHelpers$
|
|
517
|
+
const socketSdk = await (0, _sdk$j.setupSdk)((0, _sdk$j.getDefaultKey)() || _sdk$j.FREE_API_KEY);
|
|
518
|
+
const result = await (0, _apiHelpers$i.handleApiCall)(socketSdk.getIssuesByNPMPackage(pkgName, pkgVersion), 'looking up package');
|
|
519
|
+
const scoreResult = await (0, _apiHelpers$i.handleApiCall)(socketSdk.getScoreByNPMPackage(pkgName, pkgVersion), 'looking up package score');
|
|
490
520
|
if (result.success === false) {
|
|
491
|
-
return (0, _apiHelpers$
|
|
521
|
+
return (0, _apiHelpers$i.handleUnsuccessfulApiResponse)('getIssuesByNPMPackage', result, spinner);
|
|
492
522
|
}
|
|
493
523
|
if (scoreResult.success === false) {
|
|
494
|
-
return (0, _apiHelpers$
|
|
524
|
+
return (0, _apiHelpers$i.handleUnsuccessfulApiResponse)('getScoreByNPMPackage', scoreResult, spinner);
|
|
495
525
|
}
|
|
496
526
|
const severityCount = (0, _formatIssues$1.getSeverityCount)(result.data, includeAllIssues ? undefined : 'high');
|
|
497
527
|
return {
|
|
@@ -545,7 +575,7 @@ function formatPackageDataOutput({
|
|
|
545
575
|
}));
|
|
546
576
|
}
|
|
547
577
|
if (!outputMarkdown) {
|
|
548
|
-
console.log(_chalk$
|
|
578
|
+
console.log(_chalk$h.default.dim('\nOr rerun', _chalk$h.default.italic(name), 'using the', _chalk$h.default.italic('--json'), 'flag to get full JSON output'));
|
|
549
579
|
}
|
|
550
580
|
}
|
|
551
581
|
if (strict && (0, _misc$2.objectSome)(severityCount)) {
|
|
@@ -583,9 +613,9 @@ function formatPackageIssuesDetails(packageData, outputMarkdown) {
|
|
|
583
613
|
}
|
|
584
614
|
}
|
|
585
615
|
function formatScore(score) {
|
|
586
|
-
const error = _chalk$
|
|
587
|
-
const warning = _chalk$
|
|
588
|
-
const success = _chalk$
|
|
616
|
+
const error = _chalk$h.default.hex('#de7c7b');
|
|
617
|
+
const warning = _chalk$h.default.hex('#e59361');
|
|
618
|
+
const success = _chalk$h.default.hex('#a4cb9d');
|
|
589
619
|
if (score > 80) {
|
|
590
620
|
return `${success(score)}`;
|
|
591
621
|
} else if (score < 80 && score > 60) {
|
|
@@ -596,23 +626,23 @@ function formatScore(score) {
|
|
|
596
626
|
|
|
597
627
|
var login = {};
|
|
598
628
|
|
|
599
|
-
var _interopRequireDefault$
|
|
629
|
+
var _interopRequireDefault$o = vendor.interopRequireDefault.default;
|
|
600
630
|
Object.defineProperty(login, "__esModule", {
|
|
601
631
|
value: true
|
|
602
632
|
});
|
|
603
633
|
login.login = void 0;
|
|
604
634
|
var _prompts$1 = require$$1$1;
|
|
605
|
-
var _isInteractive = _interopRequireDefault$
|
|
606
|
-
var _meow$
|
|
607
|
-
var _ora$
|
|
608
|
-
var _terminalLink = _interopRequireDefault$
|
|
609
|
-
var _errors$
|
|
610
|
-
var _formatting$
|
|
611
|
-
var _sdk$
|
|
635
|
+
var _isInteractive = _interopRequireDefault$o(vendor.isInteractive);
|
|
636
|
+
var _meow$n = _interopRequireDefault$o(vendor.build);
|
|
637
|
+
var _ora$j = _interopRequireDefault$o(vendor.ora);
|
|
638
|
+
var _terminalLink = _interopRequireDefault$o(vendor.terminalLink);
|
|
639
|
+
var _errors$j = sdk.errors;
|
|
640
|
+
var _formatting$k = formatting;
|
|
641
|
+
var _sdk$i = sdk.sdk;
|
|
612
642
|
var _settings$1 = sdk.settings;
|
|
613
|
-
const description$
|
|
643
|
+
const description$7 = 'Socket API login';
|
|
614
644
|
login.login = {
|
|
615
|
-
description: description$
|
|
645
|
+
description: description$7,
|
|
616
646
|
run: async (argv, importMeta, {
|
|
617
647
|
parentName
|
|
618
648
|
}) => {
|
|
@@ -627,14 +657,14 @@ login.login = {
|
|
|
627
657
|
}
|
|
628
658
|
};
|
|
629
659
|
const name = `${parentName} login`;
|
|
630
|
-
const cli = (0, _meow$
|
|
660
|
+
const cli = (0, _meow$n.default)(`
|
|
631
661
|
Usage
|
|
632
662
|
$ ${name}
|
|
633
663
|
|
|
634
664
|
Logs into the Socket API by prompting for an API key
|
|
635
665
|
|
|
636
666
|
Options
|
|
637
|
-
${(0, _formatting$
|
|
667
|
+
${(0, _formatting$k.printFlagList)({
|
|
638
668
|
'api-base-url': flags['apiBaseUrl'].description,
|
|
639
669
|
'api-proxy': flags['apiProxy'].description
|
|
640
670
|
}, 8)}
|
|
@@ -643,7 +673,7 @@ login.login = {
|
|
|
643
673
|
$ ${name}
|
|
644
674
|
`, {
|
|
645
675
|
argv,
|
|
646
|
-
description: description$
|
|
676
|
+
description: description$7,
|
|
647
677
|
importMeta,
|
|
648
678
|
flags
|
|
649
679
|
});
|
|
@@ -651,22 +681,22 @@ login.login = {
|
|
|
651
681
|
cli.showHelp();
|
|
652
682
|
}
|
|
653
683
|
if (!(0, _isInteractive.default)()) {
|
|
654
|
-
throw new _errors$
|
|
684
|
+
throw new _errors$j.InputError('Cannot prompt for credentials in a non-interactive shell');
|
|
655
685
|
}
|
|
656
686
|
const apiKey = (await (0, _prompts$1.password)({
|
|
657
687
|
message: `Enter your ${(0, _terminalLink.default)('Socket.dev API key', 'https://docs.socket.dev/docs/api-keys')} (leave blank for a public key)`
|
|
658
|
-
})) || _sdk$
|
|
688
|
+
})) || _sdk$i.FREE_API_KEY;
|
|
659
689
|
let apiBaseUrl = cli.flags['apiBaseUrl'];
|
|
660
690
|
apiBaseUrl ??= (0, _settings$1.getSetting)('apiBaseUrl') ?? undefined;
|
|
661
691
|
let apiProxy = cli.flags['apiProxy'];
|
|
662
692
|
apiProxy ??= (0, _settings$1.getSetting)('apiProxy') ?? undefined;
|
|
663
|
-
const spinner = (0, _ora$
|
|
693
|
+
const spinner = (0, _ora$j.default)('Verifying API key...').start();
|
|
664
694
|
let orgs;
|
|
665
695
|
try {
|
|
666
|
-
const sdk = await (0, _sdk$
|
|
696
|
+
const sdk = await (0, _sdk$i.setupSdk)(apiKey, apiBaseUrl, apiProxy);
|
|
667
697
|
const result = await sdk.getOrganizations();
|
|
668
698
|
if (!result.success) {
|
|
669
|
-
throw new _errors$
|
|
699
|
+
throw new _errors$j.AuthError();
|
|
670
700
|
}
|
|
671
701
|
orgs = result.data;
|
|
672
702
|
spinner.succeed('API key verified\n');
|
|
@@ -715,22 +745,22 @@ login.login = {
|
|
|
715
745
|
|
|
716
746
|
var logout = {};
|
|
717
747
|
|
|
718
|
-
var _interopRequireDefault$
|
|
748
|
+
var _interopRequireDefault$n = vendor.interopRequireDefault.default;
|
|
719
749
|
Object.defineProperty(logout, "__esModule", {
|
|
720
750
|
value: true
|
|
721
751
|
});
|
|
722
752
|
logout.logout = void 0;
|
|
723
|
-
var _meow$
|
|
724
|
-
var _ora$
|
|
753
|
+
var _meow$m = _interopRequireDefault$n(vendor.build);
|
|
754
|
+
var _ora$i = _interopRequireDefault$n(vendor.ora);
|
|
725
755
|
var _settings = sdk.settings;
|
|
726
|
-
const description$
|
|
756
|
+
const description$6 = 'Socket API logout';
|
|
727
757
|
logout.logout = {
|
|
728
|
-
description: description$
|
|
758
|
+
description: description$6,
|
|
729
759
|
run: async (argv, importMeta, {
|
|
730
760
|
parentName
|
|
731
761
|
}) => {
|
|
732
762
|
const name = `${parentName} logout`;
|
|
733
|
-
const cli = (0, _meow$
|
|
763
|
+
const cli = (0, _meow$m.default)(`
|
|
734
764
|
Usage
|
|
735
765
|
$ ${name}
|
|
736
766
|
|
|
@@ -740,7 +770,7 @@ logout.logout = {
|
|
|
740
770
|
$ ${name}
|
|
741
771
|
`, {
|
|
742
772
|
argv,
|
|
743
|
-
description: description$
|
|
773
|
+
description: description$6,
|
|
744
774
|
importMeta
|
|
745
775
|
});
|
|
746
776
|
if (cli.input.length) {
|
|
@@ -750,7 +780,7 @@ logout.logout = {
|
|
|
750
780
|
(0, _settings.updateSetting)('apiBaseUrl', null);
|
|
751
781
|
(0, _settings.updateSetting)('apiProxy', null);
|
|
752
782
|
(0, _settings.updateSetting)('enforcedOrgs', null);
|
|
753
|
-
(0, _ora$
|
|
783
|
+
(0, _ora$i.default)('Successfully logged out').succeed();
|
|
754
784
|
}
|
|
755
785
|
};
|
|
756
786
|
|
|
@@ -763,9 +793,9 @@ npm.npm = void 0;
|
|
|
763
793
|
var _nodeChild_process$1 = require$$0$1;
|
|
764
794
|
var _nodePath$3 = require$$1;
|
|
765
795
|
const distPath$2 = __dirname;
|
|
766
|
-
const description$
|
|
796
|
+
const description$5 = 'npm wrapper functionality';
|
|
767
797
|
npm.npm = {
|
|
768
|
-
description: description$
|
|
798
|
+
description: description$5,
|
|
769
799
|
run: async (argv, _importMeta, _ctx) => {
|
|
770
800
|
const npmVersion = (0, _nodeChild_process$1.execSync)('npm -v').toString();
|
|
771
801
|
const wrapperPath = _nodePath$3.join(distPath$2, 'npm-cli.js');
|
|
@@ -795,9 +825,9 @@ npx.npx = void 0;
|
|
|
795
825
|
var _child_process$1 = require$$0$1;
|
|
796
826
|
var _nodePath$2 = require$$1;
|
|
797
827
|
const distPath$1 = __dirname;
|
|
798
|
-
const description$
|
|
828
|
+
const description$4 = 'npx wrapper functionality';
|
|
799
829
|
npx.npx = {
|
|
800
|
-
description: description$
|
|
830
|
+
description: description$4,
|
|
801
831
|
run: async (argv, _importMeta, _ctx) => {
|
|
802
832
|
const wrapperPath = _nodePath$2.join(distPath$1, 'npx-cli.js');
|
|
803
833
|
process.exitCode = 1;
|
|
@@ -815,32 +845,32 @@ npx.npx = {
|
|
|
815
845
|
|
|
816
846
|
var organization = {};
|
|
817
847
|
|
|
818
|
-
var _interopRequireDefault$
|
|
848
|
+
var _interopRequireDefault$m = vendor.interopRequireDefault.default;
|
|
819
849
|
Object.defineProperty(organization, "__esModule", {
|
|
820
850
|
value: true
|
|
821
851
|
});
|
|
822
852
|
organization.organizations = void 0;
|
|
823
|
-
var _chalk$
|
|
824
|
-
var _meow$
|
|
825
|
-
var _ora$
|
|
826
|
-
var _apiHelpers$
|
|
827
|
-
var _sdk$
|
|
828
|
-
var _errors$
|
|
853
|
+
var _chalk$g = _interopRequireDefault$m(vendor.source);
|
|
854
|
+
var _meow$l = _interopRequireDefault$m(vendor.build);
|
|
855
|
+
var _ora$h = _interopRequireDefault$m(vendor.ora);
|
|
856
|
+
var _apiHelpers$h = apiHelpers;
|
|
857
|
+
var _sdk$h = sdk.sdk;
|
|
858
|
+
var _errors$i = sdk.errors;
|
|
829
859
|
const organizations = organization.organizations = {
|
|
830
860
|
description: 'List organizations associated with the API key used',
|
|
831
861
|
async run(argv, importMeta, {
|
|
832
862
|
parentName
|
|
833
863
|
}) {
|
|
834
864
|
const name = `${parentName} organizations`;
|
|
835
|
-
setupCommand$
|
|
865
|
+
setupCommand$k(name, organizations.description, argv, importMeta);
|
|
836
866
|
await fetchOrganizations();
|
|
837
867
|
}
|
|
838
868
|
};
|
|
839
869
|
|
|
840
870
|
// Internal functions
|
|
841
871
|
|
|
842
|
-
function setupCommand$
|
|
843
|
-
(0, _meow$
|
|
872
|
+
function setupCommand$k(name, description, argv, importMeta) {
|
|
873
|
+
(0, _meow$l.default)(`
|
|
844
874
|
Usage
|
|
845
875
|
$ ${name}
|
|
846
876
|
`, {
|
|
@@ -850,20 +880,20 @@ function setupCommand$h(name, description, argv, importMeta) {
|
|
|
850
880
|
});
|
|
851
881
|
}
|
|
852
882
|
async function fetchOrganizations() {
|
|
853
|
-
const apiKey = (0, _sdk$
|
|
883
|
+
const apiKey = (0, _sdk$h.getDefaultKey)();
|
|
854
884
|
if (!apiKey) {
|
|
855
|
-
throw new _errors$
|
|
885
|
+
throw new _errors$i.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
856
886
|
}
|
|
857
|
-
const socketSdk = await (0, _sdk$
|
|
858
|
-
const spinner = (0, _ora$
|
|
859
|
-
const result = await (0, _apiHelpers$
|
|
887
|
+
const socketSdk = await (0, _sdk$h.setupSdk)(apiKey);
|
|
888
|
+
const spinner = (0, _ora$h.default)('Fetching organizations...').start();
|
|
889
|
+
const result = await (0, _apiHelpers$h.handleApiCall)(socketSdk.getOrganizations(), 'looking up organizations');
|
|
860
890
|
if (result.success === false) {
|
|
861
|
-
(0, _apiHelpers$
|
|
891
|
+
(0, _apiHelpers$h.handleUnsuccessfulApiResponse)('getOrganizations', result, spinner);
|
|
862
892
|
return;
|
|
863
893
|
}
|
|
864
894
|
spinner.stop();
|
|
865
895
|
const organizations = Object.values(result.data.organizations);
|
|
866
|
-
console.log(`List of organizations associated with your API key: ${_chalk$
|
|
896
|
+
console.log(`List of organizations associated with your API key: ${_chalk$g.default.italic(apiKey)}`);
|
|
867
897
|
for (const o of organizations) {
|
|
868
898
|
console.log(`
|
|
869
899
|
Name: ${o?.name}
|
|
@@ -875,32 +905,32 @@ Plan: ${o?.plan}
|
|
|
875
905
|
|
|
876
906
|
var rawNpm$1 = {};
|
|
877
907
|
|
|
878
|
-
var _interopRequireDefault$
|
|
908
|
+
var _interopRequireDefault$l = vendor.interopRequireDefault.default;
|
|
879
909
|
Object.defineProperty(rawNpm$1, "__esModule", {
|
|
880
910
|
value: true
|
|
881
911
|
});
|
|
882
912
|
rawNpm$1.rawNpm = void 0;
|
|
883
913
|
var _nodeChild_process = require$$0$1;
|
|
884
|
-
var _meow$
|
|
885
|
-
var _flags$
|
|
886
|
-
var _formatting$
|
|
914
|
+
var _meow$k = _interopRequireDefault$l(vendor.build);
|
|
915
|
+
var _flags$h = flags;
|
|
916
|
+
var _formatting$j = formatting;
|
|
887
917
|
const rawNpm = rawNpm$1.rawNpm = {
|
|
888
918
|
description: 'Temporarily disable the Socket npm wrapper',
|
|
889
919
|
async run(argv, importMeta, {
|
|
890
920
|
parentName
|
|
891
921
|
}) {
|
|
892
922
|
const name = `${parentName} raw-npm`;
|
|
893
|
-
setupCommand$
|
|
923
|
+
setupCommand$j(name, rawNpm.description, argv, importMeta);
|
|
894
924
|
}
|
|
895
925
|
};
|
|
896
|
-
function setupCommand$
|
|
897
|
-
const flags = _flags$
|
|
898
|
-
const cli = (0, _meow$
|
|
926
|
+
function setupCommand$j(name, description, argv, importMeta) {
|
|
927
|
+
const flags = _flags$h.validationFlags;
|
|
928
|
+
const cli = (0, _meow$k.default)(`
|
|
899
929
|
Usage
|
|
900
930
|
$ ${name} <npm command>
|
|
901
931
|
|
|
902
932
|
Options
|
|
903
|
-
${(0, _formatting$
|
|
933
|
+
${(0, _formatting$j.printFlagList)(flags, 6)}
|
|
904
934
|
|
|
905
935
|
Examples
|
|
906
936
|
$ ${name} install
|
|
@@ -928,32 +958,32 @@ function setupCommand$g(name, description, argv, importMeta) {
|
|
|
928
958
|
|
|
929
959
|
var rawNpx$1 = {};
|
|
930
960
|
|
|
931
|
-
var _interopRequireDefault$
|
|
961
|
+
var _interopRequireDefault$k = vendor.interopRequireDefault.default;
|
|
932
962
|
Object.defineProperty(rawNpx$1, "__esModule", {
|
|
933
963
|
value: true
|
|
934
964
|
});
|
|
935
965
|
rawNpx$1.rawNpx = void 0;
|
|
936
966
|
var _child_process = require$$0$1;
|
|
937
|
-
var _meow$
|
|
938
|
-
var _flags$
|
|
939
|
-
var _formatting$
|
|
967
|
+
var _meow$j = _interopRequireDefault$k(vendor.build);
|
|
968
|
+
var _flags$g = flags;
|
|
969
|
+
var _formatting$i = formatting;
|
|
940
970
|
const rawNpx = rawNpx$1.rawNpx = {
|
|
941
971
|
description: 'Temporarily disable the Socket npm/npx wrapper',
|
|
942
972
|
async run(argv, importMeta, {
|
|
943
973
|
parentName
|
|
944
974
|
}) {
|
|
945
975
|
const name = `${parentName} raw-npx`;
|
|
946
|
-
setupCommand$
|
|
976
|
+
setupCommand$i(name, rawNpx.description, argv, importMeta);
|
|
947
977
|
}
|
|
948
978
|
};
|
|
949
|
-
function setupCommand$
|
|
950
|
-
const flags = _flags$
|
|
951
|
-
const cli = (0, _meow$
|
|
979
|
+
function setupCommand$i(name, description, argv, importMeta) {
|
|
980
|
+
const flags = _flags$g.validationFlags;
|
|
981
|
+
const cli = (0, _meow$j.default)(`
|
|
952
982
|
Usage
|
|
953
983
|
$ ${name} <npx command>
|
|
954
984
|
|
|
955
985
|
Options
|
|
956
|
-
${(0, _formatting$
|
|
986
|
+
${(0, _formatting$i.printFlagList)(flags, 6)}
|
|
957
987
|
|
|
958
988
|
Examples
|
|
959
989
|
$ ${name} install
|
|
@@ -985,31 +1015,31 @@ var create$5 = {};
|
|
|
985
1015
|
|
|
986
1016
|
var view$3 = {};
|
|
987
1017
|
|
|
988
|
-
var _interopRequireDefault$
|
|
1018
|
+
var _interopRequireDefault$j = vendor.interopRequireDefault.default;
|
|
989
1019
|
Object.defineProperty(view$3, "__esModule", {
|
|
990
1020
|
value: true
|
|
991
1021
|
});
|
|
992
1022
|
view$3.fetchReportData = fetchReportData;
|
|
993
1023
|
view$3.formatReportDataOutput = formatReportDataOutput;
|
|
994
1024
|
view$3.view = void 0;
|
|
995
|
-
var _chalk$
|
|
996
|
-
var _meow$
|
|
997
|
-
var _ora$
|
|
1025
|
+
var _chalk$f = _interopRequireDefault$j(vendor.source);
|
|
1026
|
+
var _meow$i = _interopRequireDefault$j(vendor.build);
|
|
1027
|
+
var _ora$g = _interopRequireDefault$j(vendor.ora);
|
|
998
1028
|
var _ponyCause$3 = require$$6;
|
|
999
|
-
var _flags$
|
|
1000
|
-
var _apiHelpers$
|
|
1029
|
+
var _flags$f = flags;
|
|
1030
|
+
var _apiHelpers$g = apiHelpers;
|
|
1001
1031
|
var _chalkMarkdown$2 = sdk.chalkMarkdown;
|
|
1002
|
-
var _errors$
|
|
1032
|
+
var _errors$h = sdk.errors;
|
|
1003
1033
|
var _formatIssues = formatIssues;
|
|
1004
|
-
var _formatting$
|
|
1005
|
-
var _sdk$
|
|
1034
|
+
var _formatting$h = formatting;
|
|
1035
|
+
var _sdk$g = sdk.sdk;
|
|
1006
1036
|
const view$2 = view$3.view = {
|
|
1007
1037
|
description: 'View a project report',
|
|
1008
1038
|
async run(argv, importMeta, {
|
|
1009
1039
|
parentName
|
|
1010
1040
|
}) {
|
|
1011
1041
|
const name = `${parentName} view`;
|
|
1012
|
-
const input = setupCommand$
|
|
1042
|
+
const input = setupCommand$h(name, view$2.description, argv, importMeta);
|
|
1013
1043
|
const result = input ? await fetchReportData(input.reportId, input) : undefined;
|
|
1014
1044
|
if (result) {
|
|
1015
1045
|
formatReportDataOutput(result, {
|
|
@@ -1022,17 +1052,17 @@ const view$2 = view$3.view = {
|
|
|
1022
1052
|
|
|
1023
1053
|
// Internal functions
|
|
1024
1054
|
|
|
1025
|
-
function setupCommand$
|
|
1055
|
+
function setupCommand$h(name, description, argv, importMeta) {
|
|
1026
1056
|
const flags = {
|
|
1027
|
-
..._flags$
|
|
1028
|
-
..._flags$
|
|
1057
|
+
..._flags$f.outputFlags,
|
|
1058
|
+
..._flags$f.validationFlags
|
|
1029
1059
|
};
|
|
1030
|
-
const cli = (0, _meow$
|
|
1060
|
+
const cli = (0, _meow$i.default)(`
|
|
1031
1061
|
Usage
|
|
1032
1062
|
$ ${name} <report-identifier>
|
|
1033
1063
|
|
|
1034
1064
|
Options
|
|
1035
|
-
${(0, _formatting$
|
|
1065
|
+
${(0, _formatting$h.printFlagList)(flags, 6)}
|
|
1036
1066
|
|
|
1037
1067
|
Examples
|
|
1038
1068
|
$ ${name} QXU8PmK7LfH608RAwfIKdbcHgwEd_ZeWJ9QEGv05FJUQ
|
|
@@ -1060,7 +1090,7 @@ function setupCommand$e(name, description, argv, importMeta) {
|
|
|
1060
1090
|
// Validate the input
|
|
1061
1091
|
|
|
1062
1092
|
if (extraInput.length) {
|
|
1063
|
-
throw new _errors$
|
|
1093
|
+
throw new _errors$h.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
|
|
1064
1094
|
}
|
|
1065
1095
|
return {
|
|
1066
1096
|
includeAllIssues,
|
|
@@ -1077,12 +1107,12 @@ async function fetchReportData(reportId, {
|
|
|
1077
1107
|
}) {
|
|
1078
1108
|
// Do the API call
|
|
1079
1109
|
|
|
1080
|
-
const socketSdk = await (0, _sdk$
|
|
1081
|
-
const spinner = (0, _ora$
|
|
1110
|
+
const socketSdk = await (0, _sdk$g.setupSdk)();
|
|
1111
|
+
const spinner = (0, _ora$g.default)(`Fetching report with ID ${reportId} (this could take a while)`).start();
|
|
1082
1112
|
let result;
|
|
1083
1113
|
for (let retry = 1; !result; ++retry) {
|
|
1084
1114
|
try {
|
|
1085
|
-
result = await (0, _apiHelpers$
|
|
1115
|
+
result = await (0, _apiHelpers$g.handleApiCall)(socketSdk.getReport(reportId), 'fetching report');
|
|
1086
1116
|
} catch (err) {
|
|
1087
1117
|
if (retry >= MAX_TIMEOUT_RETRY || !(err instanceof _ponyCause$3.ErrorWithCause) || err.cause?.cause?.response?.statusCode !== 524) {
|
|
1088
1118
|
throw err;
|
|
@@ -1090,7 +1120,7 @@ async function fetchReportData(reportId, {
|
|
|
1090
1120
|
}
|
|
1091
1121
|
}
|
|
1092
1122
|
if (result.success === false) {
|
|
1093
|
-
return (0, _apiHelpers$
|
|
1123
|
+
return (0, _apiHelpers$g.handleUnsuccessfulApiResponse)('getReport', result, spinner);
|
|
1094
1124
|
}
|
|
1095
1125
|
|
|
1096
1126
|
// Conclude the status of the API call
|
|
@@ -1125,7 +1155,7 @@ function formatReportDataOutput(data, {
|
|
|
1125
1155
|
fallbackToUrl: true
|
|
1126
1156
|
}));
|
|
1127
1157
|
if (!outputMarkdown) {
|
|
1128
|
-
console.log(_chalk$
|
|
1158
|
+
console.log(_chalk$f.default.dim('\nOr rerun', _chalk$f.default.italic(name), 'using the', _chalk$f.default.italic('--json'), 'flag to get full JSON output'));
|
|
1129
1159
|
}
|
|
1130
1160
|
}
|
|
1131
1161
|
if (strict && data.healthy === false) {
|
|
@@ -1133,7 +1163,7 @@ function formatReportDataOutput(data, {
|
|
|
1133
1163
|
}
|
|
1134
1164
|
}
|
|
1135
1165
|
|
|
1136
|
-
var _interopRequireDefault$
|
|
1166
|
+
var _interopRequireDefault$i = vendor.interopRequireDefault.default;
|
|
1137
1167
|
Object.defineProperty(create$5, "__esModule", {
|
|
1138
1168
|
value: true
|
|
1139
1169
|
});
|
|
@@ -1141,25 +1171,25 @@ create$5.create = void 0;
|
|
|
1141
1171
|
var _nodePath$1 = require$$1;
|
|
1142
1172
|
var _betterAjvErrors = require$$2;
|
|
1143
1173
|
var _config = require$$3;
|
|
1144
|
-
var _meow$
|
|
1145
|
-
var _ora$
|
|
1174
|
+
var _meow$h = _interopRequireDefault$i(vendor.build);
|
|
1175
|
+
var _ora$f = _interopRequireDefault$i(vendor.ora);
|
|
1146
1176
|
var _ponyCause$2 = require$$6;
|
|
1147
1177
|
var _view$2 = view$3;
|
|
1148
|
-
var _flags$
|
|
1149
|
-
var _apiHelpers$
|
|
1178
|
+
var _flags$e = flags;
|
|
1179
|
+
var _apiHelpers$f = apiHelpers;
|
|
1150
1180
|
var _chalkMarkdown$1 = sdk.chalkMarkdown;
|
|
1151
|
-
var _errors$
|
|
1152
|
-
var _formatting$
|
|
1181
|
+
var _errors$g = sdk.errors;
|
|
1182
|
+
var _formatting$g = formatting;
|
|
1153
1183
|
var _misc$1 = misc;
|
|
1154
1184
|
var _pathResolve$1 = pathResolve.pathResolve;
|
|
1155
|
-
var _sdk$
|
|
1185
|
+
var _sdk$f = sdk.sdk;
|
|
1156
1186
|
const create$4 = create$5.create = {
|
|
1157
1187
|
description: 'Create a project report',
|
|
1158
1188
|
async run(argv, importMeta, {
|
|
1159
1189
|
parentName
|
|
1160
1190
|
}) {
|
|
1161
1191
|
const name = `${parentName} create`;
|
|
1162
|
-
const input = await setupCommand$
|
|
1192
|
+
const input = await setupCommand$g(name, create$4.description, argv, importMeta);
|
|
1163
1193
|
if (input) {
|
|
1164
1194
|
const {
|
|
1165
1195
|
config,
|
|
@@ -1207,10 +1237,10 @@ const create$4 = create$5.create = {
|
|
|
1207
1237
|
|
|
1208
1238
|
// Internal functions
|
|
1209
1239
|
|
|
1210
|
-
async function setupCommand$
|
|
1240
|
+
async function setupCommand$g(name, description, argv, importMeta) {
|
|
1211
1241
|
const flags = {
|
|
1212
|
-
..._flags$
|
|
1213
|
-
..._flags$
|
|
1242
|
+
..._flags$e.outputFlags,
|
|
1243
|
+
..._flags$e.validationFlags,
|
|
1214
1244
|
debug: {
|
|
1215
1245
|
type: 'boolean',
|
|
1216
1246
|
shortFlag: 'd',
|
|
@@ -1229,7 +1259,7 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1229
1259
|
description: 'Will wait for and return the created report'
|
|
1230
1260
|
}
|
|
1231
1261
|
};
|
|
1232
|
-
const cli = (0, _meow$
|
|
1262
|
+
const cli = (0, _meow$h.default)(`
|
|
1233
1263
|
Usage
|
|
1234
1264
|
$ ${name} <paths-to-package-folders-and-files>
|
|
1235
1265
|
|
|
@@ -1243,7 +1273,7 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1243
1273
|
default ignores from the "ignore-by-default" module.
|
|
1244
1274
|
|
|
1245
1275
|
Options
|
|
1246
|
-
${(0, _formatting$
|
|
1276
|
+
${(0, _formatting$g.printFlagList)({
|
|
1247
1277
|
all: 'Include all issues',
|
|
1248
1278
|
debug: 'Output debug information',
|
|
1249
1279
|
'dry-run': 'Only output what will be done without actually doing it',
|
|
@@ -1290,16 +1320,16 @@ async function setupCommand$d(name, description, argv, importMeta) {
|
|
|
1290
1320
|
errors: cause.validationErrors,
|
|
1291
1321
|
schema: cause.schema
|
|
1292
1322
|
});
|
|
1293
|
-
throw new _errors$
|
|
1323
|
+
throw new _errors$g.InputError('The socket.yml config is not valid', betterErrors.map(err => `[${err.path}] ${err.message}.${err.suggestion ? err.suggestion : ''}`).join('\n'));
|
|
1294
1324
|
} else {
|
|
1295
1325
|
throw new _ponyCause$2.ErrorWithCause('Failed to read socket.yml config', {
|
|
1296
1326
|
cause
|
|
1297
1327
|
});
|
|
1298
1328
|
}
|
|
1299
1329
|
});
|
|
1300
|
-
const socketSdk = await (0, _sdk$
|
|
1330
|
+
const socketSdk = await (0, _sdk$f.setupSdk)();
|
|
1301
1331
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
1302
|
-
if (!res.success) (0, _apiHelpers$
|
|
1332
|
+
if (!res.success) (0, _apiHelpers$f.handleUnsuccessfulApiResponse)('getReportSupportedFiles', res, (0, _ora$f.default)());
|
|
1303
1333
|
return res.data;
|
|
1304
1334
|
}).catch(cause => {
|
|
1305
1335
|
throw new _ponyCause$2.ErrorWithCause('Failed getting supported files for report', {
|
|
@@ -1330,12 +1360,12 @@ async function createReport(packagePaths, {
|
|
|
1330
1360
|
if (dryRun) {
|
|
1331
1361
|
return;
|
|
1332
1362
|
}
|
|
1333
|
-
const socketSdk = await (0, _sdk$
|
|
1334
|
-
const spinner = (0, _ora$
|
|
1363
|
+
const socketSdk = await (0, _sdk$f.setupSdk)();
|
|
1364
|
+
const spinner = (0, _ora$f.default)(`Creating report with ${packagePaths.length} package files`).start();
|
|
1335
1365
|
const apiCall = socketSdk.createReportFromFilePaths(packagePaths, cwd, config?.issueRules);
|
|
1336
|
-
const result = await (0, _apiHelpers$
|
|
1366
|
+
const result = await (0, _apiHelpers$f.handleApiCall)(apiCall, 'creating report');
|
|
1337
1367
|
if (result.success === false) {
|
|
1338
|
-
return (0, _apiHelpers$
|
|
1368
|
+
return (0, _apiHelpers$f.handleUnsuccessfulApiResponse)('createReport', result, spinner);
|
|
1339
1369
|
}
|
|
1340
1370
|
|
|
1341
1371
|
// Conclude the status of the API call
|
|
@@ -1359,13 +1389,13 @@ function formatReportCreationOutput(data, {
|
|
|
1359
1389
|
|
|
1360
1390
|
var meowWithSubcommands$1 = {};
|
|
1361
1391
|
|
|
1362
|
-
var _interopRequireDefault$
|
|
1392
|
+
var _interopRequireDefault$h = vendor.interopRequireDefault.default;
|
|
1363
1393
|
Object.defineProperty(meowWithSubcommands$1, "__esModule", {
|
|
1364
1394
|
value: true
|
|
1365
1395
|
});
|
|
1366
1396
|
meowWithSubcommands$1.meowWithSubcommands = meowWithSubcommands;
|
|
1367
|
-
var _meow$
|
|
1368
|
-
var _formatting$
|
|
1397
|
+
var _meow$g = _interopRequireDefault$h(vendor.build);
|
|
1398
|
+
var _formatting$f = formatting;
|
|
1369
1399
|
function sortKeys(object) {
|
|
1370
1400
|
return Object.fromEntries(Object.keys(object).sort().map(k => [k, object[k]]));
|
|
1371
1401
|
}
|
|
@@ -1398,18 +1428,18 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1398
1428
|
}
|
|
1399
1429
|
|
|
1400
1430
|
// ...else we provide basic instructions and help
|
|
1401
|
-
const cli = (0, _meow$
|
|
1431
|
+
const cli = (0, _meow$g.default)(`
|
|
1402
1432
|
Usage
|
|
1403
1433
|
$ ${name} <command>
|
|
1404
1434
|
|
|
1405
1435
|
Commands
|
|
1406
|
-
${(0, _formatting$
|
|
1436
|
+
${(0, _formatting$f.printHelpList)({
|
|
1407
1437
|
...sortKeys(subcommands),
|
|
1408
1438
|
...sortKeys(aliases)
|
|
1409
1439
|
}, 6)}
|
|
1410
1440
|
|
|
1411
1441
|
Options
|
|
1412
|
-
${(0, _formatting$
|
|
1442
|
+
${(0, _formatting$f.printFlagList)({}, 6)}
|
|
1413
1443
|
|
|
1414
1444
|
Examples
|
|
1415
1445
|
$ ${name} --help
|
|
@@ -1427,19 +1457,19 @@ Object.defineProperty(report, "__esModule", {
|
|
|
1427
1457
|
report.report = void 0;
|
|
1428
1458
|
var _create$2 = create$5;
|
|
1429
1459
|
var _view$1 = view$3;
|
|
1430
|
-
var _meowWithSubcommands$
|
|
1431
|
-
const description$
|
|
1460
|
+
var _meowWithSubcommands$4 = meowWithSubcommands$1;
|
|
1461
|
+
const description$3 = '[Deprecated] Project report related commands';
|
|
1432
1462
|
report.report = {
|
|
1433
|
-
description: description$
|
|
1463
|
+
description: description$3,
|
|
1434
1464
|
run: async (argv, importMeta, {
|
|
1435
1465
|
parentName
|
|
1436
1466
|
}) => {
|
|
1437
|
-
await (0, _meowWithSubcommands$
|
|
1467
|
+
await (0, _meowWithSubcommands$4.meowWithSubcommands)({
|
|
1438
1468
|
create: _create$2.create,
|
|
1439
1469
|
view: _view$1.view
|
|
1440
1470
|
}, {
|
|
1441
1471
|
argv,
|
|
1442
|
-
description: description$
|
|
1472
|
+
description: description$3,
|
|
1443
1473
|
importMeta,
|
|
1444
1474
|
name: parentName + ' report'
|
|
1445
1475
|
});
|
|
@@ -1448,7 +1478,7 @@ report.report = {
|
|
|
1448
1478
|
|
|
1449
1479
|
var wrapper$1 = {};
|
|
1450
1480
|
|
|
1451
|
-
var _interopRequireDefault$
|
|
1481
|
+
var _interopRequireDefault$g = vendor.interopRequireDefault.default;
|
|
1452
1482
|
Object.defineProperty(wrapper$1, "__esModule", {
|
|
1453
1483
|
value: true
|
|
1454
1484
|
});
|
|
@@ -1456,9 +1486,9 @@ wrapper$1.wrapper = void 0;
|
|
|
1456
1486
|
var _nodeFs$1 = require$$0;
|
|
1457
1487
|
var _nodeOs = require$$0$2;
|
|
1458
1488
|
var _nodeReadline = require$$3$1;
|
|
1459
|
-
var _meow$
|
|
1460
|
-
var _flags$
|
|
1461
|
-
var _formatting$
|
|
1489
|
+
var _meow$f = _interopRequireDefault$g(vendor.build);
|
|
1490
|
+
var _flags$d = flags;
|
|
1491
|
+
var _formatting$e = formatting;
|
|
1462
1492
|
const BASH_FILE = `${_nodeOs.homedir()}/.bashrc`;
|
|
1463
1493
|
const ZSH_BASH_FILE = `${_nodeOs.homedir()}/.zshrc`;
|
|
1464
1494
|
const wrapper = wrapper$1.wrapper = {
|
|
@@ -1467,17 +1497,17 @@ const wrapper = wrapper$1.wrapper = {
|
|
|
1467
1497
|
parentName
|
|
1468
1498
|
}) {
|
|
1469
1499
|
const name = `${parentName} wrapper`;
|
|
1470
|
-
setupCommand$
|
|
1500
|
+
setupCommand$f(name, wrapper.description, argv, importMeta);
|
|
1471
1501
|
}
|
|
1472
1502
|
};
|
|
1473
|
-
function setupCommand$
|
|
1474
|
-
const flags = _flags$
|
|
1475
|
-
const cli = (0, _meow$
|
|
1503
|
+
function setupCommand$f(name, description, argv, importMeta) {
|
|
1504
|
+
const flags = _flags$d.commandFlags;
|
|
1505
|
+
const cli = (0, _meow$f.default)(`
|
|
1476
1506
|
Usage
|
|
1477
1507
|
$ ${name} <flag>
|
|
1478
1508
|
|
|
1479
1509
|
Options
|
|
1480
|
-
${(0, _formatting$
|
|
1510
|
+
${(0, _formatting$e.printFlagList)(flags, 6)}
|
|
1481
1511
|
|
|
1482
1512
|
Examples
|
|
1483
1513
|
$ ${name} --enable
|
|
@@ -1607,38 +1637,38 @@ var scan = {};
|
|
|
1607
1637
|
|
|
1608
1638
|
var create$3 = {};
|
|
1609
1639
|
|
|
1610
|
-
var _interopRequireDefault$
|
|
1640
|
+
var _interopRequireDefault$f = vendor.interopRequireDefault.default;
|
|
1611
1641
|
Object.defineProperty(create$3, "__esModule", {
|
|
1612
1642
|
value: true
|
|
1613
1643
|
});
|
|
1614
1644
|
create$3.create = void 0;
|
|
1615
1645
|
var _nodeProcess = require$$0$3;
|
|
1616
1646
|
var _promises = require$$2$1;
|
|
1617
|
-
var _chalk$
|
|
1618
|
-
var _meow$
|
|
1619
|
-
var _open = _interopRequireDefault$
|
|
1620
|
-
var _ora$
|
|
1647
|
+
var _chalk$e = _interopRequireDefault$f(vendor.source);
|
|
1648
|
+
var _meow$e = _interopRequireDefault$f(vendor.build);
|
|
1649
|
+
var _open = _interopRequireDefault$f(vendor.open);
|
|
1650
|
+
var _ora$e = _interopRequireDefault$f(vendor.ora);
|
|
1621
1651
|
var _ponyCause$1 = require$$6;
|
|
1622
|
-
var _apiHelpers$
|
|
1623
|
-
var _formatting$
|
|
1652
|
+
var _apiHelpers$e = apiHelpers;
|
|
1653
|
+
var _formatting$d = formatting;
|
|
1624
1654
|
var _misc = misc;
|
|
1625
1655
|
var _pathResolve = pathResolve.pathResolve;
|
|
1626
|
-
var _sdk$
|
|
1627
|
-
var _errors$
|
|
1656
|
+
var _sdk$e = sdk.sdk;
|
|
1657
|
+
var _errors$f = sdk.errors;
|
|
1628
1658
|
const create$2 = create$3.create = {
|
|
1629
1659
|
description: 'Create a scan',
|
|
1630
1660
|
async run(argv, importMeta, {
|
|
1631
1661
|
parentName
|
|
1632
1662
|
}) {
|
|
1633
1663
|
const name = `${parentName} create`;
|
|
1634
|
-
const input = await setupCommand$
|
|
1664
|
+
const input = await setupCommand$e(name, create$2.description, argv, importMeta);
|
|
1635
1665
|
if (input) {
|
|
1636
|
-
const apiKey = (0, _sdk$
|
|
1666
|
+
const apiKey = (0, _sdk$e.getDefaultKey)();
|
|
1637
1667
|
if (!apiKey) {
|
|
1638
|
-
throw new _errors$
|
|
1668
|
+
throw new _errors$f.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1639
1669
|
}
|
|
1640
1670
|
const spinnerText = 'Creating a scan... \n';
|
|
1641
|
-
const spinner = (0, _ora$
|
|
1671
|
+
const spinner = (0, _ora$e.default)(spinnerText).start();
|
|
1642
1672
|
await createFullScan(input, spinner, apiKey);
|
|
1643
1673
|
}
|
|
1644
1674
|
}
|
|
@@ -1701,16 +1731,16 @@ const createFullScanFlags = {
|
|
|
1701
1731
|
|
|
1702
1732
|
// Internal functions
|
|
1703
1733
|
|
|
1704
|
-
async function setupCommand$
|
|
1734
|
+
async function setupCommand$e(name, description, argv, importMeta) {
|
|
1705
1735
|
const flags = {
|
|
1706
1736
|
...createFullScanFlags
|
|
1707
1737
|
};
|
|
1708
|
-
const cli = (0, _meow$
|
|
1738
|
+
const cli = (0, _meow$e.default)(`
|
|
1709
1739
|
Usage
|
|
1710
1740
|
$ ${name} [...options]
|
|
1711
1741
|
|
|
1712
1742
|
Options
|
|
1713
|
-
${(0, _formatting$
|
|
1743
|
+
${(0, _formatting$d.printFlagList)(flags, 6)}
|
|
1714
1744
|
|
|
1715
1745
|
Examples
|
|
1716
1746
|
$ ${name} --org=FakeOrg --repo=test-repo --branch=main ./package.json
|
|
@@ -1739,9 +1769,9 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1739
1769
|
0: orgSlug = ''
|
|
1740
1770
|
} = cli.input;
|
|
1741
1771
|
const cwd = process.cwd();
|
|
1742
|
-
const socketSdk = await (0, _sdk$
|
|
1772
|
+
const socketSdk = await (0, _sdk$e.setupSdk)();
|
|
1743
1773
|
const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
|
|
1744
|
-
if (!res.success) (0, _apiHelpers$
|
|
1774
|
+
if (!res.success) (0, _apiHelpers$e.handleUnsuccessfulApiResponse)('getReportSupportedFiles', res, (0, _ora$e.default)());
|
|
1745
1775
|
return res.data;
|
|
1746
1776
|
}).catch( /** @type {(cause: Error) => never} */
|
|
1747
1777
|
cause => {
|
|
@@ -1752,7 +1782,7 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1752
1782
|
const debugLog = (0, _misc.createDebugLogger)(false);
|
|
1753
1783
|
const packagePaths = await (0, _pathResolve.getPackageFilesFullScans)(cwd, cli.input, supportedFiles, debugLog);
|
|
1754
1784
|
if (!repoName || !branchName || !packagePaths.length) {
|
|
1755
|
-
console.error(`${_chalk$
|
|
1785
|
+
console.error(`${_chalk$e.default.bgRed('Input error')}: Please provide the required fields:\n
|
|
1756
1786
|
- Repository name using --repo,\n
|
|
1757
1787
|
- Branch name using --branch\n
|
|
1758
1788
|
- At least one file path (e.g. ./package.json).\n`);
|
|
@@ -1774,7 +1804,7 @@ async function setupCommand$b(name, description, argv, importMeta) {
|
|
|
1774
1804
|
};
|
|
1775
1805
|
}
|
|
1776
1806
|
async function createFullScan(input, spinner, apiKey) {
|
|
1777
|
-
const socketSdk = await (0, _sdk$
|
|
1807
|
+
const socketSdk = await (0, _sdk$e.setupSdk)(apiKey);
|
|
1778
1808
|
const {
|
|
1779
1809
|
orgSlug,
|
|
1780
1810
|
repoName,
|
|
@@ -1785,7 +1815,7 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1785
1815
|
tmp,
|
|
1786
1816
|
packagePaths
|
|
1787
1817
|
} = input;
|
|
1788
|
-
const result = await (0, _apiHelpers$
|
|
1818
|
+
const result = await (0, _apiHelpers$e.handleApiCall)(socketSdk.createOrgFullScan(orgSlug, {
|
|
1789
1819
|
repo: repoName,
|
|
1790
1820
|
branch: branchName,
|
|
1791
1821
|
commit_message: commitMessage,
|
|
@@ -1794,12 +1824,12 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1794
1824
|
tmp
|
|
1795
1825
|
}, packagePaths), 'Creating scan');
|
|
1796
1826
|
if (!result.success) {
|
|
1797
|
-
(0, _apiHelpers$
|
|
1827
|
+
(0, _apiHelpers$e.handleUnsuccessfulApiResponse)('CreateOrgFullScan', result, spinner);
|
|
1798
1828
|
return;
|
|
1799
1829
|
}
|
|
1800
1830
|
spinner.stop();
|
|
1801
1831
|
console.log('\n✅ Scan created successfully\n');
|
|
1802
|
-
const link = _chalk$
|
|
1832
|
+
const link = _chalk$e.default.hex('#00FFFF').underline(`${result.data.html_report_url}`);
|
|
1803
1833
|
console.log(`Available at: ${link}\n`);
|
|
1804
1834
|
const rl = _promises.createInterface({
|
|
1805
1835
|
input: _nodeProcess.stdin,
|
|
@@ -1814,33 +1844,33 @@ async function createFullScan(input, spinner, apiKey) {
|
|
|
1814
1844
|
|
|
1815
1845
|
var _delete$3 = {};
|
|
1816
1846
|
|
|
1817
|
-
var _interopRequireDefault$
|
|
1847
|
+
var _interopRequireDefault$e = vendor.interopRequireDefault.default;
|
|
1818
1848
|
Object.defineProperty(_delete$3, "__esModule", {
|
|
1819
1849
|
value: true
|
|
1820
1850
|
});
|
|
1821
1851
|
_delete$3.del = void 0;
|
|
1822
|
-
var _chalk$
|
|
1823
|
-
var _meow$
|
|
1824
|
-
var _ora$
|
|
1825
|
-
var _flags$
|
|
1826
|
-
var _apiHelpers$
|
|
1827
|
-
var _formatting$
|
|
1828
|
-
var _sdk$
|
|
1829
|
-
var _errors$
|
|
1852
|
+
var _chalk$d = _interopRequireDefault$e(vendor.source);
|
|
1853
|
+
var _meow$d = _interopRequireDefault$e(vendor.build);
|
|
1854
|
+
var _ora$d = _interopRequireDefault$e(vendor.ora);
|
|
1855
|
+
var _flags$c = flags;
|
|
1856
|
+
var _apiHelpers$d = apiHelpers;
|
|
1857
|
+
var _formatting$c = formatting;
|
|
1858
|
+
var _sdk$d = sdk.sdk;
|
|
1859
|
+
var _errors$e = sdk.errors;
|
|
1830
1860
|
const del$1 = _delete$3.del = {
|
|
1831
1861
|
description: 'Delete a scan',
|
|
1832
1862
|
async run(argv, importMeta, {
|
|
1833
1863
|
parentName
|
|
1834
1864
|
}) {
|
|
1835
1865
|
const name = `${parentName} del`;
|
|
1836
|
-
const input = setupCommand$
|
|
1866
|
+
const input = setupCommand$d(name, del$1.description, argv, importMeta);
|
|
1837
1867
|
if (input) {
|
|
1838
|
-
const apiKey = (0, _sdk$
|
|
1868
|
+
const apiKey = (0, _sdk$d.getDefaultKey)();
|
|
1839
1869
|
if (!apiKey) {
|
|
1840
|
-
throw new _errors$
|
|
1870
|
+
throw new _errors$e.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1841
1871
|
}
|
|
1842
1872
|
const spinnerText = 'Deleting scan...';
|
|
1843
|
-
const spinner = (0, _ora$
|
|
1873
|
+
const spinner = (0, _ora$d.default)(spinnerText).start();
|
|
1844
1874
|
await deleteOrgFullScan(input.orgSlug, input.fullScanId, spinner, apiKey);
|
|
1845
1875
|
}
|
|
1846
1876
|
}
|
|
@@ -1848,16 +1878,16 @@ const del$1 = _delete$3.del = {
|
|
|
1848
1878
|
|
|
1849
1879
|
// Internal functions
|
|
1850
1880
|
|
|
1851
|
-
function setupCommand$
|
|
1881
|
+
function setupCommand$d(name, description, argv, importMeta) {
|
|
1852
1882
|
const flags = {
|
|
1853
|
-
..._flags$
|
|
1883
|
+
..._flags$c.outputFlags
|
|
1854
1884
|
};
|
|
1855
|
-
const cli = (0, _meow$
|
|
1885
|
+
const cli = (0, _meow$d.default)(`
|
|
1856
1886
|
Usage
|
|
1857
1887
|
$ ${name} <org slug> <scan ID>
|
|
1858
1888
|
|
|
1859
1889
|
Options
|
|
1860
|
-
${(0, _formatting$
|
|
1890
|
+
${(0, _formatting$c.printFlagList)(flags, 6)}
|
|
1861
1891
|
|
|
1862
1892
|
Examples
|
|
1863
1893
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -1872,7 +1902,7 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
1872
1902
|
markdown: outputMarkdown
|
|
1873
1903
|
} = cli.flags;
|
|
1874
1904
|
if (cli.input.length < 2) {
|
|
1875
|
-
console.error(`${_chalk$
|
|
1905
|
+
console.error(`${_chalk$d.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
1876
1906
|
cli.showHelp();
|
|
1877
1907
|
return;
|
|
1878
1908
|
}
|
|
@@ -1888,10 +1918,10 @@ function setupCommand$a(name, description, argv, importMeta) {
|
|
|
1888
1918
|
};
|
|
1889
1919
|
}
|
|
1890
1920
|
async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
1891
|
-
const socketSdk = await (0, _sdk$
|
|
1892
|
-
const result = await (0, _apiHelpers$
|
|
1921
|
+
const socketSdk = await (0, _sdk$d.setupSdk)(apiKey);
|
|
1922
|
+
const result = await (0, _apiHelpers$d.handleApiCall)(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting scan');
|
|
1893
1923
|
if (!result.success) {
|
|
1894
|
-
(0, _apiHelpers$
|
|
1924
|
+
(0, _apiHelpers$d.handleUnsuccessfulApiResponse)('deleteOrgFullScan', result, spinner);
|
|
1895
1925
|
return;
|
|
1896
1926
|
}
|
|
1897
1927
|
spinner.stop();
|
|
@@ -1900,20 +1930,20 @@ async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
|
|
|
1900
1930
|
|
|
1901
1931
|
var list$3 = {};
|
|
1902
1932
|
|
|
1903
|
-
var _interopRequireDefault$
|
|
1933
|
+
var _interopRequireDefault$d = vendor.interopRequireDefault.default;
|
|
1904
1934
|
Object.defineProperty(list$3, "__esModule", {
|
|
1905
1935
|
value: true
|
|
1906
1936
|
});
|
|
1907
1937
|
list$3.list = void 0;
|
|
1908
|
-
var _chalk$
|
|
1938
|
+
var _chalk$c = _interopRequireDefault$d(vendor.source);
|
|
1909
1939
|
var _chalkTable$3 = require$$2$2;
|
|
1910
|
-
var _meow$
|
|
1911
|
-
var _ora$
|
|
1912
|
-
var _flags$
|
|
1913
|
-
var _apiHelpers$
|
|
1914
|
-
var _formatting$
|
|
1915
|
-
var _sdk$
|
|
1916
|
-
var _errors$
|
|
1940
|
+
var _meow$c = _interopRequireDefault$d(vendor.build);
|
|
1941
|
+
var _ora$c = _interopRequireDefault$d(vendor.ora);
|
|
1942
|
+
var _flags$b = flags;
|
|
1943
|
+
var _apiHelpers$c = apiHelpers;
|
|
1944
|
+
var _formatting$b = formatting;
|
|
1945
|
+
var _sdk$c = sdk.sdk;
|
|
1946
|
+
var _errors$d = sdk.errors;
|
|
1917
1947
|
// @ts-ignore
|
|
1918
1948
|
|
|
1919
1949
|
const list$2 = list$3.list = {
|
|
@@ -1922,14 +1952,14 @@ const list$2 = list$3.list = {
|
|
|
1922
1952
|
parentName
|
|
1923
1953
|
}) {
|
|
1924
1954
|
const name = `${parentName} list`;
|
|
1925
|
-
const input = setupCommand$
|
|
1955
|
+
const input = setupCommand$c(name, list$2.description, argv, importMeta);
|
|
1926
1956
|
if (input) {
|
|
1927
|
-
const apiKey = (0, _sdk$
|
|
1957
|
+
const apiKey = (0, _sdk$c.getDefaultKey)();
|
|
1928
1958
|
if (!apiKey) {
|
|
1929
|
-
throw new _errors$
|
|
1959
|
+
throw new _errors$d.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
1930
1960
|
}
|
|
1931
1961
|
const spinnerText = 'Listing scans... \n';
|
|
1932
|
-
const spinner = (0, _ora$
|
|
1962
|
+
const spinner = (0, _ora$c.default)(spinnerText).start();
|
|
1933
1963
|
await listOrgFullScan(input.orgSlug, input, spinner, apiKey);
|
|
1934
1964
|
}
|
|
1935
1965
|
}
|
|
@@ -1975,17 +2005,17 @@ const listFullScanFlags = {
|
|
|
1975
2005
|
|
|
1976
2006
|
// Internal functions
|
|
1977
2007
|
|
|
1978
|
-
function setupCommand$
|
|
2008
|
+
function setupCommand$c(name, description, argv, importMeta) {
|
|
1979
2009
|
const flags = {
|
|
1980
|
-
..._flags$
|
|
2010
|
+
..._flags$b.outputFlags,
|
|
1981
2011
|
...listFullScanFlags
|
|
1982
2012
|
};
|
|
1983
|
-
const cli = (0, _meow$
|
|
2013
|
+
const cli = (0, _meow$c.default)(`
|
|
1984
2014
|
Usage
|
|
1985
2015
|
$ ${name} <org slug>
|
|
1986
2016
|
|
|
1987
2017
|
Options
|
|
1988
|
-
${(0, _formatting$
|
|
2018
|
+
${(0, _formatting$b.printFlagList)(flags, 6)}
|
|
1989
2019
|
|
|
1990
2020
|
Examples
|
|
1991
2021
|
$ ${name} FakeOrg
|
|
@@ -2006,7 +2036,7 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2006
2036
|
untilTime
|
|
2007
2037
|
} = cli.flags;
|
|
2008
2038
|
if (!cli.input[0]) {
|
|
2009
|
-
console.error(`${_chalk$
|
|
2039
|
+
console.error(`${_chalk$c.default.bgRed('Input error')}: Please specify an organization slug.\n`);
|
|
2010
2040
|
cli.showHelp();
|
|
2011
2041
|
return;
|
|
2012
2042
|
}
|
|
@@ -2026,10 +2056,10 @@ function setupCommand$9(name, description, argv, importMeta) {
|
|
|
2026
2056
|
};
|
|
2027
2057
|
}
|
|
2028
2058
|
async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
2029
|
-
const socketSdk = await (0, _sdk$
|
|
2030
|
-
const result = await (0, _apiHelpers$
|
|
2059
|
+
const socketSdk = await (0, _sdk$c.setupSdk)(apiKey);
|
|
2060
|
+
const result = await (0, _apiHelpers$c.handleApiCall)(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing scans');
|
|
2031
2061
|
if (!result.success) {
|
|
2032
|
-
(0, _apiHelpers$
|
|
2062
|
+
(0, _apiHelpers$c.handleUnsuccessfulApiResponse)('getOrgFullScanList', result, spinner);
|
|
2033
2063
|
return;
|
|
2034
2064
|
}
|
|
2035
2065
|
spinner.stop();
|
|
@@ -2037,22 +2067,22 @@ async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
|
2037
2067
|
const options = {
|
|
2038
2068
|
columns: [{
|
|
2039
2069
|
field: 'id',
|
|
2040
|
-
name: _chalk$
|
|
2070
|
+
name: _chalk$c.default.magenta('ID')
|
|
2041
2071
|
}, {
|
|
2042
2072
|
field: 'report_url',
|
|
2043
|
-
name: _chalk$
|
|
2073
|
+
name: _chalk$c.default.magenta('Scan URL')
|
|
2044
2074
|
}, {
|
|
2045
2075
|
field: 'branch',
|
|
2046
|
-
name: _chalk$
|
|
2076
|
+
name: _chalk$c.default.magenta('Branch')
|
|
2047
2077
|
}, {
|
|
2048
2078
|
field: 'created_at',
|
|
2049
|
-
name: _chalk$
|
|
2079
|
+
name: _chalk$c.default.magenta('Created at')
|
|
2050
2080
|
}]
|
|
2051
2081
|
};
|
|
2052
2082
|
const formattedResults = result.data.results.map(d => {
|
|
2053
2083
|
return {
|
|
2054
2084
|
id: d.id,
|
|
2055
|
-
report_url: _chalk$
|
|
2085
|
+
report_url: _chalk$c.default.underline(`${d.html_report_url}`),
|
|
2056
2086
|
created_at: d.created_at ? new Date(d.created_at).toLocaleDateString('en-us', {
|
|
2057
2087
|
year: 'numeric',
|
|
2058
2088
|
month: 'numeric',
|
|
@@ -2066,33 +2096,33 @@ async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
|
|
|
2066
2096
|
|
|
2067
2097
|
var metadata$1 = {};
|
|
2068
2098
|
|
|
2069
|
-
var _interopRequireDefault$
|
|
2099
|
+
var _interopRequireDefault$c = vendor.interopRequireDefault.default;
|
|
2070
2100
|
Object.defineProperty(metadata$1, "__esModule", {
|
|
2071
2101
|
value: true
|
|
2072
2102
|
});
|
|
2073
2103
|
metadata$1.metadata = void 0;
|
|
2074
|
-
var _chalk$
|
|
2075
|
-
var _meow$
|
|
2076
|
-
var _ora$
|
|
2077
|
-
var _flags$
|
|
2078
|
-
var _apiHelpers$
|
|
2079
|
-
var _formatting$
|
|
2080
|
-
var _sdk$
|
|
2081
|
-
var _errors$
|
|
2104
|
+
var _chalk$b = _interopRequireDefault$c(vendor.source);
|
|
2105
|
+
var _meow$b = _interopRequireDefault$c(vendor.build);
|
|
2106
|
+
var _ora$b = _interopRequireDefault$c(vendor.ora);
|
|
2107
|
+
var _flags$a = flags;
|
|
2108
|
+
var _apiHelpers$b = apiHelpers;
|
|
2109
|
+
var _formatting$a = formatting;
|
|
2110
|
+
var _sdk$b = sdk.sdk;
|
|
2111
|
+
var _errors$c = sdk.errors;
|
|
2082
2112
|
const metadata = metadata$1.metadata = {
|
|
2083
2113
|
description: "Get a scan's metadata",
|
|
2084
2114
|
async run(argv, importMeta, {
|
|
2085
2115
|
parentName
|
|
2086
2116
|
}) {
|
|
2087
2117
|
const name = `${parentName} metadata`;
|
|
2088
|
-
const input = setupCommand$
|
|
2118
|
+
const input = setupCommand$b(name, metadata.description, argv, importMeta);
|
|
2089
2119
|
if (input) {
|
|
2090
|
-
const apiKey = (0, _sdk$
|
|
2120
|
+
const apiKey = (0, _sdk$b.getDefaultKey)();
|
|
2091
2121
|
if (!apiKey) {
|
|
2092
|
-
throw new _errors$
|
|
2122
|
+
throw new _errors$c.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2093
2123
|
}
|
|
2094
2124
|
const spinnerText = "Getting scan's metadata... \n";
|
|
2095
|
-
const spinner = (0, _ora$
|
|
2125
|
+
const spinner = (0, _ora$b.default)(spinnerText).start();
|
|
2096
2126
|
await getOrgScanMetadata(input.orgSlug, input.scanID, spinner, apiKey);
|
|
2097
2127
|
}
|
|
2098
2128
|
}
|
|
@@ -2100,16 +2130,16 @@ const metadata = metadata$1.metadata = {
|
|
|
2100
2130
|
|
|
2101
2131
|
// Internal functions
|
|
2102
2132
|
|
|
2103
|
-
function setupCommand$
|
|
2133
|
+
function setupCommand$b(name, description, argv, importMeta) {
|
|
2104
2134
|
const flags = {
|
|
2105
|
-
..._flags$
|
|
2135
|
+
..._flags$a.outputFlags
|
|
2106
2136
|
};
|
|
2107
|
-
const cli = (0, _meow$
|
|
2137
|
+
const cli = (0, _meow$b.default)(`
|
|
2108
2138
|
Usage
|
|
2109
2139
|
$ ${name} <org slug> <scan id>
|
|
2110
2140
|
|
|
2111
2141
|
Options
|
|
2112
|
-
${(0, _formatting$
|
|
2142
|
+
${(0, _formatting$a.printFlagList)(flags, 6)}
|
|
2113
2143
|
|
|
2114
2144
|
Examples
|
|
2115
2145
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -2124,7 +2154,7 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
2124
2154
|
markdown: outputMarkdown
|
|
2125
2155
|
} = cli.flags;
|
|
2126
2156
|
if (cli.input.length < 2) {
|
|
2127
|
-
console.error(`${_chalk$
|
|
2157
|
+
console.error(`${_chalk$b.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2128
2158
|
cli.showHelp();
|
|
2129
2159
|
return;
|
|
2130
2160
|
}
|
|
@@ -2140,10 +2170,10 @@ function setupCommand$8(name, description, argv, importMeta) {
|
|
|
2140
2170
|
};
|
|
2141
2171
|
}
|
|
2142
2172
|
async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
|
|
2143
|
-
const socketSdk = await (0, _sdk$
|
|
2144
|
-
const result = await (0, _apiHelpers$
|
|
2173
|
+
const socketSdk = await (0, _sdk$b.setupSdk)(apiKey);
|
|
2174
|
+
const result = await (0, _apiHelpers$b.handleApiCall)(socketSdk.getOrgFullScanMetadata(orgSlug, scanId), 'Listing scans');
|
|
2145
2175
|
if (!result.success) {
|
|
2146
|
-
(0, _apiHelpers$
|
|
2176
|
+
(0, _apiHelpers$b.handleUnsuccessfulApiResponse)('getOrgFullScanMetadata', result, spinner);
|
|
2147
2177
|
return;
|
|
2148
2178
|
}
|
|
2149
2179
|
spinner.stop();
|
|
@@ -2153,33 +2183,33 @@ async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
|
|
|
2153
2183
|
|
|
2154
2184
|
var stream$1 = {};
|
|
2155
2185
|
|
|
2156
|
-
var _interopRequireDefault$
|
|
2186
|
+
var _interopRequireDefault$b = vendor.interopRequireDefault.default;
|
|
2157
2187
|
Object.defineProperty(stream$1, "__esModule", {
|
|
2158
2188
|
value: true
|
|
2159
2189
|
});
|
|
2160
2190
|
stream$1.stream = void 0;
|
|
2161
|
-
var _chalk$
|
|
2162
|
-
var _meow$
|
|
2163
|
-
var _ora$
|
|
2164
|
-
var _flags$
|
|
2165
|
-
var _apiHelpers$
|
|
2166
|
-
var _formatting$
|
|
2167
|
-
var _sdk$
|
|
2168
|
-
var _errors$
|
|
2191
|
+
var _chalk$a = _interopRequireDefault$b(vendor.source);
|
|
2192
|
+
var _meow$a = _interopRequireDefault$b(vendor.build);
|
|
2193
|
+
var _ora$a = _interopRequireDefault$b(vendor.ora);
|
|
2194
|
+
var _flags$9 = flags;
|
|
2195
|
+
var _apiHelpers$a = apiHelpers;
|
|
2196
|
+
var _formatting$9 = formatting;
|
|
2197
|
+
var _sdk$a = sdk.sdk;
|
|
2198
|
+
var _errors$b = sdk.errors;
|
|
2169
2199
|
const stream = stream$1.stream = {
|
|
2170
2200
|
description: 'Stream the output of a scan',
|
|
2171
2201
|
async run(argv, importMeta, {
|
|
2172
2202
|
parentName
|
|
2173
2203
|
}) {
|
|
2174
2204
|
const name = `${parentName} stream`;
|
|
2175
|
-
const input = setupCommand$
|
|
2205
|
+
const input = setupCommand$a(name, stream.description, argv, importMeta);
|
|
2176
2206
|
if (input) {
|
|
2177
|
-
const apiKey = (0, _sdk$
|
|
2207
|
+
const apiKey = (0, _sdk$a.getDefaultKey)();
|
|
2178
2208
|
if (!apiKey) {
|
|
2179
|
-
throw new _errors$
|
|
2209
|
+
throw new _errors$b.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2180
2210
|
}
|
|
2181
2211
|
const spinnerText = 'Streaming scan...\n';
|
|
2182
|
-
const spinner = (0, _ora$
|
|
2212
|
+
const spinner = (0, _ora$a.default)(spinnerText).start();
|
|
2183
2213
|
await getOrgFullScan(input.orgSlug, input.fullScanId, input.file, spinner, apiKey);
|
|
2184
2214
|
}
|
|
2185
2215
|
}
|
|
@@ -2187,16 +2217,16 @@ const stream = stream$1.stream = {
|
|
|
2187
2217
|
|
|
2188
2218
|
// Internal functions
|
|
2189
2219
|
|
|
2190
|
-
function setupCommand$
|
|
2220
|
+
function setupCommand$a(name, description, argv, importMeta) {
|
|
2191
2221
|
const flags = {
|
|
2192
|
-
..._flags$
|
|
2222
|
+
..._flags$9.outputFlags
|
|
2193
2223
|
};
|
|
2194
|
-
const cli = (0, _meow$
|
|
2224
|
+
const cli = (0, _meow$a.default)(`
|
|
2195
2225
|
Usage
|
|
2196
2226
|
$ ${name} <org slug> <scan ID> <path to output file>
|
|
2197
2227
|
|
|
2198
2228
|
Options
|
|
2199
|
-
${(0, _formatting$
|
|
2229
|
+
${(0, _formatting$9.printFlagList)(flags, 6)}
|
|
2200
2230
|
|
|
2201
2231
|
Examples
|
|
2202
2232
|
$ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
|
|
@@ -2211,7 +2241,7 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
2211
2241
|
markdown: outputMarkdown
|
|
2212
2242
|
} = cli.flags;
|
|
2213
2243
|
if (cli.input.length < 2) {
|
|
2214
|
-
console.error(`${_chalk$
|
|
2244
|
+
console.error(`${_chalk$a.default.bgRed('Input error')}: Please specify an organization slug and a scan ID.\n`);
|
|
2215
2245
|
cli.showHelp();
|
|
2216
2246
|
return;
|
|
2217
2247
|
}
|
|
@@ -2229,10 +2259,10 @@ function setupCommand$7(name, description, argv, importMeta) {
|
|
|
2229
2259
|
};
|
|
2230
2260
|
}
|
|
2231
2261
|
async function getOrgFullScan(orgSlug, fullScanId, file, spinner, apiKey) {
|
|
2232
|
-
const socketSdk = await (0, _sdk$
|
|
2233
|
-
const result = await (0, _apiHelpers$
|
|
2262
|
+
const socketSdk = await (0, _sdk$a.setupSdk)(apiKey);
|
|
2263
|
+
const result = await (0, _apiHelpers$a.handleApiCall)(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a scan');
|
|
2234
2264
|
if (!result?.success) {
|
|
2235
|
-
(0, _apiHelpers$
|
|
2265
|
+
(0, _apiHelpers$a.handleUnsuccessfulApiResponse)('getOrgFullScan', result, spinner);
|
|
2236
2266
|
return;
|
|
2237
2267
|
}
|
|
2238
2268
|
spinner.stop();
|
|
@@ -2248,14 +2278,14 @@ var _delete$2 = _delete$3;
|
|
|
2248
2278
|
var _list$1 = list$3;
|
|
2249
2279
|
var _metadata = metadata$1;
|
|
2250
2280
|
var _stream = stream$1;
|
|
2251
|
-
var _meowWithSubcommands$
|
|
2252
|
-
const description$
|
|
2281
|
+
var _meowWithSubcommands$3 = meowWithSubcommands$1;
|
|
2282
|
+
const description$2 = 'Scans related commands';
|
|
2253
2283
|
scan.scan = {
|
|
2254
|
-
description: description$
|
|
2284
|
+
description: description$2,
|
|
2255
2285
|
run: async (argv, importMeta, {
|
|
2256
2286
|
parentName
|
|
2257
2287
|
}) => {
|
|
2258
|
-
await (0, _meowWithSubcommands$
|
|
2288
|
+
await (0, _meowWithSubcommands$3.meowWithSubcommands)({
|
|
2259
2289
|
create: _create$1.create,
|
|
2260
2290
|
stream: _stream.stream,
|
|
2261
2291
|
list: _list$1.list,
|
|
@@ -2263,7 +2293,7 @@ scan.scan = {
|
|
|
2263
2293
|
metadata: _metadata.metadata
|
|
2264
2294
|
}, {
|
|
2265
2295
|
argv,
|
|
2266
|
-
description: description$
|
|
2296
|
+
description: description$2,
|
|
2267
2297
|
importMeta,
|
|
2268
2298
|
name: parentName + ' scan'
|
|
2269
2299
|
});
|
|
@@ -2272,33 +2302,33 @@ scan.scan = {
|
|
|
2272
2302
|
|
|
2273
2303
|
var auditLog$1 = {};
|
|
2274
2304
|
|
|
2275
|
-
var _interopRequireDefault$
|
|
2305
|
+
var _interopRequireDefault$a = vendor.interopRequireDefault.default;
|
|
2276
2306
|
Object.defineProperty(auditLog$1, "__esModule", {
|
|
2277
2307
|
value: true
|
|
2278
2308
|
});
|
|
2279
2309
|
auditLog$1.auditLog = void 0;
|
|
2280
2310
|
var _prompts = require$$1$1;
|
|
2281
|
-
var _chalk$
|
|
2282
|
-
var _meow$
|
|
2283
|
-
var _ora$
|
|
2284
|
-
var _flags$
|
|
2285
|
-
var _apiHelpers$
|
|
2286
|
-
var _formatting$
|
|
2287
|
-
var _sdk$
|
|
2288
|
-
var _errors$
|
|
2311
|
+
var _chalk$9 = _interopRequireDefault$a(vendor.source);
|
|
2312
|
+
var _meow$9 = _interopRequireDefault$a(vendor.build);
|
|
2313
|
+
var _ora$9 = _interopRequireDefault$a(vendor.ora);
|
|
2314
|
+
var _flags$8 = flags;
|
|
2315
|
+
var _apiHelpers$9 = apiHelpers;
|
|
2316
|
+
var _formatting$8 = formatting;
|
|
2317
|
+
var _sdk$9 = sdk.sdk;
|
|
2318
|
+
var _errors$a = sdk.errors;
|
|
2289
2319
|
const auditLog = auditLog$1.auditLog = {
|
|
2290
2320
|
description: 'Look up the audit log for an organization',
|
|
2291
2321
|
async run(argv, importMeta, {
|
|
2292
2322
|
parentName
|
|
2293
2323
|
}) {
|
|
2294
2324
|
const name = parentName + ' audit-log';
|
|
2295
|
-
const input = setupCommand$
|
|
2325
|
+
const input = setupCommand$9(name, auditLog.description, argv, importMeta);
|
|
2296
2326
|
if (input) {
|
|
2297
|
-
const apiKey = (0, _sdk$
|
|
2327
|
+
const apiKey = (0, _sdk$9.getDefaultKey)();
|
|
2298
2328
|
if (!apiKey) {
|
|
2299
|
-
throw new _errors$
|
|
2329
|
+
throw new _errors$a.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2300
2330
|
}
|
|
2301
|
-
const spinner = (0, _ora$
|
|
2331
|
+
const spinner = (0, _ora$9.default)(`Looking up audit log for ${input.orgSlug}\n`).start();
|
|
2302
2332
|
await fetchOrgAuditLog(input.orgSlug, input, spinner, apiKey);
|
|
2303
2333
|
}
|
|
2304
2334
|
}
|
|
@@ -2326,17 +2356,17 @@ const auditLogFlags = {
|
|
|
2326
2356
|
|
|
2327
2357
|
// Internal functions
|
|
2328
2358
|
|
|
2329
|
-
function setupCommand$
|
|
2359
|
+
function setupCommand$9(name, description, argv, importMeta) {
|
|
2330
2360
|
const flags = {
|
|
2331
2361
|
...auditLogFlags,
|
|
2332
|
-
..._flags$
|
|
2362
|
+
..._flags$8.outputFlags
|
|
2333
2363
|
};
|
|
2334
|
-
const cli = (0, _meow$
|
|
2364
|
+
const cli = (0, _meow$9.default)(`
|
|
2335
2365
|
Usage
|
|
2336
2366
|
$ ${name} <org slug>
|
|
2337
2367
|
|
|
2338
2368
|
Options
|
|
2339
|
-
${(0, _formatting$
|
|
2369
|
+
${(0, _formatting$8.printFlagList)(flags, 6)}
|
|
2340
2370
|
|
|
2341
2371
|
Examples
|
|
2342
2372
|
$ ${name} FakeOrg
|
|
@@ -2354,7 +2384,7 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
2354
2384
|
} = cli.flags;
|
|
2355
2385
|
const type = cli.flags['type'];
|
|
2356
2386
|
if (cli.input.length < 1) {
|
|
2357
|
-
console.error(`${_chalk$
|
|
2387
|
+
console.error(`${_chalk$9.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2358
2388
|
cli.showHelp();
|
|
2359
2389
|
return;
|
|
2360
2390
|
}
|
|
@@ -2369,10 +2399,10 @@ function setupCommand$6(name, description, argv, importMeta) {
|
|
|
2369
2399
|
};
|
|
2370
2400
|
}
|
|
2371
2401
|
async function fetchOrgAuditLog(orgSlug, input, spinner, apiKey) {
|
|
2372
|
-
const socketSdk = await (0, _sdk$
|
|
2373
|
-
const result = await (0, _apiHelpers$
|
|
2402
|
+
const socketSdk = await (0, _sdk$9.setupSdk)(apiKey);
|
|
2403
|
+
const result = await (0, _apiHelpers$9.handleApiCall)(socketSdk.getAuditLogEvents(orgSlug, input), `Looking up audit log for ${orgSlug}\n`);
|
|
2374
2404
|
if (!result.success) {
|
|
2375
|
-
(0, _apiHelpers$
|
|
2405
|
+
(0, _apiHelpers$9.handleUnsuccessfulApiResponse)('getAuditLogEvents', result, spinner);
|
|
2376
2406
|
return;
|
|
2377
2407
|
}
|
|
2378
2408
|
spinner.stop();
|
|
@@ -2405,33 +2435,33 @@ var repos = {};
|
|
|
2405
2435
|
|
|
2406
2436
|
var create$1 = {};
|
|
2407
2437
|
|
|
2408
|
-
var _interopRequireDefault$
|
|
2438
|
+
var _interopRequireDefault$9 = vendor.interopRequireDefault.default;
|
|
2409
2439
|
Object.defineProperty(create$1, "__esModule", {
|
|
2410
2440
|
value: true
|
|
2411
2441
|
});
|
|
2412
2442
|
create$1.create = void 0;
|
|
2413
|
-
var _chalk$
|
|
2414
|
-
var _meow$
|
|
2415
|
-
var _ora$
|
|
2416
|
-
var _flags$
|
|
2417
|
-
var _apiHelpers$
|
|
2418
|
-
var _formatting$
|
|
2419
|
-
var _sdk$
|
|
2420
|
-
var _errors$
|
|
2443
|
+
var _chalk$8 = _interopRequireDefault$9(vendor.source);
|
|
2444
|
+
var _meow$8 = _interopRequireDefault$9(vendor.build);
|
|
2445
|
+
var _ora$8 = _interopRequireDefault$9(vendor.ora);
|
|
2446
|
+
var _flags$7 = flags;
|
|
2447
|
+
var _apiHelpers$8 = apiHelpers;
|
|
2448
|
+
var _formatting$7 = formatting;
|
|
2449
|
+
var _sdk$8 = sdk.sdk;
|
|
2450
|
+
var _errors$9 = sdk.errors;
|
|
2421
2451
|
const create = create$1.create = {
|
|
2422
2452
|
description: 'Create a repository in an organization',
|
|
2423
2453
|
async run(argv, importMeta, {
|
|
2424
2454
|
parentName
|
|
2425
2455
|
}) {
|
|
2426
2456
|
const name = `${parentName} create`;
|
|
2427
|
-
const input = setupCommand$
|
|
2457
|
+
const input = setupCommand$8(name, create.description, argv, importMeta);
|
|
2428
2458
|
if (input) {
|
|
2429
|
-
const apiKey = (0, _sdk$
|
|
2459
|
+
const apiKey = (0, _sdk$8.getDefaultKey)();
|
|
2430
2460
|
if (!apiKey) {
|
|
2431
|
-
throw new _errors$
|
|
2461
|
+
throw new _errors$9.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2432
2462
|
}
|
|
2433
2463
|
const spinnerText = 'Creating repository... \n';
|
|
2434
|
-
const spinner = (0, _ora$
|
|
2464
|
+
const spinner = (0, _ora$8.default)(spinnerText).start();
|
|
2435
2465
|
await createRepo(input.orgSlug, input, spinner, apiKey);
|
|
2436
2466
|
}
|
|
2437
2467
|
}
|
|
@@ -2471,17 +2501,17 @@ const repositoryCreationFlags = {
|
|
|
2471
2501
|
|
|
2472
2502
|
// Internal functions
|
|
2473
2503
|
|
|
2474
|
-
function setupCommand$
|
|
2504
|
+
function setupCommand$8(name, description, argv, importMeta) {
|
|
2475
2505
|
const flags = {
|
|
2476
|
-
..._flags$
|
|
2506
|
+
..._flags$7.outputFlags,
|
|
2477
2507
|
...repositoryCreationFlags
|
|
2478
2508
|
};
|
|
2479
|
-
const cli = (0, _meow$
|
|
2509
|
+
const cli = (0, _meow$8.default)(`
|
|
2480
2510
|
Usage
|
|
2481
2511
|
$ ${name} <org slug>
|
|
2482
2512
|
|
|
2483
2513
|
Options
|
|
2484
|
-
${(0, _formatting$
|
|
2514
|
+
${(0, _formatting$7.printFlagList)(flags, 6)}
|
|
2485
2515
|
|
|
2486
2516
|
Examples
|
|
2487
2517
|
$ ${name} FakeOrg --repoName=test-repo
|
|
@@ -2502,12 +2532,12 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
2502
2532
|
} = cli.flags;
|
|
2503
2533
|
const [orgSlug = ''] = cli.input;
|
|
2504
2534
|
if (!orgSlug) {
|
|
2505
|
-
console.error(`${_chalk$
|
|
2535
|
+
console.error(`${_chalk$8.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2506
2536
|
cli.showHelp();
|
|
2507
2537
|
return;
|
|
2508
2538
|
}
|
|
2509
2539
|
if (!repoName) {
|
|
2510
|
-
console.error(`${_chalk$
|
|
2540
|
+
console.error(`${_chalk$8.default.bgRed('Input error')}: Repository name is required. \n`);
|
|
2511
2541
|
cli.showHelp();
|
|
2512
2542
|
return;
|
|
2513
2543
|
}
|
|
@@ -2523,10 +2553,10 @@ function setupCommand$5(name, description, argv, importMeta) {
|
|
|
2523
2553
|
};
|
|
2524
2554
|
}
|
|
2525
2555
|
async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
2526
|
-
const socketSdk = await (0, _sdk$
|
|
2527
|
-
const result = await (0, _apiHelpers$
|
|
2556
|
+
const socketSdk = await (0, _sdk$8.setupSdk)(apiKey);
|
|
2557
|
+
const result = await (0, _apiHelpers$8.handleApiCall)(socketSdk.createOrgRepo(orgSlug, input), 'creating repository');
|
|
2528
2558
|
if (!result.success) {
|
|
2529
|
-
(0, _apiHelpers$
|
|
2559
|
+
(0, _apiHelpers$8.handleUnsuccessfulApiResponse)('createOrgRepo', result, spinner);
|
|
2530
2560
|
return;
|
|
2531
2561
|
}
|
|
2532
2562
|
spinner.stop();
|
|
@@ -2535,31 +2565,31 @@ async function createRepo(orgSlug, input, spinner, apiKey) {
|
|
|
2535
2565
|
|
|
2536
2566
|
var _delete$1 = {};
|
|
2537
2567
|
|
|
2538
|
-
var _interopRequireDefault$
|
|
2568
|
+
var _interopRequireDefault$8 = vendor.interopRequireDefault.default;
|
|
2539
2569
|
Object.defineProperty(_delete$1, "__esModule", {
|
|
2540
2570
|
value: true
|
|
2541
2571
|
});
|
|
2542
2572
|
_delete$1.del = void 0;
|
|
2543
|
-
var _chalk$
|
|
2544
|
-
var _meow$
|
|
2545
|
-
var _ora$
|
|
2546
|
-
var _apiHelpers$
|
|
2547
|
-
var _sdk$
|
|
2548
|
-
var _errors$
|
|
2573
|
+
var _chalk$7 = _interopRequireDefault$8(vendor.source);
|
|
2574
|
+
var _meow$7 = _interopRequireDefault$8(vendor.build);
|
|
2575
|
+
var _ora$7 = _interopRequireDefault$8(vendor.ora);
|
|
2576
|
+
var _apiHelpers$7 = apiHelpers;
|
|
2577
|
+
var _sdk$7 = sdk.sdk;
|
|
2578
|
+
var _errors$8 = sdk.errors;
|
|
2549
2579
|
const del = _delete$1.del = {
|
|
2550
2580
|
description: 'Delete a repository in an organization',
|
|
2551
2581
|
async run(argv, importMeta, {
|
|
2552
2582
|
parentName
|
|
2553
2583
|
}) {
|
|
2554
2584
|
const name = `${parentName} del`;
|
|
2555
|
-
const input = setupCommand$
|
|
2585
|
+
const input = setupCommand$7(name, del.description, argv, importMeta);
|
|
2556
2586
|
if (input) {
|
|
2557
|
-
const apiKey = (0, _sdk$
|
|
2587
|
+
const apiKey = (0, _sdk$7.getDefaultKey)();
|
|
2558
2588
|
if (!apiKey) {
|
|
2559
|
-
throw new _errors$
|
|
2589
|
+
throw new _errors$8.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2560
2590
|
}
|
|
2561
2591
|
const spinnerText = 'Deleting repository... \n';
|
|
2562
|
-
const spinner = (0, _ora$
|
|
2592
|
+
const spinner = (0, _ora$7.default)(spinnerText).start();
|
|
2563
2593
|
await deleteRepository(input.orgSlug, input.repoName, spinner, apiKey);
|
|
2564
2594
|
}
|
|
2565
2595
|
}
|
|
@@ -2567,8 +2597,8 @@ const del = _delete$1.del = {
|
|
|
2567
2597
|
|
|
2568
2598
|
// Internal functions
|
|
2569
2599
|
|
|
2570
|
-
function setupCommand$
|
|
2571
|
-
const cli = (0, _meow$
|
|
2600
|
+
function setupCommand$7(name, description, argv, importMeta) {
|
|
2601
|
+
const cli = (0, _meow$7.default)(`
|
|
2572
2602
|
Usage
|
|
2573
2603
|
$ ${name} <org slug> <repo slug>
|
|
2574
2604
|
|
|
@@ -2584,7 +2614,7 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
2584
2614
|
1: repoName = ''
|
|
2585
2615
|
} = cli.input;
|
|
2586
2616
|
if (!orgSlug || !repoName) {
|
|
2587
|
-
console.error(`${_chalk$
|
|
2617
|
+
console.error(`${_chalk$7.default.bgRed('Input error')}: Please provide an organization slug and repository slug \n`);
|
|
2588
2618
|
cli.showHelp();
|
|
2589
2619
|
return;
|
|
2590
2620
|
}
|
|
@@ -2594,10 +2624,10 @@ function setupCommand$4(name, description, argv, importMeta) {
|
|
|
2594
2624
|
};
|
|
2595
2625
|
}
|
|
2596
2626
|
async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
|
|
2597
|
-
const socketSdk = await (0, _sdk$
|
|
2598
|
-
const result = await (0, _apiHelpers$
|
|
2627
|
+
const socketSdk = await (0, _sdk$7.setupSdk)(apiKey);
|
|
2628
|
+
const result = await (0, _apiHelpers$7.handleApiCall)(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository');
|
|
2599
2629
|
if (!result.success) {
|
|
2600
|
-
(0, _apiHelpers$
|
|
2630
|
+
(0, _apiHelpers$7.handleUnsuccessfulApiResponse)('deleteOrgRepo', result, spinner);
|
|
2601
2631
|
return;
|
|
2602
2632
|
}
|
|
2603
2633
|
spinner.stop();
|
|
@@ -2606,20 +2636,20 @@ async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
|
|
|
2606
2636
|
|
|
2607
2637
|
var list$1 = {};
|
|
2608
2638
|
|
|
2609
|
-
var _interopRequireDefault$
|
|
2639
|
+
var _interopRequireDefault$7 = vendor.interopRequireDefault.default;
|
|
2610
2640
|
Object.defineProperty(list$1, "__esModule", {
|
|
2611
2641
|
value: true
|
|
2612
2642
|
});
|
|
2613
2643
|
list$1.list = void 0;
|
|
2614
|
-
var _chalk$
|
|
2644
|
+
var _chalk$6 = _interopRequireDefault$7(vendor.source);
|
|
2615
2645
|
var _chalkTable$2 = require$$2$2;
|
|
2616
|
-
var _meow$
|
|
2617
|
-
var _ora$
|
|
2618
|
-
var _flags$
|
|
2619
|
-
var _apiHelpers$
|
|
2620
|
-
var _formatting$
|
|
2621
|
-
var _sdk$
|
|
2622
|
-
var _errors$
|
|
2646
|
+
var _meow$6 = _interopRequireDefault$7(vendor.build);
|
|
2647
|
+
var _ora$6 = _interopRequireDefault$7(vendor.ora);
|
|
2648
|
+
var _flags$6 = flags;
|
|
2649
|
+
var _apiHelpers$6 = apiHelpers;
|
|
2650
|
+
var _formatting$6 = formatting;
|
|
2651
|
+
var _sdk$6 = sdk.sdk;
|
|
2652
|
+
var _errors$7 = sdk.errors;
|
|
2623
2653
|
// @ts-ignore
|
|
2624
2654
|
|
|
2625
2655
|
const list = list$1.list = {
|
|
@@ -2628,14 +2658,14 @@ const list = list$1.list = {
|
|
|
2628
2658
|
parentName
|
|
2629
2659
|
}) {
|
|
2630
2660
|
const name = `${parentName} list`;
|
|
2631
|
-
const input = setupCommand$
|
|
2661
|
+
const input = setupCommand$6(name, list.description, argv, importMeta);
|
|
2632
2662
|
if (input) {
|
|
2633
|
-
const apiKey = (0, _sdk$
|
|
2663
|
+
const apiKey = (0, _sdk$6.getDefaultKey)();
|
|
2634
2664
|
if (!apiKey) {
|
|
2635
|
-
throw new _errors$
|
|
2665
|
+
throw new _errors$7.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2636
2666
|
}
|
|
2637
2667
|
const spinnerText = 'Listing repositories... \n';
|
|
2638
|
-
const spinner = (0, _ora$
|
|
2668
|
+
const spinner = (0, _ora$6.default)(spinnerText).start();
|
|
2639
2669
|
await listOrgRepos(input.orgSlug, input, spinner, apiKey);
|
|
2640
2670
|
}
|
|
2641
2671
|
}
|
|
@@ -2668,17 +2698,17 @@ const listRepoFlags = {
|
|
|
2668
2698
|
|
|
2669
2699
|
// Internal functions
|
|
2670
2700
|
|
|
2671
|
-
function setupCommand$
|
|
2701
|
+
function setupCommand$6(name, description, argv, importMeta) {
|
|
2672
2702
|
const flags = {
|
|
2673
|
-
..._flags$
|
|
2703
|
+
..._flags$6.outputFlags,
|
|
2674
2704
|
...listRepoFlags
|
|
2675
2705
|
};
|
|
2676
|
-
const cli = (0, _meow$
|
|
2706
|
+
const cli = (0, _meow$6.default)(`
|
|
2677
2707
|
Usage
|
|
2678
2708
|
$ ${name} <org slug>
|
|
2679
2709
|
|
|
2680
2710
|
Options
|
|
2681
|
-
${(0, _formatting$
|
|
2711
|
+
${(0, _formatting$6.printFlagList)(flags, 6)}
|
|
2682
2712
|
|
|
2683
2713
|
Examples
|
|
2684
2714
|
$ ${name} FakeOrg
|
|
@@ -2697,7 +2727,7 @@ function setupCommand$3(name, description, argv, importMeta) {
|
|
|
2697
2727
|
page
|
|
2698
2728
|
} = cli.flags;
|
|
2699
2729
|
if (!cli.input[0]) {
|
|
2700
|
-
console.error(`${_chalk$
|
|
2730
|
+
console.error(`${_chalk$6.default.bgRed('Input error')}: Please provide an organization slug \n`);
|
|
2701
2731
|
cli.showHelp();
|
|
2702
2732
|
return;
|
|
2703
2733
|
}
|
|
@@ -2715,29 +2745,29 @@ function setupCommand$3(name, description, argv, importMeta) {
|
|
|
2715
2745
|
};
|
|
2716
2746
|
}
|
|
2717
2747
|
async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
2718
|
-
const socketSdk = await (0, _sdk$
|
|
2719
|
-
const result = await (0, _apiHelpers$
|
|
2748
|
+
const socketSdk = await (0, _sdk$6.setupSdk)(apiKey);
|
|
2749
|
+
const result = await (0, _apiHelpers$6.handleApiCall)(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories');
|
|
2720
2750
|
if (!result.success) {
|
|
2721
|
-
(0, _apiHelpers$
|
|
2751
|
+
(0, _apiHelpers$6.handleUnsuccessfulApiResponse)('getOrgRepoList', result, spinner);
|
|
2722
2752
|
return;
|
|
2723
2753
|
}
|
|
2724
2754
|
spinner.stop();
|
|
2725
2755
|
const options = {
|
|
2726
2756
|
columns: [{
|
|
2727
2757
|
field: 'id',
|
|
2728
|
-
name: _chalk$
|
|
2758
|
+
name: _chalk$6.default.magenta('ID')
|
|
2729
2759
|
}, {
|
|
2730
2760
|
field: 'name',
|
|
2731
|
-
name: _chalk$
|
|
2761
|
+
name: _chalk$6.default.magenta('Name')
|
|
2732
2762
|
}, {
|
|
2733
2763
|
field: 'visibility',
|
|
2734
|
-
name: _chalk$
|
|
2764
|
+
name: _chalk$6.default.magenta('Visibility')
|
|
2735
2765
|
}, {
|
|
2736
2766
|
field: 'default_branch',
|
|
2737
|
-
name: _chalk$
|
|
2767
|
+
name: _chalk$6.default.magenta('Default branch')
|
|
2738
2768
|
}, {
|
|
2739
2769
|
field: 'archived',
|
|
2740
|
-
name: _chalk$
|
|
2770
|
+
name: _chalk$6.default.magenta('Archived')
|
|
2741
2771
|
}]
|
|
2742
2772
|
};
|
|
2743
2773
|
console.log(`${_chalkTable$2(options, result.data.results)}\n`);
|
|
@@ -2745,33 +2775,33 @@ async function listOrgRepos(orgSlug, input, spinner, apiKey) {
|
|
|
2745
2775
|
|
|
2746
2776
|
var update$1 = {};
|
|
2747
2777
|
|
|
2748
|
-
var _interopRequireDefault$
|
|
2778
|
+
var _interopRequireDefault$6 = vendor.interopRequireDefault.default;
|
|
2749
2779
|
Object.defineProperty(update$1, "__esModule", {
|
|
2750
2780
|
value: true
|
|
2751
2781
|
});
|
|
2752
2782
|
update$1.update = void 0;
|
|
2753
|
-
var _chalk$
|
|
2754
|
-
var _meow$
|
|
2755
|
-
var _ora$
|
|
2756
|
-
var _flags$
|
|
2757
|
-
var _apiHelpers$
|
|
2758
|
-
var _formatting$
|
|
2759
|
-
var _sdk$
|
|
2760
|
-
var _errors$
|
|
2783
|
+
var _chalk$5 = _interopRequireDefault$6(vendor.source);
|
|
2784
|
+
var _meow$5 = _interopRequireDefault$6(vendor.build);
|
|
2785
|
+
var _ora$5 = _interopRequireDefault$6(vendor.ora);
|
|
2786
|
+
var _flags$5 = flags;
|
|
2787
|
+
var _apiHelpers$5 = apiHelpers;
|
|
2788
|
+
var _formatting$5 = formatting;
|
|
2789
|
+
var _sdk$5 = sdk.sdk;
|
|
2790
|
+
var _errors$6 = sdk.errors;
|
|
2761
2791
|
const update = update$1.update = {
|
|
2762
2792
|
description: 'Update a repository in an organization',
|
|
2763
2793
|
async run(argv, importMeta, {
|
|
2764
2794
|
parentName
|
|
2765
2795
|
}) {
|
|
2766
2796
|
const name = `${parentName} update`;
|
|
2767
|
-
const input = setupCommand$
|
|
2797
|
+
const input = setupCommand$5(name, update.description, argv, importMeta);
|
|
2768
2798
|
if (input) {
|
|
2769
|
-
const apiKey = (0, _sdk$
|
|
2799
|
+
const apiKey = (0, _sdk$5.getDefaultKey)();
|
|
2770
2800
|
if (!apiKey) {
|
|
2771
|
-
throw new _errors$
|
|
2801
|
+
throw new _errors$6.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2772
2802
|
}
|
|
2773
2803
|
const spinnerText = 'Updating repository... \n';
|
|
2774
|
-
const spinner = (0, _ora$
|
|
2804
|
+
const spinner = (0, _ora$5.default)(spinnerText).start();
|
|
2775
2805
|
await updateRepository(input.orgSlug, input, spinner, apiKey);
|
|
2776
2806
|
}
|
|
2777
2807
|
}
|
|
@@ -2811,17 +2841,17 @@ const repositoryUpdateFlags = {
|
|
|
2811
2841
|
|
|
2812
2842
|
// Internal functions
|
|
2813
2843
|
|
|
2814
|
-
function setupCommand$
|
|
2844
|
+
function setupCommand$5(name, description, argv, importMeta) {
|
|
2815
2845
|
const flags = {
|
|
2816
|
-
..._flags$
|
|
2846
|
+
..._flags$5.outputFlags,
|
|
2817
2847
|
...repositoryUpdateFlags
|
|
2818
2848
|
};
|
|
2819
|
-
const cli = (0, _meow$
|
|
2849
|
+
const cli = (0, _meow$5.default)(`
|
|
2820
2850
|
Usage
|
|
2821
2851
|
$ ${name} <org slug>
|
|
2822
2852
|
|
|
2823
2853
|
Options
|
|
2824
|
-
${(0, _formatting$
|
|
2854
|
+
${(0, _formatting$5.printFlagList)(flags, 6)}
|
|
2825
2855
|
|
|
2826
2856
|
Examples
|
|
2827
2857
|
$ ${name} FakeOrg
|
|
@@ -2842,12 +2872,12 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
2842
2872
|
} = cli.flags;
|
|
2843
2873
|
const [orgSlug = ''] = cli.input;
|
|
2844
2874
|
if (!orgSlug) {
|
|
2845
|
-
console.error(`${_chalk$
|
|
2875
|
+
console.error(`${_chalk$5.default.bgRed('Input error')}: Please provide an organization slug and repository name \n`);
|
|
2846
2876
|
cli.showHelp();
|
|
2847
2877
|
return;
|
|
2848
2878
|
}
|
|
2849
2879
|
if (!repoName) {
|
|
2850
|
-
console.error(`${_chalk$
|
|
2880
|
+
console.error(`${_chalk$5.default.bgRed('Input error')}: Repository name is required. \n`);
|
|
2851
2881
|
cli.showHelp();
|
|
2852
2882
|
return;
|
|
2853
2883
|
}
|
|
@@ -2863,10 +2893,10 @@ function setupCommand$2(name, description, argv, importMeta) {
|
|
|
2863
2893
|
};
|
|
2864
2894
|
}
|
|
2865
2895
|
async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
2866
|
-
const socketSdk = await (0, _sdk$
|
|
2867
|
-
const result = await (0, _apiHelpers$
|
|
2896
|
+
const socketSdk = await (0, _sdk$5.setupSdk)(apiKey);
|
|
2897
|
+
const result = await (0, _apiHelpers$5.handleApiCall)(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository');
|
|
2868
2898
|
if (!result.success) {
|
|
2869
|
-
(0, _apiHelpers$
|
|
2899
|
+
(0, _apiHelpers$5.handleUnsuccessfulApiResponse)('updateOrgRepo', result, spinner);
|
|
2870
2900
|
return;
|
|
2871
2901
|
}
|
|
2872
2902
|
spinner.stop();
|
|
@@ -2875,20 +2905,20 @@ async function updateRepository(orgSlug, input, spinner, apiKey) {
|
|
|
2875
2905
|
|
|
2876
2906
|
var view$1 = {};
|
|
2877
2907
|
|
|
2878
|
-
var _interopRequireDefault$
|
|
2908
|
+
var _interopRequireDefault$5 = vendor.interopRequireDefault.default;
|
|
2879
2909
|
Object.defineProperty(view$1, "__esModule", {
|
|
2880
2910
|
value: true
|
|
2881
2911
|
});
|
|
2882
2912
|
view$1.view = void 0;
|
|
2883
|
-
var _chalk$
|
|
2913
|
+
var _chalk$4 = _interopRequireDefault$5(vendor.source);
|
|
2884
2914
|
var _chalkTable$1 = require$$2$2;
|
|
2885
|
-
var _meow$
|
|
2886
|
-
var _ora$
|
|
2887
|
-
var _flags$
|
|
2888
|
-
var _apiHelpers$
|
|
2889
|
-
var _formatting$
|
|
2890
|
-
var _sdk$
|
|
2891
|
-
var _errors$
|
|
2915
|
+
var _meow$4 = _interopRequireDefault$5(vendor.build);
|
|
2916
|
+
var _ora$4 = _interopRequireDefault$5(vendor.ora);
|
|
2917
|
+
var _flags$4 = flags;
|
|
2918
|
+
var _apiHelpers$4 = apiHelpers;
|
|
2919
|
+
var _formatting$4 = formatting;
|
|
2920
|
+
var _sdk$4 = sdk.sdk;
|
|
2921
|
+
var _errors$5 = sdk.errors;
|
|
2892
2922
|
// @ts-ignore
|
|
2893
2923
|
|
|
2894
2924
|
const view = view$1.view = {
|
|
@@ -2897,14 +2927,14 @@ const view = view$1.view = {
|
|
|
2897
2927
|
parentName
|
|
2898
2928
|
}) {
|
|
2899
2929
|
const name = `${parentName} view`;
|
|
2900
|
-
const input = setupCommand$
|
|
2930
|
+
const input = setupCommand$4(name, view.description, argv, importMeta);
|
|
2901
2931
|
if (input) {
|
|
2902
|
-
const apiKey = (0, _sdk$
|
|
2932
|
+
const apiKey = (0, _sdk$4.getDefaultKey)();
|
|
2903
2933
|
if (!apiKey) {
|
|
2904
|
-
throw new _errors$
|
|
2934
|
+
throw new _errors$5.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
2905
2935
|
}
|
|
2906
2936
|
const spinnerText = 'Fetching repository... \n';
|
|
2907
|
-
const spinner = (0, _ora$
|
|
2937
|
+
const spinner = (0, _ora$4.default)(spinnerText).start();
|
|
2908
2938
|
await viewRepository(input.orgSlug, input.repositoryName, spinner, apiKey);
|
|
2909
2939
|
}
|
|
2910
2940
|
}
|
|
@@ -2912,16 +2942,16 @@ const view = view$1.view = {
|
|
|
2912
2942
|
|
|
2913
2943
|
// Internal functions
|
|
2914
2944
|
|
|
2915
|
-
function setupCommand$
|
|
2945
|
+
function setupCommand$4(name, description, argv, importMeta) {
|
|
2916
2946
|
const flags = {
|
|
2917
|
-
..._flags$
|
|
2947
|
+
..._flags$4.outputFlags
|
|
2918
2948
|
};
|
|
2919
|
-
const cli = (0, _meow$
|
|
2949
|
+
const cli = (0, _meow$4.default)(`
|
|
2920
2950
|
Usage
|
|
2921
2951
|
$ ${name} <org slug>
|
|
2922
2952
|
|
|
2923
2953
|
Options
|
|
2924
|
-
${(0, _formatting$
|
|
2954
|
+
${(0, _formatting$4.printFlagList)(flags, 6)}
|
|
2925
2955
|
|
|
2926
2956
|
Examples
|
|
2927
2957
|
$ ${name} FakeOrg
|
|
@@ -2936,7 +2966,7 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
2936
2966
|
markdown: outputMarkdown
|
|
2937
2967
|
} = cli.flags;
|
|
2938
2968
|
if (!cli.input[0]) {
|
|
2939
|
-
console.error(`${_chalk$
|
|
2969
|
+
console.error(`${_chalk$4.default.bgRed('Input error')}: Please provide an organization slug and repository name \n`);
|
|
2940
2970
|
cli.showHelp();
|
|
2941
2971
|
return;
|
|
2942
2972
|
}
|
|
@@ -2952,35 +2982,35 @@ function setupCommand$1(name, description, argv, importMeta) {
|
|
|
2952
2982
|
};
|
|
2953
2983
|
}
|
|
2954
2984
|
async function viewRepository(orgSlug, repoName, spinner, apiKey) {
|
|
2955
|
-
const socketSdk = await (0, _sdk$
|
|
2956
|
-
const result = await (0, _apiHelpers$
|
|
2985
|
+
const socketSdk = await (0, _sdk$4.setupSdk)(apiKey);
|
|
2986
|
+
const result = await (0, _apiHelpers$4.handleApiCall)(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository');
|
|
2957
2987
|
if (!result.success) {
|
|
2958
|
-
(0, _apiHelpers$
|
|
2988
|
+
(0, _apiHelpers$4.handleUnsuccessfulApiResponse)('getOrgRepo', result, spinner);
|
|
2959
2989
|
return;
|
|
2960
2990
|
}
|
|
2961
2991
|
spinner.stop();
|
|
2962
2992
|
const options = {
|
|
2963
2993
|
columns: [{
|
|
2964
2994
|
field: 'id',
|
|
2965
|
-
name: _chalk$
|
|
2995
|
+
name: _chalk$4.default.magenta('ID')
|
|
2966
2996
|
}, {
|
|
2967
2997
|
field: 'name',
|
|
2968
|
-
name: _chalk$
|
|
2998
|
+
name: _chalk$4.default.magenta('Name')
|
|
2969
2999
|
}, {
|
|
2970
3000
|
field: 'visibility',
|
|
2971
|
-
name: _chalk$
|
|
3001
|
+
name: _chalk$4.default.magenta('Visibility')
|
|
2972
3002
|
}, {
|
|
2973
3003
|
field: 'default_branch',
|
|
2974
|
-
name: _chalk$
|
|
3004
|
+
name: _chalk$4.default.magenta('Default branch')
|
|
2975
3005
|
}, {
|
|
2976
3006
|
field: 'homepage',
|
|
2977
|
-
name: _chalk$
|
|
3007
|
+
name: _chalk$4.default.magenta('Homepage')
|
|
2978
3008
|
}, {
|
|
2979
3009
|
field: 'archived',
|
|
2980
|
-
name: _chalk$
|
|
3010
|
+
name: _chalk$4.default.magenta('Archived')
|
|
2981
3011
|
}, {
|
|
2982
3012
|
field: 'created_at',
|
|
2983
|
-
name: _chalk$
|
|
3013
|
+
name: _chalk$4.default.magenta('Created at')
|
|
2984
3014
|
}]
|
|
2985
3015
|
};
|
|
2986
3016
|
console.log(`${_chalkTable$1(options, [result.data])}\n`);
|
|
@@ -2995,14 +3025,14 @@ var _delete = _delete$1;
|
|
|
2995
3025
|
var _list = list$1;
|
|
2996
3026
|
var _update = update$1;
|
|
2997
3027
|
var _view = view$1;
|
|
2998
|
-
var _meowWithSubcommands$
|
|
2999
|
-
const description = 'Repositories related commands';
|
|
3028
|
+
var _meowWithSubcommands$2 = meowWithSubcommands$1;
|
|
3029
|
+
const description$1 = 'Repositories related commands';
|
|
3000
3030
|
repos.repo = {
|
|
3001
|
-
description,
|
|
3031
|
+
description: description$1,
|
|
3002
3032
|
run: async (argv, importMeta, {
|
|
3003
3033
|
parentName
|
|
3004
3034
|
}) => {
|
|
3005
|
-
await (0, _meowWithSubcommands$
|
|
3035
|
+
await (0, _meowWithSubcommands$2.meowWithSubcommands)({
|
|
3006
3036
|
create: _create.create,
|
|
3007
3037
|
view: _view.view,
|
|
3008
3038
|
list: _list.list,
|
|
@@ -3010,7 +3040,7 @@ repos.repo = {
|
|
|
3010
3040
|
update: _update.update
|
|
3011
3041
|
}, {
|
|
3012
3042
|
argv,
|
|
3013
|
-
description,
|
|
3043
|
+
description: description$1,
|
|
3014
3044
|
importMeta,
|
|
3015
3045
|
name: `${parentName} repo`
|
|
3016
3046
|
});
|
|
@@ -3019,20 +3049,20 @@ repos.repo = {
|
|
|
3019
3049
|
|
|
3020
3050
|
var dependencies$1 = {};
|
|
3021
3051
|
|
|
3022
|
-
var _interopRequireDefault$
|
|
3052
|
+
var _interopRequireDefault$4 = vendor.interopRequireDefault.default;
|
|
3023
3053
|
Object.defineProperty(dependencies$1, "__esModule", {
|
|
3024
3054
|
value: true
|
|
3025
3055
|
});
|
|
3026
3056
|
dependencies$1.dependencies = void 0;
|
|
3027
|
-
var _chalk$
|
|
3057
|
+
var _chalk$3 = _interopRequireDefault$4(vendor.source);
|
|
3028
3058
|
var _chalkTable = require$$2$2;
|
|
3029
|
-
var _meow = _interopRequireDefault$
|
|
3030
|
-
var _ora = _interopRequireDefault$
|
|
3031
|
-
var _flags = flags;
|
|
3032
|
-
var _apiHelpers = apiHelpers;
|
|
3033
|
-
var _formatting = formatting;
|
|
3034
|
-
var _sdk = sdk.sdk;
|
|
3035
|
-
var _errors$
|
|
3059
|
+
var _meow$3 = _interopRequireDefault$4(vendor.build);
|
|
3060
|
+
var _ora$3 = _interopRequireDefault$4(vendor.ora);
|
|
3061
|
+
var _flags$3 = flags;
|
|
3062
|
+
var _apiHelpers$3 = apiHelpers;
|
|
3063
|
+
var _formatting$3 = formatting;
|
|
3064
|
+
var _sdk$3 = sdk.sdk;
|
|
3065
|
+
var _errors$4 = sdk.errors;
|
|
3036
3066
|
// @ts-ignore
|
|
3037
3067
|
|
|
3038
3068
|
const dependencies = dependencies$1.dependencies = {
|
|
@@ -3041,7 +3071,7 @@ const dependencies = dependencies$1.dependencies = {
|
|
|
3041
3071
|
parentName
|
|
3042
3072
|
}) {
|
|
3043
3073
|
const name = parentName + ' dependencies';
|
|
3044
|
-
const input = setupCommand(name, dependencies.description, argv, importMeta);
|
|
3074
|
+
const input = setupCommand$3(name, dependencies.description, argv, importMeta);
|
|
3045
3075
|
if (input) {
|
|
3046
3076
|
await searchDeps(input);
|
|
3047
3077
|
}
|
|
@@ -3064,17 +3094,17 @@ const dependenciesFlags = {
|
|
|
3064
3094
|
|
|
3065
3095
|
// Internal functions
|
|
3066
3096
|
|
|
3067
|
-
function setupCommand(name, description, argv, importMeta) {
|
|
3097
|
+
function setupCommand$3(name, description, argv, importMeta) {
|
|
3068
3098
|
const flags = {
|
|
3069
|
-
..._flags.outputFlags,
|
|
3099
|
+
..._flags$3.outputFlags,
|
|
3070
3100
|
...dependenciesFlags
|
|
3071
3101
|
};
|
|
3072
|
-
const cli = (0, _meow.default)(`
|
|
3102
|
+
const cli = (0, _meow$3.default)(`
|
|
3073
3103
|
Usage
|
|
3074
3104
|
$ ${name}
|
|
3075
3105
|
|
|
3076
3106
|
Options
|
|
3077
|
-
${(0, _formatting.printFlagList)(flags, 6)}
|
|
3107
|
+
${(0, _formatting$3.printFlagList)(flags, 6)}
|
|
3078
3108
|
|
|
3079
3109
|
Examples
|
|
3080
3110
|
$ ${name}
|
|
@@ -3102,19 +3132,19 @@ async function searchDeps({
|
|
|
3102
3132
|
offset,
|
|
3103
3133
|
outputJson
|
|
3104
3134
|
}) {
|
|
3105
|
-
const apiKey = (0, _sdk.getDefaultKey)();
|
|
3135
|
+
const apiKey = (0, _sdk$3.getDefaultKey)();
|
|
3106
3136
|
if (!apiKey) {
|
|
3107
|
-
throw new _errors$
|
|
3137
|
+
throw new _errors$4.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3108
3138
|
}
|
|
3109
3139
|
const spinnerText = 'Searching dependencies...';
|
|
3110
|
-
const spinner = (0, _ora.default)(spinnerText).start();
|
|
3111
|
-
const socketSdk = await (0, _sdk.setupSdk)(apiKey);
|
|
3112
|
-
const result = await (0, _apiHelpers.handleApiCall)(socketSdk.searchDependencies({
|
|
3140
|
+
const spinner = (0, _ora$3.default)(spinnerText).start();
|
|
3141
|
+
const socketSdk = await (0, _sdk$3.setupSdk)(apiKey);
|
|
3142
|
+
const result = await (0, _apiHelpers$3.handleApiCall)(socketSdk.searchDependencies({
|
|
3113
3143
|
limit,
|
|
3114
3144
|
offset
|
|
3115
3145
|
}), 'Searching dependencies');
|
|
3116
3146
|
if (!result.success) {
|
|
3117
|
-
(0, _apiHelpers.handleUnsuccessfulApiResponse)('searchDependencies', result, spinner);
|
|
3147
|
+
(0, _apiHelpers$3.handleUnsuccessfulApiResponse)('searchDependencies', result, spinner);
|
|
3118
3148
|
return;
|
|
3119
3149
|
}
|
|
3120
3150
|
spinner.stop();
|
|
@@ -3126,57 +3156,708 @@ async function searchDeps({
|
|
|
3126
3156
|
const options = {
|
|
3127
3157
|
columns: [{
|
|
3128
3158
|
field: 'namespace',
|
|
3129
|
-
name: _chalk$
|
|
3159
|
+
name: _chalk$3.default.cyan('Namespace')
|
|
3130
3160
|
}, {
|
|
3131
3161
|
field: 'name',
|
|
3132
|
-
name: _chalk$
|
|
3162
|
+
name: _chalk$3.default.cyan('Name')
|
|
3133
3163
|
}, {
|
|
3134
3164
|
field: 'version',
|
|
3135
|
-
name: _chalk$
|
|
3165
|
+
name: _chalk$3.default.cyan('Version')
|
|
3136
3166
|
}, {
|
|
3137
3167
|
field: 'repository',
|
|
3138
|
-
name: _chalk$
|
|
3168
|
+
name: _chalk$3.default.cyan('Repository')
|
|
3139
3169
|
}, {
|
|
3140
3170
|
field: 'branch',
|
|
3141
|
-
name: _chalk$
|
|
3171
|
+
name: _chalk$3.default.cyan('Branch')
|
|
3142
3172
|
}, {
|
|
3143
3173
|
field: 'type',
|
|
3144
|
-
name: _chalk$
|
|
3174
|
+
name: _chalk$3.default.cyan('Type')
|
|
3145
3175
|
}, {
|
|
3146
3176
|
field: 'direct',
|
|
3147
|
-
name: _chalk$
|
|
3177
|
+
name: _chalk$3.default.cyan('Direct')
|
|
3148
3178
|
}]
|
|
3149
3179
|
};
|
|
3150
3180
|
console.log(`${_chalkTable(options, result.data.rows)}\n`);
|
|
3151
3181
|
}
|
|
3152
3182
|
|
|
3153
|
-
|
|
3183
|
+
var analytics$1 = {};
|
|
3154
3184
|
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3185
|
+
var _interopRequireDefault$3 = vendor.interopRequireDefault.default;
|
|
3186
|
+
Object.defineProperty(analytics$1, "__esModule", {
|
|
3187
|
+
value: true
|
|
3188
|
+
});
|
|
3189
|
+
analytics$1.analytics = void 0;
|
|
3190
|
+
var _blessed$1 = require$$1$2;
|
|
3191
|
+
var _blessedContrib$1 = require$$2$3;
|
|
3192
|
+
var _fs$1 = require$$0;
|
|
3193
|
+
var _meow$2 = _interopRequireDefault$3(vendor.build);
|
|
3194
|
+
var _ora$2 = _interopRequireDefault$3(vendor.ora);
|
|
3195
|
+
var _flags$2 = flags;
|
|
3196
|
+
var _apiHelpers$2 = apiHelpers;
|
|
3197
|
+
var _errors$3 = sdk.errors;
|
|
3198
|
+
var _formatting$2 = formatting;
|
|
3199
|
+
var _sdk$2 = sdk.sdk;
|
|
3200
|
+
var _chalk$2 = _interopRequireDefault$3(vendor.source);
|
|
3201
|
+
// @ts-ignore
|
|
3202
|
+
|
|
3203
|
+
// @ts-ignore
|
|
3204
|
+
|
|
3205
|
+
const analytics = analytics$1.analytics = {
|
|
3206
|
+
description: `Look up analytics data \n
|
|
3207
|
+
Default parameters are set to show the organization-level analytics over the last 7 days.`,
|
|
3208
|
+
async run(argv, importMeta, {
|
|
3209
|
+
parentName
|
|
3210
|
+
}) {
|
|
3211
|
+
const name = parentName + ' analytics';
|
|
3212
|
+
const input = setupCommand$2(name, analytics.description, argv, importMeta);
|
|
3213
|
+
if (input) {
|
|
3214
|
+
const apiKey = (0, _sdk$2.getDefaultKey)();
|
|
3215
|
+
if (!apiKey) {
|
|
3216
|
+
throw new _errors$3.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3217
|
+
}
|
|
3218
|
+
const spinner = (0, _ora$2.default)('Fetching analytics data').start();
|
|
3219
|
+
if (input.scope === 'org') {
|
|
3220
|
+
await fetchOrgAnalyticsData(input.time, spinner, apiKey, input.outputJson, input.file);
|
|
3221
|
+
} else {
|
|
3222
|
+
if (input.repo) {
|
|
3223
|
+
await fetchRepoAnalyticsData(input.repo, input.time, spinner, apiKey, input.outputJson, input.file);
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
};
|
|
3229
|
+
const analyticsFlags = {
|
|
3230
|
+
scope: {
|
|
3231
|
+
type: 'string',
|
|
3232
|
+
shortFlag: 's',
|
|
3233
|
+
default: 'org',
|
|
3234
|
+
description: "Scope of the analytics data - either 'org' or 'repo'"
|
|
3235
|
+
},
|
|
3236
|
+
time: {
|
|
3237
|
+
type: 'number',
|
|
3238
|
+
shortFlag: 't',
|
|
3239
|
+
default: 7,
|
|
3240
|
+
description: 'Time filter - either 7, 30 or 90'
|
|
3241
|
+
},
|
|
3242
|
+
repo: {
|
|
3243
|
+
type: 'string',
|
|
3244
|
+
shortFlag: 'r',
|
|
3245
|
+
default: '',
|
|
3246
|
+
description: "Name of the repository"
|
|
3247
|
+
},
|
|
3248
|
+
file: {
|
|
3249
|
+
type: 'string',
|
|
3250
|
+
shortFlag: 'f',
|
|
3251
|
+
default: '',
|
|
3252
|
+
description: "Path to a local file to save the output"
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
|
|
3256
|
+
// Internal functions
|
|
3257
|
+
|
|
3258
|
+
function setupCommand$2(name, description, argv, importMeta) {
|
|
3259
|
+
const flags = {
|
|
3260
|
+
..._flags$2.outputFlags,
|
|
3261
|
+
...analyticsFlags
|
|
3262
|
+
};
|
|
3263
|
+
const cli = (0, _meow$2.default)(`
|
|
3264
|
+
Usage
|
|
3265
|
+
$ ${name} --scope=<scope> --time=<time filter>
|
|
3266
|
+
|
|
3267
|
+
Options
|
|
3268
|
+
${(0, _formatting$2.printFlagList)(flags, 6)}
|
|
3269
|
+
|
|
3270
|
+
Examples
|
|
3271
|
+
$ ${name} --scope=org --time=7
|
|
3272
|
+
$ ${name} --scope=org --time=30
|
|
3273
|
+
$ ${name} --scope=repo --repo=test-repo --time=30
|
|
3274
|
+
`, {
|
|
3275
|
+
argv,
|
|
3276
|
+
description,
|
|
3277
|
+
importMeta,
|
|
3278
|
+
flags
|
|
3279
|
+
});
|
|
3280
|
+
const {
|
|
3281
|
+
json: outputJson,
|
|
3282
|
+
scope,
|
|
3283
|
+
time,
|
|
3284
|
+
repo,
|
|
3285
|
+
file
|
|
3286
|
+
} = cli.flags;
|
|
3287
|
+
if (scope !== 'org' && scope !== 'repo') {
|
|
3288
|
+
throw new _errors$3.InputError("The scope must either be 'org' or 'repo'");
|
|
3289
|
+
}
|
|
3290
|
+
if (time !== 7 && time !== 30 && time !== 90) {
|
|
3291
|
+
throw new _errors$3.InputError('The time filter must either be 7, 30 or 90');
|
|
3292
|
+
}
|
|
3293
|
+
if (scope === 'repo' && !repo) {
|
|
3294
|
+
console.error(`${_chalk$2.default.bgRed.white('Input error')}: Please provide a repository name when using the repository scope. \n`);
|
|
3295
|
+
cli.showHelp();
|
|
3296
|
+
return;
|
|
3297
|
+
}
|
|
3298
|
+
return {
|
|
3299
|
+
scope,
|
|
3300
|
+
time,
|
|
3301
|
+
repo,
|
|
3302
|
+
outputJson,
|
|
3303
|
+
file
|
|
3304
|
+
};
|
|
3305
|
+
}
|
|
3306
|
+
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'];
|
|
3307
|
+
async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath) {
|
|
3308
|
+
const socketSdk = await (0, _sdk$2.setupSdk)(apiKey);
|
|
3309
|
+
const result = await (0, _apiHelpers$2.handleApiCall)(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
|
|
3310
|
+
if (result.success === false) {
|
|
3311
|
+
return (0, _apiHelpers$2.handleUnsuccessfulApiResponse)('getOrgAnalytics', result, spinner);
|
|
3312
|
+
}
|
|
3313
|
+
spinner.stop();
|
|
3314
|
+
if (!result.data.length) {
|
|
3315
|
+
return console.log('No analytics data is available for this organization yet.');
|
|
3316
|
+
}
|
|
3317
|
+
const data = formatData(result.data, 'org');
|
|
3318
|
+
if (outputJson && !filePath) {
|
|
3319
|
+
return console.log(result.data);
|
|
3320
|
+
}
|
|
3321
|
+
if (filePath) {
|
|
3322
|
+
_fs$1.writeFile(filePath, JSON.stringify(result.data), err => {
|
|
3323
|
+
err ? console.error(err) : console.log(`Data successfully written to ${filePath}`);
|
|
3324
|
+
});
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
return displayAnalyticsScreen(data);
|
|
3328
|
+
}
|
|
3329
|
+
const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
3330
|
+
const formatDate = date => {
|
|
3331
|
+
return `${months[new Date(date).getMonth()]} ${new Date(date).getDate()}`;
|
|
3332
|
+
};
|
|
3333
|
+
const formatData = (data, scope) => {
|
|
3334
|
+
let formattedData, sortedTopFivealerts;
|
|
3335
|
+
if (scope === 'org') {
|
|
3336
|
+
const topFiveAlerts = data.map(d => d['top_five_alert_types']);
|
|
3337
|
+
const totalTopAlerts = topFiveAlerts.reduce((acc, current) => {
|
|
3338
|
+
const alertTypes = Object.keys(current);
|
|
3339
|
+
alertTypes.map(type => {
|
|
3340
|
+
if (!acc[type]) {
|
|
3341
|
+
acc[type] = current[type];
|
|
3342
|
+
} else {
|
|
3343
|
+
acc[type] += current[type];
|
|
3344
|
+
}
|
|
3345
|
+
return acc;
|
|
3346
|
+
});
|
|
3347
|
+
return acc;
|
|
3348
|
+
}, {});
|
|
3349
|
+
sortedTopFivealerts = Object.entries(totalTopAlerts).sort(([, a], [, b]) => b - a).slice(0, 5).reduce((r, [k, v]) => ({
|
|
3350
|
+
...r,
|
|
3351
|
+
[k]: v
|
|
3352
|
+
}), {});
|
|
3353
|
+
const formatData = label => {
|
|
3354
|
+
return data.reduce((acc, current) => {
|
|
3355
|
+
const date = formatDate(current['created_at']);
|
|
3356
|
+
if (!acc[date]) {
|
|
3357
|
+
acc[date] = current[label];
|
|
3358
|
+
} else {
|
|
3359
|
+
acc[date] += current[label];
|
|
3360
|
+
}
|
|
3361
|
+
return acc;
|
|
3362
|
+
}, {});
|
|
3363
|
+
};
|
|
3364
|
+
formattedData = METRICS.reduce((acc, current) => {
|
|
3365
|
+
acc[current] = formatData(current);
|
|
3366
|
+
return acc;
|
|
3367
|
+
}, {});
|
|
3368
|
+
} else if (scope === 'repo') {
|
|
3369
|
+
const topAlerts = data.reduce((acc, current) => {
|
|
3370
|
+
const alertTypes = Object.keys(current['top_five_alert_types']);
|
|
3371
|
+
alertTypes.map(type => {
|
|
3372
|
+
if (!acc[type]) {
|
|
3373
|
+
acc[type] = current['top_five_alert_types'][type];
|
|
3374
|
+
} else {
|
|
3375
|
+
if (current['top_five_alert_types'][type] > (acc[type] || 0)) {
|
|
3376
|
+
acc[type] = current['top_five_alert_types'][type];
|
|
3377
|
+
}
|
|
3378
|
+
}
|
|
3379
|
+
return acc;
|
|
3380
|
+
});
|
|
3381
|
+
return acc;
|
|
3382
|
+
}, {});
|
|
3383
|
+
sortedTopFivealerts = Object.entries(topAlerts).sort(([, a], [, b]) => b - a).slice(0, 5).reduce((r, [k, v]) => ({
|
|
3384
|
+
...r,
|
|
3385
|
+
[k]: v
|
|
3386
|
+
}), {});
|
|
3387
|
+
formattedData = data.reduce((acc, current) => {
|
|
3388
|
+
METRICS.forEach(m => {
|
|
3389
|
+
if (!acc[m]) {
|
|
3390
|
+
acc[m] = {};
|
|
3391
|
+
}
|
|
3392
|
+
acc[m][formatDate(current['created_at'])] = current[m];
|
|
3393
|
+
return acc;
|
|
3394
|
+
});
|
|
3395
|
+
return acc;
|
|
3396
|
+
}, {});
|
|
3397
|
+
}
|
|
3398
|
+
return {
|
|
3399
|
+
...formattedData,
|
|
3400
|
+
top_five_alert_types: sortedTopFivealerts
|
|
3401
|
+
};
|
|
3402
|
+
};
|
|
3403
|
+
async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, filePath) {
|
|
3404
|
+
const socketSdk = await (0, _sdk$2.setupSdk)(apiKey);
|
|
3405
|
+
const result = await (0, _apiHelpers$2.handleApiCall)(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
|
|
3406
|
+
if (result.success === false) {
|
|
3407
|
+
return (0, _apiHelpers$2.handleUnsuccessfulApiResponse)('getRepoAnalytics', result, spinner);
|
|
3408
|
+
}
|
|
3409
|
+
spinner.stop();
|
|
3410
|
+
if (!result.data.length) {
|
|
3411
|
+
return console.log('No analytics data is available for this organization yet.');
|
|
3412
|
+
}
|
|
3413
|
+
const data = formatData(result.data, 'repo');
|
|
3414
|
+
if (outputJson && !filePath) {
|
|
3415
|
+
return console.log(result.data);
|
|
3416
|
+
}
|
|
3417
|
+
if (filePath) {
|
|
3418
|
+
_fs$1.writeFile(filePath, JSON.stringify(result.data), err => {
|
|
3419
|
+
err ? console.error(err) : console.log(`Data successfully written to ${filePath}`);
|
|
3420
|
+
});
|
|
3421
|
+
return;
|
|
3422
|
+
}
|
|
3423
|
+
return displayAnalyticsScreen(data);
|
|
3424
|
+
}
|
|
3425
|
+
const displayAnalyticsScreen = data => {
|
|
3426
|
+
const screen = _blessed$1.screen();
|
|
3427
|
+
// eslint-disable-next-line
|
|
3428
|
+
const grid = new _blessedContrib$1.grid({
|
|
3429
|
+
rows: 5,
|
|
3430
|
+
cols: 4,
|
|
3431
|
+
screen
|
|
3432
|
+
});
|
|
3433
|
+
renderLineCharts(grid, screen, 'Total critical alerts', [0, 0, 1, 2], data['total_critical_alerts']);
|
|
3434
|
+
renderLineCharts(grid, screen, 'Total high alerts', [0, 2, 1, 2], data['total_high_alerts']);
|
|
3435
|
+
renderLineCharts(grid, screen, 'Total critical alerts added to the main branch', [1, 0, 1, 2], data['total_critical_added']);
|
|
3436
|
+
renderLineCharts(grid, screen, 'Total high alerts added to the main branch', [1, 2, 1, 2], data['total_high_added']);
|
|
3437
|
+
renderLineCharts(grid, screen, 'Total critical alerts prevented from the main branch', [2, 0, 1, 2], data['total_critical_prevented']);
|
|
3438
|
+
renderLineCharts(grid, screen, 'Total high alerts prevented from the main branch', [2, 2, 1, 2], data['total_high_prevented']);
|
|
3439
|
+
renderLineCharts(grid, screen, 'Total medium alerts prevented from the main branch', [3, 0, 1, 2], data['total_medium_prevented']);
|
|
3440
|
+
renderLineCharts(grid, screen, 'Total low alerts prevented from the main branch', [3, 2, 1, 2], data['total_low_prevented']);
|
|
3441
|
+
const bar = grid.set(4, 0, 1, 2, _blessedContrib$1.bar, {
|
|
3442
|
+
label: 'Top 5 alert types',
|
|
3443
|
+
barWidth: 10,
|
|
3444
|
+
barSpacing: 17,
|
|
3445
|
+
xOffset: 0,
|
|
3446
|
+
maxHeight: 9,
|
|
3447
|
+
barBgColor: 'magenta'
|
|
3448
|
+
});
|
|
3449
|
+
screen.append(bar); //must append before setting data
|
|
3450
|
+
|
|
3451
|
+
bar.setData({
|
|
3452
|
+
titles: Object.keys(data.top_five_alert_types),
|
|
3453
|
+
data: Object.values(data.top_five_alert_types)
|
|
3454
|
+
});
|
|
3455
|
+
screen.render();
|
|
3456
|
+
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
3457
|
+
};
|
|
3458
|
+
const renderLineCharts = (grid, screen, title, coords, data) => {
|
|
3459
|
+
const line = grid.set(...coords, _blessedContrib$1.line, {
|
|
3460
|
+
style: {
|
|
3461
|
+
line: "cyan",
|
|
3462
|
+
text: "cyan",
|
|
3463
|
+
baseline: "black"
|
|
3464
|
+
},
|
|
3465
|
+
xLabelPadding: 0,
|
|
3466
|
+
xPadding: 0,
|
|
3467
|
+
xOffset: 0,
|
|
3468
|
+
wholeNumbersOnly: true,
|
|
3469
|
+
legend: {
|
|
3470
|
+
width: 1
|
|
3471
|
+
},
|
|
3472
|
+
label: title
|
|
3473
|
+
});
|
|
3474
|
+
screen.append(line);
|
|
3475
|
+
const lineData = {
|
|
3476
|
+
x: Object.keys(data),
|
|
3477
|
+
y: Object.values(data)
|
|
3478
|
+
};
|
|
3479
|
+
line.setData([lineData]);
|
|
3480
|
+
};
|
|
3481
|
+
|
|
3482
|
+
var diffScan = {};
|
|
3483
|
+
|
|
3484
|
+
var get$1 = {};
|
|
3485
|
+
|
|
3486
|
+
var _interopRequireDefault$2 = vendor.interopRequireDefault.default;
|
|
3487
|
+
Object.defineProperty(get$1, "__esModule", {
|
|
3488
|
+
value: true
|
|
3489
|
+
});
|
|
3490
|
+
get$1.get = void 0;
|
|
3491
|
+
var _chalk$1 = _interopRequireDefault$2(vendor.source);
|
|
3492
|
+
var _fs = require$$0;
|
|
3493
|
+
var _meow$1 = _interopRequireDefault$2(vendor.build);
|
|
3494
|
+
var _ora$1 = _interopRequireDefault$2(vendor.ora);
|
|
3495
|
+
var _util = require$$0$4;
|
|
3496
|
+
var _flags$1 = flags;
|
|
3497
|
+
var _formatting$1 = formatting;
|
|
3498
|
+
var _sdk$1 = sdk.sdk;
|
|
3499
|
+
var _errors$2 = sdk.errors;
|
|
3500
|
+
var _apiHelpers$1 = apiHelpers;
|
|
3501
|
+
const get = get$1.get = {
|
|
3502
|
+
description: 'Get a diff scan for an organization',
|
|
3503
|
+
async run(argv, importMeta, {
|
|
3504
|
+
parentName
|
|
3505
|
+
}) {
|
|
3506
|
+
const name = `${parentName} get`;
|
|
3507
|
+
const input = setupCommand$1(name, get.description, argv, importMeta);
|
|
3508
|
+
if (input) {
|
|
3509
|
+
const apiKey = (0, _sdk$1.getDefaultKey)();
|
|
3510
|
+
if (!apiKey) {
|
|
3511
|
+
throw new _errors$2.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3512
|
+
}
|
|
3513
|
+
const spinnerText = 'Getting diff scan... \n';
|
|
3514
|
+
const spinner = (0, _ora$1.default)(spinnerText).start();
|
|
3515
|
+
await getDiffScan(input, spinner, apiKey);
|
|
3516
|
+
}
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
const getDiffScanFlags = {
|
|
3520
|
+
before: {
|
|
3521
|
+
type: 'string',
|
|
3522
|
+
shortFlag: 'b',
|
|
3523
|
+
default: '',
|
|
3524
|
+
description: 'The full scan ID of the base scan'
|
|
3525
|
+
},
|
|
3526
|
+
after: {
|
|
3527
|
+
type: 'string',
|
|
3528
|
+
shortFlag: 'a',
|
|
3529
|
+
default: '',
|
|
3530
|
+
description: 'The full scan ID of the head scan'
|
|
3531
|
+
},
|
|
3532
|
+
preview: {
|
|
3533
|
+
type: 'boolean',
|
|
3534
|
+
shortFlag: 'p',
|
|
3535
|
+
default: true,
|
|
3536
|
+
description: 'A boolean flag to persist or not the diff scan result'
|
|
3537
|
+
},
|
|
3538
|
+
file: {
|
|
3539
|
+
type: 'string',
|
|
3540
|
+
shortFlag: 'f',
|
|
3541
|
+
default: '',
|
|
3542
|
+
description: 'Path to a local file where the output should be saved'
|
|
3543
|
+
}
|
|
3544
|
+
};
|
|
3545
|
+
|
|
3546
|
+
// Internal functions
|
|
3547
|
+
|
|
3548
|
+
function setupCommand$1(name, description, argv, importMeta) {
|
|
3549
|
+
const flags = {
|
|
3550
|
+
..._flags$1.outputFlags,
|
|
3551
|
+
...getDiffScanFlags
|
|
3552
|
+
};
|
|
3553
|
+
const cli = (0, _meow$1.default)(`
|
|
3554
|
+
Usage
|
|
3555
|
+
$ ${name} <org slug> --before=<before> --after=<after>
|
|
3556
|
+
|
|
3557
|
+
Options
|
|
3558
|
+
${(0, _formatting$1.printFlagList)(flags, 6)}
|
|
3559
|
+
|
|
3560
|
+
Examples
|
|
3561
|
+
$ ${name} FakeCorp --before=aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 --after=aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
|
|
3562
|
+
`, {
|
|
3563
|
+
argv,
|
|
3564
|
+
description,
|
|
3565
|
+
importMeta,
|
|
3566
|
+
flags
|
|
3567
|
+
});
|
|
3568
|
+
const {
|
|
3569
|
+
json: outputJson,
|
|
3570
|
+
markdown: outputMarkdown,
|
|
3571
|
+
before,
|
|
3572
|
+
after,
|
|
3573
|
+
preview,
|
|
3574
|
+
file
|
|
3575
|
+
} = cli.flags;
|
|
3576
|
+
if (!before || !after) {
|
|
3577
|
+
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please specify a before and after full scan ID. To get full scans IDs, you can run the command "socket scan list <your org slug>". \n`);
|
|
3578
|
+
cli.showHelp();
|
|
3579
|
+
return;
|
|
3580
|
+
}
|
|
3581
|
+
if (cli.input.length < 1) {
|
|
3582
|
+
console.error(`${_chalk$1.default.bgRed.white('Input error')}: Please provide an organization slug \n`);
|
|
3583
|
+
cli.showHelp();
|
|
3584
|
+
return;
|
|
3585
|
+
}
|
|
3586
|
+
const [orgSlug = ''] = cli.input;
|
|
3587
|
+
return {
|
|
3588
|
+
outputJson,
|
|
3589
|
+
outputMarkdown,
|
|
3590
|
+
before,
|
|
3591
|
+
after,
|
|
3592
|
+
preview,
|
|
3593
|
+
orgSlug,
|
|
3594
|
+
file
|
|
3595
|
+
};
|
|
3596
|
+
}
|
|
3597
|
+
async function getDiffScan({
|
|
3598
|
+
before,
|
|
3599
|
+
after,
|
|
3600
|
+
orgSlug,
|
|
3601
|
+
file,
|
|
3602
|
+
outputJson
|
|
3603
|
+
}, spinner, apiKey) {
|
|
3604
|
+
const response = await (0, _apiHelpers$1.queryOrgsAPI)(`${orgSlug}/full-scans/diff?before=${before}&after=${after}&preview`, apiKey);
|
|
3605
|
+
const data = await response.json();
|
|
3606
|
+
if (!response.ok) {
|
|
3607
|
+
spinner.stop();
|
|
3608
|
+
const err = await (0, _apiHelpers$1.handleAPIError)(response.status);
|
|
3609
|
+
console.error(`${_chalk$1.default.bgRed.white(response.statusText)}: ${err} \n`);
|
|
3610
|
+
return;
|
|
3611
|
+
}
|
|
3612
|
+
spinner.stop();
|
|
3613
|
+
if (file && !outputJson) {
|
|
3614
|
+
_fs.writeFile(file, JSON.stringify(data), err => {
|
|
3615
|
+
err ? console.error(err) : console.log(`Data successfully written to ${file}`);
|
|
3616
|
+
});
|
|
3617
|
+
return;
|
|
3618
|
+
}
|
|
3619
|
+
if (outputJson) {
|
|
3620
|
+
console.log(`\n Diff scan result: \n`);
|
|
3621
|
+
console.log(_util.inspect(data, {
|
|
3622
|
+
showHidden: false,
|
|
3623
|
+
depth: null,
|
|
3624
|
+
colors: true
|
|
3625
|
+
}));
|
|
3626
|
+
// @ts-ignore
|
|
3627
|
+
console.log(`\n View this diff scan in the Socket dashboard: ${_chalk$1.default.cyan(data.diff_report_url)} \n`);
|
|
3628
|
+
return;
|
|
3629
|
+
}
|
|
3630
|
+
console.log("Diff scan result: ");
|
|
3631
|
+
console.log(data);
|
|
3632
|
+
console.log(`\n 📝 To display the detailed report in the terminal, use the --json flag \n`);
|
|
3633
|
+
// @ts-ignore
|
|
3634
|
+
console.log(`\n View this diff scan in the Socket dashboard: ${_chalk$1.default.cyan(data.diff_report_url)} \n`);
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
Object.defineProperty(diffScan, "__esModule", {
|
|
3638
|
+
value: true
|
|
3639
|
+
});
|
|
3640
|
+
diffScan.diffScan = void 0;
|
|
3641
|
+
var _get = get$1;
|
|
3642
|
+
var _meowWithSubcommands$1 = meowWithSubcommands$1;
|
|
3643
|
+
const description = 'Diff scans related commands';
|
|
3644
|
+
diffScan.diffScan = {
|
|
3645
|
+
description,
|
|
3646
|
+
run: async (argv, importMeta, {
|
|
3647
|
+
parentName
|
|
3648
|
+
}) => {
|
|
3649
|
+
await (0, _meowWithSubcommands$1.meowWithSubcommands)({
|
|
3650
|
+
get: _get.get
|
|
3651
|
+
}, {
|
|
3652
|
+
argv,
|
|
3653
|
+
description,
|
|
3654
|
+
importMeta,
|
|
3655
|
+
name: parentName + ' diff-scan'
|
|
3656
|
+
});
|
|
3657
|
+
}
|
|
3658
|
+
};
|
|
3659
|
+
|
|
3660
|
+
var threatFeed$1 = {};
|
|
3661
|
+
|
|
3662
|
+
var _interopRequireDefault$1 = vendor.interopRequireDefault.default;
|
|
3663
|
+
Object.defineProperty(threatFeed$1, "__esModule", {
|
|
3664
|
+
value: true
|
|
3665
|
+
});
|
|
3666
|
+
threatFeed$1.threatFeed = void 0;
|
|
3667
|
+
var _blessed = require$$1$2;
|
|
3668
|
+
var _blessedContrib = require$$2$3;
|
|
3669
|
+
var _meow = _interopRequireDefault$1(vendor.build);
|
|
3670
|
+
var _ora = _interopRequireDefault$1(vendor.ora);
|
|
3671
|
+
var _flags = flags;
|
|
3672
|
+
var _formatting = formatting;
|
|
3673
|
+
var _sdk = sdk.sdk;
|
|
3674
|
+
var _errors$1 = sdk.errors;
|
|
3675
|
+
var _apiHelpers = apiHelpers;
|
|
3676
|
+
/* Not a fan of adding the no-check, mainly doing it because
|
|
3677
|
+
the types associated with the blessed packages
|
|
3678
|
+
create some type errors
|
|
3679
|
+
*/
|
|
3680
|
+
// @ts-nocheck
|
|
3681
|
+
// @ts-ignore
|
|
3682
|
+
|
|
3683
|
+
// @ts-ignore
|
|
3684
|
+
|
|
3685
|
+
const threatFeed = threatFeed$1.threatFeed = {
|
|
3686
|
+
description: 'Look up the threat feed',
|
|
3687
|
+
async run(argv, importMeta, {
|
|
3688
|
+
parentName
|
|
3689
|
+
}) {
|
|
3690
|
+
const name = parentName + ' threat-feed';
|
|
3691
|
+
const input = setupCommand(name, threatFeed.description, argv, importMeta);
|
|
3692
|
+
if (input) {
|
|
3693
|
+
const apiKey = (0, _sdk.getDefaultKey)();
|
|
3694
|
+
if (!apiKey) {
|
|
3695
|
+
throw new _errors$1.AuthError("User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.");
|
|
3696
|
+
}
|
|
3697
|
+
const spinner = (0, _ora.default)(`Looking up the threat feed \n`).start();
|
|
3698
|
+
await fetchThreatFeed(input, spinner, apiKey);
|
|
3699
|
+
}
|
|
3700
|
+
}
|
|
3701
|
+
};
|
|
3702
|
+
const threatFeedFlags = {
|
|
3703
|
+
perPage: {
|
|
3704
|
+
type: 'number',
|
|
3705
|
+
shortFlag: 'pp',
|
|
3706
|
+
default: 30,
|
|
3707
|
+
description: 'Number of items per page'
|
|
3708
|
+
},
|
|
3709
|
+
page: {
|
|
3710
|
+
type: 'string',
|
|
3711
|
+
shortFlag: 'p',
|
|
3712
|
+
default: '1',
|
|
3713
|
+
description: 'Page token'
|
|
3714
|
+
},
|
|
3715
|
+
direction: {
|
|
3716
|
+
type: 'string',
|
|
3717
|
+
shortFlag: 'd',
|
|
3718
|
+
default: 'desc',
|
|
3719
|
+
description: 'Order asc or desc by the createdAt attribute.'
|
|
3720
|
+
},
|
|
3721
|
+
filter: {
|
|
3722
|
+
type: 'string',
|
|
3723
|
+
shortFlag: 'f',
|
|
3724
|
+
default: 'mal',
|
|
3725
|
+
description: 'Filter what type of threats to return'
|
|
3726
|
+
}
|
|
3727
|
+
};
|
|
3728
|
+
|
|
3729
|
+
// Internal functions
|
|
3730
|
+
|
|
3731
|
+
function setupCommand(name, description, argv, importMeta) {
|
|
3732
|
+
const flags = {
|
|
3733
|
+
...threatFeedFlags,
|
|
3734
|
+
..._flags.outputFlags
|
|
3735
|
+
};
|
|
3736
|
+
const cli = (0, _meow.default)(`
|
|
3737
|
+
Usage
|
|
3738
|
+
$ ${name}
|
|
3739
|
+
|
|
3740
|
+
Options
|
|
3741
|
+
${(0, _formatting.printFlagList)(flags, 6)}
|
|
3742
|
+
|
|
3743
|
+
Examples
|
|
3744
|
+
$ ${name}
|
|
3745
|
+
$ ${name} --perPage=5 --page=2 --direction=asc --filter=joke
|
|
3746
|
+
`, {
|
|
3747
|
+
argv,
|
|
3748
|
+
description,
|
|
3749
|
+
importMeta,
|
|
3750
|
+
flags
|
|
3751
|
+
});
|
|
3752
|
+
const {
|
|
3753
|
+
json: outputJson,
|
|
3754
|
+
markdown: outputMarkdown,
|
|
3755
|
+
perPage: per_page,
|
|
3756
|
+
page,
|
|
3757
|
+
direction,
|
|
3758
|
+
filter
|
|
3759
|
+
} = cli.flags;
|
|
3760
|
+
return {
|
|
3761
|
+
outputJson,
|
|
3762
|
+
outputMarkdown,
|
|
3763
|
+
per_page,
|
|
3764
|
+
page,
|
|
3765
|
+
direction,
|
|
3766
|
+
filter
|
|
3767
|
+
};
|
|
3768
|
+
}
|
|
3769
|
+
async function fetchThreatFeed({
|
|
3770
|
+
per_page,
|
|
3771
|
+
page,
|
|
3772
|
+
direction,
|
|
3773
|
+
filter,
|
|
3774
|
+
outputJson
|
|
3775
|
+
}, spinner, apiKey) {
|
|
3776
|
+
const formattedQueryParams = formatQueryParams({
|
|
3777
|
+
per_page,
|
|
3778
|
+
page,
|
|
3779
|
+
direction,
|
|
3780
|
+
filter
|
|
3781
|
+
}).join('&');
|
|
3782
|
+
const response = await (0, _apiHelpers.queryAPI)(`threat-feed?${formattedQueryParams}`, apiKey);
|
|
3783
|
+
const data = await response.json();
|
|
3784
|
+
spinner.stop();
|
|
3785
|
+
if (outputJson) {
|
|
3786
|
+
return console.log(data);
|
|
3787
|
+
}
|
|
3788
|
+
const screen = _blessed.screen();
|
|
3789
|
+
var table = _blessedContrib.table({
|
|
3790
|
+
keys: 'true',
|
|
3791
|
+
fg: 'white',
|
|
3792
|
+
selectedFg: 'white',
|
|
3793
|
+
selectedBg: 'magenta',
|
|
3794
|
+
interactive: 'true',
|
|
3795
|
+
label: 'Threat feed',
|
|
3796
|
+
width: '100%',
|
|
3797
|
+
height: '100%',
|
|
3798
|
+
border: {
|
|
3799
|
+
type: "line",
|
|
3800
|
+
fg: "cyan"
|
|
3801
|
+
},
|
|
3802
|
+
columnSpacing: 3,
|
|
3803
|
+
//in chars
|
|
3804
|
+
columnWidth: [9, 30, 10, 17, 13, 100] /*in chars*/
|
|
3805
|
+
});
|
|
3806
|
+
|
|
3807
|
+
// allow control the table with the keyboard
|
|
3808
|
+
table.focus();
|
|
3809
|
+
screen.append(table);
|
|
3810
|
+
const formattedOutput = formatResults(data.results);
|
|
3811
|
+
table.setData({
|
|
3812
|
+
headers: ['Ecosystem', 'Name', 'Version', 'Threat type', 'Detected at', 'Details'],
|
|
3813
|
+
data: formattedOutput
|
|
3814
|
+
});
|
|
3815
|
+
screen.render();
|
|
3816
|
+
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
3817
|
+
}
|
|
3818
|
+
const formatResults = data => {
|
|
3819
|
+
return data.map(d => {
|
|
3820
|
+
const ecosystem = d.purl.split('pkg:')[1].split('/')[0];
|
|
3821
|
+
const name = d.purl.split('/')[1].split('@')[0];
|
|
3822
|
+
const version = d.purl.split('@')[1];
|
|
3823
|
+
const timeStart = new Date(d.createdAt);
|
|
3824
|
+
const timeEnd = new Date();
|
|
3825
|
+
const diff = getHourDiff(timeStart, timeEnd);
|
|
3826
|
+
const hourDiff = diff > 0 ? `${diff} hours ago` : `${getMinDiff(timeStart, timeEnd)} minutes ago`;
|
|
3827
|
+
return [ecosystem, decodeURIComponent(name), version, d.threatType, hourDiff, d.locationHtmlUrl];
|
|
3828
|
+
});
|
|
3829
|
+
};
|
|
3830
|
+
const formatQueryParams = params => Object.entries(params).map(entry => `${entry[0]}=${entry[1]}`);
|
|
3831
|
+
const getHourDiff = (start, end) => Math.floor((end - start) / 3600000);
|
|
3832
|
+
const getMinDiff = (start, end) => Math.floor((end - start) / 60000);
|
|
3833
|
+
|
|
3834
|
+
(function (exports) {
|
|
3835
|
+
|
|
3836
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3837
|
+
value: true
|
|
3838
|
+
});
|
|
3839
|
+
var _cdxgen = cdxgen;
|
|
3840
|
+
Object.keys(_cdxgen).forEach(function (key) {
|
|
3841
|
+
if (key === "default" || key === "__esModule") return;
|
|
3842
|
+
if (key in exports && exports[key] === _cdxgen[key]) return;
|
|
3843
|
+
Object.defineProperty(exports, key, {
|
|
3844
|
+
enumerable: true,
|
|
3845
|
+
get: function () {
|
|
3846
|
+
return _cdxgen[key];
|
|
3847
|
+
}
|
|
3848
|
+
});
|
|
3849
|
+
});
|
|
3850
|
+
var _info = info$1;
|
|
3851
|
+
Object.keys(_info).forEach(function (key) {
|
|
3852
|
+
if (key === "default" || key === "__esModule") return;
|
|
3853
|
+
if (key in exports && exports[key] === _info[key]) return;
|
|
3854
|
+
Object.defineProperty(exports, key, {
|
|
3855
|
+
enumerable: true,
|
|
3856
|
+
get: function () {
|
|
3857
|
+
return _info[key];
|
|
3858
|
+
}
|
|
3859
|
+
});
|
|
3860
|
+
});
|
|
3180
3861
|
var _login = login;
|
|
3181
3862
|
Object.keys(_login).forEach(function (key) {
|
|
3182
3863
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3319,6 +4000,39 @@ async function searchDeps({
|
|
|
3319
4000
|
return _dependencies[key];
|
|
3320
4001
|
}
|
|
3321
4002
|
});
|
|
4003
|
+
});
|
|
4004
|
+
var _analytics = analytics$1;
|
|
4005
|
+
Object.keys(_analytics).forEach(function (key) {
|
|
4006
|
+
if (key === "default" || key === "__esModule") return;
|
|
4007
|
+
if (key in exports && exports[key] === _analytics[key]) return;
|
|
4008
|
+
Object.defineProperty(exports, key, {
|
|
4009
|
+
enumerable: true,
|
|
4010
|
+
get: function () {
|
|
4011
|
+
return _analytics[key];
|
|
4012
|
+
}
|
|
4013
|
+
});
|
|
4014
|
+
});
|
|
4015
|
+
var _diffScan = diffScan;
|
|
4016
|
+
Object.keys(_diffScan).forEach(function (key) {
|
|
4017
|
+
if (key === "default" || key === "__esModule") return;
|
|
4018
|
+
if (key in exports && exports[key] === _diffScan[key]) return;
|
|
4019
|
+
Object.defineProperty(exports, key, {
|
|
4020
|
+
enumerable: true,
|
|
4021
|
+
get: function () {
|
|
4022
|
+
return _diffScan[key];
|
|
4023
|
+
}
|
|
4024
|
+
});
|
|
4025
|
+
});
|
|
4026
|
+
var _threatFeed = threatFeed$1;
|
|
4027
|
+
Object.keys(_threatFeed).forEach(function (key) {
|
|
4028
|
+
if (key === "default" || key === "__esModule") return;
|
|
4029
|
+
if (key in exports && exports[key] === _threatFeed[key]) return;
|
|
4030
|
+
Object.defineProperty(exports, key, {
|
|
4031
|
+
enumerable: true,
|
|
4032
|
+
get: function () {
|
|
4033
|
+
return _threatFeed[key];
|
|
4034
|
+
}
|
|
4035
|
+
});
|
|
3322
4036
|
});
|
|
3323
4037
|
} (commands));
|
|
3324
4038
|
|
|
@@ -3326,7 +4040,7 @@ var _interopRequireWildcard = vendor.interopRequireWildcard.default;
|
|
|
3326
4040
|
var _interopRequireDefault = vendor.interopRequireDefault.default;
|
|
3327
4041
|
var _nodeFs = require$$0;
|
|
3328
4042
|
var _nodePath = require$$1;
|
|
3329
|
-
var _nodeUrl = require$$2$
|
|
4043
|
+
var _nodeUrl = require$$2$4;
|
|
3330
4044
|
var _chalk = _interopRequireDefault(vendor.source);
|
|
3331
4045
|
var _ponyCause = require$$6;
|
|
3332
4046
|
var _updateNotifier = _interopRequireDefault(vendor.updateNotifier);
|