socket 1.0.64 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +704 -521
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +18 -11
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-inject.js +13 -16
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts +6 -2
- package/dist/types/commands/analytics/fetch-org-analytics.d.mts.map +1 -1
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts +6 -2
- package/dist/types/commands/analytics/fetch-repo-analytics.d.mts.map +1 -1
- package/dist/types/commands/analytics/output-analytics.d.mts +4 -4
- package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts +10 -5
- package/dist/types/commands/audit-log/fetch-audit-log.d.mts.map +1 -1
- package/dist/types/commands/audit-log/handle-audit-log.d.mts +1 -1
- package/dist/types/commands/audit-log/handle-audit-log.d.mts.map +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts +6 -6
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts +1 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-get.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-set.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +1 -1
- package/dist/types/commands/config/discover-config-value.d.mts.map +1 -1
- package/dist/types/commands/config/output-config-list.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts +2 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/login/attempt-login.d.mts.map +1 -1
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts +1 -1
- package/dist/types/commands/manifest/convert-conda-to-requirements.d.mts.map +1 -1
- package/dist/types/commands/manifest/output-requirements.d.mts +1 -1
- package/dist/types/commands/manifest/output-requirements.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-dependencies.d.mts +8 -3
- package/dist/types/commands/organization/fetch-dependencies.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-license-policy.d.mts +6 -2
- package/dist/types/commands/organization/fetch-license-policy.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +6 -2
- package/dist/types/commands/organization/fetch-organization-list.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-quota.d.mts +6 -2
- package/dist/types/commands/organization/fetch-quota.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-security-policy.d.mts +6 -2
- package/dist/types/commands/organization/fetch-security-policy.d.mts.map +1 -1
- package/dist/types/commands/organization/output-dependencies.d.mts +2 -2
- package/dist/types/commands/organization/output-dependencies.d.mts.map +1 -1
- package/dist/types/commands/organization/output-license-policy.d.mts +2 -2
- package/dist/types/commands/organization/output-license-policy.d.mts.map +1 -1
- package/dist/types/commands/organization/output-organization-list.d.mts +2 -2
- package/dist/types/commands/organization/output-organization-list.d.mts.map +1 -1
- package/dist/types/commands/organization/output-quota.d.mts +2 -2
- package/dist/types/commands/organization/output-quota.d.mts.map +1 -1
- package/dist/types/commands/organization/output-security-policy.d.mts +2 -2
- package/dist/types/commands/organization/output-security-policy.d.mts.map +1 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts +6 -2
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-create-repo.d.mts +11 -6
- package/dist/types/commands/repository/fetch-create-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-delete-repo.d.mts +6 -2
- package/dist/types/commands/repository/fetch-delete-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts +8 -6
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-repos.d.mts +9 -4
- package/dist/types/commands/repository/fetch-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-update-repo.d.mts +11 -6
- package/dist/types/commands/repository/fetch-update-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-view-repo.d.mts +6 -2
- package/dist/types/commands/repository/fetch-view-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-create-repo.d.mts +2 -2
- package/dist/types/commands/repository/handle-create-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-list-repos.d.mts +2 -2
- package/dist/types/commands/repository/handle-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-update-repo.d.mts +2 -2
- package/dist/types/commands/repository/handle-update-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-create-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-create-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-delete-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-delete-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-list-repos.d.mts +2 -2
- package/dist/types/commands/repository/output-list-repos.d.mts.map +1 -1
- package/dist/types/commands/repository/output-update-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-update-repo.d.mts.map +1 -1
- package/dist/types/commands/repository/output-view-repo.d.mts +2 -2
- package/dist/types/commands/repository/output-view-repo.d.mts.map +1 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts +12 -3
- package/dist/types/commands/scan/fetch-create-org-full-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts +6 -2
- package/dist/types/commands/scan/fetch-delete-org-full-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-diff-scan.d.mts +2 -2
- package/dist/types/commands/scan/fetch-diff-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-list-scans.d.mts +9 -4
- package/dist/types/commands/scan/fetch-list-scans.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts +8 -3
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts +6 -2
- package/dist/types/commands/scan/fetch-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts +6 -2
- package/dist/types/commands/scan/fetch-supported-scan-file-names.d.mts.map +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +2 -2
- package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-list-scans.d.mts +2 -2
- package/dist/types/commands/scan/handle-list-scans.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/output-create-new-scan.d.mts +2 -2
- package/dist/types/commands/scan/output-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-delete-scan.d.mts +2 -2
- package/dist/types/commands/scan/output-delete-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-diff-scan.d.mts +2 -2
- package/dist/types/commands/scan/output-diff-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/output-list-scans.d.mts +2 -2
- package/dist/types/commands/scan/output-list-scans.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-metadata.d.mts +2 -2
- package/dist/types/commands/scan/output-scan-metadata.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-report.d.mts +2 -2
- package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/stream-scan.d.mts +6 -1
- package/dist/types/commands/scan/stream-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/suggest-org-slug.d.mts.map +1 -1
- package/dist/types/commands/scan/suggest-repo-slug.d.mts +5 -1
- package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +1 -1
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/utils/alert/severity.d.mts +2 -2
- package/dist/types/utils/alert/severity.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts +1 -1
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts +8 -3
- 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 +4 -2
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/fs.d.mts +3 -1
- package/dist/types/utils/fs.d.mts.map +1 -1
- package/dist/types/utils/glob.d.mts +4 -2
- package/dist/types/utils/glob.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts +2 -2
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/types/utils/sdk.d.mts +6 -1
- package/dist/types/utils/sdk.d.mts.map +1 -1
- package/dist/utils.js +262 -145
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +143 -64
- package/external/@socketsecurity/registry/extensions.json +2 -2
- package/external/@socketsecurity/registry/external/@inquirer/select.js +14 -2
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +4 -4
- package/external/@socketsecurity/registry/external/@socketregistry/yocto-spinner.js +20 -11
- package/external/@socketsecurity/registry/external/libnpmpack.js +4 -4
- package/external/@socketsecurity/registry/external/npm-package-arg.js +4 -4
- package/external/@socketsecurity/registry/external/pacote.js +4 -4
- package/external/@socketsecurity/registry/external/validate-npm-package-name.js +4 -4
- package/external/@socketsecurity/registry/lib/regexps.js +1 -1
- package/external/@socketsecurity/registry/lib/spinner.js +27 -23
- package/external/@socketsecurity/registry/manifest.json +7 -7
- package/package.json +14 -14
package/dist/cli.js
CHANGED
|
@@ -14,44 +14,59 @@ var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
|
14
14
|
var fs$1 = require('node:fs');
|
|
15
15
|
var path = require('node:path');
|
|
16
16
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
17
|
+
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
17
18
|
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
18
19
|
var registry = require('../external/@socketsecurity/registry');
|
|
19
20
|
var npm = require('../external/@socketsecurity/registry/lib/npm');
|
|
20
21
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
21
22
|
var sorts = require('../external/@socketsecurity/registry/lib/sorts');
|
|
22
|
-
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
23
23
|
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
24
24
|
var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
|
|
25
25
|
var shadowNpmInject = require('./shadow-npm-inject.js');
|
|
26
|
-
var
|
|
26
|
+
var require$$7 = require('../external/@socketsecurity/registry/lib/objects');
|
|
27
27
|
var shadowNpmBin = require('./shadow-npm-bin.js');
|
|
28
|
-
var require$$
|
|
28
|
+
var require$$8 = require('../external/@socketsecurity/registry/lib/promises');
|
|
29
29
|
var require$$1 = require('node:util');
|
|
30
30
|
var os = require('node:os');
|
|
31
31
|
var promises = require('node:stream/promises');
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
async function fetchOrgAnalyticsData(time, options) {
|
|
34
|
+
const {
|
|
35
|
+
sdkOptions
|
|
36
|
+
} = {
|
|
37
|
+
__proto__: null,
|
|
38
|
+
...options
|
|
39
|
+
};
|
|
40
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
36
41
|
if (!sockSdkCResult.ok) {
|
|
37
42
|
return sockSdkCResult;
|
|
38
43
|
}
|
|
39
44
|
const sockSdk = sockSdkCResult.data;
|
|
40
|
-
return await utils.handleApiCall(sockSdk.getOrgAnalytics(time.toString()),
|
|
45
|
+
return await utils.handleApiCall(sockSdk.getOrgAnalytics(time.toString()), {
|
|
46
|
+
desc: 'analytics data'
|
|
47
|
+
});
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
async function fetchRepoAnalyticsData(repo, time) {
|
|
44
|
-
const
|
|
50
|
+
async function fetchRepoAnalyticsData(repo, time, options) {
|
|
51
|
+
const {
|
|
52
|
+
sdkOptions
|
|
53
|
+
} = {
|
|
54
|
+
__proto__: null,
|
|
55
|
+
...options
|
|
56
|
+
};
|
|
57
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
45
58
|
if (!sockSdkCResult.ok) {
|
|
46
59
|
return sockSdkCResult;
|
|
47
60
|
}
|
|
48
61
|
const sockSdk = sockSdkCResult.data;
|
|
49
|
-
return await utils.handleApiCall(sockSdk.getRepoAnalytics(repo, time.toString()),
|
|
62
|
+
return await utils.handleApiCall(sockSdk.getRepoAnalytics(repo, time.toString()), {
|
|
63
|
+
desc: 'analytics data'
|
|
64
|
+
});
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
// Note: Widgets does not seem to actually work as code :'(
|
|
53
68
|
|
|
54
|
-
const require$5 = require$$5.createRequire((
|
|
69
|
+
const require$5 = require$$5.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
55
70
|
const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
|
|
56
71
|
|
|
57
72
|
// Note: This maps `new Date(date).getMonth()` to English three letters
|
|
@@ -130,12 +145,12 @@ ${utils.mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
|
|
|
130
145
|
`.trim() + '\n';
|
|
131
146
|
}
|
|
132
147
|
function displayAnalyticsScreen(data) {
|
|
133
|
-
const ScreenWidget = require$5('../external/blessed/lib/widgets/screen.js');
|
|
148
|
+
const ScreenWidget = /*@__PURE__*/require$5('../external/blessed/lib/widgets/screen.js');
|
|
134
149
|
// Lazily access constants.blessedOptions.
|
|
135
150
|
const screen = new ScreenWidget({
|
|
136
151
|
...constants.blessedOptions
|
|
137
152
|
});
|
|
138
|
-
const GridLayout = require$5('../external/blessed-contrib/lib/layout/grid.js');
|
|
153
|
+
const GridLayout = /*@__PURE__*/require$5('../external/blessed-contrib/lib/layout/grid.js');
|
|
139
154
|
const grid = new GridLayout({
|
|
140
155
|
rows: 5,
|
|
141
156
|
cols: 4,
|
|
@@ -149,7 +164,7 @@ function displayAnalyticsScreen(data) {
|
|
|
149
164
|
renderLineCharts(grid, screen, 'Total high alerts prevented from the main branch', [2, 2, 1, 2], data['total_high_prevented']);
|
|
150
165
|
renderLineCharts(grid, screen, 'Total medium alerts prevented from the main branch', [3, 0, 1, 2], data['total_medium_prevented']);
|
|
151
166
|
renderLineCharts(grid, screen, 'Total low alerts prevented from the main branch', [3, 2, 1, 2], data['total_low_prevented']);
|
|
152
|
-
const BarChart = require$5('../external/blessed-contrib/lib/widget/charts/bar.js');
|
|
167
|
+
const BarChart = /*@__PURE__*/require$5('../external/blessed-contrib/lib/widget/charts/bar.js');
|
|
153
168
|
const bar = grid.set(4, 0, 1, 2, BarChart, {
|
|
154
169
|
label: 'Top 5 alert types',
|
|
155
170
|
barWidth: 10,
|
|
@@ -242,7 +257,7 @@ function formatDate(date) {
|
|
|
242
257
|
return `${Months[new Date(date).getMonth()]} ${new Date(date).getDate()}`;
|
|
243
258
|
}
|
|
244
259
|
function renderLineCharts(grid, screen, title, coords, data) {
|
|
245
|
-
const LineChart = require$5('../external/blessed-contrib/lib/widget/charts/line.js');
|
|
260
|
+
const LineChart = /*@__PURE__*/require$5('../external/blessed-contrib/lib/widget/charts/line.js');
|
|
246
261
|
const line = grid.set(...coords, LineChart, {
|
|
247
262
|
style: {
|
|
248
263
|
line: 'cyan',
|
|
@@ -303,7 +318,7 @@ async function handleAnalytics({
|
|
|
303
318
|
const {
|
|
304
319
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$M
|
|
305
320
|
} = constants;
|
|
306
|
-
const config$
|
|
321
|
+
const config$M = {
|
|
307
322
|
commandName: 'analytics',
|
|
308
323
|
description: `Look up analytics data`,
|
|
309
324
|
hidden: false,
|
|
@@ -341,8 +356,8 @@ const config$P = {
|
|
|
341
356
|
`
|
|
342
357
|
};
|
|
343
358
|
const cmdAnalytics = {
|
|
344
|
-
description: config$
|
|
345
|
-
hidden: config$
|
|
359
|
+
description: config$M.description,
|
|
360
|
+
hidden: config$M.hidden,
|
|
346
361
|
run: run$P
|
|
347
362
|
};
|
|
348
363
|
async function run$P(argv, importMeta, {
|
|
@@ -350,7 +365,7 @@ async function run$P(argv, importMeta, {
|
|
|
350
365
|
}) {
|
|
351
366
|
const cli = utils.meowOrExit({
|
|
352
367
|
argv,
|
|
353
|
-
config: config$
|
|
368
|
+
config: config$M,
|
|
354
369
|
importMeta,
|
|
355
370
|
parentName
|
|
356
371
|
});
|
|
@@ -447,18 +462,28 @@ async function run$P(argv, importMeta, {
|
|
|
447
462
|
});
|
|
448
463
|
}
|
|
449
464
|
|
|
450
|
-
async function fetchAuditLog({
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
}
|
|
457
|
-
const sockSdkCResult = await utils.setupSdk();
|
|
465
|
+
async function fetchAuditLog(config, options) {
|
|
466
|
+
const {
|
|
467
|
+
sdkOptions
|
|
468
|
+
} = {
|
|
469
|
+
__proto__: null,
|
|
470
|
+
...options
|
|
471
|
+
};
|
|
472
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
458
473
|
if (!sockSdkCResult.ok) {
|
|
459
474
|
return sockSdkCResult;
|
|
460
475
|
}
|
|
461
476
|
const sockSdk = sockSdkCResult.data;
|
|
477
|
+
const {
|
|
478
|
+
logType,
|
|
479
|
+
orgSlug,
|
|
480
|
+
outputKind,
|
|
481
|
+
page,
|
|
482
|
+
perPage
|
|
483
|
+
} = {
|
|
484
|
+
__proto__: null,
|
|
485
|
+
...config
|
|
486
|
+
};
|
|
462
487
|
return await utils.handleApiCall(sockSdk.getAuditLogEvents(orgSlug, {
|
|
463
488
|
// I'm not sure this is used at all.
|
|
464
489
|
outputJson: String(outputKind === 'json'),
|
|
@@ -468,10 +493,12 @@ async function fetchAuditLog({
|
|
|
468
493
|
type: logType,
|
|
469
494
|
page: String(page),
|
|
470
495
|
per_page: String(perPage)
|
|
471
|
-
}),
|
|
496
|
+
}), {
|
|
497
|
+
desc: `audit log for ${orgSlug}`
|
|
498
|
+
});
|
|
472
499
|
}
|
|
473
500
|
|
|
474
|
-
const require$4 = require$$5.createRequire((
|
|
501
|
+
const require$4 = require$$5.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
475
502
|
const {
|
|
476
503
|
REDACTED
|
|
477
504
|
} = constants;
|
|
@@ -539,10 +566,10 @@ async function outputAsJson(auditLogs, {
|
|
|
539
566
|
desc: 'Audit logs for given query',
|
|
540
567
|
// Lazily access constants.ENV.VITEST.
|
|
541
568
|
generated: constants.ENV.VITEST ? REDACTED : new Date().toISOString(),
|
|
542
|
-
org: orgSlug,
|
|
543
569
|
logType,
|
|
544
|
-
page,
|
|
545
570
|
nextPage: auditLogs.data.nextPage,
|
|
571
|
+
org: orgSlug,
|
|
572
|
+
page,
|
|
546
573
|
perPage,
|
|
547
574
|
logs: auditLogs.data.results.map(log => {
|
|
548
575
|
// Note: The subset is pretty arbitrary
|
|
@@ -603,7 +630,7 @@ async function outputWithBlessed(data, orgSlug) {
|
|
|
603
630
|
const headers = [' Event id', ' Created at', ' Event type', ' User email', ' IP address', ' User agent'];
|
|
604
631
|
|
|
605
632
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
606
|
-
const ScreenWidget = require$4('../external/blessed/lib/widgets/screen.js');
|
|
633
|
+
const ScreenWidget = /*@__PURE__*/require$4('../external/blessed/lib/widgets/screen.js');
|
|
607
634
|
// Lazily access constants.blessedOptions.
|
|
608
635
|
const screen = new ScreenWidget({
|
|
609
636
|
...constants.blessedOptions
|
|
@@ -613,7 +640,7 @@ async function outputWithBlessed(data, orgSlug) {
|
|
|
613
640
|
// node process just to exit it. That's very bad UX.
|
|
614
641
|
// eslint-disable-next-line n/no-process-exit
|
|
615
642
|
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
616
|
-
const TableWidget = require$4('../external/blessed-contrib/lib/widget/table.js');
|
|
643
|
+
const TableWidget = /*@__PURE__*/require$4('../external/blessed-contrib/lib/widget/table.js');
|
|
617
644
|
const tipsBoxHeight = 1; // 1 row for tips box
|
|
618
645
|
const detailsBoxHeight = 20; // bottom N rows for details box. 20 gives 4 lines for condensed payload before it scrolls out of view
|
|
619
646
|
|
|
@@ -643,7 +670,7 @@ async function outputWithBlessed(data, orgSlug) {
|
|
|
643
670
|
columnSpacing: 4,
|
|
644
671
|
truncate: '_'
|
|
645
672
|
});
|
|
646
|
-
const BoxWidget = require$4('../external/blessed/lib/widgets/box.js');
|
|
673
|
+
const BoxWidget = /*@__PURE__*/require$4('../external/blessed/lib/widgets/box.js');
|
|
647
674
|
const tipsBox = new BoxWidget({
|
|
648
675
|
bottom: detailsBoxHeight,
|
|
649
676
|
// sits just above the details box
|
|
@@ -709,11 +736,11 @@ async function handleAuditLog({
|
|
|
709
736
|
perPage
|
|
710
737
|
}) {
|
|
711
738
|
const auditLogs = await fetchAuditLog({
|
|
739
|
+
logType,
|
|
712
740
|
orgSlug,
|
|
713
741
|
outputKind,
|
|
714
742
|
page,
|
|
715
|
-
perPage
|
|
716
|
-
logType
|
|
743
|
+
perPage
|
|
717
744
|
});
|
|
718
745
|
await outputAuditLog(auditLogs, {
|
|
719
746
|
logType,
|
|
@@ -728,7 +755,7 @@ const {
|
|
|
728
755
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$L,
|
|
729
756
|
SOCKET_WEBSITE_URL: SOCKET_WEBSITE_URL$3
|
|
730
757
|
} = constants;
|
|
731
|
-
const config$
|
|
758
|
+
const config$L = {
|
|
732
759
|
commandName: 'audit-log',
|
|
733
760
|
description: 'Look up the audit log for an organization',
|
|
734
761
|
hidden: false,
|
|
@@ -786,8 +813,8 @@ const config$O = {
|
|
|
786
813
|
`
|
|
787
814
|
};
|
|
788
815
|
const cmdAuditLog = {
|
|
789
|
-
description: config$
|
|
790
|
-
hidden: config$
|
|
816
|
+
description: config$L.description,
|
|
817
|
+
hidden: config$L.hidden,
|
|
791
818
|
run: run$O
|
|
792
819
|
};
|
|
793
820
|
async function run$O(argv, importMeta, {
|
|
@@ -795,7 +822,7 @@ async function run$O(argv, importMeta, {
|
|
|
795
822
|
}) {
|
|
796
823
|
const cli = utils.meowOrExit({
|
|
797
824
|
argv,
|
|
798
|
-
config: config$
|
|
825
|
+
config: config$L,
|
|
799
826
|
importMeta,
|
|
800
827
|
parentName
|
|
801
828
|
});
|
|
@@ -861,68 +888,34 @@ async function run$O(argv, importMeta, {
|
|
|
861
888
|
});
|
|
862
889
|
}
|
|
863
890
|
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
if (!sockSdkCResult.ok) {
|
|
876
|
-
return sockSdkCResult;
|
|
877
|
-
}
|
|
878
|
-
const sockSdk = sockSdkCResult.data;
|
|
879
|
-
const result = await utils.handleApiCall(sockSdk.getOrganizations(), 'list of organizations');
|
|
880
|
-
if (!result.ok) {
|
|
881
|
-
return result;
|
|
882
|
-
}
|
|
883
|
-
const orgs = result.data.organizations;
|
|
884
|
-
const keys = Object.keys(orgs);
|
|
885
|
-
if (!keys[0]) {
|
|
886
|
-
return {
|
|
887
|
-
ok: false,
|
|
888
|
-
message: 'Failed to establish identity',
|
|
889
|
-
data: `API did not return any organization associated with the current API token. Unable to continue.`
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
const slug = (keys[0] in orgs && orgs?.[keys[0]]?.name) ?? undefined;
|
|
893
|
-
if (!slug) {
|
|
894
|
-
return {
|
|
895
|
-
ok: false,
|
|
896
|
-
message: 'Failed to establish identity',
|
|
897
|
-
data: `Was unable to determine the default organization for the current API token. Unable to continue.`
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
debug.debugFn('notice', 'resolve: org', slug);
|
|
901
|
-
return {
|
|
902
|
-
ok: true,
|
|
903
|
-
message: 'Retrieved default org from server',
|
|
904
|
-
data: slug
|
|
891
|
+
async function fetchCreateOrgFullScan(packagePaths, orgSlug, config, options) {
|
|
892
|
+
const {
|
|
893
|
+
branchName,
|
|
894
|
+
commitHash,
|
|
895
|
+
commitMessage,
|
|
896
|
+
committers,
|
|
897
|
+
pullRequest,
|
|
898
|
+
repoName
|
|
899
|
+
} = {
|
|
900
|
+
__proto__: null,
|
|
901
|
+
...config
|
|
905
902
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
repoName
|
|
918
|
-
}) {
|
|
919
|
-
const sockSdkCResult = await utils.setupSdk();
|
|
903
|
+
const {
|
|
904
|
+
cwd = process.cwd(),
|
|
905
|
+
defaultBranch,
|
|
906
|
+
pendingHead,
|
|
907
|
+
sdkOptions,
|
|
908
|
+
tmp
|
|
909
|
+
} = {
|
|
910
|
+
__proto__: null,
|
|
911
|
+
...options
|
|
912
|
+
};
|
|
913
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
920
914
|
if (!sockSdkCResult.ok) {
|
|
921
915
|
return sockSdkCResult;
|
|
922
916
|
}
|
|
923
917
|
const sockSdk = sockSdkCResult.data;
|
|
924
|
-
|
|
925
|
-
return await utils.handleApiCall(sockSdk.createOrgFullScan(orgSlug, {
|
|
918
|
+
return await utils.handleApiCall(sockSdk.createOrgFullScan(orgSlug, packagePaths, cwd, {
|
|
926
919
|
...(branchName ? {
|
|
927
920
|
branch: branchName
|
|
928
921
|
} : {}),
|
|
@@ -939,28 +932,44 @@ async function fetchCreateOrgFullScan(packagePaths, orgSlug, defaultBranch, pend
|
|
|
939
932
|
...(pullRequest ? {
|
|
940
933
|
pull_request: String(pullRequest)
|
|
941
934
|
} : {}),
|
|
942
|
-
|
|
943
|
-
repo,
|
|
935
|
+
repo: repoName,
|
|
944
936
|
set_as_pending_head: String(pendingHead),
|
|
945
937
|
tmp: String(tmp)
|
|
946
|
-
}
|
|
938
|
+
}), {
|
|
939
|
+
desc: 'to create a scan'
|
|
940
|
+
});
|
|
947
941
|
}
|
|
948
942
|
|
|
949
|
-
async function fetchSupportedScanFileNames() {
|
|
950
|
-
const
|
|
943
|
+
async function fetchSupportedScanFileNames(options) {
|
|
944
|
+
const {
|
|
945
|
+
sdkOptions
|
|
946
|
+
} = {
|
|
947
|
+
__proto__: null,
|
|
948
|
+
...options
|
|
949
|
+
};
|
|
950
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
951
951
|
if (!sockSdkCResult.ok) {
|
|
952
952
|
return sockSdkCResult;
|
|
953
953
|
}
|
|
954
954
|
const sockSdk = sockSdkCResult.data;
|
|
955
|
-
return await utils.handleApiCall(sockSdk.
|
|
955
|
+
return await utils.handleApiCall(sockSdk.getSupportedScanFiles(), {
|
|
956
|
+
desc: 'supported scan file types'
|
|
957
|
+
});
|
|
956
958
|
}
|
|
957
959
|
|
|
958
960
|
/**
|
|
959
961
|
* This fetches all the relevant pieces of data to generate a report, given a
|
|
960
962
|
* full scan ID.
|
|
961
963
|
*/
|
|
962
|
-
async function
|
|
963
|
-
const
|
|
964
|
+
async function fetchScanData(orgSlug, scanId, options) {
|
|
965
|
+
const {
|
|
966
|
+
includeLicensePolicy,
|
|
967
|
+
sdkOptions
|
|
968
|
+
} = {
|
|
969
|
+
__proto__: null,
|
|
970
|
+
...options
|
|
971
|
+
};
|
|
972
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
964
973
|
if (!sockSdkCResult.ok) {
|
|
965
974
|
return sockSdkCResult;
|
|
966
975
|
}
|
|
@@ -1439,8 +1448,10 @@ async function handleScanReport({
|
|
|
1439
1448
|
scanId,
|
|
1440
1449
|
short
|
|
1441
1450
|
}) {
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1451
|
+
const scanDataCResult = await fetchScanData(orgSlug, scanId, {
|
|
1452
|
+
includeLicensePolicy
|
|
1453
|
+
});
|
|
1454
|
+
await outputScanReport(scanDataCResult, {
|
|
1444
1455
|
filePath,
|
|
1445
1456
|
fold,
|
|
1446
1457
|
scanId: scanId,
|
|
@@ -1465,7 +1476,7 @@ async function outputCreateNewScan(result, outputKind, interactive) {
|
|
|
1465
1476
|
return;
|
|
1466
1477
|
}
|
|
1467
1478
|
if (!result.data.id) {
|
|
1468
|
-
logger.logger.fail('Did not receive a scan ID from the API
|
|
1479
|
+
logger.logger.fail('Did not receive a scan ID from the API.');
|
|
1469
1480
|
process.exitCode = 1;
|
|
1470
1481
|
}
|
|
1471
1482
|
if (outputKind === 'markdown') {
|
|
@@ -1745,20 +1756,23 @@ async function convertSbtToMaven({
|
|
|
1745
1756
|
}
|
|
1746
1757
|
}
|
|
1747
1758
|
|
|
1759
|
+
function prepareContent(content) {
|
|
1760
|
+
return strings.stripAnsi(content.trim());
|
|
1761
|
+
}
|
|
1748
1762
|
async function convertCondaToRequirements(filename, cwd, verbose) {
|
|
1749
|
-
let
|
|
1763
|
+
let content;
|
|
1750
1764
|
if (filename === '-') {
|
|
1751
1765
|
if (verbose) {
|
|
1752
1766
|
logger.logger.info(`[VERBOSE] reading input from stdin`);
|
|
1753
1767
|
}
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1768
|
+
const strings = [];
|
|
1769
|
+
content = await new Promise((resolve, reject) => {
|
|
1756
1770
|
process.stdin.on('data', chunk => {
|
|
1757
1771
|
const input = chunk.toString();
|
|
1758
|
-
|
|
1772
|
+
strings.push(input);
|
|
1759
1773
|
});
|
|
1760
1774
|
process.stdin.on('end', () => {
|
|
1761
|
-
resolve(
|
|
1775
|
+
resolve(prepareContent(strings.join('')));
|
|
1762
1776
|
});
|
|
1763
1777
|
process.stdin.on('error', e => {
|
|
1764
1778
|
if (verbose) {
|
|
@@ -1767,20 +1781,20 @@ async function convertCondaToRequirements(filename, cwd, verbose) {
|
|
|
1767
1781
|
reject(e);
|
|
1768
1782
|
});
|
|
1769
1783
|
process.stdin.on('close', () => {
|
|
1770
|
-
if (
|
|
1784
|
+
if (strings.length) {
|
|
1771
1785
|
if (verbose) {
|
|
1772
|
-
logger.logger.error('stdin closed explicitly
|
|
1786
|
+
logger.logger.error('warning: stdin closed explicitly with some data received');
|
|
1773
1787
|
}
|
|
1774
|
-
|
|
1788
|
+
resolve(prepareContent(strings.join('')));
|
|
1775
1789
|
} else {
|
|
1776
1790
|
if (verbose) {
|
|
1777
|
-
logger.logger.error('
|
|
1791
|
+
logger.logger.error('stdin closed explicitly without data received');
|
|
1778
1792
|
}
|
|
1779
|
-
|
|
1793
|
+
reject(new Error('No data received from stdin'));
|
|
1780
1794
|
}
|
|
1781
1795
|
});
|
|
1782
1796
|
});
|
|
1783
|
-
if (!
|
|
1797
|
+
if (!content) {
|
|
1784
1798
|
return {
|
|
1785
1799
|
ok: false,
|
|
1786
1800
|
message: 'Manifest Generation Failed',
|
|
@@ -1799,8 +1813,8 @@ async function convertCondaToRequirements(filename, cwd, verbose) {
|
|
|
1799
1813
|
cause: `The file was not found at ${filepath}`
|
|
1800
1814
|
};
|
|
1801
1815
|
}
|
|
1802
|
-
|
|
1803
|
-
if (!
|
|
1816
|
+
content = fs$1.readFileSync(filepath, 'utf8');
|
|
1817
|
+
if (!content) {
|
|
1804
1818
|
return {
|
|
1805
1819
|
ok: false,
|
|
1806
1820
|
message: 'Manifest Generation Failed',
|
|
@@ -1811,60 +1825,59 @@ async function convertCondaToRequirements(filename, cwd, verbose) {
|
|
|
1811
1825
|
return {
|
|
1812
1826
|
ok: true,
|
|
1813
1827
|
data: {
|
|
1814
|
-
|
|
1815
|
-
pip: convertCondaToRequirementsFromInput(
|
|
1828
|
+
content,
|
|
1829
|
+
pip: convertCondaToRequirementsFromInput(content)
|
|
1816
1830
|
}
|
|
1817
1831
|
};
|
|
1818
1832
|
}
|
|
1819
1833
|
|
|
1820
1834
|
// Just extract the first pip block, if one exists at all.
|
|
1821
1835
|
function convertCondaToRequirementsFromInput(input) {
|
|
1822
|
-
const keeping = [];
|
|
1823
1836
|
let collecting = false;
|
|
1824
1837
|
let delim = '-';
|
|
1825
1838
|
let indent = '';
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1839
|
+
const keeping = [];
|
|
1840
|
+
for (const line of input.split('\n')) {
|
|
1841
|
+
const trimmed = line.trim();
|
|
1842
|
+
if (!trimmed) {
|
|
1843
|
+
// Ignore empty lines.
|
|
1844
|
+
continue;
|
|
1830
1845
|
}
|
|
1831
1846
|
if (collecting) {
|
|
1832
1847
|
if (line.startsWith('#')) {
|
|
1833
|
-
// Ignore comment lines (keep?)
|
|
1834
|
-
|
|
1848
|
+
// Ignore comment lines (keep?).
|
|
1849
|
+
continue;
|
|
1835
1850
|
}
|
|
1836
1851
|
if (line.startsWith(delim)) {
|
|
1837
1852
|
// In this case we have a line with the same indentation as the
|
|
1838
1853
|
// `- pip:` line, so we have reached the end of the pip block.
|
|
1839
|
-
|
|
1840
|
-
}
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
}
|
|
1854
|
+
break;
|
|
1855
|
+
}
|
|
1856
|
+
if (!indent) {
|
|
1857
|
+
// Store the indentation of the block.
|
|
1858
|
+
if (trimmed.startsWith('-')) {
|
|
1859
|
+
indent = line.split('-')[0] + '-';
|
|
1860
|
+
if (indent.length <= delim.length) {
|
|
1861
|
+
// The first line after the `pip:` line does not indent further
|
|
1862
|
+
// than that so the block is empty?
|
|
1863
|
+
break;
|
|
1850
1864
|
}
|
|
1851
1865
|
}
|
|
1852
|
-
if (line.startsWith(indent)) {
|
|
1853
|
-
keeping.push(line.slice(indent.length).trim());
|
|
1854
|
-
} else {
|
|
1855
|
-
// Unexpected input. bail.
|
|
1856
|
-
return true;
|
|
1857
|
-
}
|
|
1858
1866
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1867
|
+
if (line.startsWith(indent)) {
|
|
1868
|
+
keeping.push(line.slice(indent.length).trim());
|
|
1869
|
+
} else {
|
|
1870
|
+
// Unexpected input. bail.
|
|
1871
|
+
break;
|
|
1864
1872
|
}
|
|
1865
1873
|
}
|
|
1866
|
-
|
|
1867
|
-
|
|
1874
|
+
// Note: the line may end with a line comment so don't === it.
|
|
1875
|
+
else if (trimmed.startsWith('- pip:')) {
|
|
1876
|
+
delim = line.split('-')[0] + '-';
|
|
1877
|
+
collecting = true;
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
return prepareContent(keeping.join('\n'));
|
|
1868
1881
|
}
|
|
1869
1882
|
|
|
1870
1883
|
async function outputRequirements(result, outputKind, out) {
|
|
@@ -2035,13 +2048,18 @@ async function handleCreateNewScan({
|
|
|
2035
2048
|
logger.logger.log('[ReadOnly] Bailing now');
|
|
2036
2049
|
return;
|
|
2037
2050
|
}
|
|
2038
|
-
const fullScanCResult = await fetchCreateOrgFullScan(packagePaths, orgSlug,
|
|
2051
|
+
const fullScanCResult = await fetchCreateOrgFullScan(packagePaths, orgSlug, {
|
|
2039
2052
|
commitHash,
|
|
2040
2053
|
commitMessage,
|
|
2041
2054
|
committers,
|
|
2042
2055
|
pullRequest,
|
|
2043
2056
|
repoName,
|
|
2044
2057
|
branchName
|
|
2058
|
+
}, {
|
|
2059
|
+
cwd,
|
|
2060
|
+
defaultBranch,
|
|
2061
|
+
pendingHead,
|
|
2062
|
+
tmp
|
|
2045
2063
|
});
|
|
2046
2064
|
if (fullScanCResult.ok && report) {
|
|
2047
2065
|
if (fullScanCResult.data?.id) {
|
|
@@ -2068,40 +2086,39 @@ async function handleCreateNewScan({
|
|
|
2068
2086
|
}
|
|
2069
2087
|
}
|
|
2070
2088
|
|
|
2071
|
-
|
|
2072
|
-
SOCKET_DEFAULT_BRANCH: SOCKET_DEFAULT_BRANCH$2,
|
|
2073
|
-
SOCKET_DEFAULT_REPOSITORY: SOCKET_DEFAULT_REPOSITORY$2
|
|
2074
|
-
} = constants;
|
|
2075
|
-
async function handleCI(autoManifest) {
|
|
2089
|
+
async function handleCi(autoManifest) {
|
|
2076
2090
|
// ci: {
|
|
2077
2091
|
// description: 'Alias for "report create --view --strict"',
|
|
2078
2092
|
// argv: ['report', 'create', '--view', '--strict']
|
|
2079
2093
|
// }
|
|
2080
|
-
const
|
|
2081
|
-
if (!
|
|
2082
|
-
process.exitCode =
|
|
2094
|
+
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
2095
|
+
if (!orgSlugCResult.ok) {
|
|
2096
|
+
process.exitCode = orgSlugCResult.code ?? 1;
|
|
2083
2097
|
// Always assume json mode.
|
|
2084
|
-
logger.logger.log(utils.serializeResultJson(
|
|
2098
|
+
logger.logger.log(utils.serializeResultJson(orgSlugCResult));
|
|
2085
2099
|
return;
|
|
2086
2100
|
}
|
|
2101
|
+
const orgSlug = orgSlugCResult.data;
|
|
2087
2102
|
const cwd = process.cwd();
|
|
2088
|
-
|
|
2089
|
-
|
|
2103
|
+
// Lazily access constants.SOCKET_DEFAULT_BRANCH.
|
|
2104
|
+
const branchName = (await utils.gitBranch(cwd)) || constants.SOCKET_DEFAULT_BRANCH;
|
|
2105
|
+
// Lazily access constants.SOCKET_DEFAULT_REPOSITORY.
|
|
2106
|
+
const repoName = (await utils.getRepoName(cwd)) || constants.SOCKET_DEFAULT_REPOSITORY;
|
|
2090
2107
|
await handleCreateNewScan({
|
|
2091
2108
|
autoManifest,
|
|
2092
|
-
branchName
|
|
2109
|
+
branchName,
|
|
2093
2110
|
commitMessage: '',
|
|
2094
2111
|
commitHash: '',
|
|
2095
2112
|
committers: '',
|
|
2096
|
-
cwd
|
|
2113
|
+
cwd,
|
|
2097
2114
|
defaultBranch: false,
|
|
2098
2115
|
interactive: false,
|
|
2099
|
-
orgSlug
|
|
2116
|
+
orgSlug,
|
|
2100
2117
|
outputKind: 'json',
|
|
2101
2118
|
// When 'pendingHead' is true, it requires 'branchName' set and 'tmp' false.
|
|
2102
2119
|
pendingHead: true,
|
|
2103
2120
|
pullRequest: 0,
|
|
2104
|
-
repoName
|
|
2121
|
+
repoName,
|
|
2105
2122
|
readOnly: false,
|
|
2106
2123
|
report: true,
|
|
2107
2124
|
targets: ['.'],
|
|
@@ -2113,7 +2130,7 @@ async function handleCI(autoManifest) {
|
|
|
2113
2130
|
const {
|
|
2114
2131
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$K
|
|
2115
2132
|
} = constants;
|
|
2116
|
-
const config$
|
|
2133
|
+
const config$K = {
|
|
2117
2134
|
commandName: 'ci',
|
|
2118
2135
|
description: 'Create a new scan and report whether it passes your security policy',
|
|
2119
2136
|
hidden: true,
|
|
@@ -2131,7 +2148,7 @@ const config$N = {
|
|
|
2131
2148
|
$ ${command} [options]
|
|
2132
2149
|
|
|
2133
2150
|
Options
|
|
2134
|
-
${utils.getFlagListOutput(config$
|
|
2151
|
+
${utils.getFlagListOutput(config$K.flags)}
|
|
2135
2152
|
|
|
2136
2153
|
This command is intended to use in CI runs to allow automated systems to
|
|
2137
2154
|
accept or reject a current build. When the scan does not pass your security
|
|
@@ -2150,8 +2167,8 @@ const config$N = {
|
|
|
2150
2167
|
`
|
|
2151
2168
|
};
|
|
2152
2169
|
const cmdCI = {
|
|
2153
|
-
description: config$
|
|
2154
|
-
hidden: config$
|
|
2170
|
+
description: config$K.description,
|
|
2171
|
+
hidden: config$K.hidden,
|
|
2155
2172
|
run: run$N
|
|
2156
2173
|
};
|
|
2157
2174
|
async function run$N(argv, importMeta, {
|
|
@@ -2159,7 +2176,7 @@ async function run$N(argv, importMeta, {
|
|
|
2159
2176
|
}) {
|
|
2160
2177
|
const cli = utils.meowOrExit({
|
|
2161
2178
|
argv,
|
|
2162
|
-
config: config$
|
|
2179
|
+
config: config$K,
|
|
2163
2180
|
importMeta,
|
|
2164
2181
|
parentName
|
|
2165
2182
|
});
|
|
@@ -2167,7 +2184,7 @@ async function run$N(argv, importMeta, {
|
|
|
2167
2184
|
logger.logger.log(DRY_RUN_BAILING_NOW$K);
|
|
2168
2185
|
return;
|
|
2169
2186
|
}
|
|
2170
|
-
await
|
|
2187
|
+
await handleCi(Boolean(cli.flags['autoManifest']));
|
|
2171
2188
|
}
|
|
2172
2189
|
|
|
2173
2190
|
async function discoverConfigValue(key) {
|
|
@@ -2175,7 +2192,7 @@ async function discoverConfigValue(key) {
|
|
|
2175
2192
|
// keys should request information from particular API endpoints while
|
|
2176
2193
|
// others should simply return their default value, like endpoint URL.
|
|
2177
2194
|
|
|
2178
|
-
if (!utils.
|
|
2195
|
+
if (key !== 'test' && !utils.isSupportedConfigKey(key)) {
|
|
2179
2196
|
return {
|
|
2180
2197
|
ok: false,
|
|
2181
2198
|
message: 'Auto discover failed',
|
|
@@ -2274,43 +2291,35 @@ async function discoverConfigValue(key) {
|
|
|
2274
2291
|
};
|
|
2275
2292
|
}
|
|
2276
2293
|
async function getDefaultOrgFromToken() {
|
|
2277
|
-
const
|
|
2278
|
-
if (!
|
|
2294
|
+
const orgsCResult = await utils.fetchOrganization();
|
|
2295
|
+
if (!orgsCResult.ok) {
|
|
2279
2296
|
return undefined;
|
|
2280
2297
|
}
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
if (arr.length === 1) {
|
|
2291
|
-
return arr[0];
|
|
2292
|
-
}
|
|
2293
|
-
return arr;
|
|
2298
|
+
const {
|
|
2299
|
+
organizations
|
|
2300
|
+
} = orgsCResult.data;
|
|
2301
|
+
const slugs = Array.from(Object.values(organizations)).map(o => o.slug);
|
|
2302
|
+
if (slugs.length === 0) {
|
|
2303
|
+
return undefined;
|
|
2304
|
+
}
|
|
2305
|
+
if (slugs.length === 1) {
|
|
2306
|
+
return slugs[0];
|
|
2294
2307
|
}
|
|
2295
|
-
return
|
|
2308
|
+
return slugs;
|
|
2296
2309
|
}
|
|
2297
2310
|
async function getEnforceableOrgsFromToken() {
|
|
2298
|
-
const
|
|
2299
|
-
if (!
|
|
2311
|
+
const orgsCResult = await utils.fetchOrganization();
|
|
2312
|
+
if (!orgsCResult.ok) {
|
|
2300
2313
|
return undefined;
|
|
2301
2314
|
}
|
|
2302
|
-
const
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
if (arr.length === 0) {
|
|
2309
|
-
return undefined;
|
|
2310
|
-
}
|
|
2311
|
-
return arr;
|
|
2315
|
+
const {
|
|
2316
|
+
organizations
|
|
2317
|
+
} = orgsCResult.data;
|
|
2318
|
+
const slugs = Array.from(Object.values(organizations)).map(o => o.slug);
|
|
2319
|
+
if (!slugs.length) {
|
|
2320
|
+
return undefined;
|
|
2312
2321
|
}
|
|
2313
|
-
return
|
|
2322
|
+
return slugs;
|
|
2314
2323
|
}
|
|
2315
2324
|
|
|
2316
2325
|
async function outputConfigAuto(key, result, outputKind) {
|
|
@@ -2410,49 +2419,43 @@ async function handleConfigAuto({
|
|
|
2410
2419
|
const {
|
|
2411
2420
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$J
|
|
2412
2421
|
} = constants;
|
|
2413
|
-
const
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
+
const description$a = 'Automatically discover and set the correct value config item';
|
|
2423
|
+
const hidden$2 = false;
|
|
2424
|
+
const cmdConfigAuto = {
|
|
2425
|
+
description: description$a,
|
|
2426
|
+
hidden: hidden$2,
|
|
2427
|
+
run: run$M
|
|
2428
|
+
};
|
|
2429
|
+
async function run$M(argv, importMeta, {
|
|
2430
|
+
parentName
|
|
2431
|
+
}) {
|
|
2432
|
+
const config = {
|
|
2433
|
+
commandName: 'auto',
|
|
2434
|
+
description: description$a,
|
|
2435
|
+
hidden: hidden$2,
|
|
2436
|
+
flags: {
|
|
2437
|
+
...utils.commonFlags,
|
|
2438
|
+
...utils.outputFlags
|
|
2439
|
+
},
|
|
2440
|
+
help: (command, config) => `
|
|
2422
2441
|
Usage
|
|
2423
2442
|
$ ${command} [options] KEY
|
|
2424
2443
|
|
|
2425
2444
|
Options
|
|
2426
2445
|
${utils.getFlagListOutput(config.flags)}
|
|
2427
2446
|
|
|
2428
|
-
Attempt to automatically discover the correct value for given config KEY.
|
|
2429
|
-
|
|
2430
|
-
Keys:
|
|
2431
|
-
|
|
2432
|
-
${Array.from(utils.supportedConfigKeys.entries()).map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2433
|
-
|
|
2434
|
-
For certain keys it will request the value from server, for others it will
|
|
2435
|
-
reset the value to the default. For some keys this has no effect.
|
|
2436
|
-
|
|
2437
|
-
Keys:
|
|
2438
|
-
|
|
2439
|
-
${Array.from(utils.supportedConfigKeys.entries()).map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2447
|
+
Attempt to automatically discover the correct value for a given config KEY.
|
|
2440
2448
|
|
|
2441
2449
|
Examples
|
|
2442
2450
|
$ ${command} defaultOrg
|
|
2451
|
+
|
|
2452
|
+
Keys:
|
|
2453
|
+
${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2443
2454
|
`
|
|
2444
|
-
};
|
|
2445
|
-
const cmdConfigAuto = {
|
|
2446
|
-
description: config$M.description,
|
|
2447
|
-
hidden: config$M.hidden,
|
|
2448
|
-
run: run$M
|
|
2449
|
-
};
|
|
2450
|
-
async function run$M(argv, importMeta, {
|
|
2451
|
-
parentName
|
|
2452
|
-
}) {
|
|
2455
|
+
};
|
|
2453
2456
|
const cli = utils.meowOrExit({
|
|
2454
2457
|
argv,
|
|
2455
|
-
config
|
|
2458
|
+
config,
|
|
2456
2459
|
importMeta,
|
|
2457
2460
|
parentName
|
|
2458
2461
|
});
|
|
@@ -2463,7 +2466,7 @@ async function run$M(argv, importMeta, {
|
|
|
2463
2466
|
const [key = ''] = cli.input;
|
|
2464
2467
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
2465
2468
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
2466
|
-
test:
|
|
2469
|
+
test: key !== 'test' && utils.isSupportedConfigKey(key),
|
|
2467
2470
|
message: 'Config key should be the first arg',
|
|
2468
2471
|
pass: 'ok',
|
|
2469
2472
|
fail: key ? 'invalid config key' : 'missing'
|
|
@@ -2528,7 +2531,7 @@ async function handleConfigGet({
|
|
|
2528
2531
|
const {
|
|
2529
2532
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$I
|
|
2530
2533
|
} = constants;
|
|
2531
|
-
const config$
|
|
2534
|
+
const config$J = {
|
|
2532
2535
|
commandName: 'get',
|
|
2533
2536
|
description: 'Get the value of a local CLI config item',
|
|
2534
2537
|
hidden: false,
|
|
@@ -2548,15 +2551,15 @@ const config$L = {
|
|
|
2548
2551
|
|
|
2549
2552
|
KEY is an enum. Valid keys:
|
|
2550
2553
|
|
|
2551
|
-
${
|
|
2554
|
+
${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2552
2555
|
|
|
2553
2556
|
Examples
|
|
2554
2557
|
$ ${command} defaultOrg
|
|
2555
2558
|
`
|
|
2556
2559
|
};
|
|
2557
2560
|
const cmdConfigGet = {
|
|
2558
|
-
description: config$
|
|
2559
|
-
hidden: config$
|
|
2561
|
+
description: config$J.description,
|
|
2562
|
+
hidden: config$J.hidden,
|
|
2560
2563
|
run: run$L
|
|
2561
2564
|
};
|
|
2562
2565
|
async function run$L(argv, importMeta, {
|
|
@@ -2564,7 +2567,7 @@ async function run$L(argv, importMeta, {
|
|
|
2564
2567
|
}) {
|
|
2565
2568
|
const cli = utils.meowOrExit({
|
|
2566
2569
|
argv,
|
|
2567
|
-
config: config$
|
|
2570
|
+
config: config$J,
|
|
2568
2571
|
importMeta,
|
|
2569
2572
|
parentName
|
|
2570
2573
|
});
|
|
@@ -2575,7 +2578,7 @@ async function run$L(argv, importMeta, {
|
|
|
2575
2578
|
const [key = ''] = cli.input;
|
|
2576
2579
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
2577
2580
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
2578
|
-
test:
|
|
2581
|
+
test: key === 'test' || utils.isSupportedConfigKey(key),
|
|
2579
2582
|
message: 'Config key should be the first arg',
|
|
2580
2583
|
pass: 'ok',
|
|
2581
2584
|
fail: key ? 'invalid config key' : 'missing'
|
|
@@ -2604,16 +2607,17 @@ async function outputConfigList({
|
|
|
2604
2607
|
outputKind
|
|
2605
2608
|
}) {
|
|
2606
2609
|
const readOnly = utils.isReadOnlyConfig();
|
|
2610
|
+
const supportedConfigKeys = utils.getSupportedConfigKeys();
|
|
2607
2611
|
if (outputKind === 'json') {
|
|
2608
2612
|
let failed = false;
|
|
2609
2613
|
const obj = {};
|
|
2610
|
-
for (const key of
|
|
2614
|
+
for (const key of supportedConfigKeys) {
|
|
2611
2615
|
const result = utils.getConfigValue(key);
|
|
2612
2616
|
let value = result.data;
|
|
2613
2617
|
if (!result.ok) {
|
|
2614
2618
|
value = `Failed to retrieve: ${result.message}`;
|
|
2615
2619
|
failed = true;
|
|
2616
|
-
} else if (!full && utils.
|
|
2620
|
+
} else if (!full && utils.isSensitiveConfigKey(key)) {
|
|
2617
2621
|
value = '********';
|
|
2618
2622
|
}
|
|
2619
2623
|
if (full || value !== undefined) {
|
|
@@ -2640,18 +2644,18 @@ async function outputConfigList({
|
|
|
2640
2644
|
}
|
|
2641
2645
|
}));
|
|
2642
2646
|
} else {
|
|
2643
|
-
const maxWidth =
|
|
2647
|
+
const maxWidth = supportedConfigKeys.reduce((a, b) => Math.max(a, b.length), 0);
|
|
2644
2648
|
logger.logger.log('# Local CLI Config');
|
|
2645
2649
|
logger.logger.log('');
|
|
2646
2650
|
logger.logger.log(`This is the local CLI config (full=${!!full}):`);
|
|
2647
2651
|
logger.logger.log('');
|
|
2648
|
-
for (const key of
|
|
2652
|
+
for (const key of supportedConfigKeys) {
|
|
2649
2653
|
const result = utils.getConfigValue(key);
|
|
2650
2654
|
if (!result.ok) {
|
|
2651
2655
|
logger.logger.log(`- ${key}: failed to read: ${result.message}`);
|
|
2652
2656
|
} else {
|
|
2653
2657
|
let value = result.data;
|
|
2654
|
-
if (!full && utils.
|
|
2658
|
+
if (!full && utils.isSensitiveConfigKey(key)) {
|
|
2655
2659
|
value = '********';
|
|
2656
2660
|
}
|
|
2657
2661
|
if (full || value !== undefined) {
|
|
@@ -2669,7 +2673,7 @@ async function outputConfigList({
|
|
|
2669
2673
|
const {
|
|
2670
2674
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$H
|
|
2671
2675
|
} = constants;
|
|
2672
|
-
const config$
|
|
2676
|
+
const config$I = {
|
|
2673
2677
|
commandName: 'list',
|
|
2674
2678
|
description: 'Show all local CLI config items and their values',
|
|
2675
2679
|
hidden: false,
|
|
@@ -2694,8 +2698,8 @@ const config$K = {
|
|
|
2694
2698
|
`
|
|
2695
2699
|
};
|
|
2696
2700
|
const cmdConfigList = {
|
|
2697
|
-
description: config$
|
|
2698
|
-
hidden: config$
|
|
2701
|
+
description: config$I.description,
|
|
2702
|
+
hidden: config$I.hidden,
|
|
2699
2703
|
run: run$K
|
|
2700
2704
|
};
|
|
2701
2705
|
async function run$K(argv, importMeta, {
|
|
@@ -2703,7 +2707,7 @@ async function run$K(argv, importMeta, {
|
|
|
2703
2707
|
}) {
|
|
2704
2708
|
const cli = utils.meowOrExit({
|
|
2705
2709
|
argv,
|
|
2706
|
-
config: config$
|
|
2710
|
+
config: config$I,
|
|
2707
2711
|
importMeta,
|
|
2708
2712
|
parentName
|
|
2709
2713
|
});
|
|
@@ -2775,15 +2779,25 @@ async function handleConfigSet({
|
|
|
2775
2779
|
const {
|
|
2776
2780
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$G
|
|
2777
2781
|
} = constants;
|
|
2778
|
-
const
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2782
|
+
const description$9 = 'Update the value of a local CLI config item';
|
|
2783
|
+
const hidden$1 = false;
|
|
2784
|
+
const cmdConfigSet = {
|
|
2785
|
+
description: description$9,
|
|
2786
|
+
hidden: hidden$1,
|
|
2787
|
+
run: run$J
|
|
2788
|
+
};
|
|
2789
|
+
async function run$J(argv, importMeta, {
|
|
2790
|
+
parentName
|
|
2791
|
+
}) {
|
|
2792
|
+
const config = {
|
|
2793
|
+
commandName: 'set',
|
|
2794
|
+
description: description$9,
|
|
2795
|
+
hidden: hidden$1,
|
|
2796
|
+
flags: {
|
|
2797
|
+
...utils.commonFlags,
|
|
2798
|
+
...utils.outputFlags
|
|
2799
|
+
},
|
|
2800
|
+
help: (command, config) => `
|
|
2787
2801
|
Usage
|
|
2788
2802
|
$ ${command} [options] <KEY> <VALUE>
|
|
2789
2803
|
|
|
@@ -2801,23 +2815,15 @@ const config$J = {
|
|
|
2801
2815
|
|
|
2802
2816
|
Keys:
|
|
2803
2817
|
|
|
2804
|
-
${
|
|
2818
|
+
${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2805
2819
|
|
|
2806
2820
|
Examples
|
|
2807
2821
|
$ ${command} apiProxy https://example.com
|
|
2808
2822
|
`
|
|
2809
|
-
};
|
|
2810
|
-
const cmdConfigSet = {
|
|
2811
|
-
description: config$J.description,
|
|
2812
|
-
hidden: config$J.hidden,
|
|
2813
|
-
run: run$J
|
|
2814
|
-
};
|
|
2815
|
-
async function run$J(argv, importMeta, {
|
|
2816
|
-
parentName
|
|
2817
|
-
}) {
|
|
2823
|
+
};
|
|
2818
2824
|
const cli = utils.meowOrExit({
|
|
2819
2825
|
argv,
|
|
2820
|
-
config
|
|
2826
|
+
config,
|
|
2821
2827
|
importMeta,
|
|
2822
2828
|
parentName
|
|
2823
2829
|
});
|
|
@@ -2829,7 +2835,7 @@ async function run$J(argv, importMeta, {
|
|
|
2829
2835
|
const value = rest.join(' ');
|
|
2830
2836
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
2831
2837
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
2832
|
-
test: key === 'test' || utils.
|
|
2838
|
+
test: key === 'test' || utils.isSupportedConfigKey(key),
|
|
2833
2839
|
message: 'Config key should be the first arg',
|
|
2834
2840
|
pass: 'ok',
|
|
2835
2841
|
fail: key ? 'invalid config key' : 'missing'
|
|
@@ -2901,15 +2907,25 @@ async function handleConfigUnset({
|
|
|
2901
2907
|
const {
|
|
2902
2908
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$F
|
|
2903
2909
|
} = constants;
|
|
2904
|
-
const
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2910
|
+
const description$8 = 'Clear the value of a local CLI config item';
|
|
2911
|
+
const hidden = false;
|
|
2912
|
+
const cmdConfigUnset = {
|
|
2913
|
+
description: description$8,
|
|
2914
|
+
hidden,
|
|
2915
|
+
run: run$I
|
|
2916
|
+
};
|
|
2917
|
+
async function run$I(argv, importMeta, {
|
|
2918
|
+
parentName
|
|
2919
|
+
}) {
|
|
2920
|
+
const config = {
|
|
2921
|
+
commandName: 'unset',
|
|
2922
|
+
description: description$8,
|
|
2923
|
+
hidden,
|
|
2924
|
+
flags: {
|
|
2925
|
+
...utils.commonFlags,
|
|
2926
|
+
...utils.outputFlags
|
|
2927
|
+
},
|
|
2928
|
+
help: (command, config) => `
|
|
2913
2929
|
Usage
|
|
2914
2930
|
$ ${command} [options] <KEY> <VALUE>
|
|
2915
2931
|
|
|
@@ -2921,23 +2937,15 @@ const config$I = {
|
|
|
2921
2937
|
|
|
2922
2938
|
Keys:
|
|
2923
2939
|
|
|
2924
|
-
${
|
|
2940
|
+
${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${desc}`).join('\n')}
|
|
2925
2941
|
|
|
2926
|
-
Examples
|
|
2927
|
-
$ ${command} defaultOrg
|
|
2928
|
-
`
|
|
2929
|
-
};
|
|
2930
|
-
const cmdConfigUnset = {
|
|
2931
|
-
description: config$I.description,
|
|
2932
|
-
hidden: config$I.hidden,
|
|
2933
|
-
run: run$I
|
|
2934
|
-
};
|
|
2935
|
-
async function run$I(argv, importMeta, {
|
|
2936
|
-
parentName
|
|
2937
|
-
}) {
|
|
2942
|
+
Examples
|
|
2943
|
+
$ ${command} defaultOrg
|
|
2944
|
+
`
|
|
2945
|
+
};
|
|
2938
2946
|
const cli = utils.meowOrExit({
|
|
2939
2947
|
argv,
|
|
2940
|
-
config
|
|
2948
|
+
config,
|
|
2941
2949
|
importMeta,
|
|
2942
2950
|
parentName
|
|
2943
2951
|
});
|
|
@@ -2948,7 +2956,7 @@ async function run$I(argv, importMeta, {
|
|
|
2948
2956
|
const [key = ''] = cli.input;
|
|
2949
2957
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
2950
2958
|
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
2951
|
-
test: key === 'test' || utils.
|
|
2959
|
+
test: key === 'test' || utils.isSupportedConfigKey(key),
|
|
2952
2960
|
message: 'Config key should be the first arg',
|
|
2953
2961
|
pass: 'ok',
|
|
2954
2962
|
fail: key ? 'invalid config key' : 'missing'
|
|
@@ -3566,9 +3574,9 @@ async function getActualTree(cwd = process.cwd()) {
|
|
|
3566
3574
|
|
|
3567
3575
|
const {
|
|
3568
3576
|
BUN: BUN$4,
|
|
3569
|
-
NPM: NPM$
|
|
3577
|
+
NPM: NPM$7,
|
|
3570
3578
|
OVERRIDES: OVERRIDES$2,
|
|
3571
|
-
PNPM: PNPM$
|
|
3579
|
+
PNPM: PNPM$7,
|
|
3572
3580
|
RESOLUTIONS: RESOLUTIONS$1,
|
|
3573
3581
|
VLT: VLT$5,
|
|
3574
3582
|
YARN_BERRY: YARN_BERRY$4,
|
|
@@ -3587,7 +3595,7 @@ function getOverridesDataBun(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJ
|
|
|
3587
3595
|
function getOverridesDataNpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
|
|
3588
3596
|
const overrides = pkgJson?.[OVERRIDES$2] ?? {};
|
|
3589
3597
|
return {
|
|
3590
|
-
type: NPM$
|
|
3598
|
+
type: NPM$7,
|
|
3591
3599
|
overrides
|
|
3592
3600
|
};
|
|
3593
3601
|
}
|
|
@@ -3595,9 +3603,9 @@ function getOverridesDataNpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJ
|
|
|
3595
3603
|
// pnpm overrides documentation:
|
|
3596
3604
|
// https://pnpm.io/package_json#pnpmoverrides
|
|
3597
3605
|
function getOverridesDataPnpm(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
|
|
3598
|
-
const overrides = pkgJson?.[PNPM$
|
|
3606
|
+
const overrides = pkgJson?.[PNPM$7]?.[OVERRIDES$2] ?? {};
|
|
3599
3607
|
return {
|
|
3600
|
-
type: PNPM$
|
|
3608
|
+
type: PNPM$7,
|
|
3601
3609
|
overrides
|
|
3602
3610
|
};
|
|
3603
3611
|
}
|
|
@@ -3632,7 +3640,7 @@ function getOverridesData(pkgEnvDetails, pkgJson) {
|
|
|
3632
3640
|
switch (pkgEnvDetails.agent) {
|
|
3633
3641
|
case BUN$4:
|
|
3634
3642
|
return getOverridesDataBun(pkgEnvDetails, pkgJson);
|
|
3635
|
-
case PNPM$
|
|
3643
|
+
case PNPM$7:
|
|
3636
3644
|
return getOverridesDataPnpm(pkgEnvDetails, pkgJson);
|
|
3637
3645
|
case VLT$5:
|
|
3638
3646
|
return getOverridesDataVlt(pkgEnvDetails, pkgJson);
|
|
@@ -3640,7 +3648,7 @@ function getOverridesData(pkgEnvDetails, pkgJson) {
|
|
|
3640
3648
|
return getOverridesDataYarn(pkgEnvDetails, pkgJson);
|
|
3641
3649
|
case YARN_CLASSIC$4:
|
|
3642
3650
|
return getOverridesDataYarnClassic(pkgEnvDetails, pkgJson);
|
|
3643
|
-
case NPM$
|
|
3651
|
+
case NPM$7:
|
|
3644
3652
|
default:
|
|
3645
3653
|
return getOverridesDataNpm(pkgEnvDetails, pkgJson);
|
|
3646
3654
|
}
|
|
@@ -4266,7 +4274,7 @@ async function outputFixResult(result, outputKind) {
|
|
|
4266
4274
|
|
|
4267
4275
|
const {
|
|
4268
4276
|
OVERRIDES: OVERRIDES$1,
|
|
4269
|
-
PNPM: PNPM$
|
|
4277
|
+
PNPM: PNPM$6
|
|
4270
4278
|
} = constants;
|
|
4271
4279
|
async function install(pkgEnvDetails, options) {
|
|
4272
4280
|
const {
|
|
@@ -4383,15 +4391,15 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4383
4391
|
const {
|
|
4384
4392
|
overrides: oldOverrides
|
|
4385
4393
|
} = getOverridesDataPnpm(pkgEnvDetails, editablePkgJson.content);
|
|
4386
|
-
const oldPnpmSection = editablePkgJson.content[PNPM$
|
|
4394
|
+
const oldPnpmSection = editablePkgJson.content[PNPM$6];
|
|
4387
4395
|
const overrideKey = `${packument.name}@${vulnerableVersionRange}`;
|
|
4388
4396
|
revertOverrides = undefined;
|
|
4389
4397
|
revertOverridesSrc = utils.extractOverridesFromPnpmLockSrc(lockSrc);
|
|
4390
4398
|
if (isWorkspaceRoot) {
|
|
4391
4399
|
revertOverrides = {
|
|
4392
|
-
[PNPM$
|
|
4400
|
+
[PNPM$6]: oldPnpmSection ? {
|
|
4393
4401
|
...oldPnpmSection,
|
|
4394
|
-
[OVERRIDES$1]:
|
|
4402
|
+
[OVERRIDES$1]: require$$7.hasKeys(oldOverrides) ? {
|
|
4395
4403
|
...oldOverrides,
|
|
4396
4404
|
[overrideKey]: undefined
|
|
4397
4405
|
} : undefined
|
|
@@ -4400,7 +4408,7 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4400
4408
|
// Update overrides in the root package.json so that when `pnpm install`
|
|
4401
4409
|
// generates pnpm-lock.yaml it updates transitive dependencies too.
|
|
4402
4410
|
editablePkgJson.update({
|
|
4403
|
-
[PNPM$
|
|
4411
|
+
[PNPM$6]: {
|
|
4404
4412
|
...oldPnpmSection,
|
|
4405
4413
|
[OVERRIDES$1]: {
|
|
4406
4414
|
...oldOverrides,
|
|
@@ -4451,16 +4459,13 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4451
4459
|
}, fixConfig);
|
|
4452
4460
|
}
|
|
4453
4461
|
|
|
4454
|
-
const {
|
|
4455
|
-
NPM: NPM$7,
|
|
4456
|
-
PNPM: PNPM$6
|
|
4457
|
-
} = constants;
|
|
4458
4462
|
async function handleFix({
|
|
4459
4463
|
autoMerge,
|
|
4460
4464
|
cwd,
|
|
4461
4465
|
ghsas,
|
|
4462
4466
|
limit,
|
|
4463
4467
|
minSatisfying,
|
|
4468
|
+
orgSlug,
|
|
4464
4469
|
outputKind,
|
|
4465
4470
|
prCheck,
|
|
4466
4471
|
purls,
|
|
@@ -4470,49 +4475,66 @@ async function handleFix({
|
|
|
4470
4475
|
testScript,
|
|
4471
4476
|
unknownFlags
|
|
4472
4477
|
}) {
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4478
|
+
if (ghsas.length === 1 && ghsas[0] === 'auto') {
|
|
4479
|
+
let lastCResult;
|
|
4480
|
+
const sockSdkCResult = await utils.setupSdk();
|
|
4481
|
+
lastCResult = sockSdkCResult;
|
|
4482
|
+
const sockSdk = sockSdkCResult.ok ? sockSdkCResult.data : undefined;
|
|
4483
|
+
const supportedFilesCResult = sockSdk ? await fetchSupportedScanFileNames() : undefined;
|
|
4484
|
+
if (supportedFilesCResult) {
|
|
4485
|
+
lastCResult = supportedFilesCResult;
|
|
4486
|
+
}
|
|
4487
|
+
const supportedFiles = supportedFilesCResult?.ok ? supportedFilesCResult.data : undefined;
|
|
4488
|
+
const packagePaths = supportedFiles ? await utils.getPackageFilesForScan(['.'], supportedFiles, {
|
|
4489
|
+
cwd
|
|
4490
|
+
}) : [];
|
|
4491
|
+
const uploadCResult = sockSdk ? await utils.handleApiCall(sockSdk?.uploadManifestFiles(orgSlug, packagePaths), {
|
|
4492
|
+
desc: 'upload manifests'
|
|
4493
|
+
}) : undefined;
|
|
4494
|
+
if (uploadCResult) {
|
|
4495
|
+
lastCResult = uploadCResult;
|
|
4496
|
+
}
|
|
4497
|
+
const tarHash = uploadCResult?.ok ? uploadCResult.data.tarHash : '';
|
|
4498
|
+
const idsOutputCResult = tarHash ? await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash], {
|
|
4499
|
+
cwd,
|
|
4500
|
+
spinner,
|
|
4501
|
+
env: {
|
|
4502
|
+
SOCKET_ORG_SLUG: orgSlug
|
|
4495
4503
|
}
|
|
4496
|
-
|
|
4504
|
+
}) : undefined;
|
|
4505
|
+
if (idsOutputCResult) {
|
|
4506
|
+
lastCResult = idsOutputCResult;
|
|
4497
4507
|
}
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
if (!applyFixesCResult.ok) {
|
|
4506
|
-
debug.debugFn('error', 'fail: Coana CLI');
|
|
4507
|
-
debug.debugDir('inspect', {
|
|
4508
|
-
message: applyFixesCResult.message,
|
|
4509
|
-
cause: applyFixesCResult.cause
|
|
4510
|
-
});
|
|
4508
|
+
const idsOutput = idsOutputCResult?.ok ? idsOutputCResult.data : '';
|
|
4509
|
+
const ids = utils.cmdFlagValueToArray(/(?<=Vulnerabilities found: )[^\n]+/.exec(idsOutput)?.[0]);
|
|
4510
|
+
const fixCResult = ids.length ? await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...ids, ...unknownFlags], {
|
|
4511
|
+
cwd,
|
|
4512
|
+
spinner,
|
|
4513
|
+
env: {
|
|
4514
|
+
SOCKET_ORG_SLUG: orgSlug
|
|
4511
4515
|
}
|
|
4512
|
-
|
|
4516
|
+
}) : undefined;
|
|
4517
|
+
if (fixCResult) {
|
|
4518
|
+
lastCResult = fixCResult;
|
|
4519
|
+
}
|
|
4520
|
+
// const fixCResult = await spawnCoana(
|
|
4521
|
+
// [
|
|
4522
|
+
// cwd,
|
|
4523
|
+
// '--socket-mode',
|
|
4524
|
+
// DOT_SOCKET_DOT_FACTS_JSON,
|
|
4525
|
+
// '--manifests-tar-hash',
|
|
4526
|
+
// tarHash,
|
|
4527
|
+
// ...unknownFlags,
|
|
4528
|
+
// ],
|
|
4529
|
+
// { cwd, spinner, env: { SOCKET_ORG_SLUG: orgSlug } },
|
|
4530
|
+
// )
|
|
4531
|
+
debug.debugDir('inspect', {
|
|
4532
|
+
lastCResult
|
|
4533
|
+
});
|
|
4534
|
+
if (!lastCResult.ok) {
|
|
4535
|
+
await outputFixResult(lastCResult, outputKind);
|
|
4513
4536
|
return;
|
|
4514
4537
|
}
|
|
4515
|
-
spinner?.infoAndStop('No GHSA IDs found.');
|
|
4516
4538
|
await outputFixResult({
|
|
4517
4539
|
ok: true,
|
|
4518
4540
|
data: ''
|
|
@@ -4538,11 +4560,17 @@ async function handleFix({
|
|
|
4538
4560
|
}, outputKind);
|
|
4539
4561
|
return;
|
|
4540
4562
|
}
|
|
4563
|
+
|
|
4564
|
+
// Lazily access constants.
|
|
4565
|
+
const {
|
|
4566
|
+
NPM,
|
|
4567
|
+
PNPM
|
|
4568
|
+
} = constants;
|
|
4541
4569
|
const {
|
|
4542
4570
|
agent,
|
|
4543
4571
|
agentVersion
|
|
4544
4572
|
} = pkgEnvDetails;
|
|
4545
|
-
if (agent !== NPM
|
|
4573
|
+
if (agent !== NPM && agent !== PNPM) {
|
|
4546
4574
|
await outputFixResult({
|
|
4547
4575
|
ok: false,
|
|
4548
4576
|
message: 'Not supported.',
|
|
@@ -4551,7 +4579,7 @@ async function handleFix({
|
|
|
4551
4579
|
return;
|
|
4552
4580
|
}
|
|
4553
4581
|
logger.logger.info(`Fixing packages for ${agent} v${agentVersion}.\n`);
|
|
4554
|
-
const fixer = agent === NPM
|
|
4582
|
+
const fixer = agent === NPM ? npmFix : pnpmFix;
|
|
4555
4583
|
await outputFixResult(await fixer(pkgEnvDetails, {
|
|
4556
4584
|
autoMerge,
|
|
4557
4585
|
cwd,
|
|
@@ -4589,7 +4617,8 @@ const config$H = {
|
|
|
4589
4617
|
type: 'string',
|
|
4590
4618
|
default: [],
|
|
4591
4619
|
description: `Provide a list of ${vendor.terminalLinkExports('GHSA IDs', 'https://docs.github.com/en/code-security/security-advisories/working-with-global-security-advisories-from-the-github-advisory-database/about-the-github-advisory-database#about-ghsa-ids')} to compute fixes for, as either a comma separated value or as multiple flags.\n Use '--ghsa auto' to automatically lookup GHSA IDs and compute fixes for them.`,
|
|
4592
|
-
isMultiple: true
|
|
4620
|
+
isMultiple: true,
|
|
4621
|
+
hidden: true
|
|
4593
4622
|
},
|
|
4594
4623
|
limit: {
|
|
4595
4624
|
type: 'number',
|
|
@@ -4714,6 +4743,14 @@ async function run$H(argv, importMeta, {
|
|
|
4714
4743
|
autoMerge = true;
|
|
4715
4744
|
test = true;
|
|
4716
4745
|
}
|
|
4746
|
+
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
4747
|
+
if (!orgSlugCResult.ok) {
|
|
4748
|
+
process.exitCode = orgSlugCResult.code ?? 1;
|
|
4749
|
+
// Always assume json mode.
|
|
4750
|
+
// logger.log(serializeResultJson(orgSlugCResult))
|
|
4751
|
+
return;
|
|
4752
|
+
}
|
|
4753
|
+
const orgSlug = orgSlugCResult.data;
|
|
4717
4754
|
const ghsas = utils.cmdFlagValueToArray(cli.flags['ghsa']);
|
|
4718
4755
|
const limit = (cli.flags['limit'] ? parseInt(String(cli.flags['limit'] || ''), 10) : Infinity) || Infinity;
|
|
4719
4756
|
const maxSatisfying = Boolean(cli.flags['maxSatisfying']);
|
|
@@ -4728,6 +4765,7 @@ async function run$H(argv, importMeta, {
|
|
|
4728
4765
|
limit,
|
|
4729
4766
|
minSatisfying,
|
|
4730
4767
|
prCheck,
|
|
4768
|
+
orgSlug,
|
|
4731
4769
|
outputKind,
|
|
4732
4770
|
purls,
|
|
4733
4771
|
rangeStyle,
|
|
@@ -4819,7 +4857,7 @@ async function setupTabCompletion(targetName) {
|
|
|
4819
4857
|
};
|
|
4820
4858
|
}
|
|
4821
4859
|
function getTabCompletionScriptRaw() {
|
|
4822
|
-
const sourceDir = path.dirname(require$$0.fileURLToPath((
|
|
4860
|
+
const sourceDir = path.dirname(require$$0.fileURLToPath(require('node:url').pathToFileURL(__filename).href));
|
|
4823
4861
|
const sourcePath = path.join(sourceDir, 'socket-completion.bash');
|
|
4824
4862
|
if (!fs$1.existsSync(sourcePath)) {
|
|
4825
4863
|
return {
|
|
@@ -5022,22 +5060,31 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5022
5060
|
};
|
|
5023
5061
|
}
|
|
5024
5062
|
const apiToken = apiTokenInput || SOCKET_PUBLIC_API_TOKEN;
|
|
5025
|
-
const
|
|
5026
|
-
|
|
5063
|
+
const sockSdkCResult = await utils.setupSdk({
|
|
5064
|
+
apiBaseUrl,
|
|
5065
|
+
apiProxy,
|
|
5066
|
+
apiToken
|
|
5067
|
+
});
|
|
5068
|
+
if (!sockSdkCResult.ok) {
|
|
5027
5069
|
process.exitCode = 1;
|
|
5028
|
-
logger.logger.fail(utils.failMsgWithBadge(
|
|
5070
|
+
logger.logger.fail(utils.failMsgWithBadge(sockSdkCResult.message, sockSdkCResult.cause));
|
|
5029
5071
|
return;
|
|
5030
5072
|
}
|
|
5031
|
-
const
|
|
5032
|
-
|
|
5073
|
+
const sockSdk = sockSdkCResult.data;
|
|
5074
|
+
const orgsCResult = await utils.handleApiCall(sockSdk.getOrganizations(), {
|
|
5075
|
+
desc: 'token verification'
|
|
5076
|
+
});
|
|
5077
|
+
if (!orgsCResult.ok) {
|
|
5033
5078
|
process.exitCode = 1;
|
|
5034
|
-
logger.logger.fail(utils.failMsgWithBadge(
|
|
5079
|
+
logger.logger.fail(utils.failMsgWithBadge(orgsCResult.message, orgsCResult.cause));
|
|
5035
5080
|
return;
|
|
5036
5081
|
}
|
|
5037
|
-
const
|
|
5038
|
-
|
|
5082
|
+
const {
|
|
5083
|
+
organizations
|
|
5084
|
+
} = orgsCResult.data;
|
|
5085
|
+
const orgSlugs = Object.values(organizations).map(obj => obj.slug);
|
|
5039
5086
|
logger.logger.success(`API key verified: ${orgSlugs}`);
|
|
5040
|
-
const enforcedChoices = Object.values(
|
|
5087
|
+
const enforcedChoices = Object.values(organizations).filter(org => org?.plan === 'enterprise').map(org => ({
|
|
5041
5088
|
name: org.name ?? 'undefined',
|
|
5042
5089
|
value: org.id
|
|
5043
5090
|
}));
|
|
@@ -6847,7 +6894,7 @@ async function run$v(argv, importMeta, {
|
|
|
6847
6894
|
});
|
|
6848
6895
|
}
|
|
6849
6896
|
|
|
6850
|
-
const require$3 = require$$5.createRequire((
|
|
6897
|
+
const require$3 = require$$5.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6851
6898
|
const {
|
|
6852
6899
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$u
|
|
6853
6900
|
} = constants;
|
|
@@ -6896,11 +6943,11 @@ async function run$u(argv, importMeta, {
|
|
|
6896
6943
|
}
|
|
6897
6944
|
|
|
6898
6945
|
// Lazily access constants.shadowNpmBinPath.
|
|
6899
|
-
const shadowBin = require$3(constants.shadowNpmBinPath);
|
|
6946
|
+
const shadowBin = /*@__PURE__*/require$3(constants.shadowNpmBinPath);
|
|
6900
6947
|
await shadowBin('npm', argv);
|
|
6901
6948
|
}
|
|
6902
6949
|
|
|
6903
|
-
const require$2 = require$$5.createRequire((
|
|
6950
|
+
const require$2 = require$$5.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6904
6951
|
const {
|
|
6905
6952
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$t
|
|
6906
6953
|
} = constants;
|
|
@@ -6949,7 +6996,7 @@ async function run$t(argv, importMeta, {
|
|
|
6949
6996
|
}
|
|
6950
6997
|
|
|
6951
6998
|
// Lazily access constants.shadowNpmBinPath.
|
|
6952
|
-
const shadowBin = require$2(constants.shadowNpmBinPath);
|
|
6999
|
+
const shadowBin = /*@__PURE__*/require$2(constants.shadowNpmBinPath);
|
|
6953
7000
|
await shadowBin('npx', argv);
|
|
6954
7001
|
}
|
|
6955
7002
|
|
|
@@ -7348,8 +7395,8 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7348
7395
|
if (oldValue) {
|
|
7349
7396
|
// The field already exists so we simply update the field value.
|
|
7350
7397
|
if (field === PNPM$1) {
|
|
7351
|
-
const isPnpmObj =
|
|
7352
|
-
if (
|
|
7398
|
+
const isPnpmObj = require$$7.isObject(oldValue);
|
|
7399
|
+
if (require$$7.hasKeys(value)) {
|
|
7353
7400
|
editablePkgJson.update({
|
|
7354
7401
|
[field]: {
|
|
7355
7402
|
...(isPnpmObj ? oldValue : {}),
|
|
@@ -7361,7 +7408,7 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7361
7408
|
});
|
|
7362
7409
|
} else {
|
|
7363
7410
|
// Properties with undefined values are omitted when saved as JSON.
|
|
7364
|
-
editablePkgJson.update(
|
|
7411
|
+
editablePkgJson.update(require$$7.hasKeys(oldValue) ? {
|
|
7365
7412
|
[field]: {
|
|
7366
7413
|
...(isPnpmObj ? oldValue : {}),
|
|
7367
7414
|
overrides: undefined
|
|
@@ -7373,7 +7420,7 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7373
7420
|
} else if (field === OVERRIDES || field === RESOLUTIONS) {
|
|
7374
7421
|
// Properties with undefined values are omitted when saved as JSON.
|
|
7375
7422
|
editablePkgJson.update({
|
|
7376
|
-
[field]:
|
|
7423
|
+
[field]: require$$7.hasKeys(value) ? value : undefined
|
|
7377
7424
|
});
|
|
7378
7425
|
} else {
|
|
7379
7426
|
editablePkgJson.update({
|
|
@@ -7382,7 +7429,7 @@ function updatePkgJsonField(editablePkgJson, field, value) {
|
|
|
7382
7429
|
}
|
|
7383
7430
|
return;
|
|
7384
7431
|
}
|
|
7385
|
-
if ((field === OVERRIDES || field === PNPM$1 || field === RESOLUTIONS) && !
|
|
7432
|
+
if ((field === OVERRIDES || field === PNPM$1 || field === RESOLUTIONS) && !require$$7.hasKeys(value)) {
|
|
7386
7433
|
return;
|
|
7387
7434
|
}
|
|
7388
7435
|
// Since the field doesn't exist we want to insert it into the package.json
|
|
@@ -7517,7 +7564,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7517
7564
|
let loggedAddingText = false;
|
|
7518
7565
|
|
|
7519
7566
|
// Chunk package names to process them in parallel 3 at a time.
|
|
7520
|
-
await require$$
|
|
7567
|
+
await require$$8.pEach(manifestEntries, 3, async ({
|
|
7521
7568
|
1: data
|
|
7522
7569
|
}) => {
|
|
7523
7570
|
const {
|
|
@@ -7531,11 +7578,11 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7531
7578
|
for (const {
|
|
7532
7579
|
1: depObj
|
|
7533
7580
|
} of depEntries) {
|
|
7534
|
-
const sockSpec =
|
|
7581
|
+
const sockSpec = require$$7.hasOwn(depObj, sockRegPkgName) ? depObj[sockRegPkgName] : undefined;
|
|
7535
7582
|
if (sockSpec) {
|
|
7536
7583
|
depAliasMap.set(sockRegPkgName, sockSpec);
|
|
7537
7584
|
}
|
|
7538
|
-
const origSpec =
|
|
7585
|
+
const origSpec = require$$7.hasOwn(depObj, origPkgName) ? depObj[origPkgName] : undefined;
|
|
7539
7586
|
if (origSpec) {
|
|
7540
7587
|
let thisSpec = origSpec;
|
|
7541
7588
|
// Add package aliases for direct dependencies to avoid npm EOVERRIDE
|
|
@@ -7571,11 +7618,11 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7571
7618
|
npmExecPath
|
|
7572
7619
|
});
|
|
7573
7620
|
// Chunk package names to process them in parallel 3 at a time.
|
|
7574
|
-
await require$$
|
|
7621
|
+
await require$$8.pEach(overridesDataObjects, 3, async ({
|
|
7575
7622
|
overrides,
|
|
7576
7623
|
type
|
|
7577
7624
|
}) => {
|
|
7578
|
-
const overrideExists =
|
|
7625
|
+
const overrideExists = require$$7.hasOwn(overrides, origPkgName);
|
|
7579
7626
|
if (overrideExists || thingScanner(pkgEnvDetails, thingToScan, origPkgName, lockName)) {
|
|
7580
7627
|
const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
|
|
7581
7628
|
const origDepAlias = depAliasMap.get(origPkgName);
|
|
@@ -7625,7 +7672,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7625
7672
|
});
|
|
7626
7673
|
if (isWorkspace) {
|
|
7627
7674
|
// Chunk package names to process them in parallel 3 at a time.
|
|
7628
|
-
await require$$
|
|
7675
|
+
await require$$8.pEach(workspacePkgJsonPaths, 3, async workspacePkgJsonPath => {
|
|
7629
7676
|
const otherState = await addOverrides(pkgEnvDetails, path.dirname(workspacePkgJsonPath), {
|
|
7630
7677
|
logger,
|
|
7631
7678
|
pin,
|
|
@@ -7646,7 +7693,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7646
7693
|
overrides,
|
|
7647
7694
|
type
|
|
7648
7695
|
} of overridesDataObjects) {
|
|
7649
|
-
updateManifest(type, pkgEnvDetails.editablePkgJson,
|
|
7696
|
+
updateManifest(type, pkgEnvDetails.editablePkgJson, require$$7.toSortedObject(overrides));
|
|
7650
7697
|
}
|
|
7651
7698
|
}
|
|
7652
7699
|
await pkgEnvDetails.editablePkgJson.save();
|
|
@@ -7891,19 +7938,31 @@ async function run$r(argv, importMeta, {
|
|
|
7891
7938
|
});
|
|
7892
7939
|
}
|
|
7893
7940
|
|
|
7894
|
-
async function fetchDependencies({
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
}
|
|
7898
|
-
|
|
7941
|
+
async function fetchDependencies(config, options) {
|
|
7942
|
+
const {
|
|
7943
|
+
sdkOptions
|
|
7944
|
+
} = {
|
|
7945
|
+
__proto__: null,
|
|
7946
|
+
...options
|
|
7947
|
+
};
|
|
7948
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
7899
7949
|
if (!sockSdkCResult.ok) {
|
|
7900
7950
|
return sockSdkCResult;
|
|
7901
7951
|
}
|
|
7902
7952
|
const sockSdk = sockSdkCResult.data;
|
|
7953
|
+
const {
|
|
7954
|
+
limit,
|
|
7955
|
+
offset
|
|
7956
|
+
} = {
|
|
7957
|
+
__proto__: null,
|
|
7958
|
+
...config
|
|
7959
|
+
};
|
|
7903
7960
|
return await utils.handleApiCall(sockSdk.searchDependencies({
|
|
7904
7961
|
limit,
|
|
7905
7962
|
offset
|
|
7906
|
-
}),
|
|
7963
|
+
}), {
|
|
7964
|
+
desc: 'organization dependencies'
|
|
7965
|
+
});
|
|
7907
7966
|
}
|
|
7908
7967
|
|
|
7909
7968
|
// @ts-ignore
|
|
@@ -8068,13 +8127,21 @@ async function run$q(argv, importMeta, {
|
|
|
8068
8127
|
});
|
|
8069
8128
|
}
|
|
8070
8129
|
|
|
8071
|
-
async function fetchLicensePolicy(orgSlug) {
|
|
8072
|
-
const
|
|
8130
|
+
async function fetchLicensePolicy(orgSlug, options) {
|
|
8131
|
+
const {
|
|
8132
|
+
sdkOptions
|
|
8133
|
+
} = {
|
|
8134
|
+
__proto__: null,
|
|
8135
|
+
...options
|
|
8136
|
+
};
|
|
8137
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
8073
8138
|
if (!sockSdkCResult.ok) {
|
|
8074
8139
|
return sockSdkCResult;
|
|
8075
8140
|
}
|
|
8076
8141
|
const sockSdk = sockSdkCResult.data;
|
|
8077
|
-
return await utils.handleApiCall(sockSdk.getOrgLicensePolicy(orgSlug),
|
|
8142
|
+
return await utils.handleApiCall(sockSdk.getOrgLicensePolicy(orgSlug), {
|
|
8143
|
+
desc: 'organization license policy'
|
|
8144
|
+
});
|
|
8078
8145
|
}
|
|
8079
8146
|
|
|
8080
8147
|
async function outputLicensePolicy(result, outputKind) {
|
|
@@ -8096,7 +8163,10 @@ async function outputLicensePolicy(result, outputKind) {
|
|
|
8096
8163
|
logger.logger.log('');
|
|
8097
8164
|
const rules = result.data['license_policy'];
|
|
8098
8165
|
const entries = rules ? Object.entries(rules) : [];
|
|
8099
|
-
const mapped = entries.map((
|
|
8166
|
+
const mapped = entries.map(({
|
|
8167
|
+
0: key,
|
|
8168
|
+
1: value
|
|
8169
|
+
}) => [key, value?.['allowed'] ? ' yes' : ' no']);
|
|
8100
8170
|
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8101
8171
|
logger.logger.log(utils.mdTableOfPairs(mapped, ['License Name', 'Allowed']));
|
|
8102
8172
|
logger.logger.log('');
|
|
@@ -8193,13 +8263,21 @@ async function run$p(argv, importMeta, {
|
|
|
8193
8263
|
await handleLicensePolicy(orgSlug, outputKind);
|
|
8194
8264
|
}
|
|
8195
8265
|
|
|
8196
|
-
async function fetchSecurityPolicy(orgSlug) {
|
|
8197
|
-
const
|
|
8266
|
+
async function fetchSecurityPolicy(orgSlug, options) {
|
|
8267
|
+
const {
|
|
8268
|
+
sdkOptions
|
|
8269
|
+
} = {
|
|
8270
|
+
__proto__: null,
|
|
8271
|
+
...options
|
|
8272
|
+
};
|
|
8273
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
8198
8274
|
if (!sockSdkCResult.ok) {
|
|
8199
8275
|
return sockSdkCResult;
|
|
8200
8276
|
}
|
|
8201
8277
|
const sockSdk = sockSdkCResult.data;
|
|
8202
|
-
return await utils.handleApiCall(sockSdk.getOrgSecurityPolicy(orgSlug),
|
|
8278
|
+
return await utils.handleApiCall(sockSdk.getOrgSecurityPolicy(orgSlug), {
|
|
8279
|
+
desc: 'organization security policy'
|
|
8280
|
+
});
|
|
8203
8281
|
}
|
|
8204
8282
|
|
|
8205
8283
|
async function outputSecurityPolicy(result, outputKind) {
|
|
@@ -8222,7 +8300,10 @@ async function outputSecurityPolicy(result, outputKind) {
|
|
|
8222
8300
|
logger.logger.log('');
|
|
8223
8301
|
const rules = result.data.securityPolicyRules;
|
|
8224
8302
|
const entries = rules ? Object.entries(rules) : [];
|
|
8225
|
-
const mapped = entries.map((
|
|
8303
|
+
const mapped = entries.map(({
|
|
8304
|
+
0: key,
|
|
8305
|
+
1: value
|
|
8306
|
+
}) => [key, value.action]);
|
|
8226
8307
|
mapped.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
|
|
8227
8308
|
logger.logger.log(utils.mdTableOfPairs(mapped, ['name', 'action']));
|
|
8228
8309
|
logger.logger.log('');
|
|
@@ -8321,15 +8402,6 @@ async function run$o(argv, importMeta, {
|
|
|
8321
8402
|
await handleSecurityPolicy(orgSlug, outputKind);
|
|
8322
8403
|
}
|
|
8323
8404
|
|
|
8324
|
-
async function fetchOrganization() {
|
|
8325
|
-
const sockSdkCResult = await utils.setupSdk();
|
|
8326
|
-
if (!sockSdkCResult.ok) {
|
|
8327
|
-
return sockSdkCResult;
|
|
8328
|
-
}
|
|
8329
|
-
const sockSdk = sockSdkCResult.data;
|
|
8330
|
-
return await utils.handleApiCall(sockSdk.getOrganizations(), 'organization list');
|
|
8331
|
-
}
|
|
8332
|
-
|
|
8333
8405
|
async function outputOrganizationList(result, outputKind = 'text') {
|
|
8334
8406
|
if (!result.ok) {
|
|
8335
8407
|
process.exitCode = result.code ?? 1;
|
|
@@ -8381,7 +8453,7 @@ async function outputOrganizationList(result, outputKind = 'text') {
|
|
|
8381
8453
|
}
|
|
8382
8454
|
|
|
8383
8455
|
async function handleOrganizationList(outputKind = 'text') {
|
|
8384
|
-
const data = await fetchOrganization();
|
|
8456
|
+
const data = await utils.fetchOrganization();
|
|
8385
8457
|
await outputOrganizationList(data, outputKind);
|
|
8386
8458
|
}
|
|
8387
8459
|
|
|
@@ -8480,13 +8552,21 @@ const cmdOrganizationPolicy = {
|
|
|
8480
8552
|
}
|
|
8481
8553
|
};
|
|
8482
8554
|
|
|
8483
|
-
async function fetchQuota() {
|
|
8484
|
-
const
|
|
8555
|
+
async function fetchQuota(options) {
|
|
8556
|
+
const {
|
|
8557
|
+
sdkOptions
|
|
8558
|
+
} = {
|
|
8559
|
+
__proto__: null,
|
|
8560
|
+
...options
|
|
8561
|
+
};
|
|
8562
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
8485
8563
|
if (!sockSdkCResult.ok) {
|
|
8486
8564
|
return sockSdkCResult;
|
|
8487
8565
|
}
|
|
8488
8566
|
const sockSdk = sockSdkCResult.data;
|
|
8489
|
-
return await utils.handleApiCall(sockSdk.getQuota(),
|
|
8567
|
+
return await utils.handleApiCall(sockSdk.getQuota(), {
|
|
8568
|
+
desc: 'token quota'
|
|
8569
|
+
});
|
|
8490
8570
|
}
|
|
8491
8571
|
|
|
8492
8572
|
async function outputQuota(result, outputKind = 'text') {
|
|
@@ -8945,20 +9025,28 @@ async function run$l(argv, importMeta, {
|
|
|
8945
9025
|
await handlePurlDeepScore(purls[0] || '', outputKind);
|
|
8946
9026
|
}
|
|
8947
9027
|
|
|
8948
|
-
async function fetchPurlsShallowScore(purls) {
|
|
8949
|
-
|
|
8950
|
-
|
|
9028
|
+
async function fetchPurlsShallowScore(purls, options) {
|
|
9029
|
+
const {
|
|
9030
|
+
sdkOptions
|
|
9031
|
+
} = {
|
|
9032
|
+
__proto__: null,
|
|
9033
|
+
...options
|
|
9034
|
+
};
|
|
9035
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
8951
9036
|
if (!sockSdkCResult.ok) {
|
|
8952
9037
|
return sockSdkCResult;
|
|
8953
9038
|
}
|
|
8954
9039
|
const sockSdk = sockSdkCResult.data;
|
|
9040
|
+
logger.logger.info(`Requesting shallow score data for ${purls.length} package urls (purl): ${purls.join(', ')}`);
|
|
8955
9041
|
const result = await utils.handleApiCall(sockSdk.batchPackageFetch({
|
|
8956
|
-
alerts: 'true'
|
|
8957
|
-
}, {
|
|
8958
9042
|
components: purls.map(purl => ({
|
|
8959
9043
|
purl
|
|
8960
9044
|
}))
|
|
8961
|
-
}
|
|
9045
|
+
}, {
|
|
9046
|
+
alerts: 'true'
|
|
9047
|
+
}), {
|
|
9048
|
+
desc: 'looking up package'
|
|
9049
|
+
});
|
|
8962
9050
|
if (!result.ok) {
|
|
8963
9051
|
return result;
|
|
8964
9052
|
}
|
|
@@ -9454,26 +9542,35 @@ async function run$i(argv, importMeta, {
|
|
|
9454
9542
|
await runRawNpx(argv);
|
|
9455
9543
|
}
|
|
9456
9544
|
|
|
9457
|
-
async function fetchCreateRepo({
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9545
|
+
async function fetchCreateRepo(config, options) {
|
|
9546
|
+
const {
|
|
9547
|
+
defaultBranch,
|
|
9548
|
+
description,
|
|
9549
|
+
homepage,
|
|
9550
|
+
orgSlug,
|
|
9551
|
+
repoName,
|
|
9552
|
+
visibility
|
|
9553
|
+
} = config;
|
|
9554
|
+
const {
|
|
9555
|
+
sdkOptions
|
|
9556
|
+
} = {
|
|
9557
|
+
__proto__: null,
|
|
9558
|
+
...options
|
|
9559
|
+
};
|
|
9560
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
9466
9561
|
if (!sockSdkCResult.ok) {
|
|
9467
9562
|
return sockSdkCResult;
|
|
9468
9563
|
}
|
|
9469
9564
|
const sockSdk = sockSdkCResult.data;
|
|
9470
9565
|
return await utils.handleApiCall(sockSdk.createOrgRepo(orgSlug, {
|
|
9471
|
-
|
|
9566
|
+
default_branch: defaultBranch,
|
|
9472
9567
|
description,
|
|
9473
9568
|
homepage,
|
|
9474
|
-
|
|
9569
|
+
name: repoName,
|
|
9475
9570
|
visibility
|
|
9476
|
-
}),
|
|
9571
|
+
}), {
|
|
9572
|
+
desc: 'to create a repository'
|
|
9573
|
+
});
|
|
9477
9574
|
}
|
|
9478
9575
|
|
|
9479
9576
|
function outputCreateRepo(result, requestedName, outputKind) {
|
|
@@ -9495,7 +9592,7 @@ function outputCreateRepo(result, requestedName, outputKind) {
|
|
|
9495
9592
|
}
|
|
9496
9593
|
|
|
9497
9594
|
async function handleCreateRepo({
|
|
9498
|
-
|
|
9595
|
+
defaultBranch,
|
|
9499
9596
|
description,
|
|
9500
9597
|
homepage,
|
|
9501
9598
|
orgSlug,
|
|
@@ -9503,7 +9600,7 @@ async function handleCreateRepo({
|
|
|
9503
9600
|
visibility
|
|
9504
9601
|
}, outputKind) {
|
|
9505
9602
|
const data = await fetchCreateRepo({
|
|
9506
|
-
|
|
9603
|
+
defaultBranch,
|
|
9507
9604
|
description,
|
|
9508
9605
|
homepage,
|
|
9509
9606
|
orgSlug,
|
|
@@ -9633,18 +9730,26 @@ async function run$h(argv, importMeta, {
|
|
|
9633
9730
|
repoName: String(repoName),
|
|
9634
9731
|
description: String(cli.flags['repoDescription'] || ''),
|
|
9635
9732
|
homepage: String(cli.flags['homepage'] || ''),
|
|
9636
|
-
|
|
9733
|
+
defaultBranch: String(cli.flags['defaultBranch'] || ''),
|
|
9637
9734
|
visibility: String(cli.flags['visibility'] || 'private')
|
|
9638
9735
|
}, outputKind);
|
|
9639
9736
|
}
|
|
9640
9737
|
|
|
9641
|
-
async function fetchDeleteRepo(orgSlug, repoName) {
|
|
9642
|
-
const
|
|
9738
|
+
async function fetchDeleteRepo(orgSlug, repoName, options) {
|
|
9739
|
+
const {
|
|
9740
|
+
sdkOptions
|
|
9741
|
+
} = {
|
|
9742
|
+
__proto__: null,
|
|
9743
|
+
...options
|
|
9744
|
+
};
|
|
9745
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
9643
9746
|
if (!sockSdkCResult.ok) {
|
|
9644
9747
|
return sockSdkCResult;
|
|
9645
9748
|
}
|
|
9646
9749
|
const sockSdk = sockSdkCResult.data;
|
|
9647
|
-
return await utils.handleApiCall(sockSdk.deleteOrgRepo(orgSlug, repoName),
|
|
9750
|
+
return await utils.handleApiCall(sockSdk.deleteOrgRepo(orgSlug, repoName), {
|
|
9751
|
+
desc: 'to delete a repository'
|
|
9752
|
+
});
|
|
9648
9753
|
}
|
|
9649
9754
|
|
|
9650
9755
|
async function outputDeleteRepo(result, repoName, outputKind) {
|
|
@@ -9762,12 +9867,16 @@ async function run$g(argv, importMeta, {
|
|
|
9762
9867
|
await handleDeleteRepo(orgSlug, repoName, outputKind);
|
|
9763
9868
|
}
|
|
9764
9869
|
|
|
9765
|
-
async function fetchListAllRepos({
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9870
|
+
async function fetchListAllRepos(orgSlug, options) {
|
|
9871
|
+
const {
|
|
9872
|
+
direction,
|
|
9873
|
+
sdkOptions,
|
|
9874
|
+
sort
|
|
9875
|
+
} = {
|
|
9876
|
+
__proto__: null,
|
|
9877
|
+
...options
|
|
9878
|
+
};
|
|
9879
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
9771
9880
|
if (!sockSdkCResult.ok) {
|
|
9772
9881
|
return sockSdkCResult;
|
|
9773
9882
|
}
|
|
@@ -9790,7 +9899,9 @@ async function fetchListAllRepos({
|
|
|
9790
9899
|
per_page: String(100),
|
|
9791
9900
|
// max
|
|
9792
9901
|
page: String(nextPage)
|
|
9793
|
-
}),
|
|
9902
|
+
}), {
|
|
9903
|
+
desc: 'list of repositories'
|
|
9904
|
+
});
|
|
9794
9905
|
if (!orgRepoListCResult.ok) {
|
|
9795
9906
|
debug.debugFn('error', 'fail: fetch repo');
|
|
9796
9907
|
debug.debugDir('inspect', {
|
|
@@ -9810,14 +9921,24 @@ async function fetchListAllRepos({
|
|
|
9810
9921
|
};
|
|
9811
9922
|
}
|
|
9812
9923
|
|
|
9813
|
-
async function fetchListRepos({
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9924
|
+
async function fetchListRepos(config, options) {
|
|
9925
|
+
const {
|
|
9926
|
+
direction,
|
|
9927
|
+
orgSlug,
|
|
9928
|
+
page,
|
|
9929
|
+
perPage,
|
|
9930
|
+
sort
|
|
9931
|
+
} = {
|
|
9932
|
+
__proto__: null,
|
|
9933
|
+
...config
|
|
9934
|
+
};
|
|
9935
|
+
const {
|
|
9936
|
+
sdkOptions
|
|
9937
|
+
} = {
|
|
9938
|
+
__proto__: null,
|
|
9939
|
+
...options
|
|
9940
|
+
};
|
|
9941
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
9821
9942
|
if (!sockSdkCResult.ok) {
|
|
9822
9943
|
return sockSdkCResult;
|
|
9823
9944
|
}
|
|
@@ -9825,9 +9946,11 @@ async function fetchListRepos({
|
|
|
9825
9946
|
return await utils.handleApiCall(sockSdk.getOrgRepoList(orgSlug, {
|
|
9826
9947
|
sort,
|
|
9827
9948
|
direction,
|
|
9828
|
-
per_page: String(
|
|
9949
|
+
per_page: String(perPage),
|
|
9829
9950
|
page: String(page)
|
|
9830
|
-
}),
|
|
9951
|
+
}), {
|
|
9952
|
+
desc: 'list of repositories'
|
|
9953
|
+
});
|
|
9831
9954
|
}
|
|
9832
9955
|
|
|
9833
9956
|
// @ts-ignore
|
|
@@ -9893,13 +10016,12 @@ async function handleListRepos({
|
|
|
9893
10016
|
orgSlug,
|
|
9894
10017
|
outputKind,
|
|
9895
10018
|
page,
|
|
9896
|
-
|
|
10019
|
+
perPage,
|
|
9897
10020
|
sort
|
|
9898
10021
|
}) {
|
|
9899
10022
|
if (all) {
|
|
9900
|
-
const data = await fetchListAllRepos({
|
|
10023
|
+
const data = await fetchListAllRepos(orgSlug, {
|
|
9901
10024
|
direction,
|
|
9902
|
-
orgSlug,
|
|
9903
10025
|
sort
|
|
9904
10026
|
});
|
|
9905
10027
|
await outputListRepos(data, outputKind, 0, 0, sort, Infinity, direction);
|
|
@@ -9908,14 +10030,14 @@ async function handleListRepos({
|
|
|
9908
10030
|
direction,
|
|
9909
10031
|
orgSlug,
|
|
9910
10032
|
page,
|
|
9911
|
-
|
|
10033
|
+
perPage,
|
|
9912
10034
|
sort
|
|
9913
10035
|
});
|
|
9914
10036
|
if (!data.ok) {
|
|
9915
10037
|
await outputListRepos(data, outputKind, 0, 0, '', 0, direction);
|
|
9916
10038
|
} else {
|
|
9917
10039
|
// Note: nextPage defaults to 0, is null when there's no next page
|
|
9918
|
-
await outputListRepos(data, outputKind, page, data.data.nextPage, sort,
|
|
10040
|
+
await outputListRepos(data, outputKind, page, data.data.nextPage, sort, perPage, direction);
|
|
9919
10041
|
}
|
|
9920
10042
|
}
|
|
9921
10043
|
}
|
|
@@ -10048,32 +10170,44 @@ async function run$f(argv, importMeta, {
|
|
|
10048
10170
|
orgSlug,
|
|
10049
10171
|
outputKind,
|
|
10050
10172
|
page: Number(cli.flags['page']) || 1,
|
|
10051
|
-
|
|
10173
|
+
perPage: Number(cli.flags['perPage']) || 30,
|
|
10052
10174
|
sort: String(cli.flags['sort'] || 'created_at')
|
|
10053
10175
|
});
|
|
10054
10176
|
}
|
|
10055
10177
|
|
|
10056
|
-
async function fetchUpdateRepo({
|
|
10057
|
-
|
|
10058
|
-
|
|
10059
|
-
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10178
|
+
async function fetchUpdateRepo(config, options) {
|
|
10179
|
+
const {
|
|
10180
|
+
defaultBranch,
|
|
10181
|
+
description,
|
|
10182
|
+
homepage,
|
|
10183
|
+
orgSlug,
|
|
10184
|
+
repoName,
|
|
10185
|
+
visibility
|
|
10186
|
+
} = {
|
|
10187
|
+
__proto__: null,
|
|
10188
|
+
...config
|
|
10189
|
+
};
|
|
10190
|
+
const {
|
|
10191
|
+
sdkOptions
|
|
10192
|
+
} = {
|
|
10193
|
+
__proto__: null,
|
|
10194
|
+
...options
|
|
10195
|
+
};
|
|
10196
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
10065
10197
|
if (!sockSdkCResult.ok) {
|
|
10066
10198
|
return sockSdkCResult;
|
|
10067
10199
|
}
|
|
10068
10200
|
const sockSdk = sockSdkCResult.data;
|
|
10069
10201
|
return await utils.handleApiCall(sockSdk.updateOrgRepo(orgSlug, repoName, {
|
|
10070
|
-
|
|
10071
|
-
name: repoName,
|
|
10202
|
+
default_branch: defaultBranch,
|
|
10072
10203
|
description,
|
|
10073
10204
|
homepage,
|
|
10074
|
-
|
|
10205
|
+
name: repoName,
|
|
10206
|
+
orgSlug,
|
|
10075
10207
|
visibility
|
|
10076
|
-
}),
|
|
10208
|
+
}), {
|
|
10209
|
+
desc: 'to update a repository'
|
|
10210
|
+
});
|
|
10077
10211
|
}
|
|
10078
10212
|
|
|
10079
10213
|
async function outputUpdateRepo(result, repoName, outputKind) {
|
|
@@ -10092,7 +10226,7 @@ async function outputUpdateRepo(result, repoName, outputKind) {
|
|
|
10092
10226
|
}
|
|
10093
10227
|
|
|
10094
10228
|
async function handleUpdateRepo({
|
|
10095
|
-
|
|
10229
|
+
defaultBranch,
|
|
10096
10230
|
description,
|
|
10097
10231
|
homepage,
|
|
10098
10232
|
orgSlug,
|
|
@@ -10100,7 +10234,7 @@ async function handleUpdateRepo({
|
|
|
10100
10234
|
visibility
|
|
10101
10235
|
}, outputKind) {
|
|
10102
10236
|
const data = await fetchUpdateRepo({
|
|
10103
|
-
|
|
10237
|
+
defaultBranch,
|
|
10104
10238
|
description,
|
|
10105
10239
|
homepage,
|
|
10106
10240
|
orgSlug,
|
|
@@ -10232,18 +10366,26 @@ async function run$e(argv, importMeta, {
|
|
|
10232
10366
|
repoName: String(repoName),
|
|
10233
10367
|
description: String(cli.flags['repoDescription'] || ''),
|
|
10234
10368
|
homepage: String(cli.flags['homepage'] || ''),
|
|
10235
|
-
|
|
10369
|
+
defaultBranch: String(cli.flags['defaultBranch'] || ''),
|
|
10236
10370
|
visibility: String(cli.flags['visibility'] || 'private')
|
|
10237
10371
|
}, outputKind);
|
|
10238
10372
|
}
|
|
10239
10373
|
|
|
10240
|
-
async function fetchViewRepo(orgSlug, repoName) {
|
|
10241
|
-
const
|
|
10374
|
+
async function fetchViewRepo(orgSlug, repoName, options) {
|
|
10375
|
+
const {
|
|
10376
|
+
sdkOptions
|
|
10377
|
+
} = {
|
|
10378
|
+
__proto__: null,
|
|
10379
|
+
...options
|
|
10380
|
+
};
|
|
10381
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
10242
10382
|
if (!sockSdkCResult.ok) {
|
|
10243
10383
|
return sockSdkCResult;
|
|
10244
10384
|
}
|
|
10245
10385
|
const sockSdk = sockSdkCResult.data;
|
|
10246
|
-
return await utils.handleApiCall(sockSdk.getOrgRepo(orgSlug, repoName),
|
|
10386
|
+
return await utils.handleApiCall(sockSdk.getOrgRepo(orgSlug, repoName), {
|
|
10387
|
+
desc: 'repository data'
|
|
10388
|
+
});
|
|
10247
10389
|
}
|
|
10248
10390
|
|
|
10249
10391
|
// @ts-ignore
|
|
@@ -10685,7 +10827,7 @@ async function run$c(argv, importMeta, {
|
|
|
10685
10827
|
if (detected.count > 0 && !autoManifest) {
|
|
10686
10828
|
logger.logger.info(`Detected ${detected.count} manifest targets we could try to generate. Please set the --autoManifest flag if you want to include languages covered by \`socket manifest auto\` in the Scan.`);
|
|
10687
10829
|
}
|
|
10688
|
-
if (updatedInput && orgSlug && targets
|
|
10830
|
+
if (updatedInput && orgSlug && targets.length) {
|
|
10689
10831
|
logger.logger.info('Note: You can invoke this command next time to skip the interactive questions:');
|
|
10690
10832
|
logger.logger.info('```');
|
|
10691
10833
|
logger.logger.info(` socket scan create [other flags...] ${orgSlug} ${targets.join(' ')}`);
|
|
@@ -10753,20 +10895,28 @@ async function run$c(argv, importMeta, {
|
|
|
10753
10895
|
pendingHead: Boolean(pendingHead),
|
|
10754
10896
|
pullRequest: Number(pullRequest),
|
|
10755
10897
|
readOnly: Boolean(readOnly),
|
|
10756
|
-
repoName
|
|
10898
|
+
repoName,
|
|
10757
10899
|
report,
|
|
10758
10900
|
targets,
|
|
10759
10901
|
tmp: Boolean(tmp)
|
|
10760
10902
|
});
|
|
10761
10903
|
}
|
|
10762
10904
|
|
|
10763
|
-
async function fetchDeleteOrgFullScan(orgSlug, scanId) {
|
|
10764
|
-
const
|
|
10905
|
+
async function fetchDeleteOrgFullScan(orgSlug, scanId, options) {
|
|
10906
|
+
const {
|
|
10907
|
+
sdkOptions
|
|
10908
|
+
} = {
|
|
10909
|
+
__proto__: null,
|
|
10910
|
+
...options
|
|
10911
|
+
};
|
|
10912
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
10765
10913
|
if (!sockSdkCResult.ok) {
|
|
10766
10914
|
return sockSdkCResult;
|
|
10767
10915
|
}
|
|
10768
10916
|
const sockSdk = sockSdkCResult.data;
|
|
10769
|
-
return await utils.handleApiCall(sockSdk.deleteOrgFullScan(orgSlug, scanId),
|
|
10917
|
+
return await utils.handleApiCall(sockSdk.deleteOrgFullScan(orgSlug, scanId), {
|
|
10918
|
+
desc: 'to delete a scan'
|
|
10919
|
+
});
|
|
10770
10920
|
}
|
|
10771
10921
|
|
|
10772
10922
|
async function outputDeleteScan(result, outputKind) {
|
|
@@ -11200,10 +11350,6 @@ async function run$a(argv, importMeta, {
|
|
|
11200
11350
|
});
|
|
11201
11351
|
}
|
|
11202
11352
|
|
|
11203
|
-
// Supported manifest file name patterns
|
|
11204
|
-
// Keep in mind that we have to request these files through the GitHub API; that cost is much heavier than local disk searches
|
|
11205
|
-
// TODO: get this list from API instead? Is that too much? Has to fetch through gh api...
|
|
11206
|
-
const SUPPORTED_FILE_PATTERNS = [/.*[-.]spdx\.json/, /bom\.json/, /.*[-.]cyclonedx\.json/, /.*[-.]cyclonedx\.xml/, /package\.json/, /package-lock\.json/, /npm-shrinkwrap\.json/, /yarn\.lock/, /pnpm-lock\.yaml/, /pnpm-lock\.yml/, /pnpm-workspace\.yaml/, /pnpm-workspace\.yml/, /pipfile/, /pyproject\.toml/, /poetry\.lock/, /requirements[\\/].*\.txt/, /requirements-.*\.txt/, /requirements_.*\.txt/, /requirements\.frozen/, /setup\.py/, /pipfile\.lock/, /go\.mod/, /go\.sum/, /pom\.xml/, /.*\..*proj/, /.*\.props/, /.*\.targets/, /.*\.nuspec/, /nuget\.config/, /packages\.config/, /packages\.lock\.json/];
|
|
11207
11353
|
async function createScanFromGithub({
|
|
11208
11354
|
all,
|
|
11209
11355
|
githubApiUrl,
|
|
@@ -11217,9 +11363,8 @@ async function createScanFromGithub({
|
|
|
11217
11363
|
let targetRepos = repos.trim().split(',').map(r => r.trim()).filter(Boolean);
|
|
11218
11364
|
if (all || targetRepos.length === 0) {
|
|
11219
11365
|
// Fetch from Socket API
|
|
11220
|
-
const result = await fetchListAllRepos({
|
|
11366
|
+
const result = await fetchListAllRepos(orgSlug, {
|
|
11221
11367
|
direction: 'asc',
|
|
11222
|
-
orgSlug,
|
|
11223
11368
|
sort: 'name'
|
|
11224
11369
|
});
|
|
11225
11370
|
if (!result.ok) {
|
|
@@ -11258,7 +11403,7 @@ async function createScanFromGithub({
|
|
|
11258
11403
|
let scansCreated = 0;
|
|
11259
11404
|
for (const repoSlug of targetRepos) {
|
|
11260
11405
|
// eslint-disable-next-line no-await-in-loop
|
|
11261
|
-
const
|
|
11406
|
+
const scanCResult = await scanRepo(repoSlug, {
|
|
11262
11407
|
githubApiUrl,
|
|
11263
11408
|
githubToken,
|
|
11264
11409
|
orgSlug,
|
|
@@ -11266,8 +11411,13 @@ async function createScanFromGithub({
|
|
|
11266
11411
|
outputKind,
|
|
11267
11412
|
repos
|
|
11268
11413
|
});
|
|
11269
|
-
if (
|
|
11270
|
-
|
|
11414
|
+
if (scanCResult.ok) {
|
|
11415
|
+
const {
|
|
11416
|
+
scanCreated
|
|
11417
|
+
} = scanCResult.data;
|
|
11418
|
+
if (scanCreated) {
|
|
11419
|
+
scansCreated += 1;
|
|
11420
|
+
}
|
|
11271
11421
|
}
|
|
11272
11422
|
}
|
|
11273
11423
|
logger.logger.success(targetRepos.length, 'GitHub repos detected');
|
|
@@ -11453,7 +11603,9 @@ async function testAndDownloadManifestFile({
|
|
|
11453
11603
|
tmpDir
|
|
11454
11604
|
}) {
|
|
11455
11605
|
debug.debugFn('notice', 'testing: file', file);
|
|
11456
|
-
|
|
11606
|
+
const supportedFilesCResult = await fetchSupportedScanFileNames();
|
|
11607
|
+
const supportedFiles = supportedFilesCResult.ok ? supportedFilesCResult.data : undefined;
|
|
11608
|
+
if (!supportedFiles || !utils.isReportSupportedFile(file, supportedFiles)) {
|
|
11457
11609
|
debug.debugFn('notice', ' - skip: not a known pattern');
|
|
11458
11610
|
// Not an error.
|
|
11459
11611
|
return {
|
|
@@ -11834,7 +11986,7 @@ async function handleCreateGithubScan({
|
|
|
11834
11986
|
outputKind,
|
|
11835
11987
|
repos
|
|
11836
11988
|
}) {
|
|
11837
|
-
const
|
|
11989
|
+
const ghScanCResult = await createScanFromGithub({
|
|
11838
11990
|
all: Boolean(all),
|
|
11839
11991
|
githubApiUrl,
|
|
11840
11992
|
githubToken,
|
|
@@ -11844,7 +11996,7 @@ async function handleCreateGithubScan({
|
|
|
11844
11996
|
outputKind,
|
|
11845
11997
|
repos: String(repos || '')
|
|
11846
11998
|
});
|
|
11847
|
-
await outputScanGithub(
|
|
11999
|
+
await outputScanGithub(ghScanCResult, outputKind);
|
|
11848
12000
|
}
|
|
11849
12001
|
|
|
11850
12002
|
const {
|
|
@@ -12051,21 +12203,31 @@ async function run$9(argv, importMeta, {
|
|
|
12051
12203
|
});
|
|
12052
12204
|
}
|
|
12053
12205
|
|
|
12054
|
-
async function
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
sort
|
|
12063
|
-
}) {
|
|
12064
|
-
const sockSdkCResult = await utils.setupSdk();
|
|
12206
|
+
async function fetchOrgFullScanList(config, options) {
|
|
12207
|
+
const {
|
|
12208
|
+
sdkOptions
|
|
12209
|
+
} = {
|
|
12210
|
+
__proto__: null,
|
|
12211
|
+
...options
|
|
12212
|
+
};
|
|
12213
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
12065
12214
|
if (!sockSdkCResult.ok) {
|
|
12066
12215
|
return sockSdkCResult;
|
|
12067
12216
|
}
|
|
12068
12217
|
const sockSdk = sockSdkCResult.data;
|
|
12218
|
+
const {
|
|
12219
|
+
branch,
|
|
12220
|
+
direction,
|
|
12221
|
+
from_time,
|
|
12222
|
+
orgSlug,
|
|
12223
|
+
page,
|
|
12224
|
+
perPage,
|
|
12225
|
+
repo,
|
|
12226
|
+
sort
|
|
12227
|
+
} = {
|
|
12228
|
+
__proto__: null,
|
|
12229
|
+
...config
|
|
12230
|
+
};
|
|
12069
12231
|
return await utils.handleApiCall(sockSdk.getOrgFullScanList(orgSlug, {
|
|
12070
12232
|
...(branch ? {
|
|
12071
12233
|
branch
|
|
@@ -12075,10 +12237,12 @@ async function fetchListScans({
|
|
|
12075
12237
|
} : {}),
|
|
12076
12238
|
sort,
|
|
12077
12239
|
direction,
|
|
12078
|
-
per_page: String(
|
|
12240
|
+
per_page: String(perPage),
|
|
12079
12241
|
page: String(page),
|
|
12080
12242
|
from: from_time
|
|
12081
|
-
}),
|
|
12243
|
+
}), {
|
|
12244
|
+
desc: 'list of scans'
|
|
12245
|
+
});
|
|
12082
12246
|
}
|
|
12083
12247
|
|
|
12084
12248
|
// @ts-ignore
|
|
@@ -12135,17 +12299,17 @@ async function handleListScans({
|
|
|
12135
12299
|
orgSlug,
|
|
12136
12300
|
outputKind,
|
|
12137
12301
|
page,
|
|
12138
|
-
|
|
12302
|
+
perPage,
|
|
12139
12303
|
repo,
|
|
12140
12304
|
sort
|
|
12141
12305
|
}) {
|
|
12142
|
-
const data = await
|
|
12306
|
+
const data = await fetchOrgFullScanList({
|
|
12143
12307
|
branch,
|
|
12144
12308
|
direction,
|
|
12145
12309
|
from_time,
|
|
12146
12310
|
orgSlug,
|
|
12147
12311
|
page,
|
|
12148
|
-
|
|
12312
|
+
perPage,
|
|
12149
12313
|
repo,
|
|
12150
12314
|
sort
|
|
12151
12315
|
});
|
|
@@ -12305,19 +12469,27 @@ async function run$8(argv, importMeta, {
|
|
|
12305
12469
|
orgSlug,
|
|
12306
12470
|
outputKind,
|
|
12307
12471
|
page: Number(cli.flags['page'] || 1),
|
|
12308
|
-
|
|
12472
|
+
perPage: Number(cli.flags['perPage'] || 30),
|
|
12309
12473
|
repo: repo ? String(repo) : '',
|
|
12310
12474
|
sort: String(cli.flags['sort'] || '')
|
|
12311
12475
|
});
|
|
12312
12476
|
}
|
|
12313
12477
|
|
|
12314
|
-
async function fetchScanMetadata(orgSlug, scanId) {
|
|
12315
|
-
const
|
|
12478
|
+
async function fetchScanMetadata(orgSlug, scanId, options) {
|
|
12479
|
+
const {
|
|
12480
|
+
sdkOptions
|
|
12481
|
+
} = {
|
|
12482
|
+
__proto__: null,
|
|
12483
|
+
...options
|
|
12484
|
+
};
|
|
12485
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
12316
12486
|
if (!sockSdkCResult.ok) {
|
|
12317
12487
|
return sockSdkCResult;
|
|
12318
12488
|
}
|
|
12319
12489
|
const sockSdk = sockSdkCResult.data;
|
|
12320
|
-
return await utils.handleApiCall(sockSdk.getOrgFullScanMetadata(orgSlug, scanId),
|
|
12490
|
+
return await utils.handleApiCall(sockSdk.getOrgFullScanMetadata(orgSlug, scanId), {
|
|
12491
|
+
desc: 'meta data for a full scan'
|
|
12492
|
+
});
|
|
12321
12493
|
}
|
|
12322
12494
|
|
|
12323
12495
|
async function outputScanMetadata(result, scanId, outputKind) {
|
|
@@ -13184,8 +13356,15 @@ async function handleScanView(orgSlug, scanId, filePath, outputKind) {
|
|
|
13184
13356
|
await outputScanView(data, orgSlug, scanId, filePath, outputKind);
|
|
13185
13357
|
}
|
|
13186
13358
|
|
|
13187
|
-
async function streamScan(orgSlug, scanId,
|
|
13188
|
-
const
|
|
13359
|
+
async function streamScan(orgSlug, scanId, options) {
|
|
13360
|
+
const {
|
|
13361
|
+
file,
|
|
13362
|
+
sdkOptions
|
|
13363
|
+
} = {
|
|
13364
|
+
__proto__: null,
|
|
13365
|
+
...options
|
|
13366
|
+
};
|
|
13367
|
+
const sockSdkCResult = await utils.setupSdk(sdkOptions);
|
|
13189
13368
|
if (!sockSdkCResult.ok) {
|
|
13190
13369
|
return sockSdkCResult;
|
|
13191
13370
|
}
|
|
@@ -13193,7 +13372,9 @@ async function streamScan(orgSlug, scanId, file) {
|
|
|
13193
13372
|
logger.logger.info('Requesting data from API...');
|
|
13194
13373
|
|
|
13195
13374
|
// Note: this will write to stdout or target file. It's not a noop
|
|
13196
|
-
return await utils.handleApiCall(sockSdk.getOrgFullScan(orgSlug, scanId, file === '-' ? undefined : file),
|
|
13375
|
+
return await utils.handleApiCall(sockSdk.getOrgFullScan(orgSlug, scanId, file === '-' ? undefined : file), {
|
|
13376
|
+
desc: 'a scan'
|
|
13377
|
+
});
|
|
13197
13378
|
}
|
|
13198
13379
|
|
|
13199
13380
|
const {
|
|
@@ -13303,7 +13484,9 @@ async function run$3(argv, importMeta, {
|
|
|
13303
13484
|
return;
|
|
13304
13485
|
}
|
|
13305
13486
|
if (json && stream) {
|
|
13306
|
-
await streamScan(orgSlug, scanId,
|
|
13487
|
+
await streamScan(orgSlug, scanId, {
|
|
13488
|
+
file
|
|
13489
|
+
});
|
|
13307
13490
|
} else {
|
|
13308
13491
|
await handleScanView(orgSlug, scanId, file, outputKind);
|
|
13309
13492
|
}
|
|
@@ -13361,7 +13544,7 @@ async function fetchThreatFeed({
|
|
|
13361
13544
|
return await utils.queryApiSafeJson(`orgs/${orgSlug}/threat-feed?${queryParams}`, 'the Threat Feed data');
|
|
13362
13545
|
}
|
|
13363
13546
|
|
|
13364
|
-
const require$1 = require$$5.createRequire((
|
|
13547
|
+
const require$1 = require$$5.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
13365
13548
|
async function outputThreatFeed(result, outputKind) {
|
|
13366
13549
|
if (!result.ok) {
|
|
13367
13550
|
process.exitCode = result.code ?? 1;
|
|
@@ -13382,7 +13565,7 @@ async function outputThreatFeed(result, outputKind) {
|
|
|
13382
13565
|
const descriptions = result.data.results.map(d => d.description);
|
|
13383
13566
|
|
|
13384
13567
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
13385
|
-
const ScreenWidget = require$1('../external/blessed/lib/widgets/screen.js');
|
|
13568
|
+
const ScreenWidget = /*@__PURE__*/require$1('../external/blessed/lib/widgets/screen.js');
|
|
13386
13569
|
// Lazily access constants.blessedOptions.
|
|
13387
13570
|
const screen = new ScreenWidget({
|
|
13388
13571
|
...constants.blessedOptions
|
|
@@ -13392,7 +13575,7 @@ async function outputThreatFeed(result, outputKind) {
|
|
|
13392
13575
|
// node process just to exit it. That's very bad UX.
|
|
13393
13576
|
// eslint-disable-next-line n/no-process-exit
|
|
13394
13577
|
screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
|
|
13395
|
-
const TableWidget = require$1('../external/blessed-contrib/lib/widget/table.js');
|
|
13578
|
+
const TableWidget = /*@__PURE__*/require$1('../external/blessed-contrib/lib/widget/table.js');
|
|
13396
13579
|
const detailsBoxHeight = 20; // bottom N rows for details box
|
|
13397
13580
|
const tipsBoxHeight = 1; // 1 row for tips box
|
|
13398
13581
|
|
|
@@ -13416,7 +13599,7 @@ async function outputThreatFeed(result, outputKind) {
|
|
|
13416
13599
|
columnSpacing: 1,
|
|
13417
13600
|
truncate: '_'
|
|
13418
13601
|
});
|
|
13419
|
-
const BoxWidget = require$1('../external/blessed/lib/widgets/box.js');
|
|
13602
|
+
const BoxWidget = /*@__PURE__*/require$1('../external/blessed/lib/widgets/box.js');
|
|
13420
13603
|
const tipsBox = new BoxWidget({
|
|
13421
13604
|
bottom: detailsBoxHeight,
|
|
13422
13605
|
// sits just above the details box
|
|
@@ -14143,7 +14326,7 @@ async function run(argv, importMeta, {
|
|
|
14143
14326
|
}
|
|
14144
14327
|
}
|
|
14145
14328
|
|
|
14146
|
-
const __filename$1 = require$$0.fileURLToPath((
|
|
14329
|
+
const __filename$1 = require$$0.fileURLToPath(require('node:url').pathToFileURL(__filename).href);
|
|
14147
14330
|
const {
|
|
14148
14331
|
SOCKET_CLI_BIN_NAME
|
|
14149
14332
|
} = constants;
|
|
@@ -14339,5 +14522,5 @@ void (async () => {
|
|
|
14339
14522
|
await utils.captureException(e);
|
|
14340
14523
|
}
|
|
14341
14524
|
})();
|
|
14342
|
-
//# debugId=
|
|
14525
|
+
//# debugId=5e02c3b4-98c2-48aa-856d-526ed5a48fa7
|
|
14343
14526
|
//# sourceMappingURL=cli.js.map
|