@socketsecurity/cli-with-sentry 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +432 -0
- package/bin/cli.js +3 -1
- package/dist/cli.js +816 -688
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +232 -19
- package/dist/constants.js.map +1 -1
- package/dist/flags.js +17 -11
- package/dist/flags.js.map +1 -1
- package/dist/instrument-with-sentry.js +8 -8
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-bin.js +14 -14
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-npm-inject.js +16 -16
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
- package/dist/types/commands/analytics/handle-analytics.d.mts +6 -5
- package/dist/types/commands/analytics/handle-analytics.d.mts.map +1 -1
- package/dist/types/commands/analytics/output-analytics.d.mts +6 -5
- package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts +2 -2
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/commands/fix/types.d.mts +1 -4
- package/dist/types/commands/fix/types.d.mts.map +1 -1
- package/dist/types/commands/login/cmd-login.d.mts.map +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
- package/dist/types/commands/optimize/add-overrides.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +1 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/handle-patch.d.mts +5 -4
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/output-patch-result.d.mts +1 -1
- package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-create.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-del.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-update.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-list.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +9 -8
- package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -2
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts +7 -5
- package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-report.d.mts +10 -8
- package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/commands/scan/types.d.mts +3 -0
- package/dist/types/commands/scan/types.d.mts.map +1 -0
- package/dist/types/constants.d.mts +113 -46
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/flags.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -17
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/shadow/npm/bin.d.mts +4 -3
- package/dist/types/shadow/npm/bin.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts +8 -7
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/coana.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/ecosystem.d.mts.map +1 -1
- package/dist/types/utils/get-output-kind.d.mts.map +1 -1
- package/dist/types/utils/git.d.mts +1 -0
- package/dist/types/utils/git.d.mts.map +1 -1
- package/dist/types/utils/glob.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/purl.d.mts +39 -8
- package/dist/types/utils/purl.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/types/utils/spec.d.mts +1 -1
- package/dist/types/utils/spec.d.mts.map +1 -1
- package/dist/utils.js +209 -163
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +596 -4972
- package/external/@socketsecurity/registry/lib/constants/env.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-cts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-dts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-js.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-md.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-mts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/index.js +82 -83
- package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +4 -5
- package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +9 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -1
- package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/json.js +11 -0
- package/external/@socketsecurity/registry/lib/strings.js +16 -0
- package/package.json +17 -15
- package/external/@socketsecurity/registry/lib/constants/socket-public-api-key.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/tap.js +0 -3
- /package/external/@socketsecurity/registry/lib/constants/{ipc.js → ipc-object.js} +0 -0
package/dist/cli.js
CHANGED
|
@@ -12,12 +12,12 @@ var constants = require('./constants.js');
|
|
|
12
12
|
var flags = require('./flags.js');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var words = require('../external/@socketsecurity/registry/lib/words');
|
|
15
|
+
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
15
16
|
var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
16
17
|
var fs$1 = require('node:fs');
|
|
17
18
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
18
19
|
var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
|
|
19
20
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
20
|
-
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
21
21
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
22
22
|
var shadowNpmBin = require('./shadow-npm-bin.js');
|
|
23
23
|
var require$$11 = require('../external/@socketsecurity/registry/lib/objects');
|
|
@@ -26,6 +26,7 @@ var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
|
26
26
|
var require$$12 = require('../external/@socketsecurity/registry/lib/promises');
|
|
27
27
|
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
28
28
|
var require$$0$1 = require('node:crypto');
|
|
29
|
+
var registryConstants = require('../external/@socketsecurity/registry/lib/constants');
|
|
29
30
|
var require$$1 = require('node:util');
|
|
30
31
|
var os = require('node:os');
|
|
31
32
|
var promises = require('node:stream/promises');
|
|
@@ -44,7 +45,7 @@ async function fetchOrgAnalyticsData(time, options) {
|
|
|
44
45
|
}
|
|
45
46
|
const sockSdk = sockSdkCResult.data;
|
|
46
47
|
return await utils.handleApiCall(sockSdk.getOrgAnalytics(time.toString()), {
|
|
47
|
-
|
|
48
|
+
description: 'analytics data'
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
|
|
@@ -61,7 +62,7 @@ async function fetchRepoAnalyticsData(repo, time, options) {
|
|
|
61
62
|
}
|
|
62
63
|
const sockSdk = sockSdkCResult.data;
|
|
63
64
|
return await utils.handleApiCall(sockSdk.getRepoAnalytics(repo, time.toString()), {
|
|
64
|
-
|
|
65
|
+
description: 'analytics data'
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -73,7 +74,7 @@ const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_ale
|
|
|
73
74
|
// Note: This maps `new Date(date).getMonth()` to English three letters
|
|
74
75
|
const Months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
75
76
|
async function outputAnalytics(result, {
|
|
76
|
-
|
|
77
|
+
filepath,
|
|
77
78
|
outputKind,
|
|
78
79
|
repo,
|
|
79
80
|
scope,
|
|
@@ -92,10 +93,10 @@ async function outputAnalytics(result, {
|
|
|
92
93
|
}
|
|
93
94
|
if (outputKind === 'json') {
|
|
94
95
|
const serialized = utils.serializeResultJson(result);
|
|
95
|
-
if (
|
|
96
|
+
if (filepath) {
|
|
96
97
|
try {
|
|
97
|
-
await fs.writeFile(
|
|
98
|
-
logger.logger.success(`Data successfully written to ${
|
|
98
|
+
await fs.writeFile(filepath, serialized, 'utf8');
|
|
99
|
+
logger.logger.success(`Data successfully written to ${filepath}`);
|
|
99
100
|
} catch (e) {
|
|
100
101
|
process.exitCode = 1;
|
|
101
102
|
logger.logger.log(utils.serializeResultJson({
|
|
@@ -114,10 +115,10 @@ async function outputAnalytics(result, {
|
|
|
114
115
|
const serialized = renderMarkdown(fdata, time, repo);
|
|
115
116
|
|
|
116
117
|
// TODO: Do we want to write to file even if there was an error...?
|
|
117
|
-
if (
|
|
118
|
+
if (filepath) {
|
|
118
119
|
try {
|
|
119
|
-
await fs.writeFile(
|
|
120
|
-
logger.logger.success(`Data successfully written to ${
|
|
120
|
+
await fs.writeFile(filepath, serialized, 'utf8');
|
|
121
|
+
logger.logger.success(`Data successfully written to ${filepath}`);
|
|
121
122
|
} catch (e) {
|
|
122
123
|
logger.logger.error(e);
|
|
123
124
|
}
|
|
@@ -148,7 +149,7 @@ ${utils.mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
|
|
|
148
149
|
function displayAnalyticsScreen(data) {
|
|
149
150
|
const ScreenWidget = /*@__PURE__*/require$5('../external/blessed/lib/widgets/screen.js');
|
|
150
151
|
const screen = new ScreenWidget({
|
|
151
|
-
...constants.blessedOptions
|
|
152
|
+
...constants.default.blessedOptions
|
|
152
153
|
});
|
|
153
154
|
const GridLayout = /*@__PURE__*/require$5('../external/blessed-contrib/lib/layout/grid.js');
|
|
154
155
|
const grid = new GridLayout({
|
|
@@ -208,7 +209,10 @@ function formatDataRepo(data) {
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
const topFiveAlertEntries = Object.entries(totalTopAlerts).sort(([_keya, a], [_keyb, b]) => b - a).slice(0, 5);
|
|
211
|
-
for (const
|
|
212
|
+
for (const {
|
|
213
|
+
0: key,
|
|
214
|
+
1: value
|
|
215
|
+
} of topFiveAlertEntries) {
|
|
212
216
|
sortedTopFiveAlerts[key] = value;
|
|
213
217
|
}
|
|
214
218
|
return {
|
|
@@ -246,7 +250,10 @@ function formatDataOrg(data) {
|
|
|
246
250
|
}
|
|
247
251
|
}
|
|
248
252
|
const topFiveAlertEntries = Object.entries(totalTopAlerts).sort(([_keya, a], [_keyb, b]) => b - a).slice(0, 5);
|
|
249
|
-
for (const
|
|
253
|
+
for (const {
|
|
254
|
+
0: key,
|
|
255
|
+
1: value
|
|
256
|
+
} of topFiveAlertEntries) {
|
|
250
257
|
sortedTopFiveAlerts[key] = value;
|
|
251
258
|
}
|
|
252
259
|
return {
|
|
@@ -283,7 +290,7 @@ function renderLineCharts(grid, screen, title, coords, data) {
|
|
|
283
290
|
}
|
|
284
291
|
|
|
285
292
|
async function handleAnalytics({
|
|
286
|
-
|
|
293
|
+
filepath,
|
|
287
294
|
outputKind,
|
|
288
295
|
repo,
|
|
289
296
|
scope,
|
|
@@ -308,7 +315,7 @@ async function handleAnalytics({
|
|
|
308
315
|
};
|
|
309
316
|
}
|
|
310
317
|
await outputAnalytics(result, {
|
|
311
|
-
|
|
318
|
+
filepath,
|
|
312
319
|
outputKind,
|
|
313
320
|
repo,
|
|
314
321
|
scope,
|
|
@@ -336,6 +343,7 @@ async function run$Q(argv, importMeta, {
|
|
|
336
343
|
...flags.outputFlags,
|
|
337
344
|
file: {
|
|
338
345
|
type: 'string',
|
|
346
|
+
default: '',
|
|
339
347
|
description: 'Path to store result, only valid with --json/--markdown'
|
|
340
348
|
}
|
|
341
349
|
},
|
|
@@ -397,7 +405,7 @@ async function run$Q(argv, importMeta, {
|
|
|
397
405
|
time = cli.input[0];
|
|
398
406
|
}
|
|
399
407
|
const {
|
|
400
|
-
file,
|
|
408
|
+
file: filepath,
|
|
401
409
|
json,
|
|
402
410
|
markdown
|
|
403
411
|
} = cli.flags;
|
|
@@ -408,7 +416,7 @@ async function run$Q(argv, importMeta, {
|
|
|
408
416
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
409
417
|
nook: true,
|
|
410
418
|
test: noLegacy,
|
|
411
|
-
message:
|
|
419
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
412
420
|
fail: `received legacy flags`
|
|
413
421
|
}, {
|
|
414
422
|
nook: true,
|
|
@@ -426,7 +434,7 @@ async function run$Q(argv, importMeta, {
|
|
|
426
434
|
fail: 'invalid range set, see --help for command arg details.'
|
|
427
435
|
}, {
|
|
428
436
|
nook: true,
|
|
429
|
-
test: !
|
|
437
|
+
test: !filepath || !!json || !!markdown,
|
|
430
438
|
message: 'The `--file` flag is only valid when using `--json` or `--markdown`',
|
|
431
439
|
fail: 'bad'
|
|
432
440
|
}, {
|
|
@@ -444,15 +452,15 @@ async function run$Q(argv, importMeta, {
|
|
|
444
452
|
return;
|
|
445
453
|
}
|
|
446
454
|
if (dryRun) {
|
|
447
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
455
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
448
456
|
return;
|
|
449
457
|
}
|
|
450
458
|
return await handleAnalytics({
|
|
451
|
-
|
|
452
|
-
time: time === '90' ? 90 : time === '30' ? 30 : 7,
|
|
453
|
-
repo: repoName,
|
|
459
|
+
filepath,
|
|
454
460
|
outputKind,
|
|
455
|
-
|
|
461
|
+
repo: repoName,
|
|
462
|
+
scope,
|
|
463
|
+
time: time === '90' ? 90 : time === '30' ? 30 : 7
|
|
456
464
|
});
|
|
457
465
|
}
|
|
458
466
|
|
|
@@ -488,7 +496,7 @@ async function fetchAuditLog(config, options) {
|
|
|
488
496
|
page: String(page),
|
|
489
497
|
per_page: String(perPage)
|
|
490
498
|
}), {
|
|
491
|
-
|
|
499
|
+
description: `audit log for ${orgSlug}`
|
|
492
500
|
});
|
|
493
501
|
}
|
|
494
502
|
|
|
@@ -503,7 +511,7 @@ async function outputAuditLog(result, {
|
|
|
503
511
|
if (!result.ok) {
|
|
504
512
|
process.exitCode = result.code ?? 1;
|
|
505
513
|
}
|
|
506
|
-
if (outputKind ===
|
|
514
|
+
if (outputKind === constants.OUTPUT_JSON) {
|
|
507
515
|
logger.logger.log(await outputAsJson(result, {
|
|
508
516
|
logType,
|
|
509
517
|
orgSlug,
|
|
@@ -515,7 +523,7 @@ async function outputAuditLog(result, {
|
|
|
515
523
|
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
516
524
|
return;
|
|
517
525
|
}
|
|
518
|
-
if (outputKind ===
|
|
526
|
+
if (outputKind === constants.OUTPUT_MARKDOWN) {
|
|
519
527
|
logger.logger.log(await outputAsMarkdown(result.data, {
|
|
520
528
|
logType,
|
|
521
529
|
orgSlug,
|
|
@@ -555,7 +563,7 @@ async function outputAsJson(auditLogs, {
|
|
|
555
563
|
ok: true,
|
|
556
564
|
data: {
|
|
557
565
|
desc: 'Audit logs for given query',
|
|
558
|
-
generated: constants.ENV.VITEST ? constants.REDACTED : new Date().toISOString(),
|
|
566
|
+
generated: constants.default.ENV.VITEST ? constants.default.REDACTED : new Date().toISOString(),
|
|
559
567
|
logType,
|
|
560
568
|
nextPage: auditLogs.data.nextPage,
|
|
561
569
|
org: orgSlug,
|
|
@@ -600,7 +608,7 @@ These are the Socket.dev audit logs as per requested query.
|
|
|
600
608
|
- page: ${page}
|
|
601
609
|
- next page: ${auditLogs.nextPage}
|
|
602
610
|
- per page: ${perPage}
|
|
603
|
-
- generated: ${constants.ENV.VITEST ? constants.REDACTED : new Date().toISOString()}
|
|
611
|
+
- generated: ${constants.default.ENV.VITEST ? constants.default.REDACTED : new Date().toISOString()}
|
|
604
612
|
|
|
605
613
|
${table}
|
|
606
614
|
`;
|
|
@@ -622,7 +630,7 @@ async function outputWithBlessed(data, orgSlug) {
|
|
|
622
630
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
623
631
|
const ScreenWidget = /*@__PURE__*/require$4('../external/blessed/lib/widgets/screen.js');
|
|
624
632
|
const screen = new ScreenWidget({
|
|
625
|
-
...constants.blessedOptions
|
|
633
|
+
...constants.default.blessedOptions
|
|
626
634
|
});
|
|
627
635
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
628
636
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
@@ -785,7 +793,7 @@ async function run$P(argv, importMeta, {
|
|
|
785
793
|
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$v}`)}
|
|
786
794
|
|
|
787
795
|
This feature requires an Enterprise Plan. To learn more about getting access
|
|
788
|
-
to this feature and many more, please visit ${constants.SOCKET_WEBSITE_URL}/pricing
|
|
796
|
+
to this feature and many more, please visit ${constants.default.SOCKET_WEBSITE_URL}/pricing
|
|
789
797
|
|
|
790
798
|
The type FILTER arg is an enum. Defaults to any. It should be one of these:
|
|
791
799
|
associateLabel, cancelInvitation, changeMemberRole, changePlanSubscriptionSeats,
|
|
@@ -814,6 +822,7 @@ async function run$P(argv, importMeta, {
|
|
|
814
822
|
parentName
|
|
815
823
|
});
|
|
816
824
|
const {
|
|
825
|
+
interactive,
|
|
817
826
|
json,
|
|
818
827
|
markdown,
|
|
819
828
|
org: orgFlag,
|
|
@@ -821,17 +830,18 @@ async function run$P(argv, importMeta, {
|
|
|
821
830
|
perPage
|
|
822
831
|
} = cli.flags;
|
|
823
832
|
const dryRun = !!cli.flags['dryRun'];
|
|
824
|
-
const interactive = !!cli.flags['interactive'];
|
|
825
833
|
const noLegacy = !cli.flags['type'];
|
|
826
834
|
let [typeFilter = ''] = cli.input;
|
|
827
835
|
typeFilter = String(typeFilter);
|
|
828
836
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
829
|
-
const
|
|
837
|
+
const {
|
|
838
|
+
0: orgSlug
|
|
839
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
830
840
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
831
841
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
832
842
|
nook: true,
|
|
833
843
|
test: noLegacy,
|
|
834
|
-
message:
|
|
844
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
835
845
|
fail: `received legacy flags`
|
|
836
846
|
}, {
|
|
837
847
|
nook: true,
|
|
@@ -858,7 +868,7 @@ async function run$P(argv, importMeta, {
|
|
|
858
868
|
return;
|
|
859
869
|
}
|
|
860
870
|
if (dryRun) {
|
|
861
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
871
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
862
872
|
return;
|
|
863
873
|
}
|
|
864
874
|
await handleAuditLog({
|
|
@@ -918,7 +928,7 @@ async function fetchCreateOrgFullScan(packagePaths, orgSlug, config, options) {
|
|
|
918
928
|
set_as_pending_head: String(pendingHead),
|
|
919
929
|
tmp: String(tmp)
|
|
920
930
|
}), {
|
|
921
|
-
|
|
931
|
+
description: 'to create a scan'
|
|
922
932
|
});
|
|
923
933
|
}
|
|
924
934
|
|
|
@@ -936,7 +946,7 @@ async function fetchSupportedScanFileNames(options) {
|
|
|
936
946
|
}
|
|
937
947
|
const sockSdk = sockSdkCResult.data;
|
|
938
948
|
return await utils.handleApiCall(sockSdk.getSupportedScanFiles(), {
|
|
939
|
-
|
|
949
|
+
description: 'supported scan file types',
|
|
940
950
|
spinner
|
|
941
951
|
});
|
|
942
952
|
}
|
|
@@ -980,13 +990,13 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
980
990
|
let finishedFetching = false;
|
|
981
991
|
const {
|
|
982
992
|
spinner
|
|
983
|
-
} = constants;
|
|
984
|
-
function updateScan(
|
|
985
|
-
scanStatus =
|
|
993
|
+
} = constants.default;
|
|
994
|
+
function updateScan(status) {
|
|
995
|
+
scanStatus = status;
|
|
986
996
|
updateProgress();
|
|
987
997
|
}
|
|
988
|
-
function updatePolicy(
|
|
989
|
-
policyStatus =
|
|
998
|
+
function updatePolicy(status) {
|
|
999
|
+
policyStatus = status;
|
|
990
1000
|
updateProgress();
|
|
991
1001
|
}
|
|
992
1002
|
function updateProgress() {
|
|
@@ -1081,7 +1091,7 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
1081
1091
|
};
|
|
1082
1092
|
}
|
|
1083
1093
|
|
|
1084
|
-
// Note: The returned
|
|
1094
|
+
// Note: The returned cResult will only be ok:false when the generation
|
|
1085
1095
|
// failed. It won't reflect the healthy state.
|
|
1086
1096
|
function generateReport(scan, securityPolicy, {
|
|
1087
1097
|
fold,
|
|
@@ -1129,15 +1139,15 @@ function generateReport(scan, securityPolicy, {
|
|
|
1129
1139
|
scan.forEach(artifact => {
|
|
1130
1140
|
const {
|
|
1131
1141
|
alerts,
|
|
1132
|
-
name: pkgName =
|
|
1142
|
+
name: pkgName = constants.UNKNOWN_VALUE,
|
|
1133
1143
|
type: ecosystem,
|
|
1134
|
-
version =
|
|
1144
|
+
version = constants.UNKNOWN_VALUE
|
|
1135
1145
|
} = artifact;
|
|
1136
1146
|
alerts?.forEach(alert => {
|
|
1137
1147
|
const alertName = alert.type; // => policy[type]
|
|
1138
1148
|
const action = securityRules[alertName]?.action || '';
|
|
1139
1149
|
switch (action) {
|
|
1140
|
-
case
|
|
1150
|
+
case constants.default.REPORT_LEVEL_ERROR:
|
|
1141
1151
|
{
|
|
1142
1152
|
healthy = false;
|
|
1143
1153
|
if (!short) {
|
|
@@ -1145,31 +1155,31 @@ function generateReport(scan, securityPolicy, {
|
|
|
1145
1155
|
}
|
|
1146
1156
|
break;
|
|
1147
1157
|
}
|
|
1148
|
-
case
|
|
1158
|
+
case constants.default.REPORT_LEVEL_WARN:
|
|
1149
1159
|
{
|
|
1150
|
-
if (!short && reportLevel !==
|
|
1160
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1151
1161
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1152
1162
|
}
|
|
1153
1163
|
break;
|
|
1154
1164
|
}
|
|
1155
|
-
case
|
|
1165
|
+
case constants.default.REPORT_LEVEL_MONITOR:
|
|
1156
1166
|
{
|
|
1157
|
-
if (!short && reportLevel !==
|
|
1167
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_WARN && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1158
1168
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1159
1169
|
}
|
|
1160
1170
|
break;
|
|
1161
1171
|
}
|
|
1162
|
-
case
|
|
1172
|
+
case constants.default.REPORT_LEVEL_IGNORE:
|
|
1163
1173
|
{
|
|
1164
|
-
if (!short && reportLevel !==
|
|
1174
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_MONITOR && reportLevel !== constants.default.REPORT_LEVEL_WARN && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1165
1175
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1166
1176
|
}
|
|
1167
1177
|
break;
|
|
1168
1178
|
}
|
|
1169
|
-
case
|
|
1179
|
+
case constants.default.REPORT_LEVEL_DEFER:
|
|
1170
1180
|
{
|
|
1171
1181
|
// Not sure but ignore for now. Defer to later ;)
|
|
1172
|
-
if (!short && reportLevel ===
|
|
1182
|
+
if (!short && reportLevel === constants.default.REPORT_LEVEL_DEFER) {
|
|
1173
1183
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1174
1184
|
}
|
|
1175
1185
|
break;
|
|
@@ -1218,46 +1228,46 @@ function createLeaf(art, alert, policyAction) {
|
|
|
1218
1228
|
};
|
|
1219
1229
|
return leaf;
|
|
1220
1230
|
}
|
|
1221
|
-
function addAlert(art, violations,
|
|
1231
|
+
function addAlert(art, violations, fold, ecosystem, pkgName, version, alert, policyAction) {
|
|
1222
1232
|
if (!violations.has(ecosystem)) {
|
|
1223
1233
|
violations.set(ecosystem, new Map());
|
|
1224
1234
|
}
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
const existing =
|
|
1235
|
+
const ecoMap = violations.get(ecosystem);
|
|
1236
|
+
if (fold === constants.default.FOLD_SETTING_PKG) {
|
|
1237
|
+
const existing = ecoMap.get(pkgName);
|
|
1228
1238
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1229
|
-
|
|
1239
|
+
ecoMap.set(pkgName, createLeaf(art, alert, policyAction));
|
|
1230
1240
|
}
|
|
1231
1241
|
} else {
|
|
1232
|
-
if (!
|
|
1233
|
-
|
|
1242
|
+
if (!ecoMap.has(pkgName)) {
|
|
1243
|
+
ecoMap.set(pkgName, new Map());
|
|
1234
1244
|
}
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
const existing =
|
|
1245
|
+
const pkgMap = ecoMap.get(pkgName);
|
|
1246
|
+
if (fold === constants.default.FOLD_SETTING_VERSION) {
|
|
1247
|
+
const existing = pkgMap.get(version);
|
|
1238
1248
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1239
|
-
|
|
1249
|
+
pkgMap.set(version, createLeaf(art, alert, policyAction));
|
|
1240
1250
|
}
|
|
1241
1251
|
} else {
|
|
1242
|
-
if (!
|
|
1243
|
-
|
|
1252
|
+
if (!pkgMap.has(version)) {
|
|
1253
|
+
pkgMap.set(version, new Map());
|
|
1244
1254
|
}
|
|
1245
|
-
const file = alert.file ||
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
const existing =
|
|
1255
|
+
const file = alert.file || constants.UNKNOWN_VALUE;
|
|
1256
|
+
const verMap = pkgMap.get(version);
|
|
1257
|
+
if (fold === constants.default.FOLD_SETTING_FILE) {
|
|
1258
|
+
const existing = verMap.get(file);
|
|
1249
1259
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1250
|
-
|
|
1260
|
+
verMap.set(file, createLeaf(art, alert, policyAction));
|
|
1251
1261
|
}
|
|
1252
1262
|
} else {
|
|
1253
|
-
if (!
|
|
1254
|
-
|
|
1263
|
+
if (!verMap.has(file)) {
|
|
1264
|
+
verMap.set(file, new Map());
|
|
1255
1265
|
}
|
|
1256
1266
|
const key = `${alert.type} at ${alert.start}:${alert.end}`;
|
|
1257
|
-
const
|
|
1258
|
-
const existing =
|
|
1267
|
+
const fileMap = verMap.get(file);
|
|
1268
|
+
const existing = fileMap.get(key);
|
|
1259
1269
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1260
|
-
|
|
1270
|
+
fileMap.set(key, createLeaf(art, alert, policyAction));
|
|
1261
1271
|
}
|
|
1262
1272
|
}
|
|
1263
1273
|
}
|
|
@@ -1265,34 +1275,34 @@ function addAlert(art, violations, foldSetting, ecosystem, pkgName, version, ale
|
|
|
1265
1275
|
}
|
|
1266
1276
|
function isStricterPolicy(was, is) {
|
|
1267
1277
|
// error > warn > monitor > ignore > defer > {unknown}
|
|
1268
|
-
if (was ===
|
|
1278
|
+
if (was === constants.default.REPORT_LEVEL_ERROR) {
|
|
1269
1279
|
return false;
|
|
1270
1280
|
}
|
|
1271
|
-
if (is ===
|
|
1281
|
+
if (is === constants.default.REPORT_LEVEL_ERROR) {
|
|
1272
1282
|
return true;
|
|
1273
1283
|
}
|
|
1274
|
-
if (was ===
|
|
1284
|
+
if (was === constants.default.REPORT_LEVEL_WARN) {
|
|
1275
1285
|
return false;
|
|
1276
1286
|
}
|
|
1277
|
-
if (is ===
|
|
1287
|
+
if (is === constants.default.REPORT_LEVEL_WARN) {
|
|
1278
1288
|
return false;
|
|
1279
1289
|
}
|
|
1280
|
-
if (was ===
|
|
1290
|
+
if (was === constants.default.REPORT_LEVEL_MONITOR) {
|
|
1281
1291
|
return false;
|
|
1282
1292
|
}
|
|
1283
|
-
if (is ===
|
|
1293
|
+
if (is === constants.default.REPORT_LEVEL_MONITOR) {
|
|
1284
1294
|
return false;
|
|
1285
1295
|
}
|
|
1286
|
-
if (was ===
|
|
1296
|
+
if (was === constants.default.REPORT_LEVEL_IGNORE) {
|
|
1287
1297
|
return false;
|
|
1288
1298
|
}
|
|
1289
|
-
if (is ===
|
|
1299
|
+
if (is === constants.default.REPORT_LEVEL_IGNORE) {
|
|
1290
1300
|
return false;
|
|
1291
1301
|
}
|
|
1292
|
-
if (was ===
|
|
1302
|
+
if (was === constants.default.REPORT_LEVEL_DEFER) {
|
|
1293
1303
|
return false;
|
|
1294
1304
|
}
|
|
1295
|
-
if (is ===
|
|
1305
|
+
if (is === constants.default.REPORT_LEVEL_DEFER) {
|
|
1296
1306
|
return false;
|
|
1297
1307
|
}
|
|
1298
1308
|
// unreachable?
|
|
@@ -1300,7 +1310,7 @@ function isStricterPolicy(was, is) {
|
|
|
1300
1310
|
}
|
|
1301
1311
|
|
|
1302
1312
|
async function outputScanReport(result, {
|
|
1303
|
-
|
|
1313
|
+
filepath,
|
|
1304
1314
|
fold,
|
|
1305
1315
|
includeLicensePolicy,
|
|
1306
1316
|
orgSlug,
|
|
@@ -1313,7 +1323,7 @@ async function outputScanReport(result, {
|
|
|
1313
1323
|
process.exitCode = result.code ?? 1;
|
|
1314
1324
|
}
|
|
1315
1325
|
if (!result.ok) {
|
|
1316
|
-
if (outputKind ===
|
|
1326
|
+
if (outputKind === constants.OUTPUT_JSON) {
|
|
1317
1327
|
logger.logger.log(utils.serializeResultJson(result));
|
|
1318
1328
|
return;
|
|
1319
1329
|
}
|
|
@@ -1326,14 +1336,14 @@ async function outputScanReport(result, {
|
|
|
1326
1336
|
fold,
|
|
1327
1337
|
reportLevel,
|
|
1328
1338
|
short,
|
|
1329
|
-
spinner: constants.spinner
|
|
1339
|
+
spinner: constants.default.spinner
|
|
1330
1340
|
});
|
|
1331
1341
|
if (!scanReport.ok) {
|
|
1332
|
-
// Note:
|
|
1342
|
+
// Note: This means generation failed, it does not reflect the healthy state.
|
|
1333
1343
|
process.exitCode = scanReport.code ?? 1;
|
|
1334
1344
|
|
|
1335
1345
|
// If report generation somehow failed then .data should not be set.
|
|
1336
|
-
if (outputKind ===
|
|
1346
|
+
if (outputKind === constants.OUTPUT_JSON) {
|
|
1337
1347
|
logger.logger.log(utils.serializeResultJson(scanReport));
|
|
1338
1348
|
return;
|
|
1339
1349
|
}
|
|
@@ -1341,28 +1351,28 @@ async function outputScanReport(result, {
|
|
|
1341
1351
|
return;
|
|
1342
1352
|
}
|
|
1343
1353
|
|
|
1344
|
-
// I don't think we emit the default error message with banner for an
|
|
1345
|
-
// if (!scanReport.data.
|
|
1354
|
+
// I don't think we emit the default error message with banner for an unhealthy report, do we?
|
|
1355
|
+
// if (!scanReport.data.healthy) {
|
|
1346
1356
|
// logger.fail(failMsgWithBadge(scanReport.message, scanReport.cause))
|
|
1347
1357
|
// return
|
|
1348
1358
|
// }
|
|
1349
1359
|
|
|
1350
|
-
if (outputKind ===
|
|
1360
|
+
if (outputKind === constants.OUTPUT_JSON || outputKind === constants.OUTPUT_TEXT && filepath && filepath.endsWith(constants.EXT_JSON)) {
|
|
1351
1361
|
const json = short ? utils.serializeResultJson(scanReport) : toJsonReport(scanReport.data, includeLicensePolicy);
|
|
1352
|
-
if (
|
|
1353
|
-
logger.logger.log('Writing json report to',
|
|
1354
|
-
return await fs.writeFile(
|
|
1362
|
+
if (filepath && filepath !== '-') {
|
|
1363
|
+
logger.logger.log('Writing json report to', filepath);
|
|
1364
|
+
return await fs.writeFile(filepath, json);
|
|
1355
1365
|
}
|
|
1356
1366
|
logger.logger.log(json);
|
|
1357
1367
|
return;
|
|
1358
1368
|
}
|
|
1359
|
-
if (outputKind === 'markdown' ||
|
|
1360
|
-
const md = short ? `healthy = ${scanReport.data.healthy}` : toMarkdownReport(
|
|
1361
|
-
//
|
|
1362
|
-
includeLicensePolicy);
|
|
1363
|
-
if (
|
|
1364
|
-
logger.logger.log('Writing markdown report to',
|
|
1365
|
-
return await fs.writeFile(
|
|
1369
|
+
if (outputKind === 'markdown' || filepath && filepath.endsWith('.md')) {
|
|
1370
|
+
const md = short ? `healthy = ${scanReport.data.healthy}` : toMarkdownReport(
|
|
1371
|
+
// Not short so must be a regular report.
|
|
1372
|
+
scanReport.data, includeLicensePolicy);
|
|
1373
|
+
if (filepath && filepath !== '-') {
|
|
1374
|
+
logger.logger.log('Writing markdown report to', filepath);
|
|
1375
|
+
return await fs.writeFile(filepath, md);
|
|
1366
1376
|
}
|
|
1367
1377
|
logger.logger.log(md);
|
|
1368
1378
|
logger.logger.log('');
|
|
@@ -1389,6 +1399,8 @@ function toJsonReport(report, includeLicensePolicy) {
|
|
|
1389
1399
|
});
|
|
1390
1400
|
}
|
|
1391
1401
|
function toMarkdownReport(report, includeLicensePolicy) {
|
|
1402
|
+
const reportLevel = report.options.reportLevel;
|
|
1403
|
+
const alertFolding = report.options.fold === constants.default.FOLD_SETTING_NONE ? 'none' : `up to ${report.options.fold}`;
|
|
1392
1404
|
const flatData = Array.from(utils.walkNestedMap(report.alerts)).map(({
|
|
1393
1405
|
keys,
|
|
1394
1406
|
value
|
|
@@ -1404,10 +1416,11 @@ function toMarkdownReport(report, includeLicensePolicy) {
|
|
|
1404
1416
|
Package: keys[1] || '<unknown>',
|
|
1405
1417
|
'Introduced by': keys[2] || '<unknown>',
|
|
1406
1418
|
url,
|
|
1407
|
-
'Manifest file':
|
|
1419
|
+
'Manifest file': arrays.joinAnd(manifest),
|
|
1408
1420
|
Policy: policy
|
|
1409
1421
|
};
|
|
1410
1422
|
});
|
|
1423
|
+
const minPolicyLevel = reportLevel === constants.default.REPORT_LEVEL_DEFER ? 'everything' : reportLevel;
|
|
1411
1424
|
const md = `
|
|
1412
1425
|
# Scan Policy Report
|
|
1413
1426
|
|
|
@@ -1424,13 +1437,13 @@ Configuration used to generate this report:
|
|
|
1424
1437
|
|
|
1425
1438
|
- Organization: ${report.orgSlug}
|
|
1426
1439
|
- Scan ID: ${report.scanId}
|
|
1427
|
-
- Alert folding: ${
|
|
1428
|
-
- Minimal policy level for alert to be included in report: ${
|
|
1440
|
+
- Alert folding: ${alertFolding}
|
|
1441
|
+
- Minimal policy level for alert to be included in report: ${minPolicyLevel}
|
|
1429
1442
|
- Include license alerts: ${includeLicensePolicy ? 'yes' : 'no'}
|
|
1430
1443
|
|
|
1431
1444
|
## Alerts
|
|
1432
1445
|
|
|
1433
|
-
${report.alerts.size ? `All the alerts from the scan with a policy set to at least "${
|
|
1446
|
+
${report.alerts.size ? `All the alerts from the scan with a policy set to at least "${reportLevel}".` : `The scan contained no alerts with a policy set to at least "${reportLevel}".`}
|
|
1434
1447
|
|
|
1435
1448
|
${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'Package', 'Introduced by', 'url', 'Manifest file'])}
|
|
1436
1449
|
`.trim() + '\n';
|
|
@@ -1438,7 +1451,7 @@ ${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'P
|
|
|
1438
1451
|
}
|
|
1439
1452
|
|
|
1440
1453
|
async function handleScanReport({
|
|
1441
|
-
|
|
1454
|
+
filepath,
|
|
1442
1455
|
fold,
|
|
1443
1456
|
includeLicensePolicy,
|
|
1444
1457
|
orgSlug,
|
|
@@ -1451,7 +1464,7 @@ async function handleScanReport({
|
|
|
1451
1464
|
includeLicensePolicy
|
|
1452
1465
|
});
|
|
1453
1466
|
await outputScanReport(scanDataCResult, {
|
|
1454
|
-
|
|
1467
|
+
filepath,
|
|
1455
1468
|
fold,
|
|
1456
1469
|
scanId: scanId,
|
|
1457
1470
|
includeLicensePolicy,
|
|
@@ -1466,7 +1479,7 @@ async function outputCreateNewScan(result, options) {
|
|
|
1466
1479
|
const {
|
|
1467
1480
|
interactive = false,
|
|
1468
1481
|
outputKind = 'text',
|
|
1469
|
-
spinner = constants.spinner
|
|
1482
|
+
spinner = constants.default.spinner
|
|
1470
1483
|
} = {
|
|
1471
1484
|
__proto__: null,
|
|
1472
1485
|
...options
|
|
@@ -1545,7 +1558,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1545
1558
|
...options
|
|
1546
1559
|
};
|
|
1547
1560
|
|
|
1548
|
-
// Check if user has enterprise plan for reachability analysis
|
|
1561
|
+
// Check if user has enterprise plan for reachability analysis.
|
|
1549
1562
|
const orgsCResult = await utils.fetchOrganization();
|
|
1550
1563
|
if (!orgsCResult.ok) {
|
|
1551
1564
|
return {
|
|
@@ -1564,6 +1577,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1564
1577
|
cause: `Please ${vendor.terminalLinkExports('upgrade your plan', 'https://socket.dev/pricing')}. This feature is only available for organizations with an enterprise plan.`
|
|
1565
1578
|
};
|
|
1566
1579
|
}
|
|
1580
|
+
const wasSpinning = !!spinner?.isSpinning;
|
|
1567
1581
|
let tarHash;
|
|
1568
1582
|
if (uploadManifests && orgSlug && packagePaths) {
|
|
1569
1583
|
// Setup SDK for uploading manifests
|
|
@@ -1572,14 +1586,13 @@ async function performReachabilityAnalysis(options) {
|
|
|
1572
1586
|
return sockSdkCResult;
|
|
1573
1587
|
}
|
|
1574
1588
|
const sockSdk = sockSdkCResult.data;
|
|
1575
|
-
const wasSpinning = !!spinner?.isSpinning;
|
|
1576
1589
|
|
|
1577
1590
|
// Exclude any .socket.facts.json files that happen to be in the scan
|
|
1578
1591
|
// folder before the analysis was run.
|
|
1579
|
-
const filepathsToUpload = packagePaths.filter(p => path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON);
|
|
1592
|
+
const filepathsToUpload = packagePaths.filter(p => path.basename(p).toLowerCase() !== constants.default.DOT_SOCKET_DOT_FACTS_JSON);
|
|
1580
1593
|
spinner?.start('Uploading manifests for reachability analysis...');
|
|
1581
1594
|
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, filepathsToUpload), {
|
|
1582
|
-
|
|
1595
|
+
description: 'upload manifests',
|
|
1583
1596
|
spinner
|
|
1584
1597
|
});
|
|
1585
1598
|
spinner?.stop();
|
|
@@ -1607,31 +1620,28 @@ async function performReachabilityAnalysis(options) {
|
|
|
1607
1620
|
spinner?.infoAndStop('Running reachability analysis with Coana...');
|
|
1608
1621
|
|
|
1609
1622
|
// Build Coana arguments.
|
|
1610
|
-
const coanaArgs = ['run', cwd, '--output-dir', cwd, '--socket-mode', constants.DOT_SOCKET_DOT_FACTS_JSON, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1623
|
+
const coanaArgs = ['run', cwd, '--output-dir', cwd, '--socket-mode', constants.default.DOT_SOCKET_DOT_FACTS_JSON, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1611
1624
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1612
1625
|
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : [])];
|
|
1613
1626
|
|
|
1614
1627
|
// Build environment variables.
|
|
1615
|
-
const
|
|
1616
|
-
...process.env
|
|
1617
|
-
};
|
|
1628
|
+
const coanaEnv = {};
|
|
1618
1629
|
// do not pass default repo and branch name to coana to avoid mixing
|
|
1619
1630
|
// buckets (cached configuration) from projects that are likely very different.
|
|
1620
|
-
if (repoName && repoName !== constants.SOCKET_DEFAULT_REPOSITORY) {
|
|
1621
|
-
|
|
1631
|
+
if (repoName && repoName !== constants.default.SOCKET_DEFAULT_REPOSITORY) {
|
|
1632
|
+
coanaEnv['SOCKET_REPO_NAME'] = repoName;
|
|
1622
1633
|
}
|
|
1623
|
-
if (branchName && branchName !== constants.SOCKET_DEFAULT_BRANCH) {
|
|
1624
|
-
|
|
1634
|
+
if (branchName && branchName !== constants.default.SOCKET_DEFAULT_BRANCH) {
|
|
1635
|
+
coanaEnv['SOCKET_BRANCH_NAME'] = branchName;
|
|
1625
1636
|
}
|
|
1626
1637
|
|
|
1627
1638
|
// Run Coana with the manifests tar hash.
|
|
1628
1639
|
const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
|
|
1629
1640
|
cwd,
|
|
1630
|
-
env,
|
|
1641
|
+
env: coanaEnv,
|
|
1631
1642
|
spinner,
|
|
1632
1643
|
stdio: 'inherit'
|
|
1633
1644
|
});
|
|
1634
|
-
const wasSpinning = !!spinner?.isSpinning;
|
|
1635
1645
|
if (wasSpinning) {
|
|
1636
1646
|
spinner.start();
|
|
1637
1647
|
}
|
|
@@ -1639,8 +1649,8 @@ async function performReachabilityAnalysis(options) {
|
|
|
1639
1649
|
ok: true,
|
|
1640
1650
|
data: {
|
|
1641
1651
|
// Use the DOT_SOCKET_DOT_FACTS_JSON file for the scan.
|
|
1642
|
-
reachabilityReport: constants.DOT_SOCKET_DOT_FACTS_JSON,
|
|
1643
|
-
tier1ReachabilityScanId: utils.extractTier1ReachabilityScanId(constants.DOT_SOCKET_DOT_FACTS_JSON)
|
|
1652
|
+
reachabilityReport: constants.default.DOT_SOCKET_DOT_FACTS_JSON,
|
|
1653
|
+
tier1ReachabilityScanId: utils.extractTier1ReachabilityScanId(constants.default.DOT_SOCKET_DOT_FACTS_JSON)
|
|
1644
1654
|
}
|
|
1645
1655
|
} : coanaResult;
|
|
1646
1656
|
}
|
|
@@ -1720,7 +1730,7 @@ async function convertGradleToMaven({
|
|
|
1720
1730
|
// .socket folder. We could do a socket.pom.gz with all the poms, although
|
|
1721
1731
|
// I'd prefer something plain-text if it is to be committed.
|
|
1722
1732
|
// Note: init.gradle will be exported by .config/rollup.dist.config.mjs
|
|
1723
|
-
const initLocation = path.join(constants.distPath, 'init.gradle');
|
|
1733
|
+
const initLocation = path.join(constants.default.distPath, 'init.gradle');
|
|
1724
1734
|
const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom'];
|
|
1725
1735
|
if (verbose) {
|
|
1726
1736
|
logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs);
|
|
@@ -1764,7 +1774,7 @@ async function convertGradleToMaven({
|
|
|
1764
1774
|
async function execGradleWithSpinner(bin, commandArgs, cwd) {
|
|
1765
1775
|
const {
|
|
1766
1776
|
spinner
|
|
1767
|
-
} = constants;
|
|
1777
|
+
} = constants.default;
|
|
1768
1778
|
let pass = false;
|
|
1769
1779
|
try {
|
|
1770
1780
|
logger.logger.info('(Running gradle can take a while, it depends on how long gradlew has to run)');
|
|
@@ -1808,7 +1818,7 @@ async function convertSbtToMaven({
|
|
|
1808
1818
|
|
|
1809
1819
|
const {
|
|
1810
1820
|
spinner
|
|
1811
|
-
} = constants;
|
|
1821
|
+
} = constants.default;
|
|
1812
1822
|
logger.logger.group('sbt2maven:');
|
|
1813
1823
|
logger.logger.info(`- executing: \`${bin}\``);
|
|
1814
1824
|
logger.logger.info(`- src dir: \`${cwd}\``);
|
|
@@ -2142,6 +2152,7 @@ async function handleCreateNewScan({
|
|
|
2142
2152
|
readOnly,
|
|
2143
2153
|
repoName,
|
|
2144
2154
|
report,
|
|
2155
|
+
reportLevel,
|
|
2145
2156
|
targets,
|
|
2146
2157
|
tmp
|
|
2147
2158
|
}) {
|
|
@@ -2159,7 +2170,7 @@ async function handleCreateNewScan({
|
|
|
2159
2170
|
}
|
|
2160
2171
|
const {
|
|
2161
2172
|
spinner
|
|
2162
|
-
} = constants;
|
|
2173
|
+
} = constants.default;
|
|
2163
2174
|
const supportedFilesCResult = await fetchSupportedScanFileNames({
|
|
2164
2175
|
spinner
|
|
2165
2176
|
});
|
|
@@ -2223,7 +2234,7 @@ async function handleCreateNewScan({
|
|
|
2223
2234
|
scanPaths = [...packagePaths.filter(
|
|
2224
2235
|
// Ensure the .socket.facts.json isn't duplicated in case it happened
|
|
2225
2236
|
// to be in the scan folder before the analysis was run.
|
|
2226
|
-
p => path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON), ...(reachabilityReport ? [reachabilityReport] : [])];
|
|
2237
|
+
p => path.basename(p).toLowerCase() !== constants.default.DOT_SOCKET_DOT_FACTS_JSON), ...(reachabilityReport ? [reachabilityReport] : [])];
|
|
2227
2238
|
tier1ReachabilityScanId = reachResult.data?.tier1ReachabilityScanId;
|
|
2228
2239
|
}
|
|
2229
2240
|
const fullScanCResult = await fetchCreateOrgFullScan(scanPaths, orgSlug, {
|
|
@@ -2246,12 +2257,12 @@ async function handleCreateNewScan({
|
|
|
2246
2257
|
if (report && fullScanCResult.ok) {
|
|
2247
2258
|
if (scanId) {
|
|
2248
2259
|
await handleScanReport({
|
|
2249
|
-
|
|
2250
|
-
fold:
|
|
2260
|
+
filepath: '-',
|
|
2261
|
+
fold: constants.default.FOLD_SETTING_VERSION,
|
|
2251
2262
|
includeLicensePolicy: true,
|
|
2252
2263
|
orgSlug,
|
|
2253
2264
|
outputKind,
|
|
2254
|
-
reportLevel
|
|
2265
|
+
reportLevel,
|
|
2255
2266
|
scanId,
|
|
2256
2267
|
short: false
|
|
2257
2268
|
});
|
|
@@ -2313,6 +2324,7 @@ async function handleCi(autoManifest) {
|
|
|
2313
2324
|
repoName,
|
|
2314
2325
|
readOnly: false,
|
|
2315
2326
|
report: true,
|
|
2327
|
+
reportLevel: constants.default.REPORT_LEVEL_ERROR,
|
|
2316
2328
|
targets: ['.'],
|
|
2317
2329
|
// Don't set 'tmp' when 'pendingHead' is true.
|
|
2318
2330
|
tmp: false
|
|
@@ -2370,7 +2382,7 @@ async function run$O(argv, importMeta, {
|
|
|
2370
2382
|
});
|
|
2371
2383
|
const dryRun = !!cli.flags['dryRun'];
|
|
2372
2384
|
if (dryRun) {
|
|
2373
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2385
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2374
2386
|
return;
|
|
2375
2387
|
}
|
|
2376
2388
|
await handleCi(Boolean(cli.flags['autoManifest']));
|
|
@@ -2633,7 +2645,10 @@ async function run$N(argv, importMeta, {
|
|
|
2633
2645
|
$ ${command} defaultOrg
|
|
2634
2646
|
|
|
2635
2647
|
Keys:
|
|
2636
|
-
${utils.getSupportedConfigEntries().map((
|
|
2648
|
+
${utils.getSupportedConfigEntries().map(({
|
|
2649
|
+
0: key,
|
|
2650
|
+
1: description
|
|
2651
|
+
}) => ` - ${key} -- ${description}`).join('\n')}
|
|
2637
2652
|
`
|
|
2638
2653
|
};
|
|
2639
2654
|
const cli = utils.meowOrExit({
|
|
@@ -2663,7 +2678,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
2663
2678
|
return;
|
|
2664
2679
|
}
|
|
2665
2680
|
if (dryRun) {
|
|
2666
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2681
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2667
2682
|
return;
|
|
2668
2683
|
}
|
|
2669
2684
|
await handleConfigAuto({
|
|
@@ -2730,7 +2745,10 @@ const config$j = {
|
|
|
2730
2745
|
|
|
2731
2746
|
KEY is an enum. Valid keys:
|
|
2732
2747
|
|
|
2733
|
-
${utils.getSupportedConfigEntries().map((
|
|
2748
|
+
${utils.getSupportedConfigEntries().map(({
|
|
2749
|
+
0: key,
|
|
2750
|
+
1: description
|
|
2751
|
+
}) => ` - ${key} -- ${description}`).join('\n')}
|
|
2734
2752
|
|
|
2735
2753
|
Examples
|
|
2736
2754
|
$ ${command} defaultOrg
|
|
@@ -2771,7 +2789,7 @@ async function run$M(argv, importMeta, {
|
|
|
2771
2789
|
return;
|
|
2772
2790
|
}
|
|
2773
2791
|
if (dryRun) {
|
|
2774
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2792
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2775
2793
|
return;
|
|
2776
2794
|
}
|
|
2777
2795
|
await handleConfigGet({
|
|
@@ -2903,7 +2921,7 @@ async function run$L(argv, importMeta, {
|
|
|
2903
2921
|
return;
|
|
2904
2922
|
}
|
|
2905
2923
|
if (dryRun) {
|
|
2906
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2924
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2907
2925
|
return;
|
|
2908
2926
|
}
|
|
2909
2927
|
await outputConfigList({
|
|
@@ -2988,7 +3006,10 @@ async function run$K(argv, importMeta, {
|
|
|
2988
3006
|
|
|
2989
3007
|
Keys:
|
|
2990
3008
|
|
|
2991
|
-
${utils.getSupportedConfigEntries().map((
|
|
3009
|
+
${utils.getSupportedConfigEntries().map(({
|
|
3010
|
+
0: key,
|
|
3011
|
+
1: description
|
|
3012
|
+
}) => ` - ${key} -- ${description}`).join('\n')}
|
|
2992
3013
|
|
|
2993
3014
|
Examples
|
|
2994
3015
|
$ ${command} apiProxy https://example.com
|
|
@@ -3027,7 +3048,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
3027
3048
|
return;
|
|
3028
3049
|
}
|
|
3029
3050
|
if (dryRun) {
|
|
3030
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
3051
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
3031
3052
|
return;
|
|
3032
3053
|
}
|
|
3033
3054
|
await handleConfigSet({
|
|
@@ -3106,7 +3127,10 @@ async function run$J(argv, importMeta, {
|
|
|
3106
3127
|
|
|
3107
3128
|
Keys:
|
|
3108
3129
|
|
|
3109
|
-
${utils.getSupportedConfigEntries().map((
|
|
3130
|
+
${utils.getSupportedConfigEntries().map(({
|
|
3131
|
+
0: key,
|
|
3132
|
+
1: description
|
|
3133
|
+
}) => ` - ${key} -- ${description}`).join('\n')}
|
|
3110
3134
|
|
|
3111
3135
|
Examples
|
|
3112
3136
|
$ ${command} defaultOrg
|
|
@@ -3139,7 +3163,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
3139
3163
|
return;
|
|
3140
3164
|
}
|
|
3141
3165
|
if (dryRun) {
|
|
3142
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
3166
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
3143
3167
|
return;
|
|
3144
3168
|
}
|
|
3145
3169
|
await handleConfigUnset({
|
|
@@ -3186,14 +3210,14 @@ function getSocketFixPullRequestBody(ghsaIds, ghsaDetails) {
|
|
|
3186
3210
|
if (vulnCount === 1) {
|
|
3187
3211
|
const ghsaId = ghsaIds[0];
|
|
3188
3212
|
const details = ghsaDetails?.get(ghsaId);
|
|
3189
|
-
const body = `[Socket](${constants.SOCKET_WEBSITE_URL}) fix for [${ghsaId}](${GITHUB_ADVISORIES_URL}/${ghsaId}).`;
|
|
3213
|
+
const body = `[Socket](${constants.default.SOCKET_WEBSITE_URL}) fix for [${ghsaId}](${GITHUB_ADVISORIES_URL}/${ghsaId}).`;
|
|
3190
3214
|
if (!details) {
|
|
3191
3215
|
return body;
|
|
3192
3216
|
}
|
|
3193
3217
|
const packages = details.vulnerabilities.nodes.map(v => `${v.package.name} (${v.package.ecosystem})`);
|
|
3194
3218
|
return [body, '', '', `**Vulnerability Summary:** ${details.summary}`, '', `**Severity:** ${details.severity}`, '', `**Affected Packages:** ${arrays.joinAnd(packages)}`].join('\n');
|
|
3195
3219
|
}
|
|
3196
|
-
return [`[Socket](${constants.SOCKET_WEBSITE_URL}) fixes for ${vulnCount} GHSAs.`, '', '**Fixed Vulnerabilities:**', ...ghsaIds.map(id => {
|
|
3220
|
+
return [`[Socket](${constants.default.SOCKET_WEBSITE_URL}) fixes for ${vulnCount} GHSAs.`, '', '**Fixed Vulnerabilities:**', ...ghsaIds.map(id => {
|
|
3197
3221
|
const details = ghsaDetails?.get(id);
|
|
3198
3222
|
const item = `- [${id}](${GITHUB_ADVISORIES_URL}/${id})`;
|
|
3199
3223
|
if (details) {
|
|
@@ -3241,10 +3265,10 @@ async function openSocketFixPr(owner, repo, branch, ghsaIds, options) {
|
|
|
3241
3265
|
}
|
|
3242
3266
|
return null;
|
|
3243
3267
|
}
|
|
3244
|
-
async function
|
|
3245
|
-
return (await
|
|
3268
|
+
async function getSocketFixPrs(owner, repo, options) {
|
|
3269
|
+
return (await getSocketFixPrsWithContext(owner, repo, options)).map(d => d.match);
|
|
3246
3270
|
}
|
|
3247
|
-
async function
|
|
3271
|
+
async function getSocketFixPrsWithContext(owner, repo, options) {
|
|
3248
3272
|
const {
|
|
3249
3273
|
author,
|
|
3250
3274
|
ghsaId,
|
|
@@ -3255,117 +3279,101 @@ async function getSocketPrsWithContext(owner, repo, options) {
|
|
|
3255
3279
|
};
|
|
3256
3280
|
const branchPattern = getSocketFixBranchPattern(ghsaId);
|
|
3257
3281
|
const checkAuthor = strings.isNonEmptyString(author);
|
|
3258
|
-
const octokit = utils.getOctokit();
|
|
3259
3282
|
const octokitGraphql = utils.getOctokitGraphql();
|
|
3260
3283
|
const contextualMatches = [];
|
|
3261
|
-
const states = (typeof statesValue === 'string' ? statesValue.toLowerCase() === 'all' ? [
|
|
3284
|
+
const states = (typeof statesValue === 'string' ? statesValue.toLowerCase() === 'all' ? [constants.GQL_PR_STATE_OPEN, constants.GQL_PR_STATE_CLOSED, constants.GQL_PR_STATE_MERGED] : [statesValue] : statesValue).map(s => s.toUpperCase());
|
|
3262
3285
|
try {
|
|
3263
|
-
|
|
3264
|
-
|
|
3286
|
+
let hasNextPage = true;
|
|
3287
|
+
let cursor = null;
|
|
3288
|
+
let pageIndex = 0;
|
|
3265
3289
|
const gqlCacheKey = `${repo}-pr-graphql-snapshot`;
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3290
|
+
while (hasNextPage) {
|
|
3291
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3292
|
+
const gqlResp = await utils.cacheFetch(`${gqlCacheKey}-page-${pageIndex}`, () => octokitGraphql(`
|
|
3293
|
+
query($owner: String!, $repo: String!, $states: [PullRequestState!], $after: String) {
|
|
3294
|
+
repository(owner: $owner, name: $repo) {
|
|
3295
|
+
pullRequests(first: 100, states: $states, after: $after, orderBy: {field: CREATED_AT, direction: DESC}) {
|
|
3296
|
+
pageInfo {
|
|
3297
|
+
hasNextPage
|
|
3298
|
+
endCursor
|
|
3299
|
+
}
|
|
3300
|
+
nodes {
|
|
3301
|
+
author {
|
|
3302
|
+
login
|
|
3303
|
+
}
|
|
3304
|
+
baseRefName
|
|
3305
|
+
headRefName
|
|
3306
|
+
mergeStateStatus
|
|
3307
|
+
number
|
|
3308
|
+
state
|
|
3309
|
+
title
|
|
3310
|
+
}
|
|
3273
3311
|
}
|
|
3274
|
-
baseRefName
|
|
3275
|
-
headRefName
|
|
3276
|
-
mergeStateStatus
|
|
3277
|
-
number
|
|
3278
|
-
state
|
|
3279
|
-
title
|
|
3280
3312
|
}
|
|
3281
3313
|
}
|
|
3314
|
+
`, {
|
|
3315
|
+
owner,
|
|
3316
|
+
repo,
|
|
3317
|
+
states,
|
|
3318
|
+
after: cursor
|
|
3319
|
+
}));
|
|
3320
|
+
const {
|
|
3321
|
+
nodes,
|
|
3322
|
+
pageInfo
|
|
3323
|
+
} = gqlResp?.repository?.pullRequests ?? {
|
|
3324
|
+
nodes: [],
|
|
3325
|
+
pageInfo: {
|
|
3326
|
+
hasNextPage: false,
|
|
3327
|
+
endCursor: null
|
|
3328
|
+
}
|
|
3329
|
+
};
|
|
3330
|
+
for (let i = 0, {
|
|
3331
|
+
length
|
|
3332
|
+
} = nodes; i < length; i += 1) {
|
|
3333
|
+
const node = nodes[i];
|
|
3334
|
+
const login = node.author?.login;
|
|
3335
|
+
const matchesAuthor = checkAuthor ? login === author : true;
|
|
3336
|
+
const matchesBranch = branchPattern.test(node.headRefName);
|
|
3337
|
+
if (matchesAuthor && matchesBranch) {
|
|
3338
|
+
contextualMatches.push({
|
|
3339
|
+
context: {
|
|
3340
|
+
apiType: 'graphql',
|
|
3341
|
+
cacheKey: `${gqlCacheKey}-page-${pageIndex}`,
|
|
3342
|
+
data: gqlResp,
|
|
3343
|
+
entry: node,
|
|
3344
|
+
index: i,
|
|
3345
|
+
parent: nodes
|
|
3346
|
+
},
|
|
3347
|
+
match: {
|
|
3348
|
+
...node,
|
|
3349
|
+
author: login ?? constants.UNKNOWN_VALUE
|
|
3282
3350
|
}
|
|
3283
|
-
}
|
|
3284
|
-
|
|
3285
|
-
owner,
|
|
3286
|
-
repo,
|
|
3287
|
-
states
|
|
3288
|
-
}));
|
|
3289
|
-
const nodes = gqlResp?.repository?.pullRequests?.nodes ?? [];
|
|
3290
|
-
for (let i = 0, {
|
|
3291
|
-
length
|
|
3292
|
-
} = nodes; i < length; i += 1) {
|
|
3293
|
-
const node = nodes[i];
|
|
3294
|
-
const login = node.author?.login;
|
|
3295
|
-
const matchesAuthor = checkAuthor ? login === author : true;
|
|
3296
|
-
const matchesBranch = branchPattern.test(node.headRefName);
|
|
3297
|
-
if (matchesAuthor && matchesBranch) {
|
|
3298
|
-
contextualMatches.push({
|
|
3299
|
-
context: {
|
|
3300
|
-
apiType: 'graphql',
|
|
3301
|
-
cacheKey: gqlCacheKey,
|
|
3302
|
-
data: gqlResp,
|
|
3303
|
-
entry: node,
|
|
3304
|
-
index: i,
|
|
3305
|
-
parent: nodes
|
|
3306
|
-
},
|
|
3307
|
-
match: {
|
|
3308
|
-
...node,
|
|
3309
|
-
author: login ?? '<unknown>'
|
|
3310
|
-
}
|
|
3311
|
-
});
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3312
3353
|
}
|
|
3313
|
-
}
|
|
3314
|
-
} catch {}
|
|
3315
|
-
if (contextualMatches.length) {
|
|
3316
|
-
return contextualMatches;
|
|
3317
|
-
}
|
|
3318
3354
|
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
} = allPrs; i < length; i += 1) {
|
|
3336
|
-
const pr = allPrs[i];
|
|
3337
|
-
const login = pr.user?.login;
|
|
3338
|
-
const headRefName = pr.head.ref;
|
|
3339
|
-
const matchesAuthor = checkAuthor ? login === author : true;
|
|
3340
|
-
const matchesBranch = branchPattern.test(headRefName);
|
|
3341
|
-
if (matchesAuthor && matchesBranch) {
|
|
3342
|
-
// Upper cased mergeable_state is equivalent to mergeStateStatus.
|
|
3343
|
-
// https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
|
|
3344
|
-
const mergeStateStatus = pr.mergeable_state?.toUpperCase?.() ?? 'UNKNOWN';
|
|
3345
|
-
// The REST API does not have a distinct merged state for pull requests.
|
|
3346
|
-
// Instead, a merged pull request is represented as a closed pull request
|
|
3347
|
-
// with a non-null merged_at timestamp.
|
|
3348
|
-
const state = pr.merged_at ? 'MERGED' : pr.state.toUpperCase();
|
|
3349
|
-
contextualMatches.push({
|
|
3350
|
-
context: {
|
|
3351
|
-
apiType: 'rest',
|
|
3352
|
-
cacheKey,
|
|
3353
|
-
data: allPrs,
|
|
3354
|
-
entry: pr,
|
|
3355
|
-
index: i,
|
|
3356
|
-
parent: allPrs
|
|
3357
|
-
},
|
|
3358
|
-
match: {
|
|
3359
|
-
author: login ?? '<unknown>',
|
|
3360
|
-
baseRefName: pr.base.ref,
|
|
3361
|
-
headRefName,
|
|
3362
|
-
mergeStateStatus,
|
|
3363
|
-
number: pr.number,
|
|
3364
|
-
state,
|
|
3365
|
-
title: pr.title
|
|
3366
|
-
}
|
|
3367
|
-
});
|
|
3355
|
+
// Continue to next page.
|
|
3356
|
+
hasNextPage = pageInfo.hasNextPage;
|
|
3357
|
+
cursor = pageInfo.endCursor;
|
|
3358
|
+
pageIndex += 1;
|
|
3359
|
+
|
|
3360
|
+
// Safety limit to prevent infinite loops.
|
|
3361
|
+
if (pageIndex === constants.GQL_PAGE_SENTINEL) {
|
|
3362
|
+
require$$9.debugFn('warn', `GraphQL pagination reached safety limit (${constants.GQL_PAGE_SENTINEL} pages) for ${owner}/${repo}`);
|
|
3363
|
+
break;
|
|
3364
|
+
}
|
|
3365
|
+
|
|
3366
|
+
// Early exit optimization: if we found matches and only looking for specific GHSA,
|
|
3367
|
+
// we can stop pagination since we likely found what we need.
|
|
3368
|
+
if (contextualMatches.length > 0 && ghsaId) {
|
|
3369
|
+
break;
|
|
3370
|
+
}
|
|
3368
3371
|
}
|
|
3372
|
+
} catch (e) {
|
|
3373
|
+
require$$9.debugFn('error', `GraphQL pagination failed for ${owner}/${repo}`);
|
|
3374
|
+
require$$9.debugDir('inspect', {
|
|
3375
|
+
error: e
|
|
3376
|
+
});
|
|
3369
3377
|
}
|
|
3370
3378
|
return contextualMatches;
|
|
3371
3379
|
}
|
|
@@ -3373,7 +3381,7 @@ async function getSocketPrsWithContext(owner, repo, options) {
|
|
|
3373
3381
|
function ciRepoInfo() {
|
|
3374
3382
|
const {
|
|
3375
3383
|
GITHUB_REPOSITORY
|
|
3376
|
-
} = constants.ENV;
|
|
3384
|
+
} = constants.default.ENV;
|
|
3377
3385
|
if (!GITHUB_REPOSITORY) {
|
|
3378
3386
|
require$$9.debugFn('notice', 'miss: GITHUB_REPOSITORY env var');
|
|
3379
3387
|
}
|
|
@@ -3389,18 +3397,18 @@ function ciRepoInfo() {
|
|
|
3389
3397
|
}
|
|
3390
3398
|
async function getFixEnv() {
|
|
3391
3399
|
const baseBranch = await utils.getBaseBranch();
|
|
3392
|
-
const gitEmail = constants.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
3393
|
-
const gitUser = constants.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
3394
|
-
const githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
3395
|
-
const isCi = !!(constants.ENV.CI && gitEmail && gitUser && githubToken);
|
|
3400
|
+
const gitEmail = constants.default.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
3401
|
+
const gitUser = constants.default.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
3402
|
+
const githubToken = constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
3403
|
+
const isCi = !!(constants.default.ENV.CI && gitEmail && gitUser && githubToken);
|
|
3396
3404
|
if (
|
|
3397
3405
|
// If isCi is false,
|
|
3398
3406
|
!isCi && (
|
|
3399
3407
|
// but some CI checks are passing,
|
|
3400
|
-
constants.ENV.CI || gitEmail || gitUser || githubToken) &&
|
|
3408
|
+
constants.default.ENV.CI || gitEmail || gitUser || githubToken) &&
|
|
3401
3409
|
// then log about it when in debug mode.
|
|
3402
3410
|
require$$9.isDebug('notice')) {
|
|
3403
|
-
const envVars = [...(constants.ENV.CI ? [] : ['process.env.CI']), ...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']), ...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']), ...(githubToken ? [] : ['process.env.GITHUB_TOKEN'])];
|
|
3411
|
+
const envVars = [...(constants.default.ENV.CI ? [] : ['process.env.CI']), ...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']), ...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']), ...(githubToken ? [] : ['process.env.GITHUB_TOKEN'])];
|
|
3404
3412
|
require$$9.debugFn('notice', `miss: fixEnv.isCi is false, expected ${arrays.joinAnd(envVars)} to be set`);
|
|
3405
3413
|
}
|
|
3406
3414
|
let repoInfo = null;
|
|
@@ -3413,7 +3421,7 @@ async function getFixEnv() {
|
|
|
3413
3421
|
}
|
|
3414
3422
|
repoInfo = await utils.getRepoInfo();
|
|
3415
3423
|
}
|
|
3416
|
-
const prs = isCi && repoInfo ? await
|
|
3424
|
+
const prs = isCi && repoInfo ? await getSocketFixPrs(repoInfo.owner, repoInfo.repo, {
|
|
3417
3425
|
author: gitUser,
|
|
3418
3426
|
states: 'all'
|
|
3419
3427
|
}) : [];
|
|
@@ -3430,7 +3438,7 @@ async function getFixEnv() {
|
|
|
3430
3438
|
|
|
3431
3439
|
async function coanaFix(fixConfig) {
|
|
3432
3440
|
const {
|
|
3433
|
-
|
|
3441
|
+
autopilot,
|
|
3434
3442
|
cwd,
|
|
3435
3443
|
ghsas,
|
|
3436
3444
|
limit,
|
|
@@ -3458,7 +3466,7 @@ async function coanaFix(fixConfig) {
|
|
|
3458
3466
|
cwd
|
|
3459
3467
|
});
|
|
3460
3468
|
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, scanFilepaths), {
|
|
3461
|
-
|
|
3469
|
+
description: 'upload manifests',
|
|
3462
3470
|
spinner
|
|
3463
3471
|
});
|
|
3464
3472
|
if (!uploadCResult.ok) {
|
|
@@ -3499,18 +3507,40 @@ async function coanaFix(fixConfig) {
|
|
|
3499
3507
|
}
|
|
3500
3508
|
} : fixCResult;
|
|
3501
3509
|
}
|
|
3510
|
+
|
|
3511
|
+
// Adjust limit based on open Socket Fix PRs.
|
|
3512
|
+
let adjustedLimit = limit;
|
|
3513
|
+
if (shouldOpenPrs && fixEnv.repoInfo) {
|
|
3514
|
+
try {
|
|
3515
|
+
const openPrs = await getSocketFixPrs(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, {
|
|
3516
|
+
states: constants.GQL_PR_STATE_OPEN
|
|
3517
|
+
});
|
|
3518
|
+
const openPrCount = openPrs.length;
|
|
3519
|
+
// Reduce limit by number of open PRs to avoid creating too many.
|
|
3520
|
+
adjustedLimit = Math.max(0, limit - openPrCount);
|
|
3521
|
+
if (openPrCount > 0) {
|
|
3522
|
+
require$$9.debugFn('notice', `limit: adjusted from ${limit} to ${adjustedLimit} (${openPrCount} open Socket Fix PRs)`);
|
|
3523
|
+
}
|
|
3524
|
+
} catch (e) {
|
|
3525
|
+
require$$9.debugFn('warn', 'Failed to count open PRs, using original limit');
|
|
3526
|
+
require$$9.debugDir('inspect', {
|
|
3527
|
+
error: e
|
|
3528
|
+
});
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
const shouldSpawnCoana = adjustedLimit > 0;
|
|
3502
3532
|
let ids;
|
|
3503
|
-
if (isAll) {
|
|
3533
|
+
if (shouldSpawnCoana && isAll) {
|
|
3504
3534
|
const foundCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3505
3535
|
cwd,
|
|
3506
3536
|
spinner
|
|
3507
3537
|
});
|
|
3508
3538
|
if (foundCResult.ok) {
|
|
3509
3539
|
const foundIds = utils.cmdFlagValueToArray(/(?<=Vulnerabilities found:).*/.exec(foundCResult.data));
|
|
3510
|
-
ids = foundIds.slice(0,
|
|
3540
|
+
ids = foundIds.slice(0, adjustedLimit);
|
|
3511
3541
|
}
|
|
3512
|
-
} else {
|
|
3513
|
-
ids = ghsas.slice(0,
|
|
3542
|
+
} else if (shouldSpawnCoana) {
|
|
3543
|
+
ids = ghsas.slice(0, adjustedLimit);
|
|
3514
3544
|
}
|
|
3515
3545
|
if (!ids?.length) {
|
|
3516
3546
|
require$$9.debugFn('notice', 'miss: no GHSA IDs to process');
|
|
@@ -3534,7 +3564,7 @@ async function coanaFix(fixConfig) {
|
|
|
3534
3564
|
let count = 0;
|
|
3535
3565
|
let overallFixed = false;
|
|
3536
3566
|
|
|
3537
|
-
// Process each GHSA ID individually
|
|
3567
|
+
// Process each GHSA ID individually.
|
|
3538
3568
|
ghsaLoop: for (let i = 0, {
|
|
3539
3569
|
length
|
|
3540
3570
|
} = ids; i < length; i += 1) {
|
|
@@ -3549,7 +3579,7 @@ async function coanaFix(fixConfig) {
|
|
|
3549
3579
|
stdio: 'inherit'
|
|
3550
3580
|
});
|
|
3551
3581
|
if (!fixCResult.ok) {
|
|
3552
|
-
logger.logger.error(`Update failed for ${ghsaId}: ${fixCResult.message ||
|
|
3582
|
+
logger.logger.error(`Update failed for ${ghsaId}: ${fixCResult.message || constants.UNKNOWN_ERROR}`);
|
|
3553
3583
|
continue ghsaLoop;
|
|
3554
3584
|
}
|
|
3555
3585
|
|
|
@@ -3615,7 +3645,7 @@ async function coanaFix(fixConfig) {
|
|
|
3615
3645
|
} = prResponse;
|
|
3616
3646
|
const prRef = `PR #${data.number}`;
|
|
3617
3647
|
logger.logger.success(`Opened ${prRef} for ${ghsaId}.`);
|
|
3618
|
-
if (
|
|
3648
|
+
if (autopilot) {
|
|
3619
3649
|
logger.logger.indent();
|
|
3620
3650
|
spinner?.indent();
|
|
3621
3651
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -3650,8 +3680,8 @@ async function coanaFix(fixConfig) {
|
|
|
3650
3680
|
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
3651
3681
|
}
|
|
3652
3682
|
count += 1;
|
|
3653
|
-
require$$9.debugFn('notice', `increment: count ${count}/${Math.min(
|
|
3654
|
-
if (count >=
|
|
3683
|
+
require$$9.debugFn('notice', `increment: count ${count}/${Math.min(adjustedLimit, ids.length)}`);
|
|
3684
|
+
if (count >= adjustedLimit) {
|
|
3655
3685
|
break ghsaLoop;
|
|
3656
3686
|
}
|
|
3657
3687
|
}
|
|
@@ -3681,7 +3711,7 @@ async function outputFixResult(result, outputKind) {
|
|
|
3681
3711
|
}
|
|
3682
3712
|
|
|
3683
3713
|
async function handleFix({
|
|
3684
|
-
|
|
3714
|
+
autopilot,
|
|
3685
3715
|
cwd,
|
|
3686
3716
|
ghsas,
|
|
3687
3717
|
limit,
|
|
@@ -3689,15 +3719,12 @@ async function handleFix({
|
|
|
3689
3719
|
orgSlug,
|
|
3690
3720
|
outputKind,
|
|
3691
3721
|
prCheck,
|
|
3692
|
-
purls,
|
|
3693
3722
|
rangeStyle,
|
|
3694
3723
|
spinner,
|
|
3695
|
-
test,
|
|
3696
|
-
testScript,
|
|
3697
3724
|
unknownFlags
|
|
3698
3725
|
}) {
|
|
3699
3726
|
await outputFixResult(await coanaFix({
|
|
3700
|
-
|
|
3727
|
+
autopilot,
|
|
3701
3728
|
cwd,
|
|
3702
3729
|
ghsas,
|
|
3703
3730
|
limit,
|
|
@@ -3718,7 +3745,7 @@ const cmdFix = {
|
|
|
3718
3745
|
run: run$I
|
|
3719
3746
|
};
|
|
3720
3747
|
const generalFlags$2 = {
|
|
3721
|
-
|
|
3748
|
+
autopilot: {
|
|
3722
3749
|
type: 'boolean',
|
|
3723
3750
|
default: false,
|
|
3724
3751
|
description: `Enable auto-merge for pull requests that Socket opens.\nSee ${vendor.terminalLinkExports('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
|
|
@@ -3752,10 +3779,8 @@ Available styles:
|
|
|
3752
3779
|
}
|
|
3753
3780
|
};
|
|
3754
3781
|
const hiddenFlags = {
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
default: false,
|
|
3758
|
-
description: `Shorthand for --auto-merge --test`,
|
|
3782
|
+
autoMerge: {
|
|
3783
|
+
...generalFlags$2['autopilot'],
|
|
3759
3784
|
hidden: true
|
|
3760
3785
|
},
|
|
3761
3786
|
ghsa: {
|
|
@@ -3836,18 +3861,26 @@ async function run$I(argv, importMeta, {
|
|
|
3836
3861
|
importMeta,
|
|
3837
3862
|
parentName
|
|
3838
3863
|
});
|
|
3864
|
+
const {
|
|
3865
|
+
autopilot,
|
|
3866
|
+
json,
|
|
3867
|
+
limit,
|
|
3868
|
+
markdown,
|
|
3869
|
+
maxSatisfying,
|
|
3870
|
+
prCheck,
|
|
3871
|
+
rangeStyle,
|
|
3872
|
+
// We patched in this feature with `npx custompatch meow` at
|
|
3873
|
+
// socket-cli/patches/meow#13.2.0.patch.
|
|
3874
|
+
unknownFlags = []
|
|
3875
|
+
} = cli.flags;
|
|
3839
3876
|
const dryRun = !!cli.flags['dryRun'];
|
|
3840
|
-
|
|
3841
|
-
if (!rangeStyle) {
|
|
3842
|
-
rangeStyle = 'preserve';
|
|
3843
|
-
}
|
|
3877
|
+
const minSatisfying = cli.flags['minSatisfying'] || !maxSatisfying;
|
|
3844
3878
|
const rawPurls = utils.cmdFlagValueToArray(cli.flags['purl']);
|
|
3845
3879
|
const purls = [];
|
|
3846
3880
|
for (const purl of rawPurls) {
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
} catch {}
|
|
3881
|
+
const version = utils.getPurlObject(purl, {
|
|
3882
|
+
throws: false
|
|
3883
|
+
})?.version;
|
|
3851
3884
|
if (version) {
|
|
3852
3885
|
purls.push(purl);
|
|
3853
3886
|
} else {
|
|
@@ -3859,14 +3892,14 @@ async function run$I(argv, importMeta, {
|
|
|
3859
3892
|
logger.logger.fail('No valid --purl values provided.');
|
|
3860
3893
|
return;
|
|
3861
3894
|
}
|
|
3862
|
-
const outputKind = utils.getOutputKind(
|
|
3895
|
+
const outputKind = utils.getOutputKind(json, markdown);
|
|
3863
3896
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
3864
3897
|
test: utils.RangeStyles.includes(rangeStyle),
|
|
3865
3898
|
message: `Expecting range style of ${arrays.joinOr(utils.RangeStyles)}`,
|
|
3866
3899
|
fail: 'invalid'
|
|
3867
3900
|
}, {
|
|
3868
3901
|
nook: true,
|
|
3869
|
-
test: !
|
|
3902
|
+
test: !json || !markdown,
|
|
3870
3903
|
message: 'The json and markdown flags cannot be both set, pick one',
|
|
3871
3904
|
fail: 'omit one'
|
|
3872
3905
|
});
|
|
@@ -3874,7 +3907,7 @@ async function run$I(argv, importMeta, {
|
|
|
3874
3907
|
return;
|
|
3875
3908
|
}
|
|
3876
3909
|
if (dryRun) {
|
|
3877
|
-
logger.logger.log(constants.DRY_RUN_NOT_SAVING);
|
|
3910
|
+
logger.logger.log(constants.default.DRY_RUN_NOT_SAVING);
|
|
3878
3911
|
return;
|
|
3879
3912
|
}
|
|
3880
3913
|
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
@@ -3888,26 +3921,12 @@ async function run$I(argv, importMeta, {
|
|
|
3888
3921
|
// Note: path.resolve vs .join:
|
|
3889
3922
|
// If given path is absolute then cwd should not affect it.
|
|
3890
3923
|
cwd = path.resolve(process.cwd(), cwd);
|
|
3891
|
-
let autoMerge = Boolean(cli.flags['autoMerge']);
|
|
3892
|
-
let test = Boolean(cli.flags['test']);
|
|
3893
|
-
if (cli.flags['autopilot']) {
|
|
3894
|
-
autoMerge = true;
|
|
3895
|
-
test = true;
|
|
3896
|
-
}
|
|
3897
3924
|
const {
|
|
3898
3925
|
spinner
|
|
3899
|
-
} = constants;
|
|
3900
|
-
// We patched in this feature with `npx custompatch meow` at
|
|
3901
|
-
// socket-cli/patches/meow#13.2.0.patch.
|
|
3902
|
-
const unknownFlags = cli.unknownFlags ?? [];
|
|
3926
|
+
} = constants.default;
|
|
3903
3927
|
const ghsas = arrays.arrayUnique([...utils.cmdFlagValueToArray(cli.flags['id']), ...utils.cmdFlagValueToArray(cli.flags['ghsa'])]);
|
|
3904
|
-
const limit = Number(cli.flags['limit']) || DEFAULT_LIMIT;
|
|
3905
|
-
const maxSatisfying = Boolean(cli.flags['maxSatisfying']);
|
|
3906
|
-
const minSatisfying = Boolean(cli.flags['minSatisfying']) || !maxSatisfying;
|
|
3907
|
-
const prCheck = Boolean(cli.flags['prCheck']);
|
|
3908
|
-
const testScript = String(cli.flags['testScript'] || 'test');
|
|
3909
3928
|
await handleFix({
|
|
3910
|
-
|
|
3929
|
+
autopilot,
|
|
3911
3930
|
cwd,
|
|
3912
3931
|
ghsas,
|
|
3913
3932
|
limit,
|
|
@@ -3915,11 +3934,8 @@ async function run$I(argv, importMeta, {
|
|
|
3915
3934
|
prCheck,
|
|
3916
3935
|
orgSlug,
|
|
3917
3936
|
outputKind,
|
|
3918
|
-
purls,
|
|
3919
3937
|
rangeStyle,
|
|
3920
3938
|
spinner,
|
|
3921
|
-
test,
|
|
3922
|
-
testScript,
|
|
3923
3939
|
unknownFlags
|
|
3924
3940
|
});
|
|
3925
3941
|
}
|
|
@@ -3980,7 +3996,7 @@ async function setupTabCompletion(targetName) {
|
|
|
3980
3996
|
let bashrcUpdated = false;
|
|
3981
3997
|
|
|
3982
3998
|
// Add to ~/.bashrc if not already there
|
|
3983
|
-
const bashrcPath = constants.homePath ? path.join(constants.homePath, '.bashrc') : '';
|
|
3999
|
+
const bashrcPath = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
|
|
3984
4000
|
const foundBashrc = Boolean(bashrcPath && fs$1.existsSync(bashrcPath));
|
|
3985
4001
|
if (foundBashrc) {
|
|
3986
4002
|
const content = fs$1.readFileSync(bashrcPath, 'utf8');
|
|
@@ -4026,7 +4042,7 @@ function updateInstalledTabCompletionScript(targetPath) {
|
|
|
4026
4042
|
|
|
4027
4043
|
// When installing set the current package.json version.
|
|
4028
4044
|
// Later, we can call _socket_completion_version to get the installed version.
|
|
4029
|
-
fs$1.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
|
|
4045
|
+
fs$1.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
|
|
4030
4046
|
return {
|
|
4031
4047
|
ok: true,
|
|
4032
4048
|
data: undefined
|
|
@@ -4090,7 +4106,7 @@ async function run$H(argv, importMeta, {
|
|
|
4090
4106
|
});
|
|
4091
4107
|
const dryRun = !!cli.flags['dryRun'];
|
|
4092
4108
|
if (dryRun) {
|
|
4093
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4109
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4094
4110
|
return;
|
|
4095
4111
|
}
|
|
4096
4112
|
const targetName = cli.input[0] || 'socket';
|
|
@@ -4116,9 +4132,9 @@ const cmdInstall = {
|
|
|
4116
4132
|
};
|
|
4117
4133
|
|
|
4118
4134
|
async function outputCmdJson(cwd) {
|
|
4119
|
-
logger.logger.info('Target cwd:', constants.ENV.VITEST ? '<redacted>' : utils.tildify(cwd));
|
|
4135
|
+
logger.logger.info('Target cwd:', constants.default.ENV.VITEST ? '<redacted>' : utils.tildify(cwd));
|
|
4120
4136
|
const sockJsonPath = path.join(cwd, 'socket.json');
|
|
4121
|
-
const tildeSockJsonPath = constants.ENV.VITEST ? '<redacted>' : utils.tildify(sockJsonPath);
|
|
4137
|
+
const tildeSockJsonPath = constants.default.ENV.VITEST ? '<redacted>' : utils.tildify(sockJsonPath);
|
|
4122
4138
|
if (!fs$1.existsSync(sockJsonPath)) {
|
|
4123
4139
|
logger.logger.fail(`Not found: ${tildeSockJsonPath}`);
|
|
4124
4140
|
process.exitCode = 1;
|
|
@@ -4199,7 +4215,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
4199
4215
|
cause: 'Canceled by user'
|
|
4200
4216
|
};
|
|
4201
4217
|
}
|
|
4202
|
-
const apiToken = apiTokenInput || constants.SOCKET_PUBLIC_API_TOKEN;
|
|
4218
|
+
const apiToken = apiTokenInput || constants.default.SOCKET_PUBLIC_API_TOKEN;
|
|
4203
4219
|
const sockSdkCResult = await utils.setupSdk({
|
|
4204
4220
|
apiBaseUrl,
|
|
4205
4221
|
apiProxy,
|
|
@@ -4212,7 +4228,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
4212
4228
|
}
|
|
4213
4229
|
const sockSdk = sockSdkCResult.data;
|
|
4214
4230
|
const orgsCResult = await utils.fetchOrganization({
|
|
4215
|
-
|
|
4231
|
+
description: 'token verification',
|
|
4216
4232
|
sdk: sockSdk
|
|
4217
4233
|
});
|
|
4218
4234
|
if (!orgsCResult.ok) {
|
|
@@ -4335,10 +4351,12 @@ async function run$F(argv, importMeta, {
|
|
|
4335
4351
|
...flags.commonFlags,
|
|
4336
4352
|
apiBaseUrl: {
|
|
4337
4353
|
type: 'string',
|
|
4354
|
+
default: '',
|
|
4338
4355
|
description: 'API server to connect to for login'
|
|
4339
4356
|
},
|
|
4340
4357
|
apiProxy: {
|
|
4341
4358
|
type: 'string',
|
|
4359
|
+
default: '',
|
|
4342
4360
|
description: 'Proxy to use when making connection to API server'
|
|
4343
4361
|
}
|
|
4344
4362
|
},
|
|
@@ -4367,14 +4385,16 @@ async function run$F(argv, importMeta, {
|
|
|
4367
4385
|
});
|
|
4368
4386
|
const dryRun = !!cli.flags['dryRun'];
|
|
4369
4387
|
if (dryRun) {
|
|
4370
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4388
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4371
4389
|
return;
|
|
4372
4390
|
}
|
|
4373
4391
|
if (!vendor.isInteractiveExports()) {
|
|
4374
4392
|
throw new utils.InputError('Cannot prompt for credentials in a non-interactive shell. Use SOCKET_CLI_API_TOKEN environment variable instead');
|
|
4375
4393
|
}
|
|
4376
|
-
const
|
|
4377
|
-
|
|
4394
|
+
const {
|
|
4395
|
+
apiBaseUrl,
|
|
4396
|
+
apiProxy
|
|
4397
|
+
} = cli.flags;
|
|
4378
4398
|
await attemptLogin(apiBaseUrl, apiProxy);
|
|
4379
4399
|
}
|
|
4380
4400
|
|
|
@@ -4431,7 +4451,7 @@ async function run$E(argv, importMeta, {
|
|
|
4431
4451
|
});
|
|
4432
4452
|
const dryRun = !!cli.flags['dryRun'];
|
|
4433
4453
|
if (dryRun) {
|
|
4434
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4454
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4435
4455
|
return;
|
|
4436
4456
|
}
|
|
4437
4457
|
attemptLogout();
|
|
@@ -4441,8 +4461,8 @@ const {
|
|
|
4441
4461
|
PACKAGE_LOCK_JSON,
|
|
4442
4462
|
YARN,
|
|
4443
4463
|
YARN_LOCK
|
|
4444
|
-
} = constants;
|
|
4445
|
-
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs',
|
|
4464
|
+
} = constants.default;
|
|
4465
|
+
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', constants.NPM, constants.PNPM, 'ts', 'tsx', 'typescript']);
|
|
4446
4466
|
function argvToArray(argvObj) {
|
|
4447
4467
|
if (argvObj['help']) {
|
|
4448
4468
|
return ['--help'];
|
|
@@ -4485,29 +4505,29 @@ async function runCdxgen(argvObj) {
|
|
|
4485
4505
|
};
|
|
4486
4506
|
const shadowOpts = {
|
|
4487
4507
|
ipc: {
|
|
4488
|
-
[constants.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
|
|
4489
|
-
[constants.SOCKET_CLI_SHADOW_API_TOKEN]: constants.SOCKET_PUBLIC_API_TOKEN,
|
|
4490
|
-
[constants.SOCKET_CLI_SHADOW_SILENT]: true
|
|
4508
|
+
[constants.default.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
|
|
4509
|
+
[constants.default.SOCKET_CLI_SHADOW_API_TOKEN]: constants.default.SOCKET_PUBLIC_API_TOKEN,
|
|
4510
|
+
[constants.default.SOCKET_CLI_SHADOW_SILENT]: true
|
|
4491
4511
|
},
|
|
4492
4512
|
stdio: 'inherit'
|
|
4493
4513
|
};
|
|
4494
4514
|
if (argvMutable['type'] !== YARN && nodejsPlatformTypes.has(argvMutable['type']) && fs$1.existsSync(`./${YARN_LOCK}`)) {
|
|
4495
4515
|
if (fs$1.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
|
|
4496
|
-
argvMutable['type'] =
|
|
4516
|
+
argvMutable['type'] = constants.NPM;
|
|
4497
4517
|
} else {
|
|
4498
4518
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
4499
4519
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
4500
4520
|
try {
|
|
4501
4521
|
const {
|
|
4502
4522
|
spawnPromise: synpPromise
|
|
4503
|
-
} = await shadowNpmBin('npx', ['--yes', `synp@${constants.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`], shadowOpts);
|
|
4523
|
+
} = await shadowNpmBin('npx', ['--yes', `synp@${constants.default.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`], shadowOpts);
|
|
4504
4524
|
await synpPromise;
|
|
4505
|
-
argvMutable['type'] =
|
|
4525
|
+
argvMutable['type'] = constants.NPM;
|
|
4506
4526
|
cleanupPackageLock = true;
|
|
4507
4527
|
} catch {}
|
|
4508
4528
|
}
|
|
4509
4529
|
}
|
|
4510
|
-
const shadowResult = await shadowNpmBin('npx', ['--yes', `@cyclonedx/cdxgen@${constants.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
|
|
4530
|
+
const shadowResult = await shadowNpmBin('npx', ['--yes', `@cyclonedx/cdxgen@${constants.default.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
|
|
4511
4531
|
shadowResult.spawnPromise.process.on('exit', () => {
|
|
4512
4532
|
if (cleanupPackageLock) {
|
|
4513
4533
|
try {
|
|
@@ -4770,7 +4790,7 @@ async function run$D(argv, importMeta, {
|
|
|
4770
4790
|
return;
|
|
4771
4791
|
}
|
|
4772
4792
|
if (dryRun) {
|
|
4773
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4793
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4774
4794
|
return;
|
|
4775
4795
|
}
|
|
4776
4796
|
|
|
@@ -4878,7 +4898,7 @@ async function run$C(argv, importMeta, {
|
|
|
4878
4898
|
detected
|
|
4879
4899
|
});
|
|
4880
4900
|
if (dryRun) {
|
|
4881
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4901
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4882
4902
|
return;
|
|
4883
4903
|
}
|
|
4884
4904
|
if (!detected.count) {
|
|
@@ -5041,7 +5061,7 @@ async function run$B(argv, importMeta, {
|
|
|
5041
5061
|
}
|
|
5042
5062
|
logger.logger.warn('Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk.');
|
|
5043
5063
|
if (dryRun) {
|
|
5044
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5064
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5045
5065
|
return;
|
|
5046
5066
|
}
|
|
5047
5067
|
await handleManifestConda({
|
|
@@ -5192,7 +5212,7 @@ async function run$A(argv, importMeta, {
|
|
|
5192
5212
|
logger.logger.groupEnd();
|
|
5193
5213
|
}
|
|
5194
5214
|
if (dryRun) {
|
|
5195
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5215
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5196
5216
|
return;
|
|
5197
5217
|
}
|
|
5198
5218
|
await convertGradleToMaven({
|
|
@@ -5347,7 +5367,7 @@ async function run$z(argv, importMeta, {
|
|
|
5347
5367
|
logger.logger.groupEnd();
|
|
5348
5368
|
}
|
|
5349
5369
|
if (dryRun) {
|
|
5350
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5370
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5351
5371
|
return;
|
|
5352
5372
|
}
|
|
5353
5373
|
await convertGradleToMaven({
|
|
@@ -5525,7 +5545,7 @@ async function run$y(argv, importMeta, {
|
|
|
5525
5545
|
logger.logger.groupEnd();
|
|
5526
5546
|
}
|
|
5527
5547
|
if (dryRun) {
|
|
5528
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5548
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5529
5549
|
return;
|
|
5530
5550
|
}
|
|
5531
5551
|
await convertSbtToMaven({
|
|
@@ -6007,7 +6027,7 @@ async function run$x(argv, importMeta, {
|
|
|
6007
6027
|
// If given path is absolute then cwd should not affect it.
|
|
6008
6028
|
cwd = path.resolve(process.cwd(), cwd);
|
|
6009
6029
|
if (dryRun) {
|
|
6010
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6030
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6011
6031
|
return;
|
|
6012
6032
|
}
|
|
6013
6033
|
await handleManifestSetup(cwd, Boolean(defaultOnReadError));
|
|
@@ -6053,7 +6073,7 @@ async function run$w(argv, importMeta, {
|
|
|
6053
6073
|
}
|
|
6054
6074
|
|
|
6055
6075
|
const require$3 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6056
|
-
const CMD_NAME$p =
|
|
6076
|
+
const CMD_NAME$p = constants.NPM;
|
|
6057
6077
|
const description$u = 'Run npm with the Socket wrapper';
|
|
6058
6078
|
const hidden$o = false;
|
|
6059
6079
|
const cmdNpm = {
|
|
@@ -6096,14 +6116,14 @@ async function run$v(argv, importMeta, {
|
|
|
6096
6116
|
});
|
|
6097
6117
|
const dryRun = !!cli.flags['dryRun'];
|
|
6098
6118
|
if (dryRun) {
|
|
6099
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6119
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6100
6120
|
return;
|
|
6101
6121
|
}
|
|
6102
|
-
const shadowBin = /*@__PURE__*/require$3(constants.shadowNpmBinPath);
|
|
6122
|
+
const shadowBin = /*@__PURE__*/require$3(constants.default.shadowNpmBinPath);
|
|
6103
6123
|
process.exitCode = 1;
|
|
6104
6124
|
const {
|
|
6105
6125
|
spawnPromise
|
|
6106
|
-
} = await shadowBin(
|
|
6126
|
+
} = await shadowBin(constants.NPM, argv, {
|
|
6107
6127
|
stdio: 'inherit'
|
|
6108
6128
|
});
|
|
6109
6129
|
|
|
@@ -6120,7 +6140,7 @@ async function run$v(argv, importMeta, {
|
|
|
6120
6140
|
}
|
|
6121
6141
|
|
|
6122
6142
|
const require$2 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6123
|
-
const CMD_NAME$o =
|
|
6143
|
+
const CMD_NAME$o = constants.NPX;
|
|
6124
6144
|
const description$t = 'Run npx with the Socket wrapper';
|
|
6125
6145
|
const hidden$n = false;
|
|
6126
6146
|
const cmdNpx = {
|
|
@@ -6162,14 +6182,14 @@ async function run$u(argv, importMeta, {
|
|
|
6162
6182
|
});
|
|
6163
6183
|
const dryRun = !!cli.flags['dryRun'];
|
|
6164
6184
|
if (dryRun) {
|
|
6165
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6185
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6166
6186
|
return;
|
|
6167
6187
|
}
|
|
6168
|
-
const shadowBin = /*@__PURE__*/require$2(constants.shadowNpmBinPath);
|
|
6188
|
+
const shadowBin = /*@__PURE__*/require$2(constants.default.shadowNpmBinPath);
|
|
6169
6189
|
process.exitCode = 1;
|
|
6170
6190
|
const {
|
|
6171
6191
|
spawnPromise
|
|
6172
|
-
} = await shadowBin(
|
|
6192
|
+
} = await shadowBin(constants.NPX, argv, {
|
|
6173
6193
|
stdio: 'inherit'
|
|
6174
6194
|
});
|
|
6175
6195
|
|
|
@@ -6226,7 +6246,7 @@ async function run$t(argv, importMeta, {
|
|
|
6226
6246
|
} = cli.flags;
|
|
6227
6247
|
const dryRun = !!cli.flags['dryRun'];
|
|
6228
6248
|
if (dryRun) {
|
|
6229
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6249
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6230
6250
|
return;
|
|
6231
6251
|
}
|
|
6232
6252
|
if (json && !justThrow) {
|
|
@@ -6252,7 +6272,7 @@ const {
|
|
|
6252
6272
|
VLT: VLT$5,
|
|
6253
6273
|
YARN_BERRY: YARN_BERRY$4,
|
|
6254
6274
|
YARN_CLASSIC: YARN_CLASSIC$4
|
|
6255
|
-
} = constants;
|
|
6275
|
+
} = constants.default;
|
|
6256
6276
|
function matchLsCmdViewHumanStdout(stdout, name) {
|
|
6257
6277
|
return stdout.includes(` ${name}@`);
|
|
6258
6278
|
}
|
|
@@ -6306,7 +6326,7 @@ const {
|
|
|
6306
6326
|
VLT: VLT$4,
|
|
6307
6327
|
YARN_BERRY: YARN_BERRY$3,
|
|
6308
6328
|
YARN_CLASSIC: YARN_CLASSIC$3
|
|
6309
|
-
} = constants;
|
|
6329
|
+
} = constants.default;
|
|
6310
6330
|
function getOverridesDataBun(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
|
|
6311
6331
|
const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
|
|
6312
6332
|
return {
|
|
@@ -6381,13 +6401,13 @@ function getOverridesData(pkgEnvDetails, pkgJson) {
|
|
|
6381
6401
|
|
|
6382
6402
|
const {
|
|
6383
6403
|
BUN: BUN$2,
|
|
6384
|
-
|
|
6404
|
+
EXT_LOCK,
|
|
6385
6405
|
NPM: NPM$2,
|
|
6386
6406
|
PNPM: PNPM$2,
|
|
6387
6407
|
VLT: VLT$3,
|
|
6388
6408
|
YARN_BERRY: YARN_BERRY$2,
|
|
6389
6409
|
YARN_CLASSIC: YARN_CLASSIC$2
|
|
6390
|
-
} = constants;
|
|
6410
|
+
} = constants.default;
|
|
6391
6411
|
function npmLockSrcIncludes(lockSrc, name) {
|
|
6392
6412
|
// Detects the package name in the following cases:
|
|
6393
6413
|
// "name":
|
|
@@ -6398,7 +6418,7 @@ function bunLockSrcIncludes(lockSrc, name, lockName) {
|
|
|
6398
6418
|
// we treat it as a yarn.lock. When lockName ends with a .lock we
|
|
6399
6419
|
// treat it as a package-lock.json. The bun.lock format is not identical
|
|
6400
6420
|
// package-lock.json, however it close enough for npmLockIncludes to work.
|
|
6401
|
-
const lockfileScanner = lockName?.endsWith(
|
|
6421
|
+
const lockfileScanner = lockName?.endsWith(EXT_LOCK) ? npmLockSrcIncludes : yarnLockSrcIncludes;
|
|
6402
6422
|
return lockfileScanner(lockSrc, name);
|
|
6403
6423
|
}
|
|
6404
6424
|
function pnpmLockSrcIncludes(lockSrc, name) {
|
|
@@ -6453,7 +6473,7 @@ const {
|
|
|
6453
6473
|
VLT: VLT$2,
|
|
6454
6474
|
YARN_BERRY: YARN_BERRY$1,
|
|
6455
6475
|
YARN_CLASSIC: YARN_CLASSIC$1
|
|
6456
|
-
} = constants;
|
|
6476
|
+
} = constants.default;
|
|
6457
6477
|
function cleanupQueryStdout(stdout) {
|
|
6458
6478
|
if (stdout === '') {
|
|
6459
6479
|
return '';
|
|
@@ -6499,7 +6519,7 @@ async function npmQuery(npmExecPath, cwd) {
|
|
|
6499
6519
|
try {
|
|
6500
6520
|
stdout = (await spawn.spawn(npmExecPath, ['query', ':not(.dev)'], {
|
|
6501
6521
|
cwd,
|
|
6502
|
-
shell: constants.WIN32
|
|
6522
|
+
shell: constants.default.WIN32
|
|
6503
6523
|
})).stdout;
|
|
6504
6524
|
} catch {}
|
|
6505
6525
|
return cleanupQueryStdout(stdout);
|
|
@@ -6516,7 +6536,7 @@ async function lsBun(pkgEnvDetails, options) {
|
|
|
6516
6536
|
// https://github.com/oven-sh/bun/issues/8283
|
|
6517
6537
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['pm', 'ls', '--all'], {
|
|
6518
6538
|
cwd,
|
|
6519
|
-
shell: constants.WIN32
|
|
6539
|
+
shell: constants.default.WIN32
|
|
6520
6540
|
})).stdout;
|
|
6521
6541
|
} catch {}
|
|
6522
6542
|
return '';
|
|
@@ -6551,7 +6571,7 @@ async function lsPnpm(pkgEnvDetails, options) {
|
|
|
6551
6571
|
// https://en.wiktionary.org/wiki/parsable
|
|
6552
6572
|
['ls', '--parseable', '--prod', '--depth', 'Infinity'], {
|
|
6553
6573
|
cwd,
|
|
6554
|
-
shell: constants.WIN32
|
|
6574
|
+
shell: constants.default.WIN32
|
|
6555
6575
|
})).stdout;
|
|
6556
6576
|
} catch {}
|
|
6557
6577
|
return parsableToQueryStdout(stdout);
|
|
@@ -6568,7 +6588,7 @@ async function lsVlt(pkgEnvDetails, options) {
|
|
|
6568
6588
|
// See https://docs.vlt.sh/cli/commands/list#options.
|
|
6569
6589
|
stdout = (await spawn.spawn(pkgEnvDetails.agentExecPath, ['ls', '--view', 'human', ':not(.dev)'], {
|
|
6570
6590
|
cwd,
|
|
6571
|
-
shell: constants.WIN32
|
|
6591
|
+
shell: constants.default.WIN32
|
|
6572
6592
|
})).stdout;
|
|
6573
6593
|
} catch {}
|
|
6574
6594
|
return cleanupQueryStdout(stdout);
|
|
@@ -6585,7 +6605,7 @@ async function lsYarnBerry(pkgEnvDetails, options) {
|
|
|
6585
6605
|
// https://github.com/yarnpkg/berry/issues/5117
|
|
6586
6606
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['info', '--recursive', '--name-only'], {
|
|
6587
6607
|
cwd,
|
|
6588
|
-
shell: constants.WIN32
|
|
6608
|
+
shell: constants.default.WIN32
|
|
6589
6609
|
})).stdout;
|
|
6590
6610
|
} catch {}
|
|
6591
6611
|
return '';
|
|
@@ -6604,7 +6624,7 @@ async function lsYarnClassic(pkgEnvDetails, options) {
|
|
|
6604
6624
|
// environment is production
|
|
6605
6625
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['list', '--prod'], {
|
|
6606
6626
|
cwd,
|
|
6607
|
-
shell: constants.WIN32
|
|
6627
|
+
shell: constants.default.WIN32
|
|
6608
6628
|
})).stdout;
|
|
6609
6629
|
} catch {}
|
|
6610
6630
|
return '';
|
|
@@ -6638,7 +6658,7 @@ const {
|
|
|
6638
6658
|
VLT: VLT$1,
|
|
6639
6659
|
YARN_BERRY,
|
|
6640
6660
|
YARN_CLASSIC
|
|
6641
|
-
} = constants;
|
|
6661
|
+
} = constants.default;
|
|
6642
6662
|
const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'peerDependenciesMeta', 'optionalDependencies', 'bundleDependencies'];
|
|
6643
6663
|
function getEntryIndexes(entries, keys) {
|
|
6644
6664
|
return keys.map(n => entries.findIndex(p => p[0] === n)).filter(n => n !== -1).sort((a, b) => a - b);
|
|
@@ -6763,7 +6783,7 @@ function updateManifest(agent, editablePkgJson, overrides) {
|
|
|
6763
6783
|
}
|
|
6764
6784
|
}
|
|
6765
6785
|
|
|
6766
|
-
const manifestNpmOverrides = registry.getManifestData(
|
|
6786
|
+
const manifestNpmOverrides = registry.getManifestData(constants.NPM);
|
|
6767
6787
|
async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
6768
6788
|
const {
|
|
6769
6789
|
agent,
|
|
@@ -6789,14 +6809,14 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6789
6809
|
...options
|
|
6790
6810
|
};
|
|
6791
6811
|
const workspacePkgJsonPaths = await utils.globWorkspace(agent, pkgPath);
|
|
6792
|
-
const isPnpm = agent ===
|
|
6812
|
+
const isPnpm = agent === constants.PNPM;
|
|
6793
6813
|
const isWorkspace = workspacePkgJsonPaths.length > 0;
|
|
6794
6814
|
const isWorkspaceRoot = pkgPath === rootPath;
|
|
6795
6815
|
const isLockScanned = isWorkspaceRoot && !prod;
|
|
6796
6816
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
6797
6817
|
if (isWorkspace && isPnpm &&
|
|
6798
6818
|
// npmExecPath will === the agent name IF it CANNOT be resolved.
|
|
6799
|
-
npmExecPath ===
|
|
6819
|
+
npmExecPath === constants.NPM && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
6800
6820
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
6801
6821
|
spinner?.stop();
|
|
6802
6822
|
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$n, `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``));
|
|
@@ -6885,7 +6905,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6885
6905
|
const sockRegDepAlias = depAliasMap.get(sockRegPkgName);
|
|
6886
6906
|
const depAlias = sockRegDepAlias ?? origDepAlias;
|
|
6887
6907
|
let newSpec = sockOverrideSpec;
|
|
6888
|
-
if (type ===
|
|
6908
|
+
if (type === constants.NPM && depAlias) {
|
|
6889
6909
|
// With npm one may not set an override for a package that one directly
|
|
6890
6910
|
// depends on unless both the dependency and the override itself share
|
|
6891
6911
|
// the exact same spec. To make this limitation easier to deal with,
|
|
@@ -6965,7 +6985,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6965
6985
|
|
|
6966
6986
|
const {
|
|
6967
6987
|
NPM_BUGGY_OVERRIDES_PATCHED_VERSION
|
|
6968
|
-
} = constants;
|
|
6988
|
+
} = constants.default;
|
|
6969
6989
|
async function updateLockfile(pkgEnvDetails, options) {
|
|
6970
6990
|
const {
|
|
6971
6991
|
cmdName = '',
|
|
@@ -7016,7 +7036,7 @@ async function applyOptimization(pkgEnvDetails, {
|
|
|
7016
7036
|
}) {
|
|
7017
7037
|
const {
|
|
7018
7038
|
spinner
|
|
7019
|
-
} = constants;
|
|
7039
|
+
} = constants.default;
|
|
7020
7040
|
spinner.start();
|
|
7021
7041
|
const state = await addOverrides(pkgEnvDetails, pkgEnvDetails.pkgPath, {
|
|
7022
7042
|
logger: logger.logger,
|
|
@@ -7083,7 +7103,7 @@ function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
|
7083
7103
|
|
|
7084
7104
|
const {
|
|
7085
7105
|
VLT
|
|
7086
|
-
} = constants;
|
|
7106
|
+
} = constants.default;
|
|
7087
7107
|
async function handleOptimize({
|
|
7088
7108
|
cwd,
|
|
7089
7109
|
outputKind,
|
|
@@ -7178,7 +7198,7 @@ async function run$s(argv, importMeta, {
|
|
|
7178
7198
|
});
|
|
7179
7199
|
const dryRun = !!cli.flags['dryRun'];
|
|
7180
7200
|
if (dryRun) {
|
|
7181
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7201
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7182
7202
|
return;
|
|
7183
7203
|
}
|
|
7184
7204
|
const {
|
|
@@ -7223,7 +7243,7 @@ async function fetchDependencies(config, options) {
|
|
|
7223
7243
|
limit,
|
|
7224
7244
|
offset
|
|
7225
7245
|
}), {
|
|
7226
|
-
|
|
7246
|
+
description: 'organization dependencies'
|
|
7227
7247
|
});
|
|
7228
7248
|
}
|
|
7229
7249
|
|
|
@@ -7377,7 +7397,7 @@ async function run$r(argv, importMeta, {
|
|
|
7377
7397
|
return;
|
|
7378
7398
|
}
|
|
7379
7399
|
if (dryRun) {
|
|
7380
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7400
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7381
7401
|
return;
|
|
7382
7402
|
}
|
|
7383
7403
|
await handleDependencies({
|
|
@@ -7400,7 +7420,7 @@ async function fetchLicensePolicy(orgSlug, options) {
|
|
|
7400
7420
|
}
|
|
7401
7421
|
const sockSdk = sockSdkCResult.data;
|
|
7402
7422
|
return await utils.handleApiCall(sockSdk.getOrgLicensePolicy(orgSlug), {
|
|
7403
|
-
|
|
7423
|
+
description: 'organization license policy'
|
|
7404
7424
|
});
|
|
7405
7425
|
}
|
|
7406
7426
|
|
|
@@ -7497,7 +7517,9 @@ async function run$q(argv, importMeta, {
|
|
|
7497
7517
|
const dryRun = !!cli.flags['dryRun'];
|
|
7498
7518
|
const interactive = !!cli.flags['interactive'];
|
|
7499
7519
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
7500
|
-
const
|
|
7520
|
+
const {
|
|
7521
|
+
0: orgSlug
|
|
7522
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
7501
7523
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
7502
7524
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
7503
7525
|
nook: true,
|
|
@@ -7514,7 +7536,7 @@ async function run$q(argv, importMeta, {
|
|
|
7514
7536
|
return;
|
|
7515
7537
|
}
|
|
7516
7538
|
if (dryRun) {
|
|
7517
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7539
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7518
7540
|
return;
|
|
7519
7541
|
}
|
|
7520
7542
|
await handleLicensePolicy(orgSlug, outputKind);
|
|
@@ -7533,7 +7555,7 @@ async function fetchSecurityPolicy(orgSlug, options) {
|
|
|
7533
7555
|
}
|
|
7534
7556
|
const sockSdk = sockSdkCResult.data;
|
|
7535
7557
|
return await utils.handleApiCall(sockSdk.getOrgSecurityPolicy(orgSlug), {
|
|
7536
|
-
|
|
7558
|
+
description: 'organization security policy'
|
|
7537
7559
|
});
|
|
7538
7560
|
}
|
|
7539
7561
|
|
|
@@ -7631,7 +7653,9 @@ async function run$p(argv, importMeta, {
|
|
|
7631
7653
|
const dryRun = !!cli.flags['dryRun'];
|
|
7632
7654
|
const interactive = !!cli.flags['interactive'];
|
|
7633
7655
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
7634
|
-
const
|
|
7656
|
+
const {
|
|
7657
|
+
0: orgSlug
|
|
7658
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
7635
7659
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
7636
7660
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
7637
7661
|
nook: true,
|
|
@@ -7648,7 +7672,7 @@ async function run$p(argv, importMeta, {
|
|
|
7648
7672
|
return;
|
|
7649
7673
|
}
|
|
7650
7674
|
if (dryRun) {
|
|
7651
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7675
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7652
7676
|
return;
|
|
7653
7677
|
}
|
|
7654
7678
|
await handleSecurityPolicy(orgSlug, outputKind);
|
|
@@ -7768,7 +7792,7 @@ async function run$o(argv, importMeta, {
|
|
|
7768
7792
|
return;
|
|
7769
7793
|
}
|
|
7770
7794
|
if (dryRun) {
|
|
7771
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7795
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7772
7796
|
return;
|
|
7773
7797
|
}
|
|
7774
7798
|
await handleOrganizationList(outputKind);
|
|
@@ -7812,7 +7836,7 @@ async function fetchQuota(options) {
|
|
|
7812
7836
|
}
|
|
7813
7837
|
const sockSdk = sockSdkCResult.data;
|
|
7814
7838
|
return await utils.handleApiCall(sockSdk.getQuota(), {
|
|
7815
|
-
|
|
7839
|
+
description: 'token quota'
|
|
7816
7840
|
});
|
|
7817
7841
|
}
|
|
7818
7842
|
|
|
@@ -7898,7 +7922,7 @@ async function run$n(argv, importMeta, {
|
|
|
7898
7922
|
return;
|
|
7899
7923
|
}
|
|
7900
7924
|
if (dryRun) {
|
|
7901
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7925
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7902
7926
|
return;
|
|
7903
7927
|
}
|
|
7904
7928
|
await handleQuota(outputKind);
|
|
@@ -8256,7 +8280,7 @@ async function run$m(argv, importMeta, {
|
|
|
8256
8280
|
return;
|
|
8257
8281
|
}
|
|
8258
8282
|
if (dryRun) {
|
|
8259
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
8283
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
8260
8284
|
return;
|
|
8261
8285
|
}
|
|
8262
8286
|
await handlePurlDeepScore(purls[0] || '', outputKind);
|
|
@@ -8282,7 +8306,7 @@ async function fetchPurlsShallowScore(purls, options) {
|
|
|
8282
8306
|
}, {
|
|
8283
8307
|
alerts: 'true'
|
|
8284
8308
|
}), {
|
|
8285
|
-
|
|
8309
|
+
description: 'looking up package'
|
|
8286
8310
|
});
|
|
8287
8311
|
if (!batchPackageCResult.ok) {
|
|
8288
8312
|
return batchPackageCResult;
|
|
@@ -8638,7 +8662,7 @@ async function run$l(argv, importMeta, {
|
|
|
8638
8662
|
return;
|
|
8639
8663
|
}
|
|
8640
8664
|
if (dryRun) {
|
|
8641
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
8665
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
8642
8666
|
return;
|
|
8643
8667
|
}
|
|
8644
8668
|
await handlePurlsShallowScore({
|
|
@@ -8701,7 +8725,7 @@ async function outputPatchResult(result, outputKind) {
|
|
|
8701
8725
|
if (!result.ok) {
|
|
8702
8726
|
process.exitCode = result.code ?? 1;
|
|
8703
8727
|
}
|
|
8704
|
-
if (outputKind ===
|
|
8728
|
+
if (outputKind === constants.OUTPUT_JSON) {
|
|
8705
8729
|
logger.logger.log(utils.serializeResultJson(result));
|
|
8706
8730
|
return;
|
|
8707
8731
|
}
|
|
@@ -8710,271 +8734,316 @@ async function outputPatchResult(result, outputKind) {
|
|
|
8710
8734
|
return;
|
|
8711
8735
|
}
|
|
8712
8736
|
const {
|
|
8713
|
-
|
|
8737
|
+
patched
|
|
8714
8738
|
} = result.data;
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8739
|
+
logger.logger.log('');
|
|
8740
|
+
if (patched.length) {
|
|
8741
|
+
logger.logger.group(`Successfully processed patches for ${patched.length} ${words.pluralize('package', patched.length)}:`);
|
|
8742
|
+
for (const pkg of patched) {
|
|
8718
8743
|
logger.logger.success(pkg);
|
|
8719
8744
|
}
|
|
8745
|
+
logger.logger.groupEnd();
|
|
8720
8746
|
} else {
|
|
8721
|
-
logger.logger.
|
|
8747
|
+
logger.logger.warn('No packages found requiring patches');
|
|
8722
8748
|
}
|
|
8723
8749
|
logger.logger.log('');
|
|
8724
8750
|
logger.logger.success('Patch command completed!');
|
|
8725
8751
|
}
|
|
8726
8752
|
|
|
8727
|
-
async function
|
|
8753
|
+
async function applyNpmPatches(socketDir, patches, options) {
|
|
8754
|
+
const {
|
|
8755
|
+
cwd = process.cwd(),
|
|
8756
|
+
dryRun = false,
|
|
8757
|
+
purlObjs,
|
|
8758
|
+
spinner
|
|
8759
|
+
} = {
|
|
8760
|
+
__proto__: null,
|
|
8761
|
+
...options
|
|
8762
|
+
};
|
|
8763
|
+
const wasSpinning = !!spinner?.isSpinning;
|
|
8764
|
+
spinner?.start();
|
|
8728
8765
|
const patchLookup = new Map();
|
|
8729
8766
|
for (const patchInfo of patches) {
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
const
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8767
|
+
patchLookup.set(patchInfo.purl, patchInfo);
|
|
8768
|
+
}
|
|
8769
|
+
const nmPaths = await findNodeModulesPaths(cwd);
|
|
8770
|
+
spinner?.stop();
|
|
8771
|
+
logger.logger.log(`Found ${nmPaths.length} ${constants.NODE_MODULES} ${words.pluralize('folder', nmPaths.length)}`);
|
|
8772
|
+
logger.logger.group('');
|
|
8773
|
+
spinner?.start();
|
|
8774
|
+
const result = {
|
|
8775
|
+
passed: [],
|
|
8776
|
+
failed: []
|
|
8777
|
+
};
|
|
8778
|
+
for (const nmPath of nmPaths) {
|
|
8779
|
+
// eslint-disable-next-line no-await-in-loop
|
|
8780
|
+
const dirNames = await fs$2.readDirNames(nmPath);
|
|
8781
|
+
for (const dirName of dirNames) {
|
|
8782
|
+
const isScoped = dirName.startsWith('@');
|
|
8783
|
+
const pkgPath = path.join(nmPath, dirName);
|
|
8784
|
+
const pkgSubNames = isScoped ?
|
|
8741
8785
|
// eslint-disable-next-line no-await-in-loop
|
|
8742
|
-
|
|
8743
|
-
for (const
|
|
8744
|
-
const
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8786
|
+
await fs$2.readDirNames(pkgPath) : [dirName];
|
|
8787
|
+
for (const pkgSubName of pkgSubNames) {
|
|
8788
|
+
const dirFullName = isScoped ? `${dirName}/${pkgSubName}` : pkgSubName;
|
|
8789
|
+
const pkgPath = path.join(nmPath, dirFullName);
|
|
8790
|
+
// eslint-disable-next-line no-await-in-loop
|
|
8791
|
+
const pkgJson = await packages.readPackageJson(pkgPath, {
|
|
8792
|
+
throws: false
|
|
8793
|
+
});
|
|
8794
|
+
if (!strings.isNonEmptyString(pkgJson?.name) || !strings.isNonEmptyString(pkgJson?.version)) {
|
|
8795
|
+
continue;
|
|
8796
|
+
}
|
|
8797
|
+
const purl = `pkg:npm/${pkgJson.name}@${pkgJson.version}`;
|
|
8798
|
+
const purlObj = utils.getPurlObject(purl, {
|
|
8799
|
+
throws: false
|
|
8800
|
+
});
|
|
8801
|
+
if (!purlObj) {
|
|
8802
|
+
continue;
|
|
8803
|
+
}
|
|
8804
|
+
|
|
8805
|
+
// Skip if specific packages requested and this isn't one of them
|
|
8806
|
+
if (purlObjs?.length && purlObjs.findIndex(p => p.type === constants.NPM && p.namespace === purlObj.namespace && p.name === purlObj.name) === -1) {
|
|
8807
|
+
continue;
|
|
8808
|
+
}
|
|
8809
|
+
const patchInfo = patchLookup.get(purl);
|
|
8810
|
+
if (!patchInfo) {
|
|
8811
|
+
continue;
|
|
8812
|
+
}
|
|
8813
|
+
spinner?.stop();
|
|
8814
|
+
logger.logger.log(`Found match: ${pkgJson.name}@${pkgJson.version} at ${pkgPath}`);
|
|
8815
|
+
logger.logger.log(`Patch key: ${patchInfo.key}`);
|
|
8816
|
+
logger.logger.group(`Processing files:`);
|
|
8817
|
+
spinner?.start();
|
|
8818
|
+
let passed = true;
|
|
8819
|
+
for (const {
|
|
8820
|
+
0: fileName,
|
|
8821
|
+
1: fileInfo
|
|
8822
|
+
} of Object.entries(patchInfo.patch.files)) {
|
|
8775
8823
|
// eslint-disable-next-line no-await-in-loop
|
|
8776
|
-
const
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
const lookupKey = `${pkg.name}@${pkg.version}`;
|
|
8783
|
-
const patchInfo = patchLookup.get(lookupKey);
|
|
8784
|
-
if (patchInfo) {
|
|
8785
|
-
logger.logger.log(`Found match: ${pkg.name}@${pkg.version} at ${entryPath}`);
|
|
8786
|
-
logger.logger.log(` Patch key: ${patchInfo.key}`);
|
|
8787
|
-
logger.logger.log(` Processing files:`);
|
|
8788
|
-
for (const [fileName, fileInfo] of Object.entries(patchInfo.patch.files)) {
|
|
8789
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8790
|
-
await processFilePatch(entryPath, fileName, fileInfo, dryRun, socketDir);
|
|
8791
|
-
}
|
|
8792
|
-
}
|
|
8824
|
+
const filePatchPassed = await processFilePatch(pkgPath, fileName, fileInfo, socketDir, {
|
|
8825
|
+
dryRun,
|
|
8826
|
+
spinner
|
|
8827
|
+
});
|
|
8828
|
+
if (!filePatchPassed) {
|
|
8829
|
+
passed = false;
|
|
8793
8830
|
}
|
|
8794
8831
|
}
|
|
8832
|
+
logger.logger.groupEnd();
|
|
8833
|
+
if (passed) {
|
|
8834
|
+
result.passed.push(purl);
|
|
8835
|
+
} else {
|
|
8836
|
+
result.failed.push(purl);
|
|
8837
|
+
}
|
|
8795
8838
|
}
|
|
8796
|
-
} catch (error) {
|
|
8797
|
-
logger.logger.error(`Error processing ${nodeModulesPath}:`, error);
|
|
8798
8839
|
}
|
|
8799
8840
|
}
|
|
8841
|
+
spinner?.stop();
|
|
8842
|
+
logger.logger.groupEnd();
|
|
8843
|
+
if (wasSpinning) {
|
|
8844
|
+
spinner.start();
|
|
8845
|
+
}
|
|
8846
|
+
return result;
|
|
8800
8847
|
}
|
|
8801
|
-
async function computeSHA256(
|
|
8848
|
+
async function computeSHA256(filepath) {
|
|
8802
8849
|
try {
|
|
8803
|
-
const content = await fs$1.promises.readFile(
|
|
8850
|
+
const content = await fs$1.promises.readFile(filepath);
|
|
8804
8851
|
const hash = require$$0$1.createHash('sha256');
|
|
8805
8852
|
hash.update(content);
|
|
8806
8853
|
return hash.digest('hex');
|
|
8807
|
-
} catch {
|
|
8808
|
-
|
|
8809
|
-
}
|
|
8854
|
+
} catch {}
|
|
8855
|
+
return null;
|
|
8810
8856
|
}
|
|
8811
|
-
async function
|
|
8812
|
-
const
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
continue;
|
|
8819
|
-
}
|
|
8820
|
-
const fullPath = path.join(dir, entry);
|
|
8821
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8822
|
-
const stats = await fs$1.promises.stat(fullPath);
|
|
8823
|
-
if (stats.isDirectory()) {
|
|
8824
|
-
if (entry === 'node_modules') {
|
|
8825
|
-
nodeModulesPaths.push(fullPath);
|
|
8826
|
-
} else {
|
|
8827
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8828
|
-
await searchDir(fullPath);
|
|
8829
|
-
}
|
|
8830
|
-
}
|
|
8831
|
-
}
|
|
8832
|
-
} catch (error) {
|
|
8833
|
-
// Ignore permission errors or missing directories
|
|
8834
|
-
}
|
|
8835
|
-
}
|
|
8836
|
-
await searchDir(rootDir);
|
|
8837
|
-
return nodeModulesPaths;
|
|
8838
|
-
}
|
|
8839
|
-
function parsePURL(purlString) {
|
|
8840
|
-
const [ecosystem, rest] = purlString.split(':', 2);
|
|
8841
|
-
const [nameAndNamespace, version] = (rest ?? '').split('@', 2);
|
|
8842
|
-
let namespace;
|
|
8843
|
-
let name;
|
|
8844
|
-
if (ecosystem === 'npm' && nameAndNamespace?.startsWith('@')) {
|
|
8845
|
-
const parts = nameAndNamespace.split('/');
|
|
8846
|
-
namespace = parts[0]?.substring(1);
|
|
8847
|
-
name = parts.slice(1).join('/');
|
|
8848
|
-
} else {
|
|
8849
|
-
name = nameAndNamespace ?? '';
|
|
8857
|
+
async function findNodeModulesPaths(cwd) {
|
|
8858
|
+
const rootNmPath = await utils.findUp(constants.NODE_MODULES, {
|
|
8859
|
+
cwd,
|
|
8860
|
+
onlyDirectories: true
|
|
8861
|
+
});
|
|
8862
|
+
if (!rootNmPath) {
|
|
8863
|
+
return [];
|
|
8850
8864
|
}
|
|
8851
|
-
return {
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
};
|
|
8865
|
+
return await vendor.outExports.glob([`**/${constants.NODE_MODULES}`], {
|
|
8866
|
+
absolute: true,
|
|
8867
|
+
cwd: path.dirname(rootNmPath),
|
|
8868
|
+
dot: true,
|
|
8869
|
+
onlyDirectories: true
|
|
8870
|
+
});
|
|
8857
8871
|
}
|
|
8858
|
-
async function processFilePatch(
|
|
8859
|
-
const
|
|
8860
|
-
|
|
8872
|
+
async function processFilePatch(pkgPath, fileName, fileInfo, socketDir, options) {
|
|
8873
|
+
const {
|
|
8874
|
+
dryRun,
|
|
8875
|
+
spinner
|
|
8876
|
+
} = {
|
|
8877
|
+
__proto__: null,
|
|
8878
|
+
...options
|
|
8879
|
+
};
|
|
8880
|
+
const wasSpinning = !!spinner?.isSpinning;
|
|
8881
|
+
spinner?.stop();
|
|
8882
|
+
const filepath = path.join(pkgPath, fileName);
|
|
8883
|
+
if (!fs$1.existsSync(filepath)) {
|
|
8861
8884
|
logger.logger.log(`File not found: ${fileName}`);
|
|
8862
|
-
|
|
8885
|
+
if (wasSpinning) {
|
|
8886
|
+
spinner?.start();
|
|
8887
|
+
}
|
|
8888
|
+
return false;
|
|
8863
8889
|
}
|
|
8864
|
-
const currentHash = await computeSHA256(
|
|
8890
|
+
const currentHash = await computeSHA256(filepath);
|
|
8865
8891
|
if (!currentHash) {
|
|
8866
8892
|
logger.logger.log(`Failed to compute hash for: ${fileName}`);
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
if (currentHash === fileInfo.beforeHash) {
|
|
8870
|
-
logger.logger.success(`File matches expected hash: ${fileName}`);
|
|
8871
|
-
logger.logger.log(`Current hash: ${currentHash}`);
|
|
8872
|
-
logger.logger.log(`Ready to patch to: ${fileInfo.afterHash}`);
|
|
8873
|
-
if (!dryRun) {
|
|
8874
|
-
const blobPath = path.join(socketDir, 'blobs', fileInfo.afterHash);
|
|
8875
|
-
if (!fs$1.existsSync(blobPath)) {
|
|
8876
|
-
logger.logger.fail(`Error: Patch file not found at ${blobPath}`);
|
|
8877
|
-
return;
|
|
8878
|
-
}
|
|
8879
|
-
try {
|
|
8880
|
-
await fs$1.promises.copyFile(blobPath, filePath);
|
|
8881
|
-
logger.logger.success(`Patch applied successfully`);
|
|
8882
|
-
} catch (error) {
|
|
8883
|
-
logger.logger.log(`Error applying patch: ${error}`);
|
|
8884
|
-
}
|
|
8885
|
-
} else {
|
|
8886
|
-
logger.logger.log(`(dry run - no changes made)`);
|
|
8893
|
+
if (wasSpinning) {
|
|
8894
|
+
spinner?.start();
|
|
8887
8895
|
}
|
|
8888
|
-
|
|
8896
|
+
return false;
|
|
8897
|
+
}
|
|
8898
|
+
if (currentHash === fileInfo.afterHash) {
|
|
8889
8899
|
logger.logger.success(`File already patched: ${fileName}`);
|
|
8900
|
+
logger.logger.group();
|
|
8890
8901
|
logger.logger.log(`Current hash: ${currentHash}`);
|
|
8891
|
-
|
|
8902
|
+
logger.logger.groupEnd();
|
|
8903
|
+
if (wasSpinning) {
|
|
8904
|
+
spinner?.start();
|
|
8905
|
+
}
|
|
8906
|
+
return true;
|
|
8907
|
+
}
|
|
8908
|
+
if (currentHash !== fileInfo.beforeHash) {
|
|
8892
8909
|
logger.logger.fail(`File hash mismatch: ${fileName}`);
|
|
8910
|
+
logger.logger.group();
|
|
8893
8911
|
logger.logger.log(`Expected: ${fileInfo.beforeHash}`);
|
|
8894
8912
|
logger.logger.log(`Current: ${currentHash}`);
|
|
8895
8913
|
logger.logger.log(`Target: ${fileInfo.afterHash}`);
|
|
8914
|
+
logger.logger.groupEnd();
|
|
8915
|
+
if (wasSpinning) {
|
|
8916
|
+
spinner?.start();
|
|
8917
|
+
}
|
|
8918
|
+
return false;
|
|
8896
8919
|
}
|
|
8897
|
-
}
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8920
|
+
logger.logger.success(`File matches expected hash: ${fileName}`);
|
|
8921
|
+
logger.logger.group();
|
|
8922
|
+
logger.logger.log(`Current hash: ${currentHash}`);
|
|
8923
|
+
logger.logger.log(`Ready to patch to: ${fileInfo.afterHash}`);
|
|
8924
|
+
logger.logger.group();
|
|
8925
|
+
if (dryRun) {
|
|
8926
|
+
logger.logger.log(`(dry run - no changes made)`);
|
|
8927
|
+
logger.logger.groupEnd();
|
|
8928
|
+
logger.logger.groupEnd();
|
|
8929
|
+
if (wasSpinning) {
|
|
8930
|
+
spinner?.start();
|
|
8931
|
+
}
|
|
8932
|
+
return false;
|
|
8908
8933
|
}
|
|
8909
|
-
|
|
8934
|
+
const blobPath = path.join(socketDir, 'blobs', fileInfo.afterHash);
|
|
8935
|
+
if (!fs$1.existsSync(blobPath)) {
|
|
8936
|
+
logger.logger.fail(`Error: Patch file not found at ${blobPath}`);
|
|
8937
|
+
logger.logger.groupEnd();
|
|
8938
|
+
logger.logger.groupEnd();
|
|
8939
|
+
if (wasSpinning) {
|
|
8940
|
+
spinner?.start();
|
|
8941
|
+
}
|
|
8942
|
+
return false;
|
|
8943
|
+
}
|
|
8944
|
+
spinner?.start();
|
|
8945
|
+
let result = true;
|
|
8946
|
+
try {
|
|
8947
|
+
await fs$1.promises.copyFile(blobPath, filepath);
|
|
8948
|
+
logger.logger.success(`Patch applied successfully`);
|
|
8949
|
+
} catch (e) {
|
|
8950
|
+
logger.logger.error('Error applying patch');
|
|
8951
|
+
require$$9.debugDir('inspect', {
|
|
8952
|
+
error: e
|
|
8953
|
+
});
|
|
8954
|
+
result = false;
|
|
8955
|
+
}
|
|
8956
|
+
logger.logger.groupEnd();
|
|
8957
|
+
logger.logger.groupEnd();
|
|
8958
|
+
spinner?.stop();
|
|
8959
|
+
if (wasSpinning) {
|
|
8960
|
+
spinner?.start();
|
|
8961
|
+
}
|
|
8962
|
+
return result;
|
|
8910
8963
|
}
|
|
8911
8964
|
async function handlePatch({
|
|
8912
8965
|
cwd,
|
|
8913
8966
|
dryRun,
|
|
8914
8967
|
outputKind,
|
|
8915
|
-
|
|
8968
|
+
purlObjs,
|
|
8916
8969
|
spinner
|
|
8917
8970
|
}) {
|
|
8918
8971
|
try {
|
|
8919
|
-
const dotSocketDirPath = path.join(cwd,
|
|
8972
|
+
const dotSocketDirPath = path.join(cwd, constants.DOT_SOCKET);
|
|
8920
8973
|
const manifestPath = path.join(dotSocketDirPath, 'manifest.json');
|
|
8921
|
-
|
|
8922
|
-
// Read the manifest file.
|
|
8923
8974
|
const manifestContent = await fs$1.promises.readFile(manifestPath, 'utf-8');
|
|
8924
8975
|
const manifestData = JSON.parse(manifestContent);
|
|
8925
|
-
|
|
8926
|
-
// Validate the schema.
|
|
8976
|
+
const purls = purlObjs.map(String);
|
|
8927
8977
|
const validated = PatchManifestSchema.parse(manifestData);
|
|
8928
8978
|
|
|
8929
8979
|
// Parse PURLs and group by ecosystem.
|
|
8930
|
-
const patchesByEcosystem =
|
|
8931
|
-
for (const
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8980
|
+
const patchesByEcosystem = new Map();
|
|
8981
|
+
for (const {
|
|
8982
|
+
0: key,
|
|
8983
|
+
1: patch
|
|
8984
|
+
} of Object.entries(validated.patches)) {
|
|
8985
|
+
const purl = utils.normalizePurl(key);
|
|
8986
|
+
if (purls.length && !purls.includes(purl)) {
|
|
8987
|
+
continue;
|
|
8988
|
+
}
|
|
8989
|
+
const purlObj = utils.getPurlObject(purl, {
|
|
8990
|
+
throws: false
|
|
8991
|
+
});
|
|
8992
|
+
if (!purlObj) {
|
|
8993
|
+
continue;
|
|
8994
|
+
}
|
|
8995
|
+
let patches = patchesByEcosystem.get(purlObj.type);
|
|
8996
|
+
if (!Array.isArray(patches)) {
|
|
8997
|
+
patches = [];
|
|
8998
|
+
patchesByEcosystem.set(purlObj.type, patches);
|
|
8935
8999
|
}
|
|
8936
|
-
|
|
9000
|
+
patches.push({
|
|
8937
9001
|
key,
|
|
9002
|
+
patch,
|
|
8938
9003
|
purl,
|
|
8939
|
-
|
|
9004
|
+
purlObj
|
|
8940
9005
|
});
|
|
8941
9006
|
}
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
if (packages.length > 0) {
|
|
8945
|
-
logger.logger.info(`Checking patches for: ${packages.join(', ')}`);
|
|
9007
|
+
if (purls.length) {
|
|
9008
|
+
spinner.start(`Checking patches for: ${arrays.joinAnd(purls)}`);
|
|
8946
9009
|
} else {
|
|
8947
|
-
|
|
9010
|
+
spinner.start('Scanning all dependencies for available patches');
|
|
8948
9011
|
}
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
9012
|
+
const patched = [];
|
|
9013
|
+
const npmPatches = patchesByEcosystem.get(constants.NPM);
|
|
9014
|
+
if (npmPatches) {
|
|
9015
|
+
const patchingResults = await applyNpmPatches(dotSocketDirPath, npmPatches, {
|
|
9016
|
+
cwd,
|
|
9017
|
+
dryRun,
|
|
9018
|
+
purlObjs,
|
|
9019
|
+
spinner
|
|
9020
|
+
});
|
|
9021
|
+
patched.push(...patchingResults.passed);
|
|
8952
9022
|
}
|
|
8953
|
-
|
|
9023
|
+
spinner.stop();
|
|
9024
|
+
await outputPatchResult({
|
|
8954
9025
|
ok: true,
|
|
8955
9026
|
data: {
|
|
8956
|
-
|
|
9027
|
+
patched
|
|
8957
9028
|
}
|
|
8958
|
-
};
|
|
8959
|
-
await outputPatchResult(result, outputKind);
|
|
9029
|
+
}, outputKind);
|
|
8960
9030
|
} catch (e) {
|
|
8961
9031
|
spinner.stop();
|
|
8962
9032
|
let message = 'Failed to apply patches';
|
|
8963
|
-
let cause = e?.message ||
|
|
9033
|
+
let cause = e?.message || constants.UNKNOWN_ERROR;
|
|
8964
9034
|
if (e instanceof SyntaxError) {
|
|
8965
|
-
message =
|
|
9035
|
+
message = `Invalid JSON in ${registryConstants.MANIFEST_JSON}`;
|
|
8966
9036
|
cause = e.message;
|
|
8967
9037
|
} else if (e instanceof Error && 'issues' in e) {
|
|
8968
9038
|
message = 'Schema validation failed';
|
|
8969
9039
|
cause = String(e);
|
|
8970
9040
|
}
|
|
8971
|
-
|
|
9041
|
+
await outputPatchResult({
|
|
8972
9042
|
ok: false,
|
|
8973
9043
|
code: 1,
|
|
8974
9044
|
message,
|
|
8975
9045
|
cause
|
|
8976
|
-
};
|
|
8977
|
-
await outputPatchResult(result, outputKind);
|
|
9046
|
+
}, outputKind);
|
|
8978
9047
|
}
|
|
8979
9048
|
}
|
|
8980
9049
|
|
|
@@ -8996,10 +9065,10 @@ async function run$k(argv, importMeta, {
|
|
|
8996
9065
|
flags: {
|
|
8997
9066
|
...flags.commonFlags,
|
|
8998
9067
|
...flags.outputFlags,
|
|
8999
|
-
|
|
9068
|
+
purl: {
|
|
9000
9069
|
type: 'string',
|
|
9001
9070
|
default: [],
|
|
9002
|
-
description: 'Specify
|
|
9071
|
+
description: 'Specify purls to patch, as either a comma separated value or as multiple flags',
|
|
9003
9072
|
isMultiple: true,
|
|
9004
9073
|
shortFlag: 'p'
|
|
9005
9074
|
}
|
|
@@ -9042,24 +9111,27 @@ async function run$k(argv, importMeta, {
|
|
|
9042
9111
|
// Note: path.resolve vs .join:
|
|
9043
9112
|
// If given path is absolute then cwd should not affect it.
|
|
9044
9113
|
cwd = path.resolve(process.cwd(), cwd);
|
|
9045
|
-
const dotSocketDirPath = path.join(cwd,
|
|
9114
|
+
const dotSocketDirPath = path.join(cwd, constants.DOT_SOCKET);
|
|
9046
9115
|
if (!fs$1.existsSync(dotSocketDirPath)) {
|
|
9047
|
-
logger.logger.error(
|
|
9116
|
+
logger.logger.error(`Error: No ${constants.DOT_SOCKET} directory found in current directory`);
|
|
9048
9117
|
return;
|
|
9049
9118
|
}
|
|
9050
|
-
const manifestPath = path.join(dotSocketDirPath,
|
|
9119
|
+
const manifestPath = path.join(dotSocketDirPath, constants.MANIFEST_JSON);
|
|
9051
9120
|
if (!fs$1.existsSync(manifestPath)) {
|
|
9052
|
-
logger.logger.error(
|
|
9121
|
+
logger.logger.error(`Error: No ${constants.MANIFEST_JSON} found in ${constants.DOT_SOCKET} directory`);
|
|
9122
|
+
return;
|
|
9053
9123
|
}
|
|
9054
9124
|
const {
|
|
9055
9125
|
spinner
|
|
9056
|
-
} = constants;
|
|
9057
|
-
const
|
|
9126
|
+
} = constants.default;
|
|
9127
|
+
const purlObjs = arrays.arrayUnique(utils.cmdFlagValueToArray(cli.flags['purl'])).map(p => utils.getPurlObject(p, {
|
|
9128
|
+
throws: false
|
|
9129
|
+
})).filter(Boolean);
|
|
9058
9130
|
await handlePatch({
|
|
9059
9131
|
cwd,
|
|
9060
9132
|
dryRun,
|
|
9061
9133
|
outputKind,
|
|
9062
|
-
|
|
9134
|
+
purlObjs,
|
|
9063
9135
|
spinner
|
|
9064
9136
|
});
|
|
9065
9137
|
}
|
|
@@ -9067,7 +9139,7 @@ async function run$k(argv, importMeta, {
|
|
|
9067
9139
|
async function runRawNpm(argv) {
|
|
9068
9140
|
process.exitCode = 1;
|
|
9069
9141
|
const spawnPromise = spawn.spawn(utils.getNpmBinPath(), argv, {
|
|
9070
|
-
shell: constants.WIN32,
|
|
9142
|
+
shell: constants.default.WIN32,
|
|
9071
9143
|
stdio: 'inherit'
|
|
9072
9144
|
});
|
|
9073
9145
|
|
|
@@ -9121,7 +9193,7 @@ async function run$j(argv, importMeta, {
|
|
|
9121
9193
|
});
|
|
9122
9194
|
const dryRun = !!cli.flags['dryRun'];
|
|
9123
9195
|
if (dryRun) {
|
|
9124
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9196
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9125
9197
|
return;
|
|
9126
9198
|
}
|
|
9127
9199
|
await runRawNpm(argv);
|
|
@@ -9130,7 +9202,7 @@ async function run$j(argv, importMeta, {
|
|
|
9130
9202
|
async function runRawNpx(argv) {
|
|
9131
9203
|
process.exitCode = 1;
|
|
9132
9204
|
const spawnPromise = spawn.spawn(utils.getNpxBinPath(), argv, {
|
|
9133
|
-
shell: constants.WIN32,
|
|
9205
|
+
shell: constants.default.WIN32,
|
|
9134
9206
|
stdio: 'inherit'
|
|
9135
9207
|
});
|
|
9136
9208
|
|
|
@@ -9184,7 +9256,7 @@ async function run$i(argv, importMeta, {
|
|
|
9184
9256
|
});
|
|
9185
9257
|
const dryRun = !!cli.flags['dryRun'];
|
|
9186
9258
|
if (dryRun) {
|
|
9187
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9259
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9188
9260
|
return;
|
|
9189
9261
|
}
|
|
9190
9262
|
await runRawNpx(argv);
|
|
@@ -9217,7 +9289,7 @@ async function fetchCreateRepo(config, options) {
|
|
|
9217
9289
|
name: repoName,
|
|
9218
9290
|
visibility
|
|
9219
9291
|
}), {
|
|
9220
|
-
|
|
9292
|
+
description: 'to create a repository'
|
|
9221
9293
|
});
|
|
9222
9294
|
}
|
|
9223
9295
|
|
|
@@ -9339,7 +9411,9 @@ async function run$h(argv, importMeta, {
|
|
|
9339
9411
|
const noLegacy = !cli.flags['repoName'];
|
|
9340
9412
|
const [repoName = ''] = cli.input;
|
|
9341
9413
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
9342
|
-
const
|
|
9414
|
+
const {
|
|
9415
|
+
0: orgSlug
|
|
9416
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
9343
9417
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
9344
9418
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
9345
9419
|
nook: true,
|
|
@@ -9349,7 +9423,7 @@ async function run$h(argv, importMeta, {
|
|
|
9349
9423
|
}, {
|
|
9350
9424
|
nook: true,
|
|
9351
9425
|
test: noLegacy,
|
|
9352
|
-
message:
|
|
9426
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
9353
9427
|
fail: `received legacy flags`
|
|
9354
9428
|
}, {
|
|
9355
9429
|
test: !!repoName,
|
|
@@ -9365,7 +9439,7 @@ async function run$h(argv, importMeta, {
|
|
|
9365
9439
|
return;
|
|
9366
9440
|
}
|
|
9367
9441
|
if (dryRun) {
|
|
9368
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9442
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9369
9443
|
return;
|
|
9370
9444
|
}
|
|
9371
9445
|
await handleCreateRepo({
|
|
@@ -9391,7 +9465,7 @@ async function fetchDeleteRepo(orgSlug, repoName, options) {
|
|
|
9391
9465
|
}
|
|
9392
9466
|
const sockSdk = sockSdkCResult.data;
|
|
9393
9467
|
return await utils.handleApiCall(sockSdk.deleteOrgRepo(orgSlug, repoName), {
|
|
9394
|
-
|
|
9468
|
+
description: 'to delete a repository'
|
|
9395
9469
|
});
|
|
9396
9470
|
}
|
|
9397
9471
|
|
|
@@ -9473,12 +9547,14 @@ async function run$g(argv, importMeta, {
|
|
|
9473
9547
|
const noLegacy = !cli.flags['repoName'];
|
|
9474
9548
|
const [repoName = ''] = cli.input;
|
|
9475
9549
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
9476
|
-
const
|
|
9550
|
+
const {
|
|
9551
|
+
0: orgSlug
|
|
9552
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
9477
9553
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
9478
9554
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
9479
9555
|
nook: true,
|
|
9480
9556
|
test: noLegacy,
|
|
9481
|
-
message:
|
|
9557
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
9482
9558
|
fail: `received legacy flags`
|
|
9483
9559
|
}, {
|
|
9484
9560
|
nook: true,
|
|
@@ -9499,7 +9575,7 @@ async function run$g(argv, importMeta, {
|
|
|
9499
9575
|
return;
|
|
9500
9576
|
}
|
|
9501
9577
|
if (dryRun) {
|
|
9502
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9578
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9503
9579
|
return;
|
|
9504
9580
|
}
|
|
9505
9581
|
await handleDeleteRepo(orgSlug, repoName, outputKind);
|
|
@@ -9538,7 +9614,7 @@ async function fetchListAllRepos(orgSlug, options) {
|
|
|
9538
9614
|
// max
|
|
9539
9615
|
page: String(nextPage)
|
|
9540
9616
|
}), {
|
|
9541
|
-
|
|
9617
|
+
description: 'list of repositories'
|
|
9542
9618
|
});
|
|
9543
9619
|
if (!orgRepoListCResult.ok) {
|
|
9544
9620
|
return orgRepoListCResult;
|
|
@@ -9583,7 +9659,7 @@ async function fetchListRepos(config, options) {
|
|
|
9583
9659
|
per_page: String(perPage),
|
|
9584
9660
|
page: String(page)
|
|
9585
9661
|
}), {
|
|
9586
|
-
|
|
9662
|
+
description: 'list of repositories'
|
|
9587
9663
|
});
|
|
9588
9664
|
}
|
|
9589
9665
|
|
|
@@ -9763,7 +9839,9 @@ async function run$f(argv, importMeta, {
|
|
|
9763
9839
|
const dryRun = !!cli.flags['dryRun'];
|
|
9764
9840
|
const interactive = !!cli.flags['interactive'];
|
|
9765
9841
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
9766
|
-
const
|
|
9842
|
+
const {
|
|
9843
|
+
0: orgSlug
|
|
9844
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
9767
9845
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
9768
9846
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
9769
9847
|
nook: true,
|
|
@@ -9790,7 +9868,7 @@ async function run$f(argv, importMeta, {
|
|
|
9790
9868
|
return;
|
|
9791
9869
|
}
|
|
9792
9870
|
if (dryRun) {
|
|
9793
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9871
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9794
9872
|
return;
|
|
9795
9873
|
}
|
|
9796
9874
|
await handleListRepos({
|
|
@@ -9835,7 +9913,7 @@ async function fetchUpdateRepo(config, options) {
|
|
|
9835
9913
|
orgSlug,
|
|
9836
9914
|
visibility
|
|
9837
9915
|
}), {
|
|
9838
|
-
|
|
9916
|
+
description: 'to update a repository'
|
|
9839
9917
|
});
|
|
9840
9918
|
}
|
|
9841
9919
|
|
|
@@ -9956,12 +10034,14 @@ async function run$e(argv, importMeta, {
|
|
|
9956
10034
|
const noLegacy = !cli.flags['repoName'];
|
|
9957
10035
|
const [repoName = ''] = cli.input;
|
|
9958
10036
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
9959
|
-
const
|
|
10037
|
+
const {
|
|
10038
|
+
0: orgSlug
|
|
10039
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
9960
10040
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
9961
10041
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
9962
10042
|
nook: true,
|
|
9963
10043
|
test: noLegacy,
|
|
9964
|
-
message:
|
|
10044
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
9965
10045
|
fail: `received legacy flags`
|
|
9966
10046
|
}, {
|
|
9967
10047
|
nook: true,
|
|
@@ -9982,7 +10062,7 @@ async function run$e(argv, importMeta, {
|
|
|
9982
10062
|
return;
|
|
9983
10063
|
}
|
|
9984
10064
|
if (dryRun) {
|
|
9985
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10065
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9986
10066
|
return;
|
|
9987
10067
|
}
|
|
9988
10068
|
await handleUpdateRepo({
|
|
@@ -10008,7 +10088,7 @@ async function fetchViewRepo(orgSlug, repoName, options) {
|
|
|
10008
10088
|
}
|
|
10009
10089
|
const sockSdk = sockSdkCResult.data;
|
|
10010
10090
|
return await utils.handleApiCall(sockSdk.getOrgRepo(orgSlug, repoName), {
|
|
10011
|
-
|
|
10091
|
+
description: 'repository data'
|
|
10012
10092
|
});
|
|
10013
10093
|
}
|
|
10014
10094
|
|
|
@@ -10116,12 +10196,14 @@ async function run$d(argv, importMeta, {
|
|
|
10116
10196
|
const noLegacy = !cli.flags['repoName'];
|
|
10117
10197
|
const [repoName = ''] = cli.input;
|
|
10118
10198
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
10119
|
-
const
|
|
10199
|
+
const {
|
|
10200
|
+
0: orgSlug
|
|
10201
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
10120
10202
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
10121
10203
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
10122
10204
|
nook: true,
|
|
10123
10205
|
test: noLegacy,
|
|
10124
|
-
message:
|
|
10206
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
10125
10207
|
fail: `received legacy flags`
|
|
10126
10208
|
}, {
|
|
10127
10209
|
nook: true,
|
|
@@ -10147,7 +10229,7 @@ async function run$d(argv, importMeta, {
|
|
|
10147
10229
|
return;
|
|
10148
10230
|
}
|
|
10149
10231
|
if (dryRun) {
|
|
10150
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10232
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10151
10233
|
return;
|
|
10152
10234
|
}
|
|
10153
10235
|
await handleViewRepo(orgSlug, String(repoName), outputKind);
|
|
@@ -10237,29 +10319,31 @@ const generalFlags$1 = {
|
|
|
10237
10319
|
},
|
|
10238
10320
|
branch: {
|
|
10239
10321
|
type: 'string',
|
|
10240
|
-
|
|
10241
|
-
description: 'Branch name'
|
|
10322
|
+
default: '',
|
|
10323
|
+
description: 'Branch name',
|
|
10324
|
+
shortFlag: 'b'
|
|
10242
10325
|
},
|
|
10243
10326
|
commitHash: {
|
|
10244
10327
|
type: 'string',
|
|
10245
|
-
shortFlag: 'ch',
|
|
10246
10328
|
default: '',
|
|
10247
|
-
description: 'Commit hash'
|
|
10329
|
+
description: 'Commit hash',
|
|
10330
|
+
shortFlag: 'ch'
|
|
10248
10331
|
},
|
|
10249
10332
|
commitMessage: {
|
|
10250
10333
|
type: 'string',
|
|
10251
|
-
shortFlag: 'm',
|
|
10252
10334
|
default: '',
|
|
10253
|
-
description: 'Commit message'
|
|
10335
|
+
description: 'Commit message',
|
|
10336
|
+
shortFlag: 'm'
|
|
10254
10337
|
},
|
|
10255
10338
|
committers: {
|
|
10256
10339
|
type: 'string',
|
|
10257
|
-
shortFlag: 'c',
|
|
10258
10340
|
default: '',
|
|
10259
|
-
description: 'Committers'
|
|
10341
|
+
description: 'Committers',
|
|
10342
|
+
shortFlag: 'c'
|
|
10260
10343
|
},
|
|
10261
10344
|
cwd: {
|
|
10262
10345
|
type: 'string',
|
|
10346
|
+
default: '',
|
|
10263
10347
|
description: 'working directory, defaults to process.cwd()'
|
|
10264
10348
|
},
|
|
10265
10349
|
defaultBranch: {
|
|
@@ -10274,11 +10358,13 @@ const generalFlags$1 = {
|
|
|
10274
10358
|
},
|
|
10275
10359
|
pullRequest: {
|
|
10276
10360
|
type: 'number',
|
|
10277
|
-
|
|
10278
|
-
description: 'Pull request number'
|
|
10361
|
+
default: 0,
|
|
10362
|
+
description: 'Pull request number',
|
|
10363
|
+
shortFlag: 'pr'
|
|
10279
10364
|
},
|
|
10280
10365
|
org: {
|
|
10281
10366
|
type: 'string',
|
|
10367
|
+
default: '',
|
|
10282
10368
|
description: 'Force override the organization slug, overrides the default org from config'
|
|
10283
10369
|
},
|
|
10284
10370
|
reach: {
|
|
@@ -10300,17 +10386,22 @@ const generalFlags$1 = {
|
|
|
10300
10386
|
type: 'boolean',
|
|
10301
10387
|
description: 'Wait for the scan creation to complete, then basically run `socket scan report` on it'
|
|
10302
10388
|
},
|
|
10389
|
+
reportLevel: {
|
|
10390
|
+
type: 'string',
|
|
10391
|
+
default: constants.default.REPORT_LEVEL_ERROR,
|
|
10392
|
+
description: `Which policy level alerts should be reported (default '${constants.default.REPORT_LEVEL_ERROR}')`
|
|
10393
|
+
},
|
|
10303
10394
|
setAsAlertsPage: {
|
|
10304
10395
|
type: 'boolean',
|
|
10305
10396
|
default: true,
|
|
10306
|
-
|
|
10307
|
-
|
|
10397
|
+
description: 'When true and if this is the "default branch" then this Scan will be the one reflected on your alerts page. See help for details. Defaults to true.',
|
|
10398
|
+
aliases: ['pendingHead']
|
|
10308
10399
|
},
|
|
10309
10400
|
tmp: {
|
|
10310
10401
|
type: 'boolean',
|
|
10311
|
-
shortFlag: 't',
|
|
10312
10402
|
default: false,
|
|
10313
|
-
description: 'Set the visibility (true/false) of the scan in your dashboard.'
|
|
10403
|
+
description: 'Set the visibility (true/false) of the scan in your dashboard.',
|
|
10404
|
+
shortFlag: 't'
|
|
10314
10405
|
}
|
|
10315
10406
|
};
|
|
10316
10407
|
const cmdScanCreate = {
|
|
@@ -10402,17 +10493,14 @@ async function run$c(argv, importMeta, {
|
|
|
10402
10493
|
reachDisableAnalytics,
|
|
10403
10494
|
reachSkipCache,
|
|
10404
10495
|
readOnly,
|
|
10496
|
+
reportLevel,
|
|
10405
10497
|
setAsAlertsPage: pendingHeadFlag,
|
|
10406
10498
|
tmp
|
|
10407
10499
|
} = cli.flags;
|
|
10408
|
-
const dryRun = !!cli.flags['dryRun'];
|
|
10409
|
-
|
|
10410
|
-
// Process comma-separated values for isMultiple flags.
|
|
10411
|
-
const reachEcosystemsRaw = utils.cmdFlagValueToArray(cli.flags['reachEcosystems']);
|
|
10412
|
-
const reachExcludePaths = utils.cmdFlagValueToArray(cli.flags['reachExcludePaths']);
|
|
10413
10500
|
|
|
10414
10501
|
// Validate ecosystem values.
|
|
10415
10502
|
const reachEcosystems = [];
|
|
10503
|
+
const reachEcosystemsRaw = utils.cmdFlagValueToArray(cli.flags['reachEcosystems']);
|
|
10416
10504
|
const validEcosystems = utils.getEcosystemChoicesForMeow();
|
|
10417
10505
|
for (const ecosystem of reachEcosystemsRaw) {
|
|
10418
10506
|
if (!validEcosystems.includes(ecosystem)) {
|
|
@@ -10420,15 +10508,18 @@ async function run$c(argv, importMeta, {
|
|
|
10420
10508
|
}
|
|
10421
10509
|
reachEcosystems.push(ecosystem);
|
|
10422
10510
|
}
|
|
10511
|
+
const dryRun = !!cli.flags['dryRun'];
|
|
10423
10512
|
let {
|
|
10424
10513
|
autoManifest,
|
|
10425
10514
|
branch: branchName,
|
|
10426
10515
|
repo: repoName,
|
|
10427
10516
|
report
|
|
10428
10517
|
} = cli.flags;
|
|
10429
|
-
let
|
|
10518
|
+
let {
|
|
10519
|
+
0: orgSlug
|
|
10520
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
10430
10521
|
const processCwd = process.cwd();
|
|
10431
|
-
const cwd = cwdOverride && cwdOverride !== processCwd ? path.resolve(processCwd,
|
|
10522
|
+
const cwd = cwdOverride && cwdOverride !== '.' && cwdOverride !== processCwd ? path.resolve(processCwd, cwdOverride) : processCwd;
|
|
10432
10523
|
const sockJson = utils.readOrDefaultSocketJson(cwd);
|
|
10433
10524
|
|
|
10434
10525
|
// Note: This needs meow booleanDefault=undefined.
|
|
@@ -10519,6 +10610,7 @@ async function run$c(argv, importMeta, {
|
|
|
10519
10610
|
logger.logger.info('You can also run `socket scan setup` to persist these flag defaults to a socket.json file.');
|
|
10520
10611
|
logger.logger.error('');
|
|
10521
10612
|
}
|
|
10613
|
+
const reachExcludePaths = utils.cmdFlagValueToArray(cli.flags['reachExcludePaths']);
|
|
10522
10614
|
|
|
10523
10615
|
// Validation helpers for better readability.
|
|
10524
10616
|
const hasReachEcosystems = reachEcosystems.length > 0;
|
|
@@ -10566,7 +10658,7 @@ async function run$c(argv, importMeta, {
|
|
|
10566
10658
|
return;
|
|
10567
10659
|
}
|
|
10568
10660
|
if (dryRun) {
|
|
10569
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10661
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10570
10662
|
return;
|
|
10571
10663
|
}
|
|
10572
10664
|
await handleCreateNewScan({
|
|
@@ -10594,6 +10686,7 @@ async function run$c(argv, importMeta, {
|
|
|
10594
10686
|
readOnly: Boolean(readOnly),
|
|
10595
10687
|
repoName,
|
|
10596
10688
|
report,
|
|
10689
|
+
reportLevel,
|
|
10597
10690
|
targets,
|
|
10598
10691
|
tmp: Boolean(tmp)
|
|
10599
10692
|
});
|
|
@@ -10612,7 +10705,7 @@ async function fetchDeleteOrgFullScan(orgSlug, scanId, options) {
|
|
|
10612
10705
|
}
|
|
10613
10706
|
const sockSdk = sockSdkCResult.data;
|
|
10614
10707
|
return await utils.handleApiCall(sockSdk.deleteOrgFullScan(orgSlug, scanId), {
|
|
10615
|
-
|
|
10708
|
+
description: 'to delete a scan'
|
|
10616
10709
|
});
|
|
10617
10710
|
}
|
|
10618
10711
|
|
|
@@ -10715,7 +10808,7 @@ async function run$b(argv, importMeta, {
|
|
|
10715
10808
|
return;
|
|
10716
10809
|
}
|
|
10717
10810
|
if (dryRun) {
|
|
10718
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10811
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10719
10812
|
return;
|
|
10720
10813
|
}
|
|
10721
10814
|
await handleDeleteScan(orgSlug, scanId, outputKind);
|
|
@@ -10797,7 +10890,7 @@ async function handleJson(data, file, dashboardMessage) {
|
|
|
10797
10890
|
}
|
|
10798
10891
|
}
|
|
10799
10892
|
async function handleMarkdown(data) {
|
|
10800
|
-
const SOCKET_SBOM_URL_PREFIX = `${constants.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10893
|
+
const SOCKET_SBOM_URL_PREFIX = `${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10801
10894
|
logger.logger.log('# Scan diff result');
|
|
10802
10895
|
logger.logger.log('');
|
|
10803
10896
|
logger.logger.log('This Socket.dev report shows the changes between two scans:');
|
|
@@ -10861,7 +10954,10 @@ async function handleMarkdown(data) {
|
|
|
10861
10954
|
logger.logger.log('');
|
|
10862
10955
|
logger.logger.log('This Scan was considered to be the "base" / "from" / "before" Scan.');
|
|
10863
10956
|
logger.logger.log('');
|
|
10864
|
-
for (const
|
|
10957
|
+
for (const {
|
|
10958
|
+
0: key,
|
|
10959
|
+
1: value
|
|
10960
|
+
} of Object.entries(data.before)) {
|
|
10865
10961
|
if (key === 'pull_request' && !value) {
|
|
10866
10962
|
continue;
|
|
10867
10963
|
}
|
|
@@ -10875,7 +10971,10 @@ async function handleMarkdown(data) {
|
|
|
10875
10971
|
logger.logger.log('');
|
|
10876
10972
|
logger.logger.log('This Scan was considered to be the "head" / "to" / "after" Scan.');
|
|
10877
10973
|
logger.logger.log('');
|
|
10878
|
-
for (const
|
|
10974
|
+
for (const {
|
|
10975
|
+
0: key,
|
|
10976
|
+
1: value
|
|
10977
|
+
} of Object.entries(data.after)) {
|
|
10879
10978
|
if (key === 'pull_request' && !value) {
|
|
10880
10979
|
continue;
|
|
10881
10980
|
}
|
|
@@ -10975,7 +11074,7 @@ async function run$a(argv, importMeta, {
|
|
|
10975
11074
|
importMeta,
|
|
10976
11075
|
parentName
|
|
10977
11076
|
});
|
|
10978
|
-
const SOCKET_SBOM_URL_PREFIX = `${constants.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
11077
|
+
const SOCKET_SBOM_URL_PREFIX = `${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10979
11078
|
const SOCKET_SBOM_URL_PREFIX_LENGTH = SOCKET_SBOM_URL_PREFIX.length;
|
|
10980
11079
|
const {
|
|
10981
11080
|
depth,
|
|
@@ -10995,7 +11094,9 @@ async function run$a(argv, importMeta, {
|
|
|
10995
11094
|
id2 = id2.slice(SOCKET_SBOM_URL_PREFIX_LENGTH);
|
|
10996
11095
|
}
|
|
10997
11096
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
10998
|
-
const
|
|
11097
|
+
const {
|
|
11098
|
+
0: orgSlug
|
|
11099
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
10999
11100
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
11000
11101
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
11001
11102
|
test: !!(id1 && id2),
|
|
@@ -11021,7 +11122,7 @@ async function run$a(argv, importMeta, {
|
|
|
11021
11122
|
return;
|
|
11022
11123
|
}
|
|
11023
11124
|
if (dryRun) {
|
|
11024
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
11125
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
11025
11126
|
return;
|
|
11026
11127
|
}
|
|
11027
11128
|
await handleDiffScan({
|
|
@@ -11230,6 +11331,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
11230
11331
|
readOnly: false,
|
|
11231
11332
|
repoName: repoSlug,
|
|
11232
11333
|
report: false,
|
|
11334
|
+
reportLevel: constants.default.REPORT_LEVEL_ERROR,
|
|
11233
11335
|
targets: ['.'],
|
|
11234
11336
|
tmp: false
|
|
11235
11337
|
});
|
|
@@ -11693,6 +11795,7 @@ async function handleCreateGithubScan({
|
|
|
11693
11795
|
}
|
|
11694
11796
|
|
|
11695
11797
|
const CMD_NAME$6 = 'github';
|
|
11798
|
+
const DEFAULT_GITHUB_URL = 'https://api.github.com';
|
|
11696
11799
|
const description$8 = 'Create a scan for given GitHub repo';
|
|
11697
11800
|
const hidden$6 = true;
|
|
11698
11801
|
const cmdScanGithub = {
|
|
@@ -11716,11 +11819,13 @@ async function run$9(argv, importMeta, {
|
|
|
11716
11819
|
},
|
|
11717
11820
|
githubToken: {
|
|
11718
11821
|
type: 'string',
|
|
11822
|
+
default: constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN,
|
|
11719
11823
|
description: 'Required GitHub token for authentication.\nMay set environment variable GITHUB_TOKEN or SOCKET_CLI_GITHUB_TOKEN instead.'
|
|
11720
11824
|
},
|
|
11721
11825
|
githubApiUrl: {
|
|
11722
11826
|
type: 'string',
|
|
11723
|
-
|
|
11827
|
+
default: DEFAULT_GITHUB_URL,
|
|
11828
|
+
description: `Base URL of the GitHub API (default: ${DEFAULT_GITHUB_URL})`
|
|
11724
11829
|
},
|
|
11725
11830
|
interactive: {
|
|
11726
11831
|
type: 'boolean',
|
|
@@ -11729,14 +11834,17 @@ async function run$9(argv, importMeta, {
|
|
|
11729
11834
|
},
|
|
11730
11835
|
org: {
|
|
11731
11836
|
type: 'string',
|
|
11837
|
+
default: '',
|
|
11732
11838
|
description: 'Force override the organization slug, overrides the default org from config'
|
|
11733
11839
|
},
|
|
11734
11840
|
orgGithub: {
|
|
11735
11841
|
type: 'string',
|
|
11842
|
+
default: '',
|
|
11736
11843
|
description: 'Alternate GitHub Org if the name is different than the Socket Org'
|
|
11737
11844
|
},
|
|
11738
11845
|
repos: {
|
|
11739
11846
|
type: 'string',
|
|
11847
|
+
default: '',
|
|
11740
11848
|
description: 'List of repos to target in a comma-separated format (e.g., repo1,repo2). If not specified, the script will pull the list from Socket and ask you to pick one. Use --all to use them all.'
|
|
11741
11849
|
}
|
|
11742
11850
|
},
|
|
@@ -11774,7 +11882,7 @@ async function run$9(argv, importMeta, {
|
|
|
11774
11882
|
parentName
|
|
11775
11883
|
});
|
|
11776
11884
|
const {
|
|
11777
|
-
githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN,
|
|
11885
|
+
githubToken = constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN,
|
|
11778
11886
|
interactive = true,
|
|
11779
11887
|
json,
|
|
11780
11888
|
markdown,
|
|
@@ -11791,7 +11899,9 @@ async function run$9(argv, importMeta, {
|
|
|
11791
11899
|
// Note: path.resolve vs .join:
|
|
11792
11900
|
// If given path is absolute then cwd should not affect it.
|
|
11793
11901
|
cwd = path.resolve(process.cwd(), cwd);
|
|
11794
|
-
let
|
|
11902
|
+
let {
|
|
11903
|
+
0: orgSlug
|
|
11904
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
11795
11905
|
const sockJson = utils.readOrDefaultSocketJson(cwd);
|
|
11796
11906
|
if (all === undefined) {
|
|
11797
11907
|
if (sockJson.defaults?.scan?.github?.all !== undefined) {
|
|
@@ -11804,7 +11914,7 @@ async function run$9(argv, importMeta, {
|
|
|
11804
11914
|
if (sockJson.defaults?.scan?.github?.githubApiUrl !== undefined) {
|
|
11805
11915
|
githubApiUrl = sockJson.defaults.scan.github.githubApiUrl;
|
|
11806
11916
|
} else {
|
|
11807
|
-
githubApiUrl =
|
|
11917
|
+
githubApiUrl = DEFAULT_GITHUB_URL;
|
|
11808
11918
|
}
|
|
11809
11919
|
}
|
|
11810
11920
|
if (!orgGithub) {
|
|
@@ -11872,7 +11982,7 @@ async function run$9(argv, importMeta, {
|
|
|
11872
11982
|
|
|
11873
11983
|
// Note exiting earlier to skirt a hidden auth requirement
|
|
11874
11984
|
if (dryRun) {
|
|
11875
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
11985
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
11876
11986
|
return;
|
|
11877
11987
|
}
|
|
11878
11988
|
await handleCreateGithubScan({
|
|
@@ -11925,7 +12035,7 @@ async function fetchOrgFullScanList(config, options) {
|
|
|
11925
12035
|
page: String(page),
|
|
11926
12036
|
per_page: String(perPage)
|
|
11927
12037
|
}), {
|
|
11928
|
-
|
|
12038
|
+
description: 'list of scans'
|
|
11929
12039
|
});
|
|
11930
12040
|
}
|
|
11931
12041
|
|
|
@@ -12105,12 +12215,14 @@ async function run$8(argv, importMeta, {
|
|
|
12105
12215
|
const [repo = '', branchArg = ''] = cli.input;
|
|
12106
12216
|
const branch = String(branchFlag || branchArg || '');
|
|
12107
12217
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
12108
|
-
const
|
|
12218
|
+
const {
|
|
12219
|
+
0: orgSlug
|
|
12220
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
12109
12221
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
12110
12222
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
12111
12223
|
nook: true,
|
|
12112
12224
|
test: noLegacy,
|
|
12113
|
-
message:
|
|
12225
|
+
message: `Legacy flags are no longer supported. See ${vendor.terminalLinkExports('v1 migration guide', constants.V1_MIGRATION_GUIDE_URL)}.`,
|
|
12114
12226
|
fail: `received legacy flags`
|
|
12115
12227
|
}, {
|
|
12116
12228
|
nook: true,
|
|
@@ -12137,7 +12249,7 @@ async function run$8(argv, importMeta, {
|
|
|
12137
12249
|
return;
|
|
12138
12250
|
}
|
|
12139
12251
|
if (dryRun) {
|
|
12140
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12252
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12141
12253
|
return;
|
|
12142
12254
|
}
|
|
12143
12255
|
await handleListScans({
|
|
@@ -12166,7 +12278,7 @@ async function fetchScanMetadata(orgSlug, scanId, options) {
|
|
|
12166
12278
|
}
|
|
12167
12279
|
const sockSdk = sockSdkCResult.data;
|
|
12168
12280
|
return await utils.handleApiCall(sockSdk.getOrgFullScanMetadata(orgSlug, scanId), {
|
|
12169
|
-
|
|
12281
|
+
description: 'meta data for a full scan'
|
|
12170
12282
|
});
|
|
12171
12283
|
}
|
|
12172
12284
|
|
|
@@ -12186,7 +12298,10 @@ async function outputScanMetadata(result, scanId, outputKind) {
|
|
|
12186
12298
|
logger.logger.log('# Scan meta data\n');
|
|
12187
12299
|
}
|
|
12188
12300
|
logger.logger.log(`Scan ID: ${scanId}\n`);
|
|
12189
|
-
for (const
|
|
12301
|
+
for (const {
|
|
12302
|
+
0: key,
|
|
12303
|
+
1: value
|
|
12304
|
+
} of Object.entries(result.data)) {
|
|
12190
12305
|
if (['id', 'updated_at', 'organization_id', 'repository_id', 'commit_hash', 'html_report_url'].includes(key)) {
|
|
12191
12306
|
continue;
|
|
12192
12307
|
}
|
|
@@ -12262,7 +12377,9 @@ async function run$7(argv, importMeta, {
|
|
|
12262
12377
|
const interactive = !!cli.flags['interactive'];
|
|
12263
12378
|
const [scanId = ''] = cli.input;
|
|
12264
12379
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
12265
|
-
const
|
|
12380
|
+
const {
|
|
12381
|
+
0: orgSlug
|
|
12382
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
12266
12383
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
12267
12384
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
12268
12385
|
nook: true,
|
|
@@ -12288,7 +12405,7 @@ async function run$7(argv, importMeta, {
|
|
|
12288
12405
|
return;
|
|
12289
12406
|
}
|
|
12290
12407
|
if (dryRun) {
|
|
12291
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12408
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12292
12409
|
return;
|
|
12293
12410
|
}
|
|
12294
12411
|
await handleOrgScanMetadata(orgSlug, scanId, outputKind);
|
|
@@ -12311,7 +12428,7 @@ async function outputScanReach(result, {
|
|
|
12311
12428
|
}
|
|
12312
12429
|
logger.logger.log('');
|
|
12313
12430
|
logger.logger.success('Reachability analysis completed successfully!');
|
|
12314
|
-
logger.logger.info(`Reachability report has been written to: ${path.join(cwd, constants.DOT_SOCKET_DOT_FACTS_JSON)}`);
|
|
12431
|
+
logger.logger.info(`Reachability report has been written to: ${path.join(cwd, constants.default.DOT_SOCKET_DOT_FACTS_JSON)}`);
|
|
12315
12432
|
}
|
|
12316
12433
|
|
|
12317
12434
|
async function handleScanReach({
|
|
@@ -12324,7 +12441,7 @@ async function handleScanReach({
|
|
|
12324
12441
|
}) {
|
|
12325
12442
|
const {
|
|
12326
12443
|
spinner
|
|
12327
|
-
} = constants;
|
|
12444
|
+
} = constants.default;
|
|
12328
12445
|
|
|
12329
12446
|
// Get supported file names
|
|
12330
12447
|
const supportedFilesCResult = await fetchSupportedScanFileNames({
|
|
@@ -12377,10 +12494,12 @@ const generalFlags = {
|
|
|
12377
12494
|
...flags.outputFlags,
|
|
12378
12495
|
cwd: {
|
|
12379
12496
|
type: 'string',
|
|
12497
|
+
default: '',
|
|
12380
12498
|
description: 'working directory, defaults to process.cwd()'
|
|
12381
12499
|
},
|
|
12382
12500
|
org: {
|
|
12383
12501
|
type: 'string',
|
|
12502
|
+
default: '',
|
|
12384
12503
|
description: 'Force override the organization slug, overrides the default org from config'
|
|
12385
12504
|
}
|
|
12386
12505
|
};
|
|
@@ -12459,7 +12578,7 @@ async function run$6(argv, importMeta, {
|
|
|
12459
12578
|
reachEcosystems.push(ecosystem);
|
|
12460
12579
|
}
|
|
12461
12580
|
const processCwd = process.cwd();
|
|
12462
|
-
const cwd = cwdOverride && cwdOverride !== processCwd ? path.resolve(processCwd,
|
|
12581
|
+
const cwd = cwdOverride && cwdOverride !== '.' && cwdOverride !== processCwd ? path.resolve(processCwd, cwdOverride) : processCwd;
|
|
12463
12582
|
|
|
12464
12583
|
// Accept zero or more paths. Default to cwd() if none given.
|
|
12465
12584
|
let targets = cli.input || [cwd];
|
|
@@ -12468,7 +12587,9 @@ async function run$6(argv, importMeta, {
|
|
|
12468
12587
|
if (!targets.length && !dryRun && interactive) {
|
|
12469
12588
|
targets = await suggestTarget();
|
|
12470
12589
|
}
|
|
12471
|
-
const
|
|
12590
|
+
const {
|
|
12591
|
+
0: orgSlug
|
|
12592
|
+
} = await utils.determineOrgSlug(orgFlag, interactive, dryRun);
|
|
12472
12593
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
12473
12594
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
12474
12595
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
@@ -12491,7 +12612,7 @@ async function run$6(argv, importMeta, {
|
|
|
12491
12612
|
return;
|
|
12492
12613
|
}
|
|
12493
12614
|
if (dryRun) {
|
|
12494
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12615
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12495
12616
|
return;
|
|
12496
12617
|
}
|
|
12497
12618
|
await handleScanReach({
|
|
@@ -12531,8 +12652,8 @@ async function run$5(argv, importMeta, {
|
|
|
12531
12652
|
...flags.outputFlags,
|
|
12532
12653
|
fold: {
|
|
12533
12654
|
type: 'string',
|
|
12534
|
-
default:
|
|
12535
|
-
description:
|
|
12655
|
+
default: constants.default.FOLD_SETTING_NONE,
|
|
12656
|
+
description: `Fold reported alerts to some degree (default '${constants.default.FOLD_SETTING_NONE}')`
|
|
12536
12657
|
},
|
|
12537
12658
|
interactive: {
|
|
12538
12659
|
type: 'boolean',
|
|
@@ -12545,8 +12666,8 @@ async function run$5(argv, importMeta, {
|
|
|
12545
12666
|
},
|
|
12546
12667
|
reportLevel: {
|
|
12547
12668
|
type: 'string',
|
|
12548
|
-
default:
|
|
12549
|
-
description:
|
|
12669
|
+
default: constants.default.REPORT_LEVEL_WARN,
|
|
12670
|
+
description: `Which policy level alerts should be reported (default '${constants.default.REPORT_LEVEL_WARN}')`
|
|
12550
12671
|
},
|
|
12551
12672
|
short: {
|
|
12552
12673
|
type: 'boolean',
|
|
@@ -12583,7 +12704,7 @@ async function run$5(argv, importMeta, {
|
|
|
12583
12704
|
|
|
12584
12705
|
You can --fold these up to given level: 'pkg', 'version', 'file', and 'none'.
|
|
12585
12706
|
For example: \`socket scan report --fold=version\` will dedupe alerts to only
|
|
12586
|
-
show one alert of a particular kind, no matter how often it was
|
|
12707
|
+
show one alert of a particular kind, no matter how often it was found in a
|
|
12587
12708
|
file or in how many files it was found. At most one per version that has it.
|
|
12588
12709
|
|
|
12589
12710
|
By default only the warn and error policy level alerts are reported. You can
|
|
@@ -12606,18 +12727,21 @@ async function run$5(argv, importMeta, {
|
|
|
12606
12727
|
parentName
|
|
12607
12728
|
});
|
|
12608
12729
|
const {
|
|
12609
|
-
fold = 'none',
|
|
12610
12730
|
json,
|
|
12611
|
-
license,
|
|
12612
12731
|
markdown,
|
|
12613
|
-
org: orgFlag
|
|
12614
|
-
reportLevel = 'warn'
|
|
12732
|
+
org: orgFlag
|
|
12615
12733
|
} = cli.flags;
|
|
12616
12734
|
const dryRun = !!cli.flags['dryRun'];
|
|
12735
|
+
const fold = cli.flags['fold'];
|
|
12617
12736
|
const interactive = !!cli.flags['interactive'];
|
|
12618
|
-
const
|
|
12737
|
+
const includeLicensePolicy = !!cli.flags['license'];
|
|
12738
|
+
const reportLevel = cli.flags['reportLevel'];
|
|
12739
|
+
const short = !!cli.flags['short'];
|
|
12740
|
+
const [scanId = '', filepath = ''] = cli.input;
|
|
12619
12741
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
12620
|
-
const
|
|
12742
|
+
const {
|
|
12743
|
+
0: orgSlug
|
|
12744
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
12621
12745
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
12622
12746
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
12623
12747
|
nook: true,
|
|
@@ -12643,18 +12767,18 @@ async function run$5(argv, importMeta, {
|
|
|
12643
12767
|
return;
|
|
12644
12768
|
}
|
|
12645
12769
|
if (dryRun) {
|
|
12646
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12770
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12647
12771
|
return;
|
|
12648
12772
|
}
|
|
12649
12773
|
await handleScanReport({
|
|
12650
12774
|
orgSlug,
|
|
12651
12775
|
scanId,
|
|
12652
|
-
includeLicensePolicy
|
|
12776
|
+
includeLicensePolicy,
|
|
12653
12777
|
outputKind,
|
|
12654
|
-
|
|
12655
|
-
fold
|
|
12656
|
-
short
|
|
12657
|
-
reportLevel
|
|
12778
|
+
filepath,
|
|
12779
|
+
fold,
|
|
12780
|
+
short,
|
|
12781
|
+
reportLevel
|
|
12658
12782
|
});
|
|
12659
12783
|
}
|
|
12660
12784
|
|
|
@@ -12899,14 +13023,14 @@ async function configureGithub(config) {
|
|
|
12899
13023
|
}
|
|
12900
13024
|
const defaultGithubApiUrl = await prompts.input({
|
|
12901
13025
|
message: '(--github-api-url) Do you want to override the default github url?',
|
|
12902
|
-
default: config.githubApiUrl || constants.ENV.GITHUB_API_URL,
|
|
13026
|
+
default: config.githubApiUrl || constants.default.ENV.GITHUB_API_URL,
|
|
12903
13027
|
required: false
|
|
12904
13028
|
// validate: async string => bool
|
|
12905
13029
|
});
|
|
12906
13030
|
if (defaultGithubApiUrl === undefined) {
|
|
12907
13031
|
return canceledByUser();
|
|
12908
13032
|
}
|
|
12909
|
-
if (defaultGithubApiUrl && defaultGithubApiUrl !== constants.ENV.GITHUB_API_URL) {
|
|
13033
|
+
if (defaultGithubApiUrl && defaultGithubApiUrl !== constants.default.ENV.GITHUB_API_URL) {
|
|
12910
13034
|
config.githubApiUrl = defaultGithubApiUrl;
|
|
12911
13035
|
} else {
|
|
12912
13036
|
delete config.githubApiUrl;
|
|
@@ -13003,7 +13127,7 @@ async function run$4(argv, importMeta, {
|
|
|
13003
13127
|
});
|
|
13004
13128
|
const dryRun = !!cli.flags['dryRun'];
|
|
13005
13129
|
if (dryRun) {
|
|
13006
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13130
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13007
13131
|
return;
|
|
13008
13132
|
}
|
|
13009
13133
|
const {
|
|
@@ -13106,7 +13230,7 @@ Scan ID: ${scanId}
|
|
|
13106
13230
|
|
|
13107
13231
|
${md}
|
|
13108
13232
|
|
|
13109
|
-
View this report at: ${constants.SOCKET_WEBSITE_URL}/dashboard/org/${orgSlug}/sbom/${scanId}
|
|
13233
|
+
View this report at: ${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/${orgSlug}/sbom/${scanId}
|
|
13110
13234
|
`.trim() + '\n';
|
|
13111
13235
|
if (filePath && filePath !== '-') {
|
|
13112
13236
|
try {
|
|
@@ -13144,7 +13268,7 @@ async function streamScan(orgSlug, scanId, options) {
|
|
|
13144
13268
|
|
|
13145
13269
|
// Note: this will write to stdout or target file. It's not a noop
|
|
13146
13270
|
return await utils.handleApiCall(sockSdk.getOrgFullScan(orgSlug, scanId, file === '-' ? undefined : file), {
|
|
13147
|
-
|
|
13271
|
+
description: 'a scan'
|
|
13148
13272
|
});
|
|
13149
13273
|
}
|
|
13150
13274
|
|
|
@@ -13214,7 +13338,9 @@ async function run$3(argv, importMeta, {
|
|
|
13214
13338
|
const interactive = !!cli.flags['interactive'];
|
|
13215
13339
|
const [scanId = '', file = ''] = cli.input;
|
|
13216
13340
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
13217
|
-
const
|
|
13341
|
+
const {
|
|
13342
|
+
0: orgSlug
|
|
13343
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
13218
13344
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
13219
13345
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
13220
13346
|
nook: true,
|
|
@@ -13245,7 +13371,7 @@ async function run$3(argv, importMeta, {
|
|
|
13245
13371
|
return;
|
|
13246
13372
|
}
|
|
13247
13373
|
if (dryRun) {
|
|
13248
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13374
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13249
13375
|
return;
|
|
13250
13376
|
}
|
|
13251
13377
|
if (json && stream) {
|
|
@@ -13332,7 +13458,7 @@ async function outputThreatFeed(result, outputKind) {
|
|
|
13332
13458
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
13333
13459
|
const ScreenWidget = /*@__PURE__*/require$1('../external/blessed/lib/widgets/screen.js');
|
|
13334
13460
|
const screen = new ScreenWidget({
|
|
13335
|
-
...constants.blessedOptions
|
|
13461
|
+
...constants.default.blessedOptions
|
|
13336
13462
|
});
|
|
13337
13463
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
13338
13464
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
@@ -13471,7 +13597,7 @@ async function handleThreatFeed({
|
|
|
13471
13597
|
}
|
|
13472
13598
|
|
|
13473
13599
|
const CMD_NAME = 'threat-feed';
|
|
13474
|
-
const ECOSYSTEMS = new Set(['gem', 'golang', 'maven',
|
|
13600
|
+
const ECOSYSTEMS = new Set(['gem', 'golang', 'maven', constants.NPM, 'nuget', 'pypi']);
|
|
13475
13601
|
const TYPE_FILTERS = new Set(['anom', 'c', 'fp', 'joke', 'mal', 'secret', 'spy', 'tp', 'typo', 'u', 'vuln']);
|
|
13476
13602
|
const description$1 = '[Beta] View the threat-feed';
|
|
13477
13603
|
const hidden = false;
|
|
@@ -13649,7 +13775,9 @@ async function run$2(argv, importMeta, {
|
|
|
13649
13775
|
logger.logger.info(`Warning: ignoring these excessive args: ${Array.from(argSet).join(', ')}`);
|
|
13650
13776
|
}
|
|
13651
13777
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
13652
|
-
const
|
|
13778
|
+
const {
|
|
13779
|
+
0: orgSlug
|
|
13780
|
+
} = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
13653
13781
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
13654
13782
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
13655
13783
|
nook: true,
|
|
@@ -13671,7 +13799,7 @@ async function run$2(argv, importMeta, {
|
|
|
13671
13799
|
return;
|
|
13672
13800
|
}
|
|
13673
13801
|
if (dryRun) {
|
|
13674
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13802
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13675
13803
|
return;
|
|
13676
13804
|
}
|
|
13677
13805
|
await handleThreatFeed({
|
|
@@ -13724,7 +13852,7 @@ async function teardownTabCompletion(targetName) {
|
|
|
13724
13852
|
} = result.data;
|
|
13725
13853
|
|
|
13726
13854
|
// Remove from ~/.bashrc if found
|
|
13727
|
-
const bashrc = constants.homePath ? path.join(constants.homePath, '.bashrc') : '';
|
|
13855
|
+
const bashrc = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
|
|
13728
13856
|
if (bashrc && fs$1.existsSync(bashrc)) {
|
|
13729
13857
|
const content = fs$1.readFileSync(bashrc, 'utf8');
|
|
13730
13858
|
if (content.includes(toAddToBashrc)) {
|
|
@@ -13818,7 +13946,7 @@ async function run$1(argv, importMeta, {
|
|
|
13818
13946
|
});
|
|
13819
13947
|
const dryRun = !!cli.flags['dryRun'];
|
|
13820
13948
|
if (dryRun) {
|
|
13821
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13949
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13822
13950
|
return;
|
|
13823
13951
|
}
|
|
13824
13952
|
const targetName = cli.input[0] || 'socket';
|
|
@@ -13879,7 +14007,7 @@ async function postinstallWrapper() {
|
|
|
13879
14007
|
const {
|
|
13880
14008
|
bashRcPath,
|
|
13881
14009
|
zshRcPath
|
|
13882
|
-
} = constants;
|
|
14010
|
+
} = constants.default;
|
|
13883
14011
|
const socketWrapperEnabled = fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
|
|
13884
14012
|
if (!socketWrapperEnabled) {
|
|
13885
14013
|
await setupShadowNpm(`
|
|
@@ -13935,7 +14063,7 @@ async function setupShadowNpm(query) {
|
|
|
13935
14063
|
const {
|
|
13936
14064
|
bashRcPath,
|
|
13937
14065
|
zshRcPath
|
|
13938
|
-
} = constants;
|
|
14066
|
+
} = constants.default;
|
|
13939
14067
|
try {
|
|
13940
14068
|
if (fs$1.existsSync(bashRcPath)) {
|
|
13941
14069
|
addSocketWrapper(bashRcPath);
|
|
@@ -14049,13 +14177,13 @@ async function run(argv, importMeta, {
|
|
|
14049
14177
|
return;
|
|
14050
14178
|
}
|
|
14051
14179
|
if (dryRun) {
|
|
14052
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
14180
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
14053
14181
|
return;
|
|
14054
14182
|
}
|
|
14055
14183
|
const {
|
|
14056
14184
|
bashRcPath,
|
|
14057
14185
|
zshRcPath
|
|
14058
|
-
} = constants;
|
|
14186
|
+
} = constants.default;
|
|
14059
14187
|
if (enable) {
|
|
14060
14188
|
if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
|
|
14061
14189
|
addSocketWrapper(bashRcPath);
|
|
@@ -14191,16 +14319,16 @@ void (async () => {
|
|
|
14191
14319
|
authInfo: vendor.registryAuthTokenExports(registryUrl, {
|
|
14192
14320
|
recursive: true
|
|
14193
14321
|
}),
|
|
14194
|
-
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14322
|
+
name: constants.default.SOCKET_CLI_BIN_NAME,
|
|
14195
14323
|
registryUrl,
|
|
14196
14324
|
ttl: 86_400_000 /* 24 hours in milliseconds */,
|
|
14197
|
-
version: constants.ENV.INLINED_SOCKET_CLI_VERSION
|
|
14325
|
+
version: constants.default.ENV.INLINED_SOCKET_CLI_VERSION
|
|
14198
14326
|
});
|
|
14199
14327
|
try {
|
|
14200
14328
|
await utils.meowWithSubcommands(rootCommands, {
|
|
14201
14329
|
aliases: rootAliases,
|
|
14202
14330
|
argv: process.argv.slice(2),
|
|
14203
|
-
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14331
|
+
name: constants.default.SOCKET_CLI_BIN_NAME,
|
|
14204
14332
|
importMeta: {
|
|
14205
14333
|
url: `${require$$0.pathToFileURL(__filename$1)}`
|
|
14206
14334
|
}
|
|
@@ -14262,5 +14390,5 @@ void (async () => {
|
|
|
14262
14390
|
await utils.captureException(e);
|
|
14263
14391
|
}
|
|
14264
14392
|
})();
|
|
14265
|
-
//# debugId=
|
|
14393
|
+
//# debugId=d759edd3-a3fb-4517-b02a-4526b3195d3
|
|
14266
14394
|
//# sourceMappingURL=cli.js.map
|