@socketsecurity/cli 0.14.62 → 0.14.63

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.
@@ -16,25 +16,20 @@ var ponyCause = _socketInterop(require('pony-cause'));
16
16
  var vendor = require('./vendor.js');
17
17
  var colors = _socketInterop(require('yoctocolors-cjs'));
18
18
  var logger = require('@socketsecurity/registry/lib/logger');
19
- var micromatch = _socketInterop(require('micromatch'));
20
- var simpleGit = _socketInterop(require('simple-git'));
21
- var sdk = require('@socketsecurity/sdk');
22
- var events = require('node:events');
23
- var fs = require('node:fs');
24
- var path = require('node:path');
25
- var ndjson = _socketInterop(require('ndjson'));
19
+ var commonTags = _socketInterop(require('common-tags'));
20
+ var fs = require('node:fs/promises');
21
+ var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
22
+ var contrib = _socketInterop(require('blessed-contrib'));
26
23
  var shadowNpmInject = require('./shadow-npm-inject.js');
27
24
  var constants = require('./constants.js');
25
+ var path$1 = require('node:path');
28
26
  var objects = require('@socketsecurity/registry/lib/objects');
29
- var path$1 = require('@socketsecurity/registry/lib/path');
27
+ var path = require('@socketsecurity/registry/lib/path');
30
28
  var regexps = require('@socketsecurity/registry/lib/regexps');
31
- var commonTags = _socketInterop(require('common-tags'));
32
- var fs$1 = require('node:fs/promises');
33
- var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
34
- var contrib = _socketInterop(require('blessed-contrib'));
35
29
  var prompts = require('@socketsecurity/registry/lib/prompts');
36
30
  var yargsParse = _socketInterop(require('yargs-parser'));
37
31
  var words = require('@socketsecurity/registry/lib/words');
32
+ var fs$1 = require('node:fs');
38
33
  var shadowBin = require('./shadow-bin.js');
39
34
  var chalkTable = _socketInterop(require('chalk-table'));
40
35
  var require$$0$1 = require('node:util');
@@ -67,1229 +62,6 @@ var BoxWidget = _socketInterop(require('blessed/lib/widgets/box'));
67
62
  var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
68
63
  var readline$1 = require('node:readline');
69
64
 
70
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/classes.py
71
-
72
- class Comment {
73
- id = 0;
74
- body = '';
75
- body_list = [];
76
- constructor(arg) {
77
- this.id = arg.id ?? this.id;
78
- this.body = arg.body ?? this.body;
79
- this.body_list = arg.body_list ?? this.body_list;
80
- }
81
- }
82
- class Diff {
83
- newPackages = [];
84
- newCapabilities = {};
85
- removedPackages = [];
86
- newAlerts = [];
87
- id = '';
88
- sbom = '';
89
- packages = {};
90
- reportUrl = '';
91
- diffUrl = '';
92
- }
93
- class FullScan {
94
- id = '';
95
- created_at = '';
96
- updated_at = '';
97
- organizationId = '';
98
- repositoryId = '';
99
- branch = '';
100
- commit_message = '';
101
- commit_hash = '';
102
- pull_request = 0;
103
- sbom_artifacts = [];
104
- packages = {};
105
- constructor(obj = {}) {
106
- this.id = obj.id ?? this.id;
107
- this.created_at = obj.created_at ?? this.created_at;
108
- this.updated_at = obj.updated_at ?? this.updated_at;
109
- this.organizationId = obj.organizationId ?? this.organizationId;
110
- this.repositoryId = obj.repositoryId ?? this.repositoryId;
111
- this.branch = obj.branch ?? this.branch;
112
- this.commit_message = obj.commit_message ?? this.commit_message;
113
- this.commit_hash = obj.commit_hash ?? this.commit_hash;
114
- this.pull_request = obj.pull_request ?? this.pull_request;
115
- this.sbom_artifacts = obj.sbom_artifacts ?? this.sbom_artifacts;
116
- this.packages = obj.packages ?? this.packages;
117
- }
118
- }
119
- class Issue {
120
- pkg_type = '';
121
- pkg_name = '';
122
- pkg_version = '';
123
- category = '';
124
- type = '';
125
- severity = '';
126
- pkg_id = '';
127
- props = {};
128
- key = '';
129
- error = false;
130
- warn = false;
131
- ignore = false;
132
- monitor = false;
133
- description = '';
134
- title = '';
135
- emoji = '';
136
- next_step_title = '';
137
- suggestion = '';
138
- introduced_by = [];
139
- manifests = '';
140
- url = '';
141
- purl = '';
142
- constructor(arg) {
143
- this.pkg_type = arg.pkg_type ?? this.pkg_type;
144
- this.pkg_name = arg.pkg_name ?? this.pkg_name;
145
- this.pkg_version = arg.pkg_version ?? this.pkg_version;
146
- this.type = arg.type ?? this.type;
147
- this.severity = arg.severity ?? this.severity;
148
- this.pkg_id = arg.pkg_id ?? this.pkg_id;
149
- this.props = arg.props ?? this.props;
150
- this.key = arg.key ?? this.key;
151
- this.error = arg.error ?? this.error;
152
- this.warn = arg.warn ?? this.warn;
153
- this.ignore = arg.ignore ?? this.ignore;
154
- this.monitor = arg.monitor ?? this.monitor;
155
- this.description = arg.description ?? this.description;
156
- this.title = arg.title ?? this.title;
157
- this.next_step_title = arg.next_step_title ?? this.next_step_title;
158
- this.suggestion = arg.suggestion ?? this.suggestion;
159
- if (arg.introduced_by) {
160
- const arr = [];
161
- for (const item of arg.introduced_by) {
162
- const [, manifest] = item;
163
- arr.push(manifest);
164
- }
165
- this.manifests = arr.join(';');
166
- }
167
- }
168
- }
169
- class Package {
170
- type = '';
171
- name = '';
172
- version = '';
173
- release = '';
174
- id = '';
175
- direct = false;
176
- manifestFiles = [];
177
- author = [];
178
- size = 0;
179
- scores = {};
180
- alerts = [];
181
- alert_counts = {};
182
- topLevelAncestors = [];
183
- url = '';
184
- transitives = 0;
185
- license = 'NoLicenseFound';
186
- license_text = '';
187
- purl = '';
188
- constructor(arg) {
189
- this.type = arg.type ?? this.type;
190
- this.name = arg.name ?? this.name;
191
- this.version = arg.version ?? this.version;
192
- this.release = arg.release ?? this.release;
193
- this.id = arg.id ?? this.id;
194
- this.manifestFiles = arg.manifestFiles ?? this.manifestFiles;
195
- this.author = arg.author ?? this.author;
196
- this.size = arg.size ?? this.size;
197
- this.alerts = arg.alerts ?? this.alerts;
198
- this.topLevelAncestors = arg.topLevelAncestors ?? this.topLevelAncestors;
199
- this.license = arg.license ?? this.license;
200
- this.url = `https://socket.dev/${this.type}/package/${this.name}/overview/${this.version}`;
201
- this.score = new Score(arg.score ?? {
202
- supplyChain: 0,
203
- quality: 0,
204
- license: 0,
205
- overall: 0,
206
- vulnerability: 0
207
- });
208
- this.alert_counts = {
209
- critical: 0,
210
- high: 0,
211
- middle: 0,
212
- low: 0
213
- };
214
- this.purl = `${this.type}/${this.name}@${this.version}`;
215
- }
216
- }
217
- class Purl {
218
- id = '';
219
- name = '';
220
- version = '';
221
- ecosystem = '';
222
- direct = false;
223
- author = [];
224
- size = 0;
225
- transitives = 0;
226
- introduced_by = [];
227
- capabilities = [];
228
- // is_new = false
229
- author_url = '';
230
- url = '';
231
- purl = '';
232
- constructor(arg) {
233
- this.id = arg.id ?? this.id;
234
- this.name = arg.name ?? this.name;
235
- this.version = arg.version ?? this.version;
236
- this.ecosystem = arg.ecosystem ?? this.ecosystem;
237
- this.direct = arg.direct ?? this.direct;
238
- this.author = arg.author ?? this.author;
239
- this.size = arg.size ?? this.size;
240
- this.transitives = arg.transitives ?? this.transitives;
241
- this.introduced_by = arg.introduced_by ?? this.introduced_by;
242
- this.url = arg.url ?? this.url;
243
- this.purl = arg.purl ?? this.purl;
244
- this.author_url = this.generateAuthorData(this.author, this.ecosystem);
245
- }
246
- generateAuthorData(authors, ecosystem) {
247
- const arr = [];
248
- for (const author of authors) {
249
- const url = `https://socket.dev/${ecosystem}/user/${author}`;
250
- arr.push(`[${author}](${url})`);
251
- }
252
- return arr.join(',');
253
- }
254
- }
255
- class Score {
256
- supplyChain = 0;
257
- quality = 0;
258
- license = 0;
259
- overall = 0;
260
- vulnerability = 0;
261
- constructor(arg) {
262
- this.supplyChain = (arg.supplyChain ?? 0) * 100;
263
- this.quality = (arg.quality ?? 0) * 100;
264
- this.license = (arg.license ?? 0) * 100;
265
- this.overall = (arg.overall ?? 0) * 100;
266
- this.vulnerability = (arg.vulnerability ?? 0) * 100;
267
- }
268
- }
269
-
270
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/__init__.py
271
- class Core {
272
- securityPolicy = {};
273
- constructor({
274
- owner,
275
- repo,
276
- socket
277
- }) {
278
- this.socket = socket;
279
- this.owner = owner;
280
- this.repo = repo;
281
- this.files = [];
282
- }
283
- async getSbomData({
284
- fullScanId
285
- }) {
286
- const orgFullScanResponse = await this.socket.getOrgFullScan(this.owner, fullScanId, undefined);
287
- if (!orgFullScanResponse.success) {
288
- return [];
289
- }
290
- const {
291
- data: readStream
292
- } = orgFullScanResponse;
293
- const sbomArtifacts = [];
294
- readStream.pipe(ndjson.parse()).on('data', sbomArtifact => sbomArtifacts.push(sbomArtifact));
295
- await events.once(readStream, 'end');
296
- return sbomArtifacts;
297
- }
298
- async createFullScan({
299
- params
300
- }) {
301
- const orgFullScanResponse = await this.socket.createOrgFullScan(this.owner,
302
- // Ignoring because pull_request is of type number but URLSearchParams will convert it to a string
303
- // @ts-ignore
304
- new URLSearchParams({
305
- repo: this.repo,
306
- ...params
307
- }), this.files);
308
- if (!orgFullScanResponse.success) {
309
- return new FullScan();
310
- }
311
- const {
312
- id: fullScanId
313
- } = orgFullScanResponse.data;
314
- const fullScan = new FullScan(orgFullScanResponse.data);
315
- if (fullScanId !== undefined) {
316
- fullScan.sbom_artifacts = await this.getSbomData({
317
- fullScanId
318
- });
319
- }
320
- return fullScan;
321
- }
322
- getSourceData({
323
- packages,
324
- pkg
325
- }) {
326
- const introducedBy = [];
327
- if (pkg.direct) {
328
- const manifests = pkg.manifestFiles.map(({
329
- file
330
- }) => file).join(';');
331
- introducedBy.push(['direct', manifests]);
332
- } else {
333
- for (const topId of pkg.topLevelAncestors) {
334
- const topPackage = packages[topId];
335
- if (!topPackage) {
336
- continue;
337
- }
338
- const topPurl = `${topPackage.type}/${topPackage.name}@${topPackage.version}`;
339
- const manifests = topPackage.manifestFiles.map(({
340
- file
341
- }) => file).join(';');
342
- introducedBy.push([topPurl, manifests]);
343
- }
344
- }
345
- return introducedBy;
346
- }
347
- createPurl({
348
- packageId,
349
- packages
350
- }) {
351
- const pkg = packages[packageId];
352
- const introducedBy = this.getSourceData({
353
- pkg,
354
- packages
355
- });
356
- const purl = new Purl({
357
- id: pkg.id,
358
- name: pkg.name,
359
- version: pkg.version,
360
- ecosystem: pkg.type,
361
- direct: pkg.direct,
362
- introduced_by: introducedBy,
363
- author: pkg.author,
364
- size: pkg.size,
365
- transitives: pkg.transitives,
366
- url: pkg.url,
367
- purl: pkg.purl
368
- });
369
- return {
370
- purl,
371
- pkg
372
- };
373
- }
374
- async createIssueAlerts({
375
- alerts,
376
- packages,
377
- pkg
378
- }) {
379
- const issues = JSON.parse(fs.readFileSync(path.join(undefined, 'issues.json'), 'utf8'));
380
- for (const alert of pkg.alerts) {
381
- const issue = issues[alert.type];
382
- let description = '';
383
- let title = '';
384
- let suggestion = '';
385
- let nextStepTitle = '';
386
- if (issue !== undefined) {
387
- description = issue['description'] ?? '';
388
- title = issue['title'] ?? '';
389
- suggestion = issue['suggestion'] ?? '';
390
- nextStepTitle = issue['nextStepTitle'] ?? '';
391
- }
392
- const introducedBy = this.getSourceData({
393
- pkg,
394
- packages
395
- });
396
- const issueAlert = new Issue({
397
- pkg_type: pkg.type,
398
- pkg_name: pkg.name,
399
- pkg_version: pkg.version,
400
- pkg_id: pkg.id,
401
- type: alert.type,
402
- severity: alert.severity,
403
- key: alert.key,
404
- props: alert.props,
405
- description,
406
- title,
407
- suggestion,
408
- next_step_title: nextStepTitle,
409
- introduced_by: introducedBy,
410
- purl: pkg.purl,
411
- url: pkg.url,
412
- error: false,
413
- ignore: false,
414
- warn: false,
415
- monitor: false
416
- });
417
- if (alert.type in this.securityPolicy) {
418
- const action = this.securityPolicy[alert.type]?.action;
419
- if (action !== undefined) {
420
- issueAlert[action] = true;
421
- }
422
- }
423
- if (issueAlert.type !== 'licenseSpdxDisj') {
424
- if (!(issueAlert.key in alerts)) {
425
- alerts[issueAlert.key] = [issueAlert];
426
- } else {
427
- alerts[issueAlert.key].push(issueAlert);
428
- }
429
- }
430
- }
431
- return alerts;
432
- }
433
- compareIssueAlerts({
434
- alerts,
435
- headScanAlerts,
436
- newScanAlerts
437
- }) {
438
- const consolidatedAlerts = new Set();
439
- for (const alertKey in newScanAlerts) {
440
- if (!(alertKey in headScanAlerts)) {
441
- const newAlerts = newScanAlerts[alertKey];
442
- for (const alert of newAlerts) {
443
- const alertStr = `${alert.purl},${alert.manifests},${alert.type}`;
444
- if (alert.error || alert.warn) {
445
- if (!consolidatedAlerts.has(alertStr)) {
446
- alerts.push(alert);
447
- consolidatedAlerts.add(alertStr);
448
- }
449
- }
450
- }
451
- } else {
452
- const newAlerts = newScanAlerts[alertKey];
453
- const headAlerts = headScanAlerts[alertKey];
454
- for (const alert of newAlerts) {
455
- const alertStr = `${alert.purl},${alert.manifests},${alert.type}`;
456
- if (!headAlerts.includes(alert) && !consolidatedAlerts.has(alertStr)) {
457
- if (alert.error || alert.warn) {
458
- alerts.push(alert);
459
- consolidatedAlerts.add(alertStr);
460
- }
461
- }
462
- }
463
- }
464
- }
465
- return alerts;
466
- }
467
- checkAlertCapabilities({
468
- capabilities,
469
- headPackage,
470
- packageId,
471
- pkg
472
- }) {
473
- const alertTypes = {
474
- envVars: 'Environment',
475
- networkAccess: 'Network',
476
- filesystemAccess: 'File System',
477
- shellAccess: 'Shell'
478
- };
479
- for (const alert of pkg.alerts) {
480
- let newAlert = true;
481
- if (headPackage !== undefined && headPackage.alerts.includes(alert)) {
482
- newAlert = false;
483
- }
484
- if (alert.type in alertTypes && newAlert) {
485
- const value = alertTypes[alert.type];
486
- if (!(packageId in capabilities)) {
487
- capabilities[packageId] = [value];
488
- } else {
489
- if (!capabilities[packageId].includes(value)) {
490
- capabilities[packageId].push(value);
491
- }
492
- }
493
- }
494
- }
495
- return capabilities;
496
- }
497
- compareCapabilities({
498
- headPackages,
499
- newPackages
500
- }) {
501
- let capabilities = {};
502
- for (const packageId in newPackages) {
503
- const pkg = newPackages[packageId];
504
- if (packageId in headPackages) {
505
- const headPackage = headPackages[packageId];
506
- for (const alert of pkg.alerts) {
507
- if (!headPackage.alerts.includes(alert)) {
508
- capabilities = this.checkAlertCapabilities({
509
- pkg,
510
- capabilities,
511
- packageId,
512
- headPackage
513
- });
514
- }
515
- }
516
- } else {
517
- capabilities = this.checkAlertCapabilities({
518
- pkg,
519
- capabilities,
520
- packageId
521
- });
522
- }
523
- }
524
- return capabilities;
525
- }
526
- addCapabilitiesToPurl(diff) {
527
- const newPackages = [];
528
- for (const purl of diff.newPackages) {
529
- if (purl.id in diff.newCapabilities) {
530
- const capabilities = diff.newCapabilities[purl.id];
531
- if (capabilities.length > 0) {
532
- purl.capabilities = capabilities;
533
- newPackages.push(purl);
534
- }
535
- } else {
536
- newPackages.push(purl);
537
- }
538
- }
539
- diff.newPackages = newPackages;
540
- return diff;
541
- }
542
- async compareSBOMs({
543
- headScan,
544
- newScan
545
- }) {
546
- let diff = new Diff();
547
- const newPackages = this.createSbomDict(newScan);
548
- const headPackages = this.createSbomDict(headScan);
549
- let newScanAlerts = {};
550
- let headScanAlerts = {};
551
- const consolidated = new Set();
552
- for (const packageId in newPackages) {
553
- const {
554
- pkg,
555
- purl
556
- } = this.createPurl({
557
- packageId,
558
- packages: newPackages
559
- });
560
- const basePurl = `${purl.ecosystem}/${purl.name}@${purl.version}`;
561
- if (!(packageId in headPackages) && pkg.direct && !consolidated.has(basePurl)) {
562
- diff.newPackages.push(purl);
563
- consolidated.add(basePurl);
564
- }
565
- // eslint-disable-next-line no-await-in-loop
566
- newScanAlerts = await this.createIssueAlerts({
567
- pkg,
568
- alerts: newScanAlerts,
569
- packages: newPackages
570
- });
571
- }
572
- for (const packageId in headPackages) {
573
- const {
574
- pkg,
575
- purl
576
- } = this.createPurl({
577
- packageId,
578
- packages: headPackages
579
- });
580
- if (!(packageId in newPackages) && pkg.direct) {
581
- diff.removedPackages.push(purl);
582
- }
583
- // eslint-disable-next-line no-await-in-loop
584
- headScanAlerts = await this.createIssueAlerts({
585
- pkg,
586
- alerts: headScanAlerts,
587
- packages: headPackages
588
- });
589
- }
590
- diff.newAlerts = this.compareIssueAlerts({
591
- newScanAlerts,
592
- headScanAlerts,
593
- alerts: diff.newAlerts
594
- });
595
- diff.newCapabilities = this.compareCapabilities({
596
- newPackages,
597
- headPackages
598
- });
599
- diff = this.addCapabilitiesToPurl(diff);
600
- return diff;
601
- }
602
- createPackageFromSbomArtifact(sbomArtifact) {
603
- return sbomArtifact.map(sbomArtifact => new Package({
604
- type: sbomArtifact.type,
605
- name: sbomArtifact.name,
606
- version: sbomArtifact.version,
607
- release: sbomArtifact.release,
608
- id: sbomArtifact.id,
609
- direct: sbomArtifact.direct,
610
- manifestFiles: sbomArtifact.manifestFiles,
611
- author: sbomArtifact.author,
612
- size: sbomArtifact.size,
613
- score: sbomArtifact.score,
614
- alerts: sbomArtifact.alerts,
615
- topLevelAncestors: sbomArtifact.topLevelAncestors,
616
- license: sbomArtifact.license
617
- }));
618
- }
619
- getLicenseDetails({
620
- package: pkg
621
- }) {
622
- const licenseText = JSON.parse(fs.readFileSync(path.join(undefined, 'license_texts.json'), 'utf8'));
623
- const licenseStr = licenseText[pkg.license];
624
- if (licenseStr !== undefined) {
625
- pkg.license_text = licenseStr;
626
- }
627
- return pkg;
628
- }
629
- createSbomDict(sbomArtifacts) {
630
- const packages = {};
631
- const topLevelCount = {};
632
- for (const sbomArtifact of sbomArtifacts) {
633
- let pkg = new Package({
634
- type: sbomArtifact.type,
635
- name: sbomArtifact.name,
636
- version: sbomArtifact.version,
637
- release: sbomArtifact.release,
638
- id: sbomArtifact.id,
639
- direct: sbomArtifact.direct,
640
- manifestFiles: sbomArtifact.manifestFiles,
641
- author: sbomArtifact.author,
642
- size: sbomArtifact.size,
643
- score: sbomArtifact.score,
644
- alerts: sbomArtifact.alerts,
645
- topLevelAncestors: sbomArtifact.topLevelAncestors,
646
- license: sbomArtifact.license
647
- });
648
- if (pkg.id in packages) {
649
- logger.logger.log('Duplicate package?');
650
- } else {
651
- pkg = this.getLicenseDetails({
652
- package: pkg
653
- });
654
- packages[pkg.id] = pkg;
655
- for (const topId in sbomArtifact.topLevelAncestors ?? []) {
656
- if (!(topId in topLevelCount)) {
657
- topLevelCount[topId] = 1;
658
- } else {
659
- topLevelCount[topId] += 1;
660
- }
661
- }
662
- }
663
- }
664
- if (Object.keys(topLevelCount).length > 0) {
665
- for (const packageId in topLevelCount) {
666
- const pkg = packages[packageId];
667
- if (pkg) {
668
- pkg.transitives = topLevelCount[packageId] ?? 0;
669
- }
670
- }
671
- }
672
- return packages;
673
- }
674
- async createNewDiff({
675
- params = {}
676
- }) {
677
- let headFullScanId = '';
678
- let headFullScan = [];
679
- try {
680
- const orgRepoResponse = await this.socket.getOrgRepo(this.owner, this.repo);
681
- if (orgRepoResponse.success) {
682
- headFullScanId = orgRepoResponse.data.head_full_scan_id ?? '';
683
- if (headFullScanId !== '') {
684
- headFullScan = await this.getSbomData({
685
- fullScanId: headFullScanId
686
- });
687
- }
688
- }
689
- } catch (e) {
690
- logger.logger.error(e);
691
- }
692
- const newFullScan = await this.createFullScan({
693
- params
694
- });
695
- newFullScan.packages = this.createSbomDict(newFullScan.sbom_artifacts);
696
- const diffReport = await this.compareSBOMs({
697
- newScan: newFullScan.sbom_artifacts,
698
- headScan: headFullScan
699
- });
700
- diffReport.packages = newFullScan.packages;
701
- const baseSocket = 'https://socket.dev/dashboard/org';
702
- diffReport.id = newFullScan.id;
703
- diffReport.reportUrl = `${baseSocket}/${this.owner}/sbom/${diffReport.id}`;
704
- if (headFullScanId !== '') {
705
- diffReport.diffUrl = `${baseSocket}/${this.owner}/diff/${diffReport.id}/${headFullScanId}`;
706
- } else {
707
- diffReport.diffUrl = diffReport.reportUrl;
708
- }
709
- return diffReport;
710
- }
711
- }
712
-
713
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/scm_comments.py
714
- function checkForSocketComments({
715
- comments
716
- }) {
717
- const socketComments = {
718
- security: undefined,
719
- overview: undefined,
720
- ignore: []
721
- };
722
- for (const commentId in comments) {
723
- const comment = comments[commentId];
724
- if (comment.body.includes('socket-security-comment-actions')) {
725
- socketComments.security = comment;
726
- } else if (comment.body.includes('socket-overview-comment-actions')) {
727
- socketComments.overview = comment;
728
- } else if (
729
- // Based on:
730
- // To ignore an alert, reply with a comment starting with @SocketSecurity ignore
731
- // followed by a space separated list of ecosystem/package-name@version specifiers.
732
- // e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all
733
- comment.body.split('\n').at(0)?.includes('SocketSecurity ignore')) {
734
- socketComments.ignore.push(comment);
735
- }
736
- }
737
- return socketComments;
738
- }
739
-
740
- // Parses the ignore command
741
- // @SocketSecurity ignore pkg1 pkg2 ...
742
- // @SocketSecurity ignore ignore-all
743
- function parseIgnoreCommand(line) {
744
- const result = {
745
- packages: [],
746
- ignoreAll: false
747
- };
748
- const words = line.trim().replace(/\s+/g, ' ').split(' ');
749
- if (words.at(1) === 'ignore-all') {
750
- result.ignoreAll = true;
751
- return result;
752
- }
753
- if (words.at(1) === 'ignore') {
754
- for (let i = 2; i < words.length; i++) {
755
- const pkg = words[i];
756
- result.packages.push(pkg);
757
- }
758
- return result;
759
- }
760
- return result;
761
- }
762
-
763
- // Ref: https://github.com/socketdev-demo/javascript-threats/pull/89#issuecomment-2456015512
764
- function processSecurityComment({
765
- ignore: ignoreComments,
766
- security: securityComment
767
- }) {
768
- const result = [];
769
- let start = false;
770
- let ignoreAll = false;
771
- const ignoredPackages = [];
772
- for (const ignoreComment of ignoreComments) {
773
- const parsed = parseIgnoreCommand(ignoreComment.body?.split('\n').at(0) ?? '');
774
- if (parsed.ignoreAll) {
775
- ignoreAll = true;
776
- break;
777
- }
778
- ignoredPackages.push(parsed.packages);
779
- }
780
-
781
- // Split the comment body into lines and update them
782
- // to generate a new comment body
783
- for (let line of securityComment?.body?.split('\n') ?? []) {
784
- line = line.trim();
785
- if (line.includes('start-socket-alerts-table')) {
786
- start = true;
787
- result.push(line);
788
- } else if (start && !line.includes('end-socket-alerts-table') &&
789
- // is not heading line?
790
- !(line === '|Alert|Package|Introduced by|Manifest File|CI|' || line.includes(':---')) && line !== '') {
791
- // Parsing Markdown data colunms
792
- const [_, _title, packageLink, _introducedBy, _manifest, _ci] = line.split('|');
793
-
794
- // Parsing package link [npm/pkg](url)
795
- const [_ecosystem, pkg] = packageLink.slice(1, packageLink.indexOf(']')).split('/', 2);
796
- const [pkgName, pkgVersion] = pkg.split('@');
797
-
798
- // Checking if this package should be ignored
799
- let ignore = false;
800
- if (ignoreAll) {
801
- ignore = true;
802
- } else {
803
- for (const [ignoredPkgName, ignorePkgVersion] of ignoredPackages) {
804
- if (pkgName === ignoredPkgName && (ignorePkgVersion === '*' || pkgVersion === ignorePkgVersion)) {
805
- ignore = true;
806
- break;
807
- }
808
- }
809
- }
810
- if (ignore) {
811
- break;
812
- }
813
- result.push(line);
814
- } else if (line.includes('end-socket-alerts-table')) {
815
- start = false;
816
- result.push(line);
817
- } else {
818
- result.push(line);
819
- }
820
- }
821
- return result.join('\n');
822
- }
823
- function getIgnoreOptions({
824
- comments
825
- }) {
826
- const ignoreCommands = [];
827
- let ignoreAll = false;
828
- for (const comment of comments.ignore) {
829
- let firstLine = comment.body_list[0];
830
- if (!ignoreAll && firstLine.includes('SocketSecurity ignore')) {
831
- try {
832
- firstLine = firstLine.replace(/@/, '');
833
- let [, command] = firstLine.split('SocketSecurity ');
834
- command = command.trim();
835
- if (command === 'ignore-all') {
836
- ignoreAll = true;
837
- } else {
838
- command = command.replace(/ignore/, '').trim();
839
- const [name, version] = command.split('@');
840
- const data = `${name}/${version}`;
841
- ignoreCommands.push(data);
842
- }
843
- } catch (e) {
844
- logger.logger.fail(`Unable to process ignore command for ${comment}`);
845
- logger.logger.error(e);
846
- }
847
- }
848
- }
849
- return {
850
- ignoreAll,
851
- ignoreCommands
852
- };
853
- }
854
- function removeAlerts({
855
- comments,
856
- newAlerts
857
- }) {
858
- const alerts = [];
859
- if (comments.ignore.length === 0) {
860
- return newAlerts;
861
- }
862
- const {
863
- ignoreAll,
864
- ignoreCommands
865
- } = getIgnoreOptions({
866
- comments
867
- });
868
- for (const alert of newAlerts) {
869
- if (ignoreAll) {
870
- break;
871
- } else {
872
- const fullName = `${alert.pkg_type}/${alert.pkg_name}`;
873
- const purl = `${fullName}/${alert.pkg_version}`;
874
- const purlStar = `${fullName}/*`;
875
- if (ignoreCommands.includes(purl) || ignoreCommands.includes(purlStar)) {
876
- logger.logger.log(`Alerts for ${alert.pkg_name}@${alert.pkg_version} ignored`);
877
- } else {
878
- logger.logger.log(`Adding alert ${alert.type} for ${alert.pkg_name}@${alert.pkg_version}`);
879
- alerts.push(alert);
880
- }
881
- }
882
- }
883
- return alerts;
884
- }
885
-
886
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/github.py
887
- /* eslint-disable no-await-in-loop */
888
- class GitHub {
889
- octokit = new vendor.Octokit();
890
- constructor() {
891
- const [owner = '', repo = ''] = (process.env['GITHUB_REPOSITORY'] ?? '').split('/');
892
- // https://github.com/actions/checkout/issues/58#issuecomment-2264361099
893
- const prNumber = parseInt(process.env['GITHUB_REF']?.match(/refs\/pull\/(\d+)\/merge/)?.at(1) ?? '');
894
- this.owner = owner;
895
- this.repo = repo;
896
- this.prNumber = prNumber;
897
- }
898
- checkEventType() {
899
- switch (process.env['GITHUB_EVENT_NAME']) {
900
- case 'push':
901
- return this.prNumber ? 'diff' : 'main';
902
- case 'pull_request':
903
- {
904
- // This env variable needs to be set in the GitHub action.
905
- // Add this code below to GitHub action:
906
- // - steps:
907
- // - name: Get PR State
908
- // if: github.event_name == 'pull_request'
909
- // run: echo "EVENT_ACTION=${{ github.event.action }}" >> $GITHUB_ENV
910
- const eventAction = process.env['EVENT_ACTION'];
911
- if (eventAction === 'opened' || eventAction === 'synchronize') {
912
- return 'diff';
913
- }
914
- if (!eventAction) {
915
- throw new Error('Missing event action');
916
- }
917
- logger.logger.log(`Pull request action: ${eventAction} is not supported`);
918
- process.exit();
919
- }
920
- case 'issue_comment':
921
- return 'comment';
922
- default:
923
- throw new Error(`Unknown event type: ${process.env['GITHUB_EVENT_NAME']}`);
924
- }
925
- }
926
- async getCommentsForPR() {
927
- const {
928
- data: githubComments
929
- } = await this.octokit.rest.issues.listComments({
930
- owner: this.owner,
931
- repo: this.repo,
932
- issue_number: this.prNumber
933
- });
934
- const comments = {};
935
- for (const githubComment of githubComments) {
936
- comments[githubComment.id] = new Comment({
937
- id: githubComment.id,
938
- body: githubComment.body ?? '',
939
- body_list: (githubComment.body ?? '').split('\n')
940
- });
941
- }
942
- return checkForSocketComments({
943
- comments
944
- });
945
- }
946
- async commentReactionExists({
947
- commentId
948
- }) {
949
- const {
950
- data
951
- } = await this.octokit.reactions.listForIssueComment({
952
- owner: this.owner,
953
- repo: this.repo,
954
- comment_id: commentId
955
- });
956
- return data.some(reaction => reaction.content === '+1');
957
- }
958
- async postReaction({
959
- commentId
960
- }) {
961
- await this.octokit.reactions.createForIssueComment({
962
- owner: this.owner,
963
- repo: this.repo,
964
- comment_id: commentId,
965
- content: '+1'
966
- });
967
- }
968
- async handleIgnoreReactons({
969
- comments
970
- }) {
971
- for (const ignoreComment of comments.ignore) {
972
- if (ignoreComment.body?.includes('SocketSecurity ignore') && !(await this.commentReactionExists({
973
- commentId: ignoreComment.id
974
- }))) {
975
- await this.postReaction({
976
- commentId: ignoreComment.id
977
- });
978
- }
979
- }
980
- }
981
- async updateComment({
982
- body,
983
- id
984
- }) {
985
- await this.octokit.issues.updateComment({
986
- owner: this.owner,
987
- repo: this.repo,
988
- comment_id: id,
989
- body
990
- });
991
- }
992
- async removeCommentAlerts({
993
- comments
994
- }) {
995
- const securityAlert = comments.security;
996
- if (securityAlert !== undefined) {
997
- const newBody = processSecurityComment({
998
- security: comments.security,
999
- ignore: comments.ignore
1000
- });
1001
- await this.handleIgnoreReactons({
1002
- comments
1003
- });
1004
- await this.updateComment({
1005
- id: securityAlert.id,
1006
- body: newBody
1007
- });
1008
- }
1009
- }
1010
- async postComment({
1011
- body
1012
- }) {
1013
- await this.octokit.issues.createComment({
1014
- owner: this.owner,
1015
- repo: this.repo,
1016
- issue_number: this.prNumber,
1017
- body
1018
- });
1019
- }
1020
- async addSocketComments({
1021
- comments,
1022
- newOverviewComment,
1023
- newSecurityComment,
1024
- overviewComment,
1025
- securityComment
1026
- }) {
1027
- const {
1028
- overview: existingOverviewComment,
1029
- security: existingSecurityComment
1030
- } = comments;
1031
- if (newOverviewComment) {
1032
- logger.logger.log('New Dependency Overview comment');
1033
- if (existingOverviewComment !== undefined) {
1034
- logger.logger.log('Previous version of Dependency Overview, updating');
1035
- await this.updateComment({
1036
- body: overviewComment,
1037
- id: existingOverviewComment.id
1038
- });
1039
- } else {
1040
- logger.logger.log('No previous version of Dependency Overview, posting');
1041
- await this.postComment({
1042
- body: overviewComment
1043
- });
1044
- }
1045
- }
1046
- if (newSecurityComment) {
1047
- logger.logger.log('New Security Issue Comment');
1048
- if (existingSecurityComment !== undefined) {
1049
- logger.logger.log('Previous version of Security Issue comment, updating');
1050
- await this.updateComment({
1051
- body: securityComment,
1052
- id: existingSecurityComment.id
1053
- });
1054
- } else {
1055
- logger.logger.log('No Previous version of Security Issue comment, posting');
1056
- await this.postComment({
1057
- body: securityComment
1058
- });
1059
- }
1060
- }
1061
- }
1062
- }
1063
-
1064
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/core/messages.py
1065
-
1066
- function createPurlLink(purl) {
1067
- const packageUrl = `[${purl.purl}](${purl.url})`;
1068
- return packageUrl;
1069
- }
1070
- function createAddedTable(diff) {
1071
- const overviewTable = ['Package', 'Direct', 'Capabilities', 'Transitives', 'Size', 'Author'];
1072
- const rows = [];
1073
- for (const added of diff.newPackages) {
1074
- const packageUrl = createPurlLink(added);
1075
- const capabilities = added.capabilities.join(', ');
1076
- const row = [packageUrl, added.direct, capabilities, added.transitives, `${added.size} KB`, added.author_url];
1077
- rows.push(row);
1078
- }
1079
- let md = '';
1080
- md += `|${overviewTable.join('|')}|\n`;
1081
- md += '|---|---|---|---|---|---|\n';
1082
- for (const row of rows) {
1083
- md += `|${row.join('|')}|\n`;
1084
- }
1085
- return md;
1086
- }
1087
- function createRemoveLine(diff) {
1088
- const removedLine = ['Removed packages:'];
1089
- for (const removed of diff.removedPackages) {
1090
- const packageUrl = createPurlLink(removed);
1091
- removedLine.push(packageUrl);
1092
- }
1093
- return removedLine.join(', ');
1094
- }
1095
- function dependencyOverviewTemplate(diff) {
1096
- let md = '';
1097
- md += '<!-- socket-overview-comment-actions -->\n';
1098
- md += '# Socket Security: Dependency Overview\n';
1099
- md += 'New and removed dependencies detected. Learn more about [socket.dev](https://socket.dev)\n\n';
1100
- md += createAddedTable(diff);
1101
- if (diff.removedPackages.length > 0) {
1102
- md += createRemoveLine(diff);
1103
- }
1104
- return md;
1105
- }
1106
- function createSources(alert) {
1107
- const sources = [];
1108
- const manifests = [];
1109
- for (const [source, manifest] of alert.introduced_by) {
1110
- const addStr = `<li>${manifest}</li>`;
1111
- const sourceStr = `<li>${source}</li>`;
1112
- if (!sources.includes(sourceStr)) {
1113
- sources.push(sourceStr);
1114
- }
1115
- if (!manifests.includes(addStr)) {
1116
- manifests.push(addStr);
1117
- }
1118
- }
1119
- const manifestList = manifests.join('');
1120
- const sourceList = sources.join('');
1121
- const manifestStr = `<ul>${manifestList}</ul>`;
1122
- const sourcesStr = `<ul>${sourceList}</ul>`;
1123
- return [manifestStr, sourcesStr];
1124
- }
1125
- function createSecurityAlertTable(diff) {
1126
- const alertTable = ['Alert', 'Package', 'Introduced by', 'Manifest File', 'CI'];
1127
- const nextSteps = {};
1128
- const ignoreCommands = [];
1129
- const rows = [];
1130
- for (const alert of diff.newAlerts) {
1131
- if (!(alert.next_step_title in nextSteps)) {
1132
- nextSteps[alert.next_step_title] = [alert.description, alert.suggestion];
1133
- }
1134
- const ignore = `\`SocketSecurity ignore ${alert.purl}\``;
1135
- if (!ignoreCommands.includes(ignore)) {
1136
- ignoreCommands.push(ignore);
1137
- }
1138
- const [manifestStr, sourceStr] = createSources(alert);
1139
- const purlUrl = `[${alert.purl}](${alert.url})`;
1140
- if (alert.error) {
1141
- alert.emoji = ':no_entry_sign:';
1142
- } else {
1143
- alert.emoji = ':warning:';
1144
- }
1145
- const row = [alert.title, purlUrl, sourceStr, manifestStr, alert.emoji];
1146
- if (!rows.some(r => r.join() === row.join())) {
1147
- rows.push(row);
1148
- }
1149
- }
1150
- let md = '';
1151
- md += `|${alertTable.join('|')}|\n`;
1152
- md += '|---|---|---|---|---|\n';
1153
- for (const row of rows) {
1154
- md += `|${row.join('|')}|\n`;
1155
- }
1156
- return {
1157
- ignoreCommands,
1158
- nextSteps,
1159
- mdTable: md
1160
- };
1161
- }
1162
- function createNextSteps(nextSteps) {
1163
- let md = '';
1164
- for (const step in nextSteps) {
1165
- const detail = nextSteps[step];
1166
- md += '<details>\n';
1167
- md += `<summary>${step}</summary>\n`;
1168
- for (const line of detail) {
1169
- md += `${line}\n`;
1170
- }
1171
- md += '</details>\n';
1172
- }
1173
- return md;
1174
- }
1175
- function createDeeperLook() {
1176
- let md = '';
1177
- md += '<details>\n';
1178
- md += '<summary>Take a deeper look at the dependency</summary>\n';
1179
- md += "Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.\n";
1180
- md += '</details>\n';
1181
- return md;
1182
- }
1183
- function createRemovePackage() {
1184
- let md = '';
1185
- md += '<details>\n';
1186
- md += '<summary>Remove the package</summary>\n';
1187
- md += 'If you happen to install a dependency that Socket reports as [https://socket.dev/npm/issue/malware](Known Malware) you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.\n';
1188
- md += '</details>\n';
1189
- return md;
1190
- }
1191
- function createAcceptableRisk(ignoreCommands) {
1192
- let md = '';
1193
- md += '<details>\n';
1194
- md += '<summary>Mark a package as acceptable risk</summary>\n';
1195
- md += 'To ignore an alert, reply with a comment starting with `SocketSecurity ignore` followed by a space separated list of `ecosystem/package-name@version` specifiers. e.g. `SocketSecurity ignore npm/foo@1.0.0` or ignore all packages with `SocketSecurity ignore-all`\n';
1196
- md += '<ul>\n';
1197
- for (const ignore of ignoreCommands) {
1198
- md += `<li>${ignore}</li>\n`;
1199
- }
1200
- md += '</ul>\n';
1201
- md += '</details>\n';
1202
- return md;
1203
- }
1204
- function securityCommentTemplate(diff) {
1205
- let md = '';
1206
- md += '<!-- socket-security-comment-actions -->\n';
1207
- md += '# Socket Security: Issues Report\n';
1208
- md += 'Potential security issues detected. Learn more about [socket.dev](https://socket.dev)\n';
1209
- md += 'To accept the risk, merge this PR and you will not be notified again.\n\n';
1210
- md += '<!-- start-socket-alerts-table -->\n';
1211
- const {
1212
- ignoreCommands,
1213
- mdTable,
1214
- nextSteps
1215
- } = createSecurityAlertTable(diff);
1216
- md += mdTable;
1217
- md += '<!-- end-socket-alerts-table -->\n\n';
1218
- md += createNextSteps(nextSteps);
1219
- md += createDeeperLook();
1220
- md += createRemovePackage();
1221
- md += createAcceptableRisk(ignoreCommands);
1222
- return md.trim();
1223
- }
1224
-
1225
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
1226
-
1227
-
1228
- // TODO: is this a github action handler?
1229
- async function runAction(githubEventBefore, githubEventAfter) {
1230
- //TODO
1231
- const socket = new sdk.SocketSdk(shadowNpmInject.getDefaultToken());
1232
- const git = simpleGit.simpleGit();
1233
- const changedFiles = (await git.diff(process.env['GITHUB_EVENT_NAME'] === 'pull_request' ? ['--name-only', 'HEAD^1', 'HEAD'] : ['--name-only', githubEventBefore, githubEventAfter])).split('\n');
1234
- logger.logger.log({
1235
- changedFiles
1236
- });
1237
- // supportedFiles have 3-level deep globs
1238
- const patterns = Object.values(await socket.getReportSupportedFiles()).flatMap(i => Object.values(i)).flatMap(i => Object.values(i)).flatMap(i => Object.values(i));
1239
- const files = micromatch(changedFiles, patterns);
1240
- const scm = new GitHub();
1241
- if (scm.checkEventType() === 'comment') {
1242
- logger.logger.log('Comment initiated flow');
1243
- const comments = await scm.getCommentsForPR();
1244
- await scm.removeCommentAlerts({
1245
- comments
1246
- });
1247
- } else if (scm.checkEventType() === 'diff') {
1248
- logger.logger.log('Push initiated flow');
1249
- const core = new Core({
1250
- owner: scm.owner,
1251
- repo: scm.repo,
1252
- files,
1253
- socket
1254
- });
1255
- const diff = await core.createNewDiff({});
1256
- const comments = await scm.getCommentsForPR();
1257
- diff.newAlerts = removeAlerts({
1258
- comments,
1259
- newAlerts: diff.newAlerts
1260
- });
1261
- const overviewComment = dependencyOverviewTemplate(diff);
1262
- const securityComment = securityCommentTemplate(diff);
1263
- let newSecurityComment = true;
1264
- let newOverviewComment = true;
1265
- const updateOldSecurityComment = comments.security !== undefined;
1266
- const updateOldOverviewComment = comments.overview !== undefined;
1267
- if (diff.newAlerts.length === 0) {
1268
- if (!updateOldSecurityComment) {
1269
- newSecurityComment = false;
1270
- logger.logger.log('No new alerts or security issue comment disabled');
1271
- } else {
1272
- logger.logger.log('Updated security comment with no new alerts');
1273
- }
1274
- }
1275
- if (diff.newPackages.length === 0 && diff.removedPackages.length === 0) {
1276
- if (!updateOldOverviewComment) {
1277
- newOverviewComment = false;
1278
- logger.logger.log('No new/removed packages or Dependency Overview comment disabled');
1279
- } else {
1280
- logger.logger.log('Updated overview comment with no dependencies');
1281
- }
1282
- }
1283
- await scm.addSocketComments({
1284
- securityComment,
1285
- overviewComment,
1286
- comments,
1287
- newSecurityComment,
1288
- newOverviewComment
1289
- });
1290
- }
1291
- }
1292
-
1293
65
  const {
1294
66
  API_V0_URL
1295
67
  } = constants;
@@ -1323,288 +95,20 @@ async function handleAPIError(code) {
1323
95
  if (code === 400) {
1324
96
  return 'One of the options passed might be incorrect.';
1325
97
  } else if (code === 403) {
1326
- return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
1327
- }
1328
- }
1329
- function getLastFiveOfApiToken(token) {
1330
- // Get the last 5 characters of the API token before the trailing "_api".
1331
- return token.slice(-9, -4);
1332
- }
1333
- async function queryAPI(path, apiToken) {
1334
- return await fetch(`${API_V0_URL}/${path}`, {
1335
- method: 'GET',
1336
- headers: {
1337
- Authorization: `Basic ${btoa(`${apiToken}:${apiToken}`)}`
1338
- }
1339
- });
1340
- }
1341
-
1342
- function getFlagListOutput(list, indent, {
1343
- keyPrefix = '--',
1344
- padName
1345
- } = {}) {
1346
- return getHelpListOutput({
1347
- ...list
1348
- }, indent, {
1349
- keyPrefix,
1350
- padName
1351
- });
1352
- }
1353
- function getHelpListOutput(list, indent, {
1354
- keyPrefix = '',
1355
- padName = 18
1356
- } = {}) {
1357
- let result = '';
1358
- const names = Object.keys(list).sort();
1359
- for (const name of names) {
1360
- const rawDescription = list[name];
1361
- const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
1362
- result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
1363
- }
1364
- return result.trim();
1365
- }
1366
-
1367
- // TODO: not sure if I'm missing something but meow doesn't seem to expose this?
1368
-
1369
- // Note: we use this description in getFlagListOutput, meow doesn't care
1370
-
1371
- const commonFlags = {
1372
- help: {
1373
- type: 'boolean',
1374
- default: false,
1375
- shortFlag: 'h',
1376
- description: 'Print this help.'
1377
- },
1378
- dryRun: {
1379
- type: 'boolean',
1380
- default: false,
1381
- description: 'Do input validation for a command and exit 0 when input is ok'
1382
- }
1383
- };
1384
- const outputFlags = {
1385
- json: {
1386
- type: 'boolean',
1387
- shortFlag: 'j',
1388
- default: false,
1389
- description: 'Output result as json'
1390
- },
1391
- markdown: {
1392
- type: 'boolean',
1393
- shortFlag: 'm',
1394
- default: false,
1395
- description: 'Output result as markdown'
1396
- }
1397
- };
1398
- const validationFlags = {
1399
- all: {
1400
- type: 'boolean',
1401
- default: false,
1402
- description: 'Include all issues'
1403
- },
1404
- strict: {
1405
- type: 'boolean',
1406
- default: false,
1407
- description: 'Exits with an error code if any matching issues are found'
1408
- }
1409
- };
1410
-
1411
- const {
1412
- DRY_RUN_LABEL: DRY_RUN_LABEL$1,
1413
- REDACTED
1414
- } = constants;
1415
- async function meowWithSubcommands(subcommands, options) {
1416
- const {
1417
- aliases = {},
1418
- argv,
1419
- defaultSub,
1420
- importMeta,
1421
- name,
1422
- ...additionalOptions
1423
- } = {
1424
- __proto__: null,
1425
- ...options
1426
- };
1427
- const [commandOrAliasNamex, ...rawCommandArgv] = argv;
1428
- let commandOrAliasName = commandOrAliasNamex;
1429
- if (!commandOrAliasName && defaultSub) {
1430
- commandOrAliasName = defaultSub;
1431
- }
1432
- // If we got at least some args, then lets find out if we can find a command.
1433
- if (commandOrAliasName) {
1434
- const alias = aliases[commandOrAliasName];
1435
- // First: Resolve argv data from alias if its an alias that's been given.
1436
- const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
1437
- // Second: Find a command definition using that data.
1438
- const commandDefinition = commandName ? subcommands[commandName] : undefined;
1439
- // Third: If a valid command has been found, then we run it...
1440
- if (commandDefinition) {
1441
- return await commandDefinition.run(commandArgv, importMeta, {
1442
- parentName: name
1443
- });
1444
- }
1445
- }
1446
- const flags = {
1447
- ...commonFlags,
1448
- ...additionalOptions.flags
1449
- };
1450
- // ...else we provide basic instructions and help.
1451
-
1452
- emitBanner(name);
1453
- const cli = vendor.meow(`
1454
- Usage
1455
- $ ${name} <command>
1456
-
1457
- Commands
1458
- ${getHelpListOutput({
1459
- ...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
1460
- 1: subcommand
1461
- }) => !subcommand.hidden))),
1462
- ...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
1463
- 1: alias
1464
- }) => {
1465
- const {
1466
- hidden
1467
- } = alias;
1468
- const cmdName = hidden ? '' : alias.argv[0];
1469
- const subcommand = cmdName ? subcommands[cmdName] : undefined;
1470
- return subcommand && !subcommand.hidden;
1471
- })))
1472
- }, 6)}
1473
-
1474
- Options
1475
- ${getFlagListOutput(flags, 6)}
1476
-
1477
- Examples
1478
- $ ${name} --help
1479
- `, {
1480
- argv,
1481
- importMeta,
1482
- ...additionalOptions,
1483
- flags,
1484
- autoHelp: false // otherwise we can't exit(0)
1485
- });
1486
- if (!cli.flags['help'] && cli.flags['dryRun']) {
1487
- process.exitCode = 0;
1488
- logger.logger.log(`${DRY_RUN_LABEL$1}: No-op, call a sub-command; ok`);
1489
- } else {
1490
- cli.showHelp();
1491
- }
1492
- }
1493
-
1494
- /**
1495
- * Note: meow will exit immediately if it calls its .showHelp()
1496
- */
1497
- function meowOrExit({
1498
- allowUnknownFlags,
1499
- // commands that pass-through args need to allow this
1500
- argv,
1501
- config,
1502
- importMeta,
1503
- parentName
1504
- }) {
1505
- const command = `${parentName} ${config.commandName}`;
1506
- emitBanner(command);
1507
-
1508
- // This exits if .printHelp() is called either by meow itself or by us.
1509
- const cli = vendor.meow({
1510
- argv,
1511
- description: config.description,
1512
- help: config.help(command, config),
1513
- importMeta,
1514
- flags: config.flags,
1515
- allowUnknownFlags: Boolean(allowUnknownFlags),
1516
- autoHelp: false // otherwise we can't exit(0)
1517
- });
1518
- if (cli.flags['help']) {
1519
- cli.showHelp();
98
+ return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
1520
99
  }
1521
- return cli;
1522
- }
1523
- function emitBanner(name) {
1524
- // Print a banner at the top of each command.
1525
- // This helps with brand recognition and marketing.
1526
- // It also helps with debugging since it contains version and command details.
1527
- // Note: print over stderr to preserve stdout for flags like --json and
1528
- // --markdown. If we don't do this, you can't use --json in particular
1529
- // and pipe the result to other tools. By emitting the banner over stderr
1530
- // you can do something like `socket scan view xyz | jq | process`.
1531
- // The spinner also emits over stderr for example.
1532
- logger.logger.error(getAsciiHeader(name));
1533
100
  }
1534
- function getAsciiHeader(command) {
1535
- const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
1536
- "0.14.62:681c774:be9a8ff8:pub";
1537
- const nodeVersion = process.version;
1538
- const apiToken = shadowNpmInject.getSetting('apiToken');
1539
- const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
1540
- const relCwd = path$1.normalizePath(process.cwd().replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}(?:${path.sep}|$)`, 'i'), '~/'));
1541
- const body = `
1542
- _____ _ _ /---------------
1543
- | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
1544
- |__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}
1545
- |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
1546
- return ` ${body}\n`;
101
+ function getLastFiveOfApiToken(token) {
102
+ // Get the last 5 characters of the API token before the trailing "_api".
103
+ return token.slice(-9, -4);
1547
104
  }
1548
-
1549
- // https://github.com/SocketDev/socket-python-cli/blob/6d4fc56faee68d3a4764f1f80f84710635bdaf05/socketsecurity/socketcli.py
1550
-
1551
- const {
1552
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B
1553
- } = constants;
1554
- const config$C = {
1555
- commandName: 'action',
1556
- description: 'Socket action command',
1557
- // GitHub Action ?
1558
- hidden: true,
1559
- flags: {
1560
- // This flag is unused
1561
- // socketSecurityApiKey: { // deprecate this asap.
1562
- // type: 'string',
1563
- // default: 'env var SOCKET_SECURITY_API_KEY',
1564
- // description: 'Socket API token'
1565
- // },
1566
- githubEventBefore: {
1567
- type: 'string',
1568
- default: '',
1569
- description: 'Before marker'
1570
- },
1571
- githubEventAfter: {
1572
- type: 'string',
1573
- default: '',
1574
- description: 'After marker'
105
+ async function queryAPI(path, apiToken) {
106
+ return await fetch(`${API_V0_URL}/${path}`, {
107
+ method: 'GET',
108
+ headers: {
109
+ Authorization: `Basic ${btoa(`${apiToken}:${apiToken}`)}`
1575
110
  }
1576
- },
1577
- help: (command, {
1578
- flags
1579
- }) => `
1580
- Usage
1581
- $ ${command} [options]
1582
-
1583
- Options
1584
- ${getFlagListOutput(flags, 6)}
1585
- `
1586
- };
1587
- const cmdAction = {
1588
- description: config$C.description,
1589
- hidden: config$C.hidden,
1590
- run: run$C
1591
- };
1592
- async function run$C(argv, importMeta, {
1593
- parentName
1594
- }) {
1595
- const cli = meowOrExit({
1596
- argv,
1597
- config: config$C,
1598
- importMeta,
1599
- parentName
1600
111
  });
1601
- const githubEventBefore = String(cli.flags['githubEventBefore'] || '');
1602
- const githubEventAfter = String(cli.flags['githubEventAfter'] || '');
1603
- if (cli.flags['dryRun']) {
1604
- logger.logger.log(DRY_RUN_BAIL_TEXT$B);
1605
- return;
1606
- }
1607
- await runAction(githubEventBefore, githubEventAfter);
1608
112
  }
1609
113
 
1610
114
  async function fetchOrgAnalyticsData(time, spinner, apiToken) {
@@ -1765,7 +269,7 @@ async function outputAnalyticsWithToken({
1765
269
  if (!serialized) return;
1766
270
  if (filePath && filePath !== '-') {
1767
271
  try {
1768
- await fs$1.writeFile(filePath, serialized, 'utf8');
272
+ await fs.writeFile(filePath, serialized, 'utf8');
1769
273
  logger.logger.log(`Data successfully written to ${filePath}`);
1770
274
  } catch (e) {
1771
275
  process.exitCode = 1;
@@ -1781,7 +285,7 @@ async function outputAnalyticsWithToken({
1781
285
  const serialized = renderMarkdown(fdata, time, repo);
1782
286
  if (filePath && filePath !== '-') {
1783
287
  try {
1784
- await fs$1.writeFile(filePath, serialized, 'utf8');
288
+ await fs.writeFile(filePath, serialized, 'utf8');
1785
289
  logger.logger.log(`Data successfully written to ${filePath}`);
1786
290
  } catch (e) {
1787
291
  logger.logger.error(e);
@@ -1950,10 +454,217 @@ function renderLineCharts(grid, screen, title, coords, data) {
1950
454
  line.setData([lineData]);
1951
455
  }
1952
456
 
457
+ // TODO: not sure if I'm missing something but meow doesn't seem to expose this?
458
+
459
+ // Note: we use this description in getFlagListOutput, meow doesn't care
460
+
461
+ const commonFlags = {
462
+ help: {
463
+ type: 'boolean',
464
+ default: false,
465
+ shortFlag: 'h',
466
+ description: 'Print this help.'
467
+ },
468
+ dryRun: {
469
+ type: 'boolean',
470
+ default: false,
471
+ description: 'Do input validation for a command and exit 0 when input is ok'
472
+ }
473
+ };
474
+ const outputFlags = {
475
+ json: {
476
+ type: 'boolean',
477
+ shortFlag: 'j',
478
+ default: false,
479
+ description: 'Output result as json'
480
+ },
481
+ markdown: {
482
+ type: 'boolean',
483
+ shortFlag: 'm',
484
+ default: false,
485
+ description: 'Output result as markdown'
486
+ }
487
+ };
488
+ const validationFlags = {
489
+ all: {
490
+ type: 'boolean',
491
+ default: false,
492
+ description: 'Include all issues'
493
+ },
494
+ strict: {
495
+ type: 'boolean',
496
+ default: false,
497
+ description: 'Exits with an error code if any matching issues are found'
498
+ }
499
+ };
500
+
501
+ function getFlagListOutput(list, indent, {
502
+ keyPrefix = '--',
503
+ padName
504
+ } = {}) {
505
+ return getHelpListOutput({
506
+ ...list
507
+ }, indent, {
508
+ keyPrefix,
509
+ padName
510
+ });
511
+ }
512
+ function getHelpListOutput(list, indent, {
513
+ keyPrefix = '',
514
+ padName = 18
515
+ } = {}) {
516
+ let result = '';
517
+ const names = Object.keys(list).sort();
518
+ for (const name of names) {
519
+ const rawDescription = list[name];
520
+ const description = (typeof rawDescription === 'object' ? rawDescription.description : rawDescription) || '';
521
+ result += ''.padEnd(indent) + (keyPrefix + name).padEnd(padName) + description + '\n';
522
+ }
523
+ return result.trim();
524
+ }
525
+
526
+ const {
527
+ DRY_RUN_LABEL: DRY_RUN_LABEL$1,
528
+ REDACTED
529
+ } = constants;
530
+ async function meowWithSubcommands(subcommands, options) {
531
+ const {
532
+ aliases = {},
533
+ argv,
534
+ defaultSub,
535
+ importMeta,
536
+ name,
537
+ ...additionalOptions
538
+ } = {
539
+ __proto__: null,
540
+ ...options
541
+ };
542
+ const [commandOrAliasNamex, ...rawCommandArgv] = argv;
543
+ let commandOrAliasName = commandOrAliasNamex;
544
+ if (!commandOrAliasName && defaultSub) {
545
+ commandOrAliasName = defaultSub;
546
+ }
547
+ // If we got at least some args, then lets find out if we can find a command.
548
+ if (commandOrAliasName) {
549
+ const alias = aliases[commandOrAliasName];
550
+ // First: Resolve argv data from alias if its an alias that's been given.
551
+ const [commandName, ...commandArgv] = alias ? [...alias.argv, ...rawCommandArgv] : [commandOrAliasName, ...rawCommandArgv];
552
+ // Second: Find a command definition using that data.
553
+ const commandDefinition = commandName ? subcommands[commandName] : undefined;
554
+ // Third: If a valid command has been found, then we run it...
555
+ if (commandDefinition) {
556
+ return await commandDefinition.run(commandArgv, importMeta, {
557
+ parentName: name
558
+ });
559
+ }
560
+ }
561
+ const flags = {
562
+ ...commonFlags,
563
+ ...additionalOptions.flags
564
+ };
565
+ // ...else we provide basic instructions and help.
566
+
567
+ emitBanner(name);
568
+ const cli = vendor.meow(`
569
+ Usage
570
+ $ ${name} <command>
571
+
572
+ Commands
573
+ ${getHelpListOutput({
574
+ ...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
575
+ 1: subcommand
576
+ }) => !subcommand.hidden))),
577
+ ...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
578
+ 1: alias
579
+ }) => {
580
+ const {
581
+ hidden
582
+ } = alias;
583
+ const cmdName = hidden ? '' : alias.argv[0];
584
+ const subcommand = cmdName ? subcommands[cmdName] : undefined;
585
+ return subcommand && !subcommand.hidden;
586
+ })))
587
+ }, 6)}
588
+
589
+ Options
590
+ ${getFlagListOutput(flags, 6)}
591
+
592
+ Examples
593
+ $ ${name} --help
594
+ `, {
595
+ argv,
596
+ importMeta,
597
+ ...additionalOptions,
598
+ flags,
599
+ autoHelp: false // otherwise we can't exit(0)
600
+ });
601
+ if (!cli.flags['help'] && cli.flags['dryRun']) {
602
+ process.exitCode = 0;
603
+ logger.logger.log(`${DRY_RUN_LABEL$1}: No-op, call a sub-command; ok`);
604
+ } else {
605
+ cli.showHelp();
606
+ }
607
+ }
608
+
609
+ /**
610
+ * Note: meow will exit immediately if it calls its .showHelp()
611
+ */
612
+ function meowOrExit({
613
+ allowUnknownFlags,
614
+ // commands that pass-through args need to allow this
615
+ argv,
616
+ config,
617
+ importMeta,
618
+ parentName
619
+ }) {
620
+ const command = `${parentName} ${config.commandName}`;
621
+ emitBanner(command);
622
+
623
+ // This exits if .printHelp() is called either by meow itself or by us.
624
+ const cli = vendor.meow({
625
+ argv,
626
+ description: config.description,
627
+ help: config.help(command, config),
628
+ importMeta,
629
+ flags: config.flags,
630
+ allowUnknownFlags: Boolean(allowUnknownFlags),
631
+ autoHelp: false // otherwise we can't exit(0)
632
+ });
633
+ if (cli.flags['help']) {
634
+ cli.showHelp();
635
+ }
636
+ return cli;
637
+ }
638
+ function emitBanner(name) {
639
+ // Print a banner at the top of each command.
640
+ // This helps with brand recognition and marketing.
641
+ // It also helps with debugging since it contains version and command details.
642
+ // Note: print over stderr to preserve stdout for flags like --json and
643
+ // --markdown. If we don't do this, you can't use --json in particular
644
+ // and pipe the result to other tools. By emitting the banner over stderr
645
+ // you can do something like `socket scan view xyz | jq | process`.
646
+ // The spinner also emits over stderr for example.
647
+ logger.logger.error(getAsciiHeader(name));
648
+ }
649
+ function getAsciiHeader(command) {
650
+ const cliVersion = // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
651
+ "0.14.63:988a495:e7fc86b0:pub";
652
+ const nodeVersion = process.version;
653
+ const apiToken = shadowNpmInject.getSetting('apiToken');
654
+ const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no';
655
+ const relCwd = path.normalizePath(process.cwd().replace(new RegExp(`^${regexps.escapeRegExp(constants.homePath)}(?:${path$1.sep}|$)`, 'i'), '~/'));
656
+ const body = `
657
+ _____ _ _ /---------------
658
+ | __|___ ___| |_ ___| |_ | Socket.dev CLI ver ${cliVersion}
659
+ |__ | . | _| '_| -_| _| | Node: ${nodeVersion}, API token set: ${shownToken}
660
+ |_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}`.trimStart();
661
+ return ` ${body}\n`;
662
+ }
663
+
1953
664
  const {
1954
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A
665
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$B
1955
666
  } = constants;
1956
- const config$B = {
667
+ const config$C = {
1957
668
  commandName: 'analytics',
1958
669
  description: `Look up analytics data`,
1959
670
  hidden: false,
@@ -2004,16 +715,16 @@ const config$B = {
2004
715
  `
2005
716
  };
2006
717
  const cmdAnalytics = {
2007
- description: config$B.description,
2008
- hidden: config$B.hidden,
2009
- run: run$B
718
+ description: config$C.description,
719
+ hidden: config$C.hidden,
720
+ run: run$C
2010
721
  };
2011
- async function run$B(argv, importMeta, {
722
+ async function run$C(argv, importMeta, {
2012
723
  parentName
2013
724
  }) {
2014
725
  const cli = meowOrExit({
2015
726
  argv,
2016
- config: config$B,
727
+ config: config$C,
2017
728
  importMeta,
2018
729
  parentName
2019
730
  });
@@ -2050,7 +761,7 @@ async function run$B(argv, importMeta, {
2050
761
  return;
2051
762
  }
2052
763
  if (cli.flags['dryRun']) {
2053
- logger.logger.log(DRY_RUN_BAIL_TEXT$A);
764
+ logger.logger.log(DRY_RUN_BAIL_TEXT$B);
2054
765
  return;
2055
766
  }
2056
767
  return await displayAnalytics({
@@ -2183,14 +894,14 @@ async function getAuditLogWithToken({
2183
894
  spinner.start(`Looking up audit log for ${orgSlug}`);
2184
895
  const socketSdk = await shadowNpmInject.setupSdk(apiToken);
2185
896
  const result = await handleApiCall(socketSdk.getAuditLogEvents(orgSlug, {
2186
- outputJson: outputKind === 'json',
2187
- // I'm not sure this is used at all
2188
- outputMarkdown: outputKind === 'markdown',
2189
- // I'm not sure this is used at all
897
+ // I'm not sure this is used at all.
898
+ outputJson: String(outputKind === 'json'),
899
+ // I'm not sure this is used at all.
900
+ outputMarkdown: String(outputKind === 'markdown'),
2190
901
  orgSlug,
2191
902
  type: logType,
2192
- page,
2193
- per_page: perPage
903
+ page: String(page),
904
+ per_page: String(perPage)
2194
905
  }), `Looking up audit log for ${orgSlug}\n`);
2195
906
  if (!result.success) {
2196
907
  handleUnsuccessfulApiResponse('getAuditLogEvents', result);
@@ -2201,9 +912,9 @@ async function getAuditLogWithToken({
2201
912
  }
2202
913
 
2203
914
  const {
2204
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z
915
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$A
2205
916
  } = constants;
2206
- const config$A = {
917
+ const config$B = {
2207
918
  commandName: 'audit-log',
2208
919
  description: 'Look up the audit log for an organization',
2209
920
  hidden: false,
@@ -2244,16 +955,16 @@ const config$A = {
2244
955
  `
2245
956
  };
2246
957
  const cmdAuditLog = {
2247
- description: config$A.description,
2248
- hidden: config$A.hidden,
2249
- run: run$A
958
+ description: config$B.description,
959
+ hidden: config$B.hidden,
960
+ run: run$B
2250
961
  };
2251
- async function run$A(argv, importMeta, {
962
+ async function run$B(argv, importMeta, {
2252
963
  parentName
2253
964
  }) {
2254
965
  const cli = meowOrExit({
2255
966
  argv,
2256
- config: config$A,
967
+ config: config$B,
2257
968
  importMeta,
2258
969
  parentName
2259
970
  });
@@ -2278,7 +989,7 @@ async function run$A(argv, importMeta, {
2278
989
  return;
2279
990
  }
2280
991
  if (cli.flags['dryRun']) {
2281
- logger.logger.log(DRY_RUN_BAIL_TEXT$z);
992
+ logger.logger.log(DRY_RUN_BAIL_TEXT$A);
2282
993
  return;
2283
994
  }
2284
995
  await getAuditLog({
@@ -2309,8 +1020,8 @@ async function runCycloneDX(yargvWithYes) {
2309
1020
  ...yargvWithYes
2310
1021
  };
2311
1022
  const yesArgs = yes ? ['--yes'] : [];
2312
- if (yargv.type !== YARN$1 && nodejsPlatformTypes.has(yargv.type) && fs.existsSync(`./${YARN_LOCK}`)) {
2313
- if (fs.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
1023
+ if (yargv.type !== YARN$1 && nodejsPlatformTypes.has(yargv.type) && fs$1.existsSync(`./${YARN_LOCK}`)) {
1024
+ if (fs$1.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
2314
1025
  yargv.type = NPM$f;
2315
1026
  } else {
2316
1027
  // Use synp to create a package-lock.json from the yarn.lock,
@@ -2326,14 +1037,14 @@ async function runCycloneDX(yargvWithYes) {
2326
1037
  }
2327
1038
  await shadowBin(NPX$3, [...yesArgs,
2328
1039
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_CYCLONEDX_CDXGEN_VERSION']".
2329
- `@cyclonedx/cdxgen@${"^11.2.1"}`, ...argvToArray(yargv)]);
1040
+ `@cyclonedx/cdxgen@${"^11.2.2"}`, ...argvToArray(yargv)]);
2330
1041
  if (cleanupPackageLock) {
2331
1042
  try {
2332
- await fs.promises.rm(`./${PACKAGE_LOCK_JSON}`);
1043
+ await fs$1.promises.rm(`./${PACKAGE_LOCK_JSON}`);
2333
1044
  } catch {}
2334
1045
  }
2335
- const fullOutputPath = path.join(process$1.cwd(), yargv.output);
2336
- if (fs.existsSync(fullOutputPath)) {
1046
+ const fullOutputPath = path$1.join(process$1.cwd(), yargv.output);
1047
+ if (fs$1.existsSync(fullOutputPath)) {
2337
1048
  logger.logger.log(colors.cyanBright(`${yargv.output} created!`));
2338
1049
  }
2339
1050
  }
@@ -2395,7 +1106,7 @@ function isHelpFlag(cmdArg) {
2395
1106
 
2396
1107
  // import { meowOrExit } from '../../utils/meow-with-subcommands'
2397
1108
  const {
2398
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y
1109
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$z
2399
1110
  } = constants;
2400
1111
 
2401
1112
  // TODO: convert yargs to meow. Or convert all the other things to yargs.
@@ -2472,7 +1183,7 @@ const yargsConfig = {
2472
1183
  'yes'],
2473
1184
  string: ['api-key', 'lifecycle', 'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'server-host', 'server-port', 'server-url', 'spec-version']
2474
1185
  };
2475
- const config$z = {
1186
+ const config$A = {
2476
1187
  commandName: 'cdxgen',
2477
1188
  description: 'Create an SBOM with CycloneDX generator (cdxgen)',
2478
1189
  hidden: false,
@@ -2488,18 +1199,18 @@ const config$z = {
2488
1199
  `
2489
1200
  };
2490
1201
  const cmdCdxgen = {
2491
- description: config$z.description,
2492
- hidden: config$z.hidden,
2493
- run: run$z
1202
+ description: config$A.description,
1203
+ hidden: config$A.hidden,
1204
+ run: run$A
2494
1205
  };
2495
- async function run$z(argv, importMeta, {
1206
+ async function run$A(argv, importMeta, {
2496
1207
  parentName
2497
1208
  }) {
2498
1209
  const cli = meowOrExit({
2499
1210
  allowUnknownFlags: true,
2500
1211
  // Don't let meow take over --help.
2501
1212
  argv: argv.filter(a => !isHelpFlag(a)),
2502
- config: config$z,
1213
+ config: config$A,
2503
1214
  importMeta,
2504
1215
  parentName
2505
1216
  });
@@ -2531,7 +1242,7 @@ async function run$z(argv, importMeta, {
2531
1242
  return;
2532
1243
  }
2533
1244
  if (cli.flags['dryRun']) {
2534
- logger.logger.log(DRY_RUN_BAIL_TEXT$y);
1245
+ logger.logger.log(DRY_RUN_BAIL_TEXT$z);
2535
1246
  return;
2536
1247
  }
2537
1248
  if (yargv.output === undefined) {
@@ -2598,9 +1309,9 @@ async function findDependencies({
2598
1309
  }
2599
1310
 
2600
1311
  const {
2601
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x
1312
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$y
2602
1313
  } = constants;
2603
- const config$y = {
1314
+ const config$z = {
2604
1315
  commandName: 'dependencies',
2605
1316
  description: 'Search for any dependency that is being used in your organization',
2606
1317
  hidden: false,
@@ -2632,21 +1343,21 @@ const config$y = {
2632
1343
  `
2633
1344
  };
2634
1345
  const cmdScanCreate$1 = {
2635
- description: config$y.description,
2636
- hidden: config$y.hidden,
2637
- run: run$y
1346
+ description: config$z.description,
1347
+ hidden: config$z.hidden,
1348
+ run: run$z
2638
1349
  };
2639
- async function run$y(argv, importMeta, {
1350
+ async function run$z(argv, importMeta, {
2640
1351
  parentName
2641
1352
  }) {
2642
1353
  const cli = meowOrExit({
2643
1354
  argv,
2644
- config: config$y,
1355
+ config: config$z,
2645
1356
  importMeta,
2646
1357
  parentName
2647
1358
  });
2648
1359
  if (cli.flags['dryRun']) {
2649
- logger.logger.log(DRY_RUN_BAIL_TEXT$x);
1360
+ logger.logger.log(DRY_RUN_BAIL_TEXT$y);
2650
1361
  return;
2651
1362
  }
2652
1363
 
@@ -2721,7 +1432,7 @@ async function getDiffScanWithToken({
2721
1432
  }
2722
1433
  if (file && file !== '-') {
2723
1434
  logger.logger.log(`Writing json to \`${file}\``);
2724
- fs.writeFile(file, JSON.stringify(result, null, 2), err => {
1435
+ fs$1.writeFile(file, JSON.stringify(result, null, 2), err => {
2725
1436
  if (err) {
2726
1437
  logger.logger.fail(`Writing to \`${file}\` failed...`);
2727
1438
  logger.logger.error(err);
@@ -2754,9 +1465,9 @@ async function getDiffScanWithToken({
2754
1465
  }
2755
1466
 
2756
1467
  const {
2757
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w
1468
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$x
2758
1469
  } = constants;
2759
- const config$x = {
1470
+ const config$y = {
2760
1471
  commandName: 'get',
2761
1472
  description: 'Get a diff scan for an organization',
2762
1473
  hidden: false,
@@ -2808,16 +1519,16 @@ const config$x = {
2808
1519
  `
2809
1520
  };
2810
1521
  const cmdDiffScanGet = {
2811
- description: config$x.description,
2812
- hidden: config$x.hidden,
2813
- run: run$x
1522
+ description: config$y.description,
1523
+ hidden: config$y.hidden,
1524
+ run: run$y
2814
1525
  };
2815
- async function run$x(argv, importMeta, {
1526
+ async function run$y(argv, importMeta, {
2816
1527
  parentName
2817
1528
  }) {
2818
1529
  const cli = meowOrExit({
2819
1530
  argv,
2820
- config: config$x,
1531
+ config: config$y,
2821
1532
  importMeta,
2822
1533
  parentName
2823
1534
  });
@@ -2837,7 +1548,7 @@ async function run$x(argv, importMeta, {
2837
1548
  return;
2838
1549
  }
2839
1550
  if (cli.flags['dryRun']) {
2840
- logger.logger.log(DRY_RUN_BAIL_TEXT$w);
1551
+ logger.logger.log(DRY_RUN_BAIL_TEXT$x);
2841
1552
  return;
2842
1553
  }
2843
1554
  await getDiffScan({
@@ -2850,9 +1561,9 @@ async function run$x(argv, importMeta, {
2850
1561
  });
2851
1562
  }
2852
1563
 
2853
- const description$5 = 'Diff scans related commands';
1564
+ const description$6 = 'Diff scans related commands';
2854
1565
  const cmdDiffScan = {
2855
- description: description$5,
1566
+ description: description$6,
2856
1567
  // Hidden because it was broken all this time (nobody could be using it)
2857
1568
  // and we're not sure if it's useful to anyone in its current state.
2858
1569
  // Until we do, we'll hide this to keep the help tidier.
@@ -2865,7 +1576,7 @@ const cmdDiffScan = {
2865
1576
  get: cmdDiffScanGet
2866
1577
  }, {
2867
1578
  argv,
2868
- description: description$5,
1579
+ description: description$6,
2869
1580
  importMeta,
2870
1581
  name: parentName + ' diff-scan'
2871
1582
  });
@@ -3297,7 +2008,7 @@ const readLockFileByAgent = (() => {
3297
2008
  const binaryReader = wrapReader(shadowNpmInject.readFileBinary);
3298
2009
  const defaultReader = wrapReader(async lockPath => await shadowNpmInject.readFileUtf8(lockPath));
3299
2010
  return new Map([[BUN$5, wrapReader(async (lockPath, agentExecPath) => {
3300
- const ext = path.extname(lockPath);
2011
+ const ext = path$1.extname(lockPath);
3301
2012
  if (ext === LOCK_EXT$1) {
3302
2013
  return await defaultReader(lockPath);
3303
2014
  }
@@ -3323,12 +2034,12 @@ async function detectPackageEnvironment({
3323
2034
  let lockPath = await shadowNpmInject.findUp(Object.keys(LOCKS), {
3324
2035
  cwd
3325
2036
  });
3326
- let lockName = lockPath ? path.basename(lockPath) : undefined;
2037
+ let lockName = lockPath ? path$1.basename(lockPath) : undefined;
3327
2038
  const isHiddenLockFile = lockName === HIDDEN_PACKAGE_LOCK_JSON;
3328
- const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../${PACKAGE_JSON}`) : await shadowNpmInject.findUp(PACKAGE_JSON, {
2039
+ const pkgJsonPath = lockPath ? path$1.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../${PACKAGE_JSON}`) : await shadowNpmInject.findUp(PACKAGE_JSON, {
3329
2040
  cwd
3330
2041
  });
3331
- const pkgPath = pkgJsonPath && fs.existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
2042
+ const pkgPath = pkgJsonPath && fs$1.existsSync(pkgJsonPath) ? path$1.dirname(pkgJsonPath) : undefined;
3332
2043
  const editablePkgJson = pkgPath ? await packages.readPackageJson(pkgPath, {
3333
2044
  editable: true
3334
2045
  }) : undefined;
@@ -3513,7 +2224,7 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
3513
2224
  logger?.fail(cmdPrefixMessage(cmdName, `--prod not supported for ${agent}${agentVersion ? `@${agentVersion}` : ''}`));
3514
2225
  return;
3515
2226
  }
3516
- if (details.lockPath && path.relative(cwd, details.lockPath).startsWith('.')) {
2227
+ if (details.lockPath && path$1.relative(cwd, details.lockPath).startsWith('.')) {
3517
2228
  logger?.warn(cmdPrefixMessage(cmdName, `Package ${lockName} found at ${details.lockPath}`));
3518
2229
  }
3519
2230
  return details;
@@ -3555,9 +2266,9 @@ async function runFix() {
3555
2266
  }
3556
2267
 
3557
2268
  const {
3558
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v
2269
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w
3559
2270
  } = constants;
3560
- const config$w = {
2271
+ const config$x = {
3561
2272
  commandName: 'fix',
3562
2273
  description: 'Fix "fixable" Socket alerts',
3563
2274
  hidden: true,
@@ -3573,27 +2284,27 @@ const config$w = {
3573
2284
  `
3574
2285
  };
3575
2286
  const cmdFix = {
3576
- description: config$w.description,
3577
- hidden: config$w.hidden,
3578
- run: run$w
2287
+ description: config$x.description,
2288
+ hidden: config$x.hidden,
2289
+ run: run$x
3579
2290
  };
3580
- async function run$w(argv, importMeta, {
2291
+ async function run$x(argv, importMeta, {
3581
2292
  parentName
3582
2293
  }) {
3583
2294
  const cli = meowOrExit({
3584
2295
  argv,
3585
- config: config$w,
2296
+ config: config$x,
3586
2297
  importMeta,
3587
2298
  parentName
3588
2299
  });
3589
2300
  if (cli.flags['dryRun']) {
3590
- logger.logger.log(DRY_RUN_BAIL_TEXT$v);
2301
+ logger.logger.log(DRY_RUN_BAIL_TEXT$w);
3591
2302
  return;
3592
2303
  }
3593
2304
  await runFix();
3594
2305
  }
3595
2306
 
3596
- async function fetchPackageInfo(pkgName, pkgVersion, includeAllIssues) {
2307
+ async function fetchPackageInfo$1(pkgName, pkgVersion, includeAllIssues) {
3597
2308
  const socketSdk = await shadowNpmInject.setupSdk(shadowNpmInject.getPublicToken());
3598
2309
  const result = await handleApiCall(socketSdk.getIssuesByNPMPackage(pkgName, pkgVersion), 'looking up package');
3599
2310
  const scoreResult = await handleApiCall(socketSdk.getScoreByNPMPackage(pkgName, pkgVersion), 'looking up package score');
@@ -3614,7 +2325,7 @@ async function fetchPackageInfo(pkgName, pkgVersion, includeAllIssues) {
3614
2325
  const {
3615
2326
  NPM: NPM$9
3616
2327
  } = registryConstants;
3617
- function formatScore(score) {
2328
+ function formatScore$1(score) {
3618
2329
  if (score > 80) {
3619
2330
  return colors.green(`${score}`);
3620
2331
  } else if (score < 80 && score > 60) {
@@ -3653,7 +2364,7 @@ function logPackageIssuesDetails(packageData, outputMarkdown) {
3653
2364
  }
3654
2365
  }
3655
2366
  }
3656
- function logPackageInfo({
2367
+ function logPackageInfo$1({
3657
2368
  data,
3658
2369
  score,
3659
2370
  severityCount
@@ -3684,7 +2395,7 @@ function logPackageInfo({
3684
2395
  License: Math.floor(score.license.score * 100)
3685
2396
  };
3686
2397
  logger.logger.log('\n');
3687
- Object.entries(scoreResult).map(score => logger.logger.log(`- ${score[0]}: ${formatScore(score[1])}`));
2398
+ Object.entries(scoreResult).map(score => logger.logger.log(`- ${score[0]}: ${formatScore$1(score[1])}`));
3688
2399
  logger.logger.log('\n');
3689
2400
  if (objects.hasKeys(severityCount)) {
3690
2401
  if (outputKind === 'markdown') {
@@ -3727,10 +2438,10 @@ async function getPackageInfo({
3727
2438
  spinner
3728
2439
  } = constants;
3729
2440
  spinner.start(pkgVersion === 'latest' ? `Looking up data for the latest version of ${pkgName}` : `Looking up data for version ${pkgVersion} of ${pkgName}`);
3730
- const packageData = await fetchPackageInfo(pkgName, pkgVersion, includeAllIssues);
2441
+ const packageData = await fetchPackageInfo$1(pkgName, pkgVersion, includeAllIssues);
3731
2442
  spinner.successAndStop('Data fetched');
3732
2443
  if (packageData) {
3733
- logPackageInfo(packageData, {
2444
+ logPackageInfo$1(packageData, {
3734
2445
  name: commandName,
3735
2446
  outputKind,
3736
2447
  pkgName,
@@ -3744,9 +2455,9 @@ async function getPackageInfo({
3744
2455
  }
3745
2456
 
3746
2457
  const {
3747
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u
2458
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$v
3748
2459
  } = constants;
3749
- const config$v = {
2460
+ const config$w = {
3750
2461
  commandName: 'info',
3751
2462
  description: 'Look up info regarding a package',
3752
2463
  hidden: false,
@@ -3768,16 +2479,16 @@ const config$v = {
3768
2479
  `
3769
2480
  };
3770
2481
  const cmdInfo = {
3771
- description: config$v.description,
3772
- hidden: config$v.hidden,
3773
- run: run$v
2482
+ description: config$w.description,
2483
+ hidden: config$w.hidden,
2484
+ run: run$w
3774
2485
  };
3775
- async function run$v(argv, importMeta, {
2486
+ async function run$w(argv, importMeta, {
3776
2487
  parentName
3777
2488
  }) {
3778
2489
  const cli = meowOrExit({
3779
2490
  argv,
3780
- config: config$v,
2491
+ config: config$w,
3781
2492
  importMeta,
3782
2493
  parentName
3783
2494
  });
@@ -3802,11 +2513,11 @@ async function run$v(argv, importMeta, {
3802
2513
  const pkgName = versionSeparator < 1 ? rawPkgName : rawPkgName.slice(0, versionSeparator);
3803
2514
  const pkgVersion = versionSeparator < 1 ? 'latest' : rawPkgName.slice(versionSeparator + 1);
3804
2515
  if (cli.flags['dryRun']) {
3805
- logger.logger.log(DRY_RUN_BAIL_TEXT$u);
2516
+ logger.logger.log(DRY_RUN_BAIL_TEXT$v);
3806
2517
  return;
3807
2518
  }
3808
2519
  await getPackageInfo({
3809
- commandName: `${parentName} ${config$v.commandName}`,
2520
+ commandName: `${parentName} ${config$w.commandName}`,
3810
2521
  includeAllIssues: Boolean(all),
3811
2522
  outputKind: json ? 'json' : markdown ? 'markdown' : 'print',
3812
2523
  pkgName,
@@ -3893,9 +2604,9 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
3893
2604
  }
3894
2605
 
3895
2606
  const {
3896
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$t
2607
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$u
3897
2608
  } = constants;
3898
- const config$u = {
2609
+ const config$v = {
3899
2610
  commandName: 'login',
3900
2611
  description: 'Socket API login',
3901
2612
  hidden: false,
@@ -3925,23 +2636,23 @@ const config$u = {
3925
2636
  `
3926
2637
  };
3927
2638
  const cmdLogin = {
3928
- description: config$u.description,
3929
- hidden: config$u.hidden,
3930
- run: run$u
2639
+ description: config$v.description,
2640
+ hidden: config$v.hidden,
2641
+ run: run$v
3931
2642
  };
3932
- async function run$u(argv, importMeta, {
2643
+ async function run$v(argv, importMeta, {
3933
2644
  parentName
3934
2645
  }) {
3935
2646
  const cli = meowOrExit({
3936
2647
  argv,
3937
- config: config$u,
2648
+ config: config$v,
3938
2649
  importMeta,
3939
2650
  parentName
3940
2651
  });
3941
2652
  const apiBaseUrl = cli.flags['apiBaseUrl'];
3942
2653
  const apiProxy = cli.flags['apiProxy'];
3943
2654
  if (cli.flags['dryRun']) {
3944
- logger.logger.log(DRY_RUN_BAIL_TEXT$t);
2655
+ logger.logger.log(DRY_RUN_BAIL_TEXT$u);
3945
2656
  return;
3946
2657
  }
3947
2658
  if (!isInteractive()) {
@@ -3967,9 +2678,9 @@ function attemptLogout() {
3967
2678
  }
3968
2679
 
3969
2680
  const {
3970
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$s
2681
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$t
3971
2682
  } = constants;
3972
- const config$t = {
2683
+ const config$u = {
3973
2684
  commandName: 'logout',
3974
2685
  description: 'Socket API logout',
3975
2686
  hidden: false,
@@ -3984,21 +2695,21 @@ const config$t = {
3984
2695
  `
3985
2696
  };
3986
2697
  const cmdLogout = {
3987
- description: config$t.description,
3988
- hidden: config$t.hidden,
3989
- run: run$t
2698
+ description: config$u.description,
2699
+ hidden: config$u.hidden,
2700
+ run: run$u
3990
2701
  };
3991
- async function run$t(argv, importMeta, {
2702
+ async function run$u(argv, importMeta, {
3992
2703
  parentName
3993
2704
  }) {
3994
2705
  const cli = meowOrExit({
3995
2706
  argv,
3996
- config: config$t,
2707
+ config: config$u,
3997
2708
  importMeta,
3998
2709
  parentName
3999
2710
  });
4000
2711
  if (cli.flags['dryRun']) {
4001
- logger.logger.log(DRY_RUN_BAIL_TEXT$s);
2712
+ logger.logger.log(DRY_RUN_BAIL_TEXT$t);
4002
2713
  return;
4003
2714
  }
4004
2715
  attemptLogout();
@@ -4009,8 +2720,8 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
4009
2720
  const {
4010
2721
  spinner
4011
2722
  } = constants;
4012
- const rbin = path.resolve(bin);
4013
- const rtarget = path.resolve(target);
2723
+ const rbin = path$1.resolve(bin);
2724
+ const rtarget = path$1.resolve(target);
4014
2725
  if (verbose) {
4015
2726
  logger.logger.group('gradle2maven:');
4016
2727
  logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\``);
@@ -4030,7 +2741,7 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
4030
2741
  // I'd prefer something plain-text if it is to be committed.
4031
2742
 
4032
2743
  // Note: init.gradle will be exported by .config/rollup.dist.config.mjs
4033
- const initLocation = path.join(constants.rootDistPath, 'init.gradle');
2744
+ const initLocation = path$1.join(constants.rootDistPath, 'init.gradle');
4034
2745
  const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom'];
4035
2746
  if (verbose) {
4036
2747
  logger.logger.log('[VERBOSE] Executing:', bin, commandArgs);
@@ -4103,9 +2814,9 @@ async function convertGradleToMaven(target, bin, _out, verbose, gradleOpts) {
4103
2814
  }
4104
2815
 
4105
2816
  const {
4106
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$r
2817
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$s
4107
2818
  } = constants;
4108
- const config$s = {
2819
+ const config$t = {
4109
2820
  commandName: 'gradle',
4110
2821
  description: '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Gradle/Java/Kotlin/etc project',
4111
2822
  hidden: false,
@@ -4177,22 +2888,22 @@ const config$s = {
4177
2888
  `
4178
2889
  };
4179
2890
  const cmdManifestGradle = {
4180
- description: config$s.description,
4181
- hidden: config$s.hidden,
4182
- run: run$s
2891
+ description: config$t.description,
2892
+ hidden: config$t.hidden,
2893
+ run: run$t
4183
2894
  };
4184
- async function run$s(argv, importMeta, {
2895
+ async function run$t(argv, importMeta, {
4185
2896
  parentName
4186
2897
  }) {
4187
2898
  const cli = meowOrExit({
4188
2899
  argv,
4189
- config: config$s,
2900
+ config: config$t,
4190
2901
  importMeta,
4191
2902
  parentName
4192
2903
  });
4193
2904
  const verbose = Boolean(cli.flags['verbose']);
4194
2905
  if (verbose) {
4195
- logger.logger.group('- ', parentName, config$s.commandName, ':');
2906
+ logger.logger.group('- ', parentName, config$t.commandName, ':');
4196
2907
  logger.logger.group('- flags:', cli.flags);
4197
2908
  logger.logger.groupEnd();
4198
2909
  logger.logger.log('- input:', cli.input);
@@ -4219,7 +2930,7 @@ async function run$s(argv, importMeta, {
4219
2930
  if (cli.flags['bin']) {
4220
2931
  bin = cli.flags['bin'];
4221
2932
  } else {
4222
- bin = path.join(target, 'gradlew');
2933
+ bin = path$1.join(target, 'gradlew');
4223
2934
  }
4224
2935
  let out = './socket.pom.xml';
4225
2936
  if (cli.flags['out']) {
@@ -4240,7 +2951,7 @@ async function run$s(argv, importMeta, {
4240
2951
  gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
4241
2952
  }
4242
2953
  if (cli.flags['dryRun']) {
4243
- logger.logger.log(DRY_RUN_BAIL_TEXT$r);
2954
+ logger.logger.log(DRY_RUN_BAIL_TEXT$s);
4244
2955
  return;
4245
2956
  }
4246
2957
  await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
@@ -4251,8 +2962,8 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
4251
2962
  const {
4252
2963
  spinner
4253
2964
  } = constants;
4254
- const rbin = path.resolve(bin);
4255
- const rtarget = path.resolve(target);
2965
+ const rbin = path$1.resolve(bin);
2966
+ const rtarget = path$1.resolve(target);
4256
2967
  if (verbose) {
4257
2968
  logger.logger.group('sbt2maven:');
4258
2969
  logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\``);
@@ -4345,9 +3056,9 @@ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
4345
3056
  }
4346
3057
 
4347
3058
  const {
4348
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$q
3059
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$r
4349
3060
  } = constants;
4350
- const config$r = {
3061
+ const config$s = {
4351
3062
  commandName: 'scala',
4352
3063
  description: "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
4353
3064
  hidden: false,
@@ -4420,22 +3131,22 @@ const config$r = {
4420
3131
  `
4421
3132
  };
4422
3133
  const cmdManifestScala = {
4423
- description: config$r.description,
4424
- hidden: config$r.hidden,
4425
- run: run$r
3134
+ description: config$s.description,
3135
+ hidden: config$s.hidden,
3136
+ run: run$s
4426
3137
  };
4427
- async function run$r(argv, importMeta, {
3138
+ async function run$s(argv, importMeta, {
4428
3139
  parentName
4429
3140
  }) {
4430
3141
  const cli = meowOrExit({
4431
3142
  argv,
4432
- config: config$r,
3143
+ config: config$s,
4433
3144
  importMeta,
4434
3145
  parentName
4435
3146
  });
4436
3147
  const verbose = Boolean(cli.flags['verbose']);
4437
3148
  if (verbose) {
4438
- logger.logger.group('- ', parentName, config$r.commandName, ':');
3149
+ logger.logger.group('- ', parentName, config$s.commandName, ':');
4439
3150
  logger.logger.group('- flags:', cli.flags);
4440
3151
  logger.logger.groupEnd();
4441
3152
  logger.logger.log('- input:', cli.input);
@@ -4481,16 +3192,16 @@ async function run$r(argv, importMeta, {
4481
3192
  sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
4482
3193
  }
4483
3194
  if (cli.flags['dryRun']) {
4484
- logger.logger.log(DRY_RUN_BAIL_TEXT$q);
3195
+ logger.logger.log(DRY_RUN_BAIL_TEXT$r);
4485
3196
  return;
4486
3197
  }
4487
3198
  await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
4488
3199
  }
4489
3200
 
4490
3201
  const {
4491
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$p
3202
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$q
4492
3203
  } = constants;
4493
- const config$q = {
3204
+ const config$r = {
4494
3205
  commandName: 'auto',
4495
3206
  description: 'Auto-detect build and attempt to generate manifest file',
4496
3207
  hidden: false,
@@ -4520,23 +3231,23 @@ const config$q = {
4520
3231
  `
4521
3232
  };
4522
3233
  const cmdManifestAuto = {
4523
- description: config$q.description,
4524
- hidden: config$q.hidden,
4525
- run: run$q
3234
+ description: config$r.description,
3235
+ hidden: config$r.hidden,
3236
+ run: run$r
4526
3237
  };
4527
- async function run$q(argv, importMeta, {
3238
+ async function run$r(argv, importMeta, {
4528
3239
  parentName
4529
3240
  }) {
4530
3241
  const cli = meowOrExit({
4531
3242
  argv,
4532
- config: config$q,
3243
+ config: config$r,
4533
3244
  importMeta,
4534
3245
  parentName
4535
3246
  });
4536
3247
  const verbose = !!cli.flags['verbose'];
4537
3248
  const cwd = cli.flags['cwd'] ?? process.cwd();
4538
3249
  if (verbose) {
4539
- logger.logger.group('- ', parentName, config$q.commandName, ':');
3250
+ logger.logger.group('- ', parentName, config$r.commandName, ':');
4540
3251
  logger.logger.group('- flags:', cli.flags);
4541
3252
  logger.logger.groupEnd();
4542
3253
  logger.logger.log('- input:', cli.input);
@@ -4548,14 +3259,14 @@ async function run$q(argv, importMeta, {
4548
3259
  subArgs.push('--verbose');
4549
3260
  }
4550
3261
  const dir = cwd;
4551
- if (fs.existsSync(path.join(dir, 'build.sbt'))) {
3262
+ if (fs$1.existsSync(path$1.join(dir, 'build.sbt'))) {
4552
3263
  logger.logger.log('Detected a Scala sbt build, running default Scala generator...');
4553
3264
  if (cwd) {
4554
3265
  subArgs.push('--cwd', cwd);
4555
3266
  }
4556
3267
  subArgs.push(dir);
4557
3268
  if (cli.flags['dryRun']) {
4558
- logger.logger.log(DRY_RUN_BAIL_TEXT$p);
3269
+ logger.logger.log(DRY_RUN_BAIL_TEXT$q);
4559
3270
  return;
4560
3271
  }
4561
3272
  await cmdManifestScala.run(subArgs, importMeta, {
@@ -4563,14 +3274,14 @@ async function run$q(argv, importMeta, {
4563
3274
  });
4564
3275
  return;
4565
3276
  }
4566
- if (fs.existsSync(path.join(dir, 'gradlew'))) {
3277
+ if (fs$1.existsSync(path$1.join(dir, 'gradlew'))) {
4567
3278
  logger.logger.log('Detected a gradle build, running default gradle generator...');
4568
3279
  if (cwd) {
4569
3280
  // This command takes the cwd as first arg.
4570
3281
  subArgs.push(cwd);
4571
3282
  }
4572
3283
  if (cli.flags['dryRun']) {
4573
- logger.logger.log(DRY_RUN_BAIL_TEXT$p);
3284
+ logger.logger.log(DRY_RUN_BAIL_TEXT$q);
4574
3285
  return;
4575
3286
  }
4576
3287
  await cmdManifestGradle.run(subArgs, importMeta, {
@@ -4579,13 +3290,13 @@ async function run$q(argv, importMeta, {
4579
3290
  return;
4580
3291
  }
4581
3292
  if (cli.flags['dryRun']) {
4582
- logger.logger.log(DRY_RUN_BAIL_TEXT$p);
3293
+ logger.logger.log(DRY_RUN_BAIL_TEXT$q);
4583
3294
  return;
4584
3295
  }
4585
3296
 
4586
3297
  // Show new help screen and exit.
4587
3298
  vendor.meow(`
4588
- $ ${parentName} ${config$q.commandName}
3299
+ $ ${parentName} ${config$r.commandName}
4589
3300
 
4590
3301
  Unfortunately this script did not discover a supported language in the
4591
3302
  current folder.
@@ -4598,13 +3309,13 @@ async function run$q(argv, importMeta, {
4598
3309
  your target language.
4599
3310
  `, {
4600
3311
  argv: [],
4601
- description: config$q.description,
3312
+ description: config$r.description,
4602
3313
  importMeta
4603
3314
  }).showHelp();
4604
3315
  }
4605
3316
 
4606
3317
  const {
4607
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$o
3318
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$p
4608
3319
  } = constants;
4609
3320
 
4610
3321
  // TODO: we may want to dedupe some pieces for all gradle languages. I think it
@@ -4612,7 +3323,7 @@ const {
4612
3323
  // sense for the help panels to note the requested language, rather than
4613
3324
  // `socket manifest kotlin` to print help screens with `gradle` as the
4614
3325
  // command. Room for improvement.
4615
- const config$p = {
3326
+ const config$q = {
4616
3327
  commandName: 'kotlin',
4617
3328
  description: '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Kotlin project',
4618
3329
  hidden: false,
@@ -4684,22 +3395,22 @@ const config$p = {
4684
3395
  `
4685
3396
  };
4686
3397
  const cmdManifestKotlin = {
4687
- description: config$p.description,
4688
- hidden: config$p.hidden,
4689
- run: run$p
3398
+ description: config$q.description,
3399
+ hidden: config$q.hidden,
3400
+ run: run$q
4690
3401
  };
4691
- async function run$p(argv, importMeta, {
3402
+ async function run$q(argv, importMeta, {
4692
3403
  parentName
4693
3404
  }) {
4694
3405
  const cli = meowOrExit({
4695
3406
  argv,
4696
- config: config$p,
3407
+ config: config$q,
4697
3408
  importMeta,
4698
3409
  parentName
4699
3410
  });
4700
3411
  const verbose = Boolean(cli.flags['verbose']);
4701
3412
  if (verbose) {
4702
- logger.logger.group('- ', parentName, config$p.commandName, ':');
3413
+ logger.logger.group('- ', parentName, config$q.commandName, ':');
4703
3414
  logger.logger.group('- flags:', cli.flags);
4704
3415
  logger.logger.groupEnd();
4705
3416
  logger.logger.log('- input:', cli.input);
@@ -4726,7 +3437,7 @@ async function run$p(argv, importMeta, {
4726
3437
  if (cli.flags['bin']) {
4727
3438
  bin = cli.flags['bin'];
4728
3439
  } else {
4729
- bin = path.join(target, 'gradlew');
3440
+ bin = path$1.join(target, 'gradlew');
4730
3441
  }
4731
3442
  let out = './socket.pom.xml';
4732
3443
  if (cli.flags['out']) {
@@ -4747,13 +3458,13 @@ async function run$p(argv, importMeta, {
4747
3458
  gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
4748
3459
  }
4749
3460
  if (cli.flags['dryRun']) {
4750
- logger.logger.log(DRY_RUN_BAIL_TEXT$o);
3461
+ logger.logger.log(DRY_RUN_BAIL_TEXT$p);
4751
3462
  return;
4752
3463
  }
4753
3464
  await convertGradleToMaven(target, bin, out, verbose, gradleOpts);
4754
3465
  }
4755
3466
 
4756
- const config$o = {
3467
+ const config$p = {
4757
3468
  commandName: 'manifest',
4758
3469
  description: 'Generate a dependency manifest for given file or dir',
4759
3470
  hidden: false,
@@ -4761,11 +3472,11 @@ const config$o = {
4761
3472
  ...commonFlags
4762
3473
  }};
4763
3474
  const cmdManifest = {
4764
- description: config$o.description,
4765
- hidden: config$o.hidden,
4766
- run: run$o
3475
+ description: config$p.description,
3476
+ hidden: config$p.hidden,
3477
+ run: run$p
4767
3478
  };
4768
- async function run$o(argv, importMeta, {
3479
+ async function run$p(argv, importMeta, {
4769
3480
  parentName
4770
3481
  }) {
4771
3482
  await meowWithSubcommands({
@@ -4777,15 +3488,15 @@ async function run$o(argv, importMeta, {
4777
3488
  argv,
4778
3489
  aliases: {
4779
3490
  yolo: {
4780
- description: config$o.description,
3491
+ description: config$p.description,
4781
3492
  hidden: true,
4782
3493
  argv: ['auto']
4783
3494
  }
4784
3495
  },
4785
- description: config$o.description,
3496
+ description: config$p.description,
4786
3497
  importMeta,
4787
- flags: config$o.flags,
4788
- name: `${parentName} ${config$o.commandName}`
3498
+ flags: config$p.flags,
3499
+ name: `${parentName} ${config$p.commandName}`
4789
3500
  });
4790
3501
  }
4791
3502
 
@@ -4799,10 +3510,10 @@ async function wrapNpm(argv) {
4799
3510
  }
4800
3511
 
4801
3512
  const {
4802
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$n,
3513
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$o,
4803
3514
  NPM: NPM$7
4804
3515
  } = constants;
4805
- const config$n = {
3516
+ const config$o = {
4806
3517
  commandName: 'npm',
4807
3518
  description: `${NPM$7} wrapper functionality`,
4808
3519
  hidden: false,
@@ -4813,22 +3524,22 @@ const config$n = {
4813
3524
  `
4814
3525
  };
4815
3526
  const cmdNpm = {
4816
- description: config$n.description,
4817
- hidden: config$n.hidden,
4818
- run: run$n
3527
+ description: config$o.description,
3528
+ hidden: config$o.hidden,
3529
+ run: run$o
4819
3530
  };
4820
- async function run$n(argv, importMeta, {
3531
+ async function run$o(argv, importMeta, {
4821
3532
  parentName
4822
3533
  }) {
4823
3534
  const cli = meowOrExit({
4824
3535
  allowUnknownFlags: true,
4825
3536
  argv,
4826
- config: config$n,
3537
+ config: config$o,
4827
3538
  importMeta,
4828
3539
  parentName
4829
3540
  });
4830
3541
  if (cli.flags['dryRun']) {
4831
- logger.logger.log(DRY_RUN_BAIL_TEXT$n);
3542
+ logger.logger.log(DRY_RUN_BAIL_TEXT$o);
4832
3543
  return;
4833
3544
  }
4834
3545
  await wrapNpm(argv);
@@ -4844,10 +3555,10 @@ async function wrapNpx(argv) {
4844
3555
  }
4845
3556
 
4846
3557
  const {
4847
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$m,
3558
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$n,
4848
3559
  NPX: NPX$1
4849
3560
  } = constants;
4850
- const config$m = {
3561
+ const config$n = {
4851
3562
  commandName: 'npx',
4852
3563
  description: `${NPX$1} wrapper functionality`,
4853
3564
  hidden: false,
@@ -4858,31 +3569,31 @@ const config$m = {
4858
3569
  `
4859
3570
  };
4860
3571
  const cmdNpx = {
4861
- description: config$m.description,
4862
- hidden: config$m.hidden,
4863
- run: run$m
3572
+ description: config$n.description,
3573
+ hidden: config$n.hidden,
3574
+ run: run$n
4864
3575
  };
4865
- async function run$m(argv, importMeta, {
3576
+ async function run$n(argv, importMeta, {
4866
3577
  parentName
4867
3578
  }) {
4868
3579
  const cli = meowOrExit({
4869
3580
  allowUnknownFlags: true,
4870
3581
  argv,
4871
- config: config$m,
3582
+ config: config$n,
4872
3583
  importMeta,
4873
3584
  parentName
4874
3585
  });
4875
3586
  if (cli.flags['dryRun']) {
4876
- logger.logger.log(DRY_RUN_BAIL_TEXT$m);
3587
+ logger.logger.log(DRY_RUN_BAIL_TEXT$n);
4877
3588
  return;
4878
3589
  }
4879
3590
  await wrapNpx(argv);
4880
3591
  }
4881
3592
 
4882
3593
  const {
4883
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$l
3594
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$m
4884
3595
  } = constants;
4885
- const config$l = {
3596
+ const config$m = {
4886
3597
  commandName: 'oops',
4887
3598
  description: 'Trigger an intentional error (for development)',
4888
3599
  hidden: true,
@@ -4897,21 +3608,21 @@ const config$l = {
4897
3608
  `
4898
3609
  };
4899
3610
  const cmdOops = {
4900
- description: config$l.description,
4901
- hidden: config$l.hidden,
4902
- run: run$l
3611
+ description: config$m.description,
3612
+ hidden: config$m.hidden,
3613
+ run: run$m
4903
3614
  };
4904
- async function run$l(argv, importMeta, {
3615
+ async function run$m(argv, importMeta, {
4905
3616
  parentName
4906
3617
  }) {
4907
3618
  const cli = meowOrExit({
4908
3619
  argv,
4909
- config: config$l,
3620
+ config: config$m,
4910
3621
  importMeta,
4911
3622
  parentName
4912
3623
  });
4913
3624
  if (cli.flags['dryRun']) {
4914
- logger.logger.log(DRY_RUN_BAIL_TEXT$l);
3625
+ logger.logger.log(DRY_RUN_BAIL_TEXT$m);
4915
3626
  return;
4916
3627
  }
4917
3628
  throw new Error('This error was intentionally left blank');
@@ -5030,7 +3741,7 @@ const PNPM_WORKSPACE = `${PNPM$4}-workspace`;
5030
3741
  async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
5031
3742
  let workspacePatterns;
5032
3743
  if (agent === PNPM$4) {
5033
- for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
3744
+ for (const workspacePath of [path$1.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path$1.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
5034
3745
  // eslint-disable-next-line no-await-in-loop
5035
3746
  const yml = await shadowNpmInject.safeReadFile(workspacePath);
5036
3747
  if (yml) {
@@ -5398,7 +4109,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
5398
4109
  const {
5399
4110
  content: pkgJson
5400
4111
  } = editablePkgJson;
5401
- const workspaceName = path.relative(rootPath, pkgPath);
4112
+ const workspaceName = path$1.relative(rootPath, pkgPath);
5402
4113
  const workspaceGlobs = await getWorkspaceGlobs(agent, pkgPath, pkgJson);
5403
4114
  const isRoot = pkgPath === rootPath;
5404
4115
  const isLockScanned = isRoot && !prod;
@@ -5532,7 +4243,7 @@ async function addOverrides(pkgPath, pkgEnvDetails, options) {
5532
4243
  });
5533
4244
  // Chunk package names to process them in parallel 3 at a time.
5534
4245
  await promises.pEach(workspacePkgJsonPaths, 3, async workspacePkgJsonPath => {
5535
- const otherState = await addOverrides(path.dirname(workspacePkgJsonPath), pkgEnvDetails, {
4246
+ const otherState = await addOverrides(path$1.dirname(workspacePkgJsonPath), pkgEnvDetails, {
5536
4247
  logger,
5537
4248
  pin,
5538
4249
  prod,
@@ -5570,7 +4281,7 @@ async function updateLockfile(pkgEnvDetails, options) {
5570
4281
  __proto__: null,
5571
4282
  ...options
5572
4283
  };
5573
- const isSpinning = !!spinner?.isSpinning;
4284
+ const isSpinning = !!spinner?.['isSpinning'];
5574
4285
  if (!isSpinning) {
5575
4286
  spinner?.start();
5576
4287
  }
@@ -5642,9 +4353,9 @@ async function applyOptimization(cwd, pin, prod) {
5642
4353
  }
5643
4354
 
5644
4355
  const {
5645
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k
4356
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$l
5646
4357
  } = constants;
5647
- const config$k = {
4358
+ const config$l = {
5648
4359
  commandName: 'optimize',
5649
4360
  description: 'Optimize dependencies with @socketregistry overrides',
5650
4361
  hidden: false,
@@ -5674,22 +4385,22 @@ const config$k = {
5674
4385
  `
5675
4386
  };
5676
4387
  const cmdOptimize = {
5677
- description: config$k.description,
5678
- hidden: config$k.hidden,
5679
- run: run$k
4388
+ description: config$l.description,
4389
+ hidden: config$l.hidden,
4390
+ run: run$l
5680
4391
  };
5681
- async function run$k(argv, importMeta, {
4392
+ async function run$l(argv, importMeta, {
5682
4393
  parentName
5683
4394
  }) {
5684
4395
  const cli = meowOrExit({
5685
4396
  argv,
5686
- config: config$k,
4397
+ config: config$l,
5687
4398
  importMeta,
5688
4399
  parentName
5689
4400
  });
5690
4401
  const cwd = process$1.cwd();
5691
4402
  if (cli.flags['dryRun']) {
5692
- logger.logger.log(DRY_RUN_BAIL_TEXT$k);
4403
+ logger.logger.log(DRY_RUN_BAIL_TEXT$l);
5693
4404
  return;
5694
4405
  }
5695
4406
  await applyOptimization(cwd, Boolean(cli.flags['pin']), Boolean(cli.flags['prod']));
@@ -5763,9 +4474,9 @@ async function printOrganizationsFromToken(apiToken, format = 'text') {
5763
4474
  }
5764
4475
 
5765
4476
  const {
5766
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$j
4477
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$k
5767
4478
  } = constants;
5768
- const config$j = {
4479
+ const config$k = {
5769
4480
  commandName: 'list',
5770
4481
  description: 'List organizations associated with the API key used',
5771
4482
  hidden: false,
@@ -5778,20 +4489,20 @@ const config$j = {
5778
4489
  $ ${command}
5779
4490
 
5780
4491
  Options
5781
- ${getFlagListOutput(config$j.flags, 6)}
4492
+ ${getFlagListOutput(config$k.flags, 6)}
5782
4493
  `
5783
4494
  };
5784
4495
  const cmdOrganizationList = {
5785
- description: config$j.description,
5786
- hidden: config$j.hidden,
5787
- run: run$j
4496
+ description: config$k.description,
4497
+ hidden: config$k.hidden,
4498
+ run: run$k
5788
4499
  };
5789
- async function run$j(argv, importMeta, {
4500
+ async function run$k(argv, importMeta, {
5790
4501
  parentName
5791
4502
  }) {
5792
4503
  const cli = meowOrExit({
5793
4504
  argv,
5794
- config: config$j,
4505
+ config: config$k,
5795
4506
  importMeta,
5796
4507
  parentName
5797
4508
  });
@@ -5810,7 +4521,7 @@ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields
5810
4521
  return;
5811
4522
  }
5812
4523
  if (cli.flags['dryRun']) {
5813
- logger.logger.log(DRY_RUN_BAIL_TEXT$j);
4524
+ logger.logger.log(DRY_RUN_BAIL_TEXT$k);
5814
4525
  return;
5815
4526
  }
5816
4527
  await getOrganization(json ? 'json' : markdown ? 'markdown' : 'text');
@@ -5858,11 +4569,11 @@ async function getSecurityPolicyWithToken(apiToken, orgSlug, format) {
5858
4569
  }
5859
4570
 
5860
4571
  const {
5861
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$i
4572
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$j
5862
4573
  } = constants;
5863
4574
 
5864
4575
  // TODO: secret toplevel alias `socket security policy`?
5865
- const config$i = {
4576
+ const config$j = {
5866
4577
  commandName: 'security',
5867
4578
  description: 'Retrieve the security policy of an organization.',
5868
4579
  hidden: true,
@@ -5875,7 +4586,7 @@ const config$i = {
5875
4586
  $ ${command} <org slug>
5876
4587
 
5877
4588
  Options
5878
- ${getFlagListOutput(config$i.flags, 6)}
4589
+ ${getFlagListOutput(config$j.flags, 6)}
5879
4590
 
5880
4591
  Your API token will need the \`security-policy:read\` permission otherwise
5881
4592
  the request will fail with an authentication error.
@@ -5886,16 +4597,16 @@ const config$i = {
5886
4597
  `
5887
4598
  };
5888
4599
  const cmdOrganizationPolicyPolicy = {
5889
- description: config$i.description,
5890
- hidden: config$i.hidden,
5891
- run: run$i
4600
+ description: config$j.description,
4601
+ hidden: config$j.hidden,
4602
+ run: run$j
5892
4603
  };
5893
- async function run$i(argv, importMeta, {
4604
+ async function run$j(argv, importMeta, {
5894
4605
  parentName
5895
4606
  }) {
5896
4607
  const cli = meowOrExit({
5897
4608
  argv,
5898
- config: config$i,
4609
+ config: config$j,
5899
4610
  importMeta,
5900
4611
  parentName
5901
4612
  });
@@ -5916,15 +4627,15 @@ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields
5916
4627
  return;
5917
4628
  }
5918
4629
  if (cli.flags['dryRun']) {
5919
- logger.logger.log(DRY_RUN_BAIL_TEXT$i);
4630
+ logger.logger.log(DRY_RUN_BAIL_TEXT$j);
5920
4631
  return;
5921
4632
  }
5922
4633
  await getSecurityPolicy(orgSlug, json ? 'json' : markdown ? 'markdown' : 'text');
5923
4634
  }
5924
4635
 
5925
- const description$4 = 'Organization policy details';
4636
+ const description$5 = 'Organization policy details';
5926
4637
  const cmdOrganizationPolicy = {
5927
- description: description$4,
4638
+ description: description$5,
5928
4639
  // Hidden because it was broken all this time (nobody could be using it)
5929
4640
  // and we're not sure if it's useful to anyone in its current state.
5930
4641
  // Until we do, we'll hide this to keep the help tidier.
@@ -5937,7 +4648,7 @@ const cmdOrganizationPolicy = {
5937
4648
  security: cmdOrganizationPolicyPolicy
5938
4649
  }, {
5939
4650
  argv,
5940
- description: description$4,
4651
+ description: description$5,
5941
4652
  defaultSub: 'list',
5942
4653
  // Backwards compat
5943
4654
  importMeta,
@@ -5988,9 +4699,9 @@ async function getQuotaWithToken(apiToken, format = 'text') {
5988
4699
  }
5989
4700
 
5990
4701
  const {
5991
- DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$h
4702
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$i
5992
4703
  } = constants;
5993
- const config$h = {
4704
+ const config$i = {
5994
4705
  commandName: 'quota',
5995
4706
  description: 'List organizations associated with the API key used',
5996
4707
  hidden: true,
@@ -6003,20 +4714,20 @@ const config$h = {
6003
4714
  $ ${command}
6004
4715
 
6005
4716
  Options
6006
- ${getFlagListOutput(config$h.flags, 6)}
4717
+ ${getFlagListOutput(config$i.flags, 6)}
6007
4718
  `
6008
4719
  };
6009
4720
  const cmdOrganizationQuota = {
6010
- description: config$h.description,
6011
- hidden: config$h.hidden,
6012
- run: run$h
4721
+ description: config$i.description,
4722
+ hidden: config$i.hidden,
4723
+ run: run$i
6013
4724
  };
6014
- async function run$h(argv, importMeta, {
4725
+ async function run$i(argv, importMeta, {
6015
4726
  parentName
6016
4727
  }) {
6017
4728
  const cli = meowOrExit({
6018
4729
  argv,
6019
- config: config$h,
4730
+ config: config$i,
6020
4731
  importMeta,
6021
4732
  parentName
6022
4733
  });
@@ -6035,15 +4746,15 @@ ${colors.bgRed(colors.white('Input error'))}: Please provide the required fields
6035
4746
  return;
6036
4747
  }
6037
4748
  if (cli.flags['dryRun']) {
6038
- logger.logger.log(DRY_RUN_BAIL_TEXT$h);
4749
+ logger.logger.log(DRY_RUN_BAIL_TEXT$i);
6039
4750
  return;
6040
4751
  }
6041
4752
  await getQuota(json ? 'json' : markdown ? 'markdown' : 'text');
6042
4753
  }
6043
4754
 
6044
- const description$3 = 'Account details';
4755
+ const description$4 = 'Account details';
6045
4756
  const cmdOrganization = {
6046
- description: description$3,
4757
+ description: description$4,
6047
4758
  // Hidden because it was broken all this time (nobody could be using it)
6048
4759
  // and we're not sure if it's useful to anyone in its current state.
6049
4760
  // Until we do, we'll hide this to keep the help tidier.
@@ -6058,7 +4769,7 @@ const cmdOrganization = {
6058
4769
  policy: cmdOrganizationPolicy
6059
4770
  }, {
6060
4771
  argv,
6061
- description: description$3,
4772
+ description: description$4,
6062
4773
  defaultSub: 'list',
6063
4774
  // Backwards compat
6064
4775
  importMeta,
@@ -6067,6 +4778,298 @@ const cmdOrganization = {
6067
4778
  }
6068
4779
  };
6069
4780
 
4781
+ // Either an ecosystem was given or all args must be (namespaced) purls
4782
+ // The `pkg:` part is optional here. We'll scan for `eco/name@version`.
4783
+ // Not hardcoding the namespace since we don't know what the server accepts.
4784
+ // The ecosystem is considered as the first package if it is not an a-z string.
4785
+ function parsePackageSpecifiers(ecosystem, pkgs) {
4786
+ let valid = true;
4787
+ const purls = [];
4788
+ if (!ecosystem) {
4789
+ valid = false;
4790
+ } else if (/^[a-zA-Z]+$/.test(ecosystem)) {
4791
+ for (let i = 0; i < pkgs.length; ++i) {
4792
+ const pkg = pkgs[i] ?? '';
4793
+ if (!pkg) {
4794
+ valid = false;
4795
+ break;
4796
+ } else if (pkg.startsWith('pkg:')) {
4797
+ // keep
4798
+ purls.push(pkg);
4799
+ } else if (pkg.includes('/')) {
4800
+ // Looks like this arg was already namespaced
4801
+ purls.push('pkg:' + pkg);
4802
+ } else {
4803
+ purls.push('pkg:' + ecosystem + '/' + pkg);
4804
+ }
4805
+ }
4806
+ if (!purls.length) {
4807
+ valid = false;
4808
+ }
4809
+ } else {
4810
+ // Assume ecosystem is a purl, too
4811
+ pkgs.unshift(ecosystem);
4812
+ for (let i = 0; i < pkgs.length; ++i) {
4813
+ const pkg = pkgs[i] ?? '';
4814
+ if (!/^(?:pkg:)?[a-zA-Z]+\/./.test(pkg)) {
4815
+ // At least one purl did not start with `pkg:eco/x` or `eco/x`
4816
+ valid = false;
4817
+ break;
4818
+ } else if (pkg.startsWith('pkg:')) {
4819
+ purls.push(pkg);
4820
+ } else {
4821
+ purls.push('pkg:' + pkg);
4822
+ }
4823
+ }
4824
+ if (!purls.length) {
4825
+ valid = false;
4826
+ }
4827
+ }
4828
+ return {
4829
+ purls,
4830
+ valid
4831
+ };
4832
+ }
4833
+
4834
+ async function fetchPackageInfo(purls) {
4835
+ const socketSdk = await shadowNpmInject.setupSdk(shadowNpmInject.getPublicToken());
4836
+
4837
+ // Lazily access constants.spinner.
4838
+ const {
4839
+ spinner
4840
+ } = constants;
4841
+ logger.logger.error(`Requesting shallow score data for ${purls.length} package urls (purl): ${purls.join(', ')}`);
4842
+ spinner.start(`Requesting data ...`);
4843
+ const result = await handleApiCall(socketSdk.batchPackageFetch({
4844
+ alerts: 'true'
4845
+ // compact: false,
4846
+ // fixable: false,
4847
+ // licenseattrib: false,
4848
+ // licensedetails: false
4849
+ }, {
4850
+ components: purls.map(purl => ({
4851
+ purl
4852
+ }))
4853
+ }), 'looking up package');
4854
+ spinner.successAndStop('Request completed');
4855
+ if (result.success) {
4856
+ return result;
4857
+ } else {
4858
+ handleUnsuccessfulApiResponse('batchPackageFetch', result);
4859
+ }
4860
+ }
4861
+
4862
+ function logPackageInfo(purls, packageData, outputKind) {
4863
+ if (outputKind === 'json') {
4864
+ // In JSON simply return what the server responds with. Don't bother trying
4865
+ // to match the response with the requested packages/purls.
4866
+ logger.logger.log(JSON.stringify(packageData, undefined, 2));
4867
+ return;
4868
+ }
4869
+
4870
+ // Make some effort to match the requested data with the response
4871
+
4872
+ const set = new Set();
4873
+ packageData.forEach(data => {
4874
+ set.add('pkg:' + data.type + '/' + data.name + '@' + data.version);
4875
+ set.add('pkg:' + data.type + '/' + data.name);
4876
+ });
4877
+ const missing = purls.filter(purl => {
4878
+ if (set.has(purl)) return false;
4879
+ if (purl.endsWith('@latest') && set.has(purl.slice(0, -'@latest'.length))) return false;
4880
+ return true; // not found
4881
+ });
4882
+ if (outputKind === 'markdown') {
4883
+ logger.logger.log(commonTags.stripIndents`
4884
+ # Shallow Package Report
4885
+
4886
+ This report contains the response for requesting data on some package url(s).
4887
+
4888
+ Please note: The listed scores are ONLY for the package itself. It does NOT
4889
+ reflect the scores of any dependencies, transitive or otherwise.
4890
+
4891
+ ${missing.length ? `\n## Missing response\n\nAt least one package had no response or the purl was not canonical:\n\n${missing.map(purl => '- ' + purl + '\n').join('')}` : ''}
4892
+
4893
+ ${packageData.map(data => '## ' + formatReportCard(data, false)).join('\n\n\n')}
4894
+ `);
4895
+ return;
4896
+ }
4897
+ logger.logger.log('\n' + colors.bold('Shallow Package Score') + '\n');
4898
+ logger.logger.log('Please note: The listed scores are ONLY for the package itself. It does NOT\n' + ' reflect the scores of any dependencies, transitive or otherwise.');
4899
+ if (missing.length) {
4900
+ logger.logger.log(`\nAt least one package had no response or the purl was not canonical:\n${missing.map(purl => '\n- ' + colors.bold(purl)).join('')}`);
4901
+ }
4902
+ packageData.forEach(data => {
4903
+ logger.logger.log('\n');
4904
+ logger.logger.log(formatReportCard(data, true));
4905
+ });
4906
+ logger.logger.log('');
4907
+ }
4908
+ function formatReportCard(data, color) {
4909
+ const scoreResult = {
4910
+ 'Supply Chain Risk': Math.floor((data.score?.supplyChain ?? 0) * 100),
4911
+ Maintenance: Math.floor((data.score?.maintenance ?? 0) * 100),
4912
+ Quality: Math.floor((data.score?.quality ?? 0) * 100),
4913
+ Vulnerabilities: Math.floor((data.score?.vulnerability ?? 0) * 100),
4914
+ License: Math.floor((data.score?.license ?? 0) * 100)
4915
+ };
4916
+ const alertString = getAlertString(data.alerts, !color);
4917
+ const purl = 'pkg:' + data.type + '/' + data.name + '@' + data.version;
4918
+ return ['Package: ' + (color ? colors.bold(purl) : purl), '', ...Object.entries(scoreResult).map(score => `- ${score[0]}:`.padEnd(20, ' ') + ` ${formatScore(score[1], !color, true)}`), alertString].join('\n');
4919
+ }
4920
+ function formatScore(score, noColor = false, pad = false) {
4921
+ const padded = String(score).padStart(pad ? 3 : 0, ' ');
4922
+ if (noColor) return padded;else if (score >= 80) return colors.green(padded);else if (score >= 60) return colors.yellow(padded);else return colors.red(padded);
4923
+ }
4924
+ function getAlertString(alerts, noColor = false) {
4925
+ if (!alerts?.length) {
4926
+ return noColor ? `- Alerts: none!` : `- Alerts: ${colors.green('none')}!`;
4927
+ } else {
4928
+ const bad = alerts.filter(alert => alert.severity !== 'low' && alert.severity !== 'middle').sort((a, b) => a.type < b.type ? -1 : a.type > b.type ? 1 : 0);
4929
+ const mid = alerts.filter(alert => alert.severity === 'middle').sort((a, b) => a.type < b.type ? -1 : a.type > b.type ? 1 : 0);
4930
+ const low = alerts.filter(alert => alert.severity === 'low').sort((a, b) => a.type < b.type ? -1 : a.type > b.type ? 1 : 0);
4931
+
4932
+ // We need to create the no-color string regardless because the actual string
4933
+ // contains a bunch of invisible ANSI chars which would screw up length checks.
4934
+ const colorless = `- Alerts (${bad.length}/${mid.length.toString()}/${low.length}):`;
4935
+ if (noColor) {
4936
+ return colorless + ' '.repeat(Math.max(0, 20 - colorless.length)) + ' ' + [bad.map(alert => `[${alert.severity}] ` + alert.type).join(', '), mid.map(alert => `[${alert.severity}] ` + alert.type).join(', '), low.map(alert => `[${alert.severity}] ` + alert.type).join(', ')].filter(Boolean).join(', ');
4937
+ }
4938
+ return `- Alerts (${colors.red(bad.length.toString())}/${colors.yellow(mid.length.toString())}/${low.length}):` + ' '.repeat(Math.max(0, 20 - colorless.length)) + ' ' + [bad.map(alert => colors.red(colors.dim(`[${alert.severity}] `) + alert.type)).join(', '), mid.map(alert => colors.yellow(colors.dim(`[${alert.severity}] `) + alert.type)).join(', '), low.map(alert => colors.dim(`[${alert.severity}] `) + alert.type).join(', ')].filter(Boolean).join(', ');
4939
+ }
4940
+ }
4941
+
4942
+ async function showPurlInfo({
4943
+ outputKind,
4944
+ purls
4945
+ }) {
4946
+ const packageData = await fetchPackageInfo(purls);
4947
+ if (packageData) {
4948
+ logPackageInfo(purls, packageData.data, outputKind);
4949
+ }
4950
+ }
4951
+
4952
+ const {
4953
+ DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$h
4954
+ } = constants;
4955
+ const config$h = {
4956
+ commandName: 'shallow',
4957
+ description: 'Look up info regarding one or more packages but not their transitives',
4958
+ hidden: true,
4959
+ flags: {
4960
+ ...commonFlags,
4961
+ ...outputFlags
4962
+ },
4963
+ help: (command, config) => `
4964
+ Usage
4965
+ $ ${command} <<ecosystem> <name> [<name> ...] | <purl> [<purl> ...]>
4966
+
4967
+ Options
4968
+ ${getFlagListOutput(config.flags, 6)}
4969
+
4970
+ Requirements
4971
+ - quota: 100
4972
+ - scope: \`packages:list\`
4973
+
4974
+ Show scoring details for one or more packages purely based on their own package.
4975
+ This means that any dependency scores are not reflected by the score. You can
4976
+ use the \`socket package score <pkg>\` command to get its full transitive score.
4977
+
4978
+ Only a few ecosystems are supported like npm, golang, and maven.
4979
+
4980
+ A "purl" is a standard package name formatting: \`pkg:eco/name@version\`
4981
+ This command will automatically prepend "pkg:" when not present.
4982
+
4983
+ If the first arg is an ecosystem, remaining args that are not a purl are
4984
+ assumed to be scoped to that ecosystem.
4985
+
4986
+ Examples
4987
+ $ ${command} npm webtorrent
4988
+ $ ${command} npm webtorrent@1.9.1
4989
+ $ ${command} npm/webtorrent@1.9.1
4990
+ $ ${command} pkg:npm/webtorrent@1.9.1
4991
+ $ ${command} maven webtorrent babel
4992
+ $ ${command} npm/webtorrent golang/babel
4993
+ $ ${command} npm npm/webtorrent@1.0.1 babel
4994
+ `
4995
+ };
4996
+ const cmdPackageShallow = {
4997
+ description: config$h.description,
4998
+ hidden: config$h.hidden,
4999
+ alias: {
5000
+ shallowScore: {
5001
+ description: config$h.description,
5002
+ hidden: true,
5003
+ argv: []
5004
+ }
5005
+ },
5006
+ run: run$h
5007
+ };
5008
+ async function run$h(argv, importMeta, {
5009
+ parentName
5010
+ }) {
5011
+ const cli = meowOrExit({
5012
+ argv,
5013
+ config: config$h,
5014
+ importMeta,
5015
+ parentName
5016
+ });
5017
+ const {
5018
+ json,
5019
+ markdown
5020
+ } = cli.flags;
5021
+ const [ecosystem = '', ...pkgs] = cli.input;
5022
+ const {
5023
+ purls,
5024
+ valid
5025
+ } = parsePackageSpecifiers(ecosystem, pkgs);
5026
+ if (!valid || !purls.length) {
5027
+ // Use exit status of 2 to indicate incorrect usage, generally invalid
5028
+ // options or missing arguments.
5029
+ // https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html
5030
+ process.exitCode = 2;
5031
+ logger.logger.fail(`${colors.bgRed(colors.white('Input error'))}: Please provide the required fields:\n
5032
+ - First parameter should be an ecosystem or all args must be purls ${!valid ? colors.red('(bad!)') : colors.green('(ok)')}\n
5033
+ - Expecting at least one package ${!purls.length ? colors.red('(missing!)') : colors.green('(ok)')}\n
5034
+ `);
5035
+ return;
5036
+ }
5037
+ if (cli.flags['dryRun']) {
5038
+ logger.logger.log(DRY_RUN_BAIL_TEXT$h);
5039
+ return;
5040
+ }
5041
+ await showPurlInfo({
5042
+ outputKind: json ? 'json' : markdown ? 'markdown' : 'text',
5043
+ purls
5044
+ });
5045
+ }
5046
+
5047
+ const description$3 = 'Commands relating to looking up published packages';
5048
+ const cmdPackage = {
5049
+ description: description$3,
5050
+ hidden: true,
5051
+ // [beta]
5052
+ async run(argv, importMeta, {
5053
+ parentName
5054
+ }) {
5055
+ await meowWithSubcommands({
5056
+ shallow: cmdPackageShallow
5057
+ }, {
5058
+ aliases: {
5059
+ pkg: {
5060
+ description: description$3,
5061
+ hidden: true,
5062
+ argv: []
5063
+ }
5064
+ },
5065
+ argv,
5066
+ description: description$3,
5067
+ importMeta,
5068
+ name: parentName + ' package'
5069
+ });
5070
+ }
5071
+ };
5072
+
6070
5073
  async function runRawNpm(argv) {
6071
5074
  const spawnPromise = spawn.spawn(shadowNpmPaths.getNpmBinPath(), argv, {
6072
5075
  stdio: 'inherit'
@@ -6394,7 +5397,7 @@ async function run$e(argv, importMeta, {
6394
5397
 
6395
5398
  // TODO: Allow setting a custom cwd and/or configFile path?
6396
5399
  const cwd = process$1.cwd();
6397
- const absoluteConfigPath = path.join(cwd, 'socket.yml');
5400
+ const absoluteConfigPath = path$1.join(cwd, 'socket.yml');
6398
5401
  const dryRun = Boolean(cli.flags['dryRun']);
6399
5402
  const json = Boolean(cli.flags['json']);
6400
5403
  const markdown = Boolean(cli.flags['markdown']);
@@ -6775,8 +5778,8 @@ async function listReposWithToken({
6775
5778
  const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, {
6776
5779
  sort,
6777
5780
  direction,
6778
- per_page,
6779
- page
5781
+ per_page: String(per_page),
5782
+ page: String(page)
6780
5783
  }), 'listing repositories');
6781
5784
  if (!result.success) {
6782
5785
  handleUnsuccessfulApiResponse('getOrgRepoList', result);
@@ -7237,13 +6240,13 @@ async function suggestRepoSlug(socketSdk, orgSlug) {
7237
6240
  // There's no guarantee that the cwd is part of this page. If it's not
7238
6241
  // then do an additional request and specific search for it instead.
7239
6242
  // This way we can offer the tip of "do you want to create [cwd]?".
7240
- perPage: 10,
7241
- page: 0
6243
+ perPage: '10',
6244
+ page: '0'
7242
6245
  }), 'looking up known repos');
7243
6246
  // Ignore a failed request here. It was not the primary goal of
7244
6247
  // running this command and reporting it only leads to end-user confusion.
7245
6248
  if (result.success) {
7246
- const currentDirName = dirNameToSlug(path.basename(process$1.cwd()));
6249
+ const currentDirName = dirNameToSlug(path$1.basename(process$1.cwd()));
7247
6250
  let cwdIsKnown = !!currentDirName && result.data.results.some(obj => obj.slug === currentDirName);
7248
6251
  if (!cwdIsKnown && currentDirName) {
7249
6252
  // Do an explicit request so we can assert that the cwd exists or not
@@ -7463,9 +6466,9 @@ async function createFullScan({
7463
6466
  repo: repoName,
7464
6467
  branch: branchName,
7465
6468
  commit_message: commitMessage,
7466
- make_default_branch: defaultBranch,
7467
- set_as_pending_head: pendingHead,
7468
- tmp
6469
+ make_default_branch: String(defaultBranch),
6470
+ set_as_pending_head: String(pendingHead),
6471
+ tmp: String(tmp)
7469
6472
  }, packagePaths, cwd), 'Creating scan');
7470
6473
  if (!result.success) {
7471
6474
  handleUnsuccessfulApiResponse('CreateOrgFullScan', result);
@@ -7782,8 +6785,8 @@ async function listFullScansWithToken({
7782
6785
  const result = await handleApiCall(socketSdk.getOrgFullScanList(orgSlug, {
7783
6786
  sort,
7784
6787
  direction,
7785
- per_page,
7786
- page,
6788
+ per_page: String(per_page),
6789
+ page: String(page),
7787
6790
  from: from_time
7788
6791
  }), 'Listing scans');
7789
6792
  if (!result.success) {
@@ -8391,7 +7394,7 @@ async function reportFullScan({
8391
7394
  const json = short ? JSON.stringify(scanReport) : toJsonReport(scanReport);
8392
7395
  if (filePath && filePath !== '-') {
8393
7396
  logger.logger.log('Writing json report to', filePath);
8394
- return await fs$1.writeFile(filePath, json);
7397
+ return await fs.writeFile(filePath, json);
8395
7398
  }
8396
7399
  logger.logger.log(json);
8397
7400
  return;
@@ -8400,7 +7403,7 @@ async function reportFullScan({
8400
7403
  const md = short ? `healthy = ${scanReport.healthy}` : toMarkdownReport(scanReport);
8401
7404
  if (filePath && filePath !== '-') {
8402
7405
  logger.logger.log('Writing markdown report to', filePath);
8403
- return await fs$1.writeFile(filePath, md);
7406
+ return await fs.writeFile(filePath, md);
8404
7407
  }
8405
7408
  logger.logger.log(md);
8406
7409
  return;
@@ -8641,7 +7644,7 @@ View this report at: https://socket.dev/dashboard/org/${orgSlug}/sbom/${fullScan
8641
7644
  `.trim() + '\n';
8642
7645
  if (filePath && filePath !== '-') {
8643
7646
  try {
8644
- await fs$1.writeFile(filePath, report, 'utf8');
7647
+ await fs.writeFile(filePath, report, 'utf8');
8645
7648
  logger.logger.log(`Data successfully written to ${filePath}`);
8646
7649
  } catch (e) {
8647
7650
  process.exitCode = 1;
@@ -9004,7 +8007,7 @@ async function run$1(argv, importMeta, {
9004
8007
  }
9005
8008
 
9006
8009
  function addSocketWrapper(file) {
9007
- return fs.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
8010
+ return fs$1.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
9008
8011
  if (err) {
9009
8012
  return new Error(`There was an error setting up the alias: ${err}`);
9010
8013
  }
@@ -9018,7 +8021,7 @@ If you want to disable it at any time, run \`socket wrapper --disable\`
9018
8021
  }
9019
8022
 
9020
8023
  function checkSocketWrapperSetup(file) {
9021
- const fileContent = fs.readFileSync(file, 'utf8');
8024
+ const fileContent = fs$1.readFileSync(file, 'utf8');
9022
8025
  const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
9023
8026
  if (linesWithSocketAlias.length) {
9024
8027
  logger.logger.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
@@ -9033,7 +8036,7 @@ function postinstallWrapper() {
9033
8036
  bashRcPath,
9034
8037
  zshRcPath
9035
8038
  } = constants;
9036
- const socketWrapperEnabled = fs.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
8039
+ const socketWrapperEnabled = fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
9037
8040
  if (!socketWrapperEnabled) {
9038
8041
  installSafeNpm(`The Socket CLI is now successfully installed! 🎉
9039
8042
 
@@ -9065,10 +8068,10 @@ function askQuestion(rl, query) {
9065
8068
  zshRcPath
9066
8069
  } = constants;
9067
8070
  try {
9068
- if (fs.existsSync(bashRcPath)) {
8071
+ if (fs$1.existsSync(bashRcPath)) {
9069
8072
  addSocketWrapper(bashRcPath);
9070
8073
  }
9071
- if (fs.existsSync(zshRcPath)) {
8074
+ if (fs$1.existsSync(zshRcPath)) {
9072
8075
  addSocketWrapper(zshRcPath);
9073
8076
  }
9074
8077
  } catch (e) {
@@ -9084,7 +8087,7 @@ function askQuestion(rl, query) {
9084
8087
  }
9085
8088
 
9086
8089
  function removeSocketWrapper(file) {
9087
- return fs.readFile(file, 'utf8', function (err, data) {
8090
+ return fs$1.readFile(file, 'utf8', function (err, data) {
9088
8091
  if (err) {
9089
8092
  logger.logger.fail('There was an error removing the alias:');
9090
8093
  logger.logger.error(err);
@@ -9092,7 +8095,7 @@ function removeSocketWrapper(file) {
9092
8095
  }
9093
8096
  const linesWithoutSocketAlias = data.split('\n').filter(l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"');
9094
8097
  const updatedFileContent = linesWithoutSocketAlias.join('\n');
9095
- fs.writeFile(file, updatedFileContent, function (err) {
8098
+ fs$1.writeFile(file, updatedFileContent, function (err) {
9096
8099
  if (err) {
9097
8100
  logger.logger.error(err);
9098
8101
  return;
@@ -9181,21 +8184,21 @@ async function run(argv, importMeta, {
9181
8184
  zshRcPath
9182
8185
  } = constants;
9183
8186
  if (enable) {
9184
- if (fs.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
8187
+ if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
9185
8188
  addSocketWrapper(bashRcPath);
9186
8189
  }
9187
- if (fs.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
8190
+ if (fs$1.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
9188
8191
  addSocketWrapper(zshRcPath);
9189
8192
  }
9190
8193
  } else {
9191
- if (fs.existsSync(bashRcPath)) {
8194
+ if (fs$1.existsSync(bashRcPath)) {
9192
8195
  removeSocketWrapper(bashRcPath);
9193
8196
  }
9194
- if (fs.existsSync(zshRcPath)) {
8197
+ if (fs$1.existsSync(zshRcPath)) {
9195
8198
  removeSocketWrapper(zshRcPath);
9196
8199
  }
9197
8200
  }
9198
- if (!fs.existsSync(bashRcPath) && !fs.existsSync(zshRcPath)) {
8201
+ if (!fs$1.existsSync(bashRcPath) && !fs$1.existsSync(zshRcPath)) {
9199
8202
  logger.logger.fail('There was an issue setting up the alias in your bash profile');
9200
8203
  }
9201
8204
  }
@@ -9209,12 +8212,11 @@ void (async () => {
9209
8212
  await vendor.updater({
9210
8213
  name: SOCKET_CLI_BIN_NAME,
9211
8214
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
9212
- version: "0.14.62",
8215
+ version: "0.14.63",
9213
8216
  ttl: 86_400_000 /* 24 hours in milliseconds */
9214
8217
  });
9215
8218
  try {
9216
8219
  await meowWithSubcommands({
9217
- action: cmdAction,
9218
8220
  cdxgen: cmdCdxgen,
9219
8221
  fix: cmdFix,
9220
8222
  info: cmdInfo,
@@ -9225,6 +8227,7 @@ void (async () => {
9225
8227
  oops: cmdOops,
9226
8228
  optimize: cmdOptimize,
9227
8229
  organization: cmdOrganization,
8230
+ package: cmdPackage,
9228
8231
  'raw-npm': cmdRawNpm,
9229
8232
  'raw-npx': cmdRawNpx,
9230
8233
  report: cmdReport,
@@ -9276,5 +8279,5 @@ void (async () => {
9276
8279
  await shadowNpmInject.captureException(e);
9277
8280
  }
9278
8281
  })();
9279
- //# debugId=a794b9bc-963d-4504-a1af-e5c87018417b
8282
+ //# debugId=c590986b-fa07-40bd-8503-b619777b396e
9280
8283
  //# sourceMappingURL=cli.js.map