socket 1.0.97 → 1.0.99
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 +795 -369
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-inject.js +2 -2
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts +28 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +11 -0
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -0
- package/dist/types/commands/patch/handle-patch.d.mts +10 -0
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -0
- package/dist/types/commands/patch/output-patch-result.d.mts +5 -0
- package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -0
- package/dist/types/commands.d.mts +7 -0
- package/dist/types/commands.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/utils.js +40 -38
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +4621 -4613
- package/external/@coana-tech/cli/cli.mjs +61 -52
- package/external/@coana-tech/cli/repos/coana-tech/alucard/alucard.jar +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
- package/package.json +4 -4
- package/dist/types/commands/scan/suggest-repo-slug.d.mts +0 -9
- package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -18,11 +18,11 @@ var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
|
18
18
|
var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
|
|
19
19
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
20
20
|
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
21
|
+
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
21
22
|
var registry = require('../external/@socketsecurity/registry');
|
|
22
23
|
var npm = require('../external/@socketsecurity/registry/lib/npm');
|
|
23
24
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
24
25
|
var sorts = require('../external/@socketsecurity/registry/lib/sorts');
|
|
25
|
-
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
26
26
|
var shadowNpmInject = require('./shadow-npm-inject.js');
|
|
27
27
|
var require$$9 = require('../external/@socketsecurity/registry/lib/objects');
|
|
28
28
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
@@ -322,21 +322,21 @@ async function handleAnalytics({
|
|
|
322
322
|
const {
|
|
323
323
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$M
|
|
324
324
|
} = constants;
|
|
325
|
-
const CMD_NAME$
|
|
326
|
-
const description$
|
|
327
|
-
const hidden$
|
|
325
|
+
const CMD_NAME$x = 'analytics';
|
|
326
|
+
const description$D = 'Look up analytics data';
|
|
327
|
+
const hidden$v = false;
|
|
328
328
|
const cmdAnalytics = {
|
|
329
|
-
description: description$
|
|
330
|
-
hidden: hidden$
|
|
331
|
-
run: run$
|
|
329
|
+
description: description$D,
|
|
330
|
+
hidden: hidden$v,
|
|
331
|
+
run: run$Q
|
|
332
332
|
};
|
|
333
|
-
async function run$
|
|
333
|
+
async function run$Q(argv, importMeta, {
|
|
334
334
|
parentName
|
|
335
335
|
}) {
|
|
336
336
|
const config = {
|
|
337
|
-
commandName: CMD_NAME$
|
|
338
|
-
description: description$
|
|
339
|
-
hidden: hidden$
|
|
337
|
+
commandName: CMD_NAME$x,
|
|
338
|
+
description: description$D,
|
|
339
|
+
hidden: hidden$v,
|
|
340
340
|
flags: {
|
|
341
341
|
...flags.commonFlags,
|
|
342
342
|
...flags.outputFlags,
|
|
@@ -352,7 +352,7 @@ async function run$P(argv, importMeta, {
|
|
|
352
352
|
$ ${command} [options] [ "org" | "repo" <reponame>] [TIME]
|
|
353
353
|
|
|
354
354
|
API Token Requirements
|
|
355
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
355
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$x}`)}
|
|
356
356
|
|
|
357
357
|
The scope is either org or repo level, defaults to org.
|
|
358
358
|
|
|
@@ -755,21 +755,21 @@ const {
|
|
|
755
755
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$L,
|
|
756
756
|
SOCKET_WEBSITE_URL: SOCKET_WEBSITE_URL$3
|
|
757
757
|
} = constants;
|
|
758
|
-
const CMD_NAME$
|
|
759
|
-
const description$
|
|
760
|
-
const hidden$
|
|
758
|
+
const CMD_NAME$w = 'audit-log';
|
|
759
|
+
const description$C = 'Look up the audit log for an organization';
|
|
760
|
+
const hidden$u = false;
|
|
761
761
|
const cmdAuditLog = {
|
|
762
|
-
description: description$
|
|
763
|
-
hidden: hidden$
|
|
764
|
-
run: run$
|
|
762
|
+
description: description$C,
|
|
763
|
+
hidden: hidden$u,
|
|
764
|
+
run: run$P
|
|
765
765
|
};
|
|
766
|
-
async function run$
|
|
766
|
+
async function run$P(argv, importMeta, {
|
|
767
767
|
parentName
|
|
768
768
|
}) {
|
|
769
769
|
const config = {
|
|
770
|
-
commandName: CMD_NAME$
|
|
771
|
-
description: description$
|
|
772
|
-
hidden: hidden$
|
|
770
|
+
commandName: CMD_NAME$w,
|
|
771
|
+
description: description$C,
|
|
772
|
+
hidden: hidden$u,
|
|
773
773
|
flags: {
|
|
774
774
|
...flags.commonFlags,
|
|
775
775
|
...flags.outputFlags,
|
|
@@ -797,7 +797,7 @@ async function run$O(argv, importMeta, {
|
|
|
797
797
|
$ ${command} [options] [FILTER]
|
|
798
798
|
|
|
799
799
|
API Token Requirements
|
|
800
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
800
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$w}`)}
|
|
801
801
|
|
|
802
802
|
This feature requires an Enterprise Plan. To learn more about getting access
|
|
803
803
|
to this feature and many more, please visit ${SOCKET_WEBSITE_URL$3}/pricing
|
|
@@ -2376,9 +2376,9 @@ const config$k = {
|
|
|
2376
2376
|
const cmdCI = {
|
|
2377
2377
|
description: config$k.description,
|
|
2378
2378
|
hidden: config$k.hidden,
|
|
2379
|
-
run: run$
|
|
2379
|
+
run: run$O
|
|
2380
2380
|
};
|
|
2381
|
-
async function run$
|
|
2381
|
+
async function run$O(argv, importMeta, {
|
|
2382
2382
|
parentName
|
|
2383
2383
|
}) {
|
|
2384
2384
|
const cli = utils.meowOrExit({
|
|
@@ -2623,21 +2623,21 @@ async function handleConfigAuto({
|
|
|
2623
2623
|
const {
|
|
2624
2624
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$J
|
|
2625
2625
|
} = constants;
|
|
2626
|
-
const CMD_NAME$
|
|
2627
|
-
const description$
|
|
2628
|
-
const hidden$
|
|
2626
|
+
const CMD_NAME$v = 'auto';
|
|
2627
|
+
const description$B = 'Automatically discover and set the correct value config item';
|
|
2628
|
+
const hidden$t = false;
|
|
2629
2629
|
const cmdConfigAuto = {
|
|
2630
|
-
description: description$
|
|
2631
|
-
hidden: hidden$
|
|
2632
|
-
run: run$
|
|
2630
|
+
description: description$B,
|
|
2631
|
+
hidden: hidden$t,
|
|
2632
|
+
run: run$N
|
|
2633
2633
|
};
|
|
2634
|
-
async function run$
|
|
2634
|
+
async function run$N(argv, importMeta, {
|
|
2635
2635
|
parentName
|
|
2636
2636
|
}) {
|
|
2637
2637
|
const config = {
|
|
2638
|
-
commandName: CMD_NAME$
|
|
2639
|
-
description: description$
|
|
2640
|
-
hidden: hidden$
|
|
2638
|
+
commandName: CMD_NAME$v,
|
|
2639
|
+
description: description$B,
|
|
2640
|
+
hidden: hidden$t,
|
|
2641
2641
|
flags: {
|
|
2642
2642
|
...flags.commonFlags,
|
|
2643
2643
|
...flags.outputFlags
|
|
@@ -2764,9 +2764,9 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
2764
2764
|
const cmdConfigGet = {
|
|
2765
2765
|
description: config$j.description,
|
|
2766
2766
|
hidden: config$j.hidden,
|
|
2767
|
-
run: run$
|
|
2767
|
+
run: run$M
|
|
2768
2768
|
};
|
|
2769
|
-
async function run$
|
|
2769
|
+
async function run$M(argv, importMeta, {
|
|
2770
2770
|
parentName
|
|
2771
2771
|
}) {
|
|
2772
2772
|
const cli = utils.meowOrExit({
|
|
@@ -2903,9 +2903,9 @@ const config$i = {
|
|
|
2903
2903
|
const cmdConfigList = {
|
|
2904
2904
|
description: config$i.description,
|
|
2905
2905
|
hidden: config$i.hidden,
|
|
2906
|
-
run: run$
|
|
2906
|
+
run: run$L
|
|
2907
2907
|
};
|
|
2908
|
-
async function run$
|
|
2908
|
+
async function run$L(argv, importMeta, {
|
|
2909
2909
|
parentName
|
|
2910
2910
|
}) {
|
|
2911
2911
|
const cli = utils.meowOrExit({
|
|
@@ -2982,21 +2982,21 @@ async function handleConfigSet({
|
|
|
2982
2982
|
const {
|
|
2983
2983
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$G
|
|
2984
2984
|
} = constants;
|
|
2985
|
-
const CMD_NAME$
|
|
2986
|
-
const description$
|
|
2987
|
-
const hidden$
|
|
2985
|
+
const CMD_NAME$u = 'set';
|
|
2986
|
+
const description$A = 'Update the value of a local CLI config item';
|
|
2987
|
+
const hidden$s = false;
|
|
2988
2988
|
const cmdConfigSet = {
|
|
2989
|
-
description: description$
|
|
2990
|
-
hidden: hidden$
|
|
2991
|
-
run: run$
|
|
2989
|
+
description: description$A,
|
|
2990
|
+
hidden: hidden$s,
|
|
2991
|
+
run: run$K
|
|
2992
2992
|
};
|
|
2993
|
-
async function run$
|
|
2993
|
+
async function run$K(argv, importMeta, {
|
|
2994
2994
|
parentName
|
|
2995
2995
|
}) {
|
|
2996
2996
|
const config = {
|
|
2997
|
-
commandName: CMD_NAME$
|
|
2998
|
-
description: description$
|
|
2999
|
-
hidden: hidden$
|
|
2997
|
+
commandName: CMD_NAME$u,
|
|
2998
|
+
description: description$A,
|
|
2999
|
+
hidden: hidden$s,
|
|
3000
3000
|
flags: {
|
|
3001
3001
|
...flags.commonFlags,
|
|
3002
3002
|
...flags.outputFlags
|
|
@@ -3109,21 +3109,21 @@ async function handleConfigUnset({
|
|
|
3109
3109
|
const {
|
|
3110
3110
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$F
|
|
3111
3111
|
} = constants;
|
|
3112
|
-
const CMD_NAME$
|
|
3113
|
-
const description$
|
|
3114
|
-
const hidden$
|
|
3112
|
+
const CMD_NAME$t = 'unset';
|
|
3113
|
+
const description$z = 'Clear the value of a local CLI config item';
|
|
3114
|
+
const hidden$r = false;
|
|
3115
3115
|
const cmdConfigUnset = {
|
|
3116
|
-
description: description$
|
|
3117
|
-
hidden: hidden$
|
|
3118
|
-
run: run$
|
|
3116
|
+
description: description$z,
|
|
3117
|
+
hidden: hidden$r,
|
|
3118
|
+
run: run$J
|
|
3119
3119
|
};
|
|
3120
|
-
async function run$
|
|
3120
|
+
async function run$J(argv, importMeta, {
|
|
3121
3121
|
parentName
|
|
3122
3122
|
}) {
|
|
3123
3123
|
const config = {
|
|
3124
|
-
commandName: CMD_NAME$
|
|
3125
|
-
description: description$
|
|
3126
|
-
hidden: hidden$
|
|
3124
|
+
commandName: CMD_NAME$t,
|
|
3125
|
+
description: description$z,
|
|
3126
|
+
hidden: hidden$r,
|
|
3127
3127
|
flags: {
|
|
3128
3128
|
...flags.commonFlags,
|
|
3129
3129
|
...flags.outputFlags
|
|
@@ -3182,9 +3182,9 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
3182
3182
|
});
|
|
3183
3183
|
}
|
|
3184
3184
|
|
|
3185
|
-
const description$
|
|
3185
|
+
const description$y = 'Manage Socket CLI configuration';
|
|
3186
3186
|
const cmdConfig = {
|
|
3187
|
-
description: description$
|
|
3187
|
+
description: description$y,
|
|
3188
3188
|
hidden: false,
|
|
3189
3189
|
async run(argv, importMeta, {
|
|
3190
3190
|
parentName
|
|
@@ -3197,74 +3197,13 @@ const cmdConfig = {
|
|
|
3197
3197
|
unset: cmdConfigUnset
|
|
3198
3198
|
}, {
|
|
3199
3199
|
argv,
|
|
3200
|
-
description: description$
|
|
3200
|
+
description: description$y,
|
|
3201
3201
|
importMeta,
|
|
3202
3202
|
name: `${parentName} config`
|
|
3203
3203
|
});
|
|
3204
3204
|
}
|
|
3205
3205
|
};
|
|
3206
3206
|
|
|
3207
|
-
async function coanaFix(fixConfig) {
|
|
3208
|
-
const {
|
|
3209
|
-
ghsas
|
|
3210
|
-
} = fixConfig;
|
|
3211
|
-
if (!ghsas.length) {
|
|
3212
|
-
return {
|
|
3213
|
-
ok: true,
|
|
3214
|
-
data: {
|
|
3215
|
-
fixed: false
|
|
3216
|
-
}
|
|
3217
|
-
};
|
|
3218
|
-
}
|
|
3219
|
-
const {
|
|
3220
|
-
cwd,
|
|
3221
|
-
orgSlug,
|
|
3222
|
-
spinner
|
|
3223
|
-
} = fixConfig;
|
|
3224
|
-
spinner?.start();
|
|
3225
|
-
const sockSdkCResult = await utils.setupSdk();
|
|
3226
|
-
let lastCResult = sockSdkCResult;
|
|
3227
|
-
const sockSdk = sockSdkCResult.ok ? sockSdkCResult.data : undefined;
|
|
3228
|
-
const supportedFilesCResult = sockSdk ? await fetchSupportedScanFileNames() : undefined;
|
|
3229
|
-
if (supportedFilesCResult) {
|
|
3230
|
-
lastCResult = supportedFilesCResult;
|
|
3231
|
-
}
|
|
3232
|
-
const supportedFiles = supportedFilesCResult?.ok ? supportedFilesCResult.data : undefined;
|
|
3233
|
-
const packagePaths = supportedFiles ? await utils.getPackageFilesForScan(['.'], supportedFiles, {
|
|
3234
|
-
cwd
|
|
3235
|
-
}) : [];
|
|
3236
|
-
const uploadCResult = sockSdk ? await utils.handleApiCall(sockSdk?.uploadManifestFiles(orgSlug, packagePaths), {
|
|
3237
|
-
desc: 'upload manifests'
|
|
3238
|
-
}) : undefined;
|
|
3239
|
-
if (uploadCResult) {
|
|
3240
|
-
lastCResult = uploadCResult;
|
|
3241
|
-
}
|
|
3242
|
-
const tarHash = uploadCResult?.ok ? uploadCResult.data.tarHash : '';
|
|
3243
|
-
if (!tarHash) {
|
|
3244
|
-
spinner?.stop();
|
|
3245
|
-
return lastCResult;
|
|
3246
|
-
}
|
|
3247
|
-
const isAllOrAuto = ghsas.length === 1 && (ghsas[0] === 'all' || ghsas[0] === 'auto');
|
|
3248
|
-
const ids = isAllOrAuto ? ['all'] : ghsas;
|
|
3249
|
-
const fixCResult = ids.length ? await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...ids, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3250
|
-
cwd,
|
|
3251
|
-
spinner
|
|
3252
|
-
}) : undefined;
|
|
3253
|
-
if (fixCResult) {
|
|
3254
|
-
lastCResult = fixCResult;
|
|
3255
|
-
}
|
|
3256
|
-
spinner?.stop();
|
|
3257
|
-
require$$8.debugDir('inspect', {
|
|
3258
|
-
lastCResult
|
|
3259
|
-
});
|
|
3260
|
-
return lastCResult.ok ? {
|
|
3261
|
-
ok: true,
|
|
3262
|
-
data: {
|
|
3263
|
-
fixed: true
|
|
3264
|
-
}
|
|
3265
|
-
} : lastCResult;
|
|
3266
|
-
}
|
|
3267
|
-
|
|
3268
3207
|
function formatBranchName(name) {
|
|
3269
3208
|
return name.replace(/[^-a-zA-Z0-9/._-]+/g, '+');
|
|
3270
3209
|
}
|
|
@@ -3352,34 +3291,6 @@ function getSocketPullRequestTitle(purl, newVersion, workspace) {
|
|
|
3352
3291
|
return `Bump ${fullName} from ${purlObj.version} to ${newVersion}${workspace ? ` in ${workspace}` : ''}`;
|
|
3353
3292
|
}
|
|
3354
3293
|
|
|
3355
|
-
function getPrsForPurl(fixEnv, partialPurl) {
|
|
3356
|
-
if (!fixEnv) {
|
|
3357
|
-
return [];
|
|
3358
|
-
}
|
|
3359
|
-
const prs = [];
|
|
3360
|
-
const partialPurlObj = utils.getPurlObject(partialPurl);
|
|
3361
|
-
const branchFullName = getSocketBranchFullNameComponent(partialPurlObj);
|
|
3362
|
-
const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj);
|
|
3363
|
-
for (const pr of fixEnv.prs) {
|
|
3364
|
-
const parsedBranch = genericSocketBranchParser(pr.headRefName);
|
|
3365
|
-
if (branchPurlType === parsedBranch?.type && branchFullName === parsedBranch?.fullName) {
|
|
3366
|
-
prs.push(pr);
|
|
3367
|
-
}
|
|
3368
|
-
}
|
|
3369
|
-
if (require$$8.isDebug('notice,silly')) {
|
|
3370
|
-
const fullName = packages.resolvePackageName(partialPurlObj);
|
|
3371
|
-
if (prs.length) {
|
|
3372
|
-
require$$8.debugFn('notice', `found: ${prs.length} PRs for ${fullName}`);
|
|
3373
|
-
require$$8.debugDir('silly', {
|
|
3374
|
-
prs
|
|
3375
|
-
});
|
|
3376
|
-
} else if (fixEnv.prs.length) {
|
|
3377
|
-
require$$8.debugFn('notice', `miss: 0 PRs found for ${fullName}`);
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
return prs;
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
3294
|
let _octokit;
|
|
3384
3295
|
function getOctokit() {
|
|
3385
3296
|
if (_octokit === undefined) {
|
|
@@ -3420,19 +3331,6 @@ function getOctokitGraphql() {
|
|
|
3420
3331
|
}
|
|
3421
3332
|
return _octokitGraphql;
|
|
3422
3333
|
}
|
|
3423
|
-
async function cacheFetch(key, fetcher, ttlMs) {
|
|
3424
|
-
// Optionally disable cache.
|
|
3425
|
-
// Lazily access constants.ENV.DISABLE_GITHUB_CACHE.
|
|
3426
|
-
if (constants.ENV.DISABLE_GITHUB_CACHE) {
|
|
3427
|
-
return await fetcher();
|
|
3428
|
-
}
|
|
3429
|
-
let data = await readCache(key, ttlMs);
|
|
3430
|
-
if (!data) {
|
|
3431
|
-
data = await fetcher();
|
|
3432
|
-
await writeCache(key, data);
|
|
3433
|
-
}
|
|
3434
|
-
return data;
|
|
3435
|
-
}
|
|
3436
3334
|
async function readCache(key,
|
|
3437
3335
|
// 5 minute in milliseconds time to live (TTL).
|
|
3438
3336
|
ttlMs = 5 * 60 * 1000) {
|
|
@@ -3460,6 +3358,75 @@ async function writeCache(key, data) {
|
|
|
3460
3358
|
}
|
|
3461
3359
|
await fs$2.writeJson(cacheJsonPath, data);
|
|
3462
3360
|
}
|
|
3361
|
+
async function cacheFetch(key, fetcher, ttlMs) {
|
|
3362
|
+
// Optionally disable cache.
|
|
3363
|
+
// Lazily access constants.ENV.DISABLE_GITHUB_CACHE.
|
|
3364
|
+
if (constants.ENV.DISABLE_GITHUB_CACHE) {
|
|
3365
|
+
return await fetcher();
|
|
3366
|
+
}
|
|
3367
|
+
let data = await readCache(key, ttlMs);
|
|
3368
|
+
if (!data) {
|
|
3369
|
+
data = await fetcher();
|
|
3370
|
+
await writeCache(key, data);
|
|
3371
|
+
}
|
|
3372
|
+
return data;
|
|
3373
|
+
}
|
|
3374
|
+
async function fetchGhsaDetails(ids) {
|
|
3375
|
+
const results = new Map();
|
|
3376
|
+
if (!ids.length) {
|
|
3377
|
+
return results;
|
|
3378
|
+
}
|
|
3379
|
+
const octokitGraphql = getOctokitGraphql();
|
|
3380
|
+
try {
|
|
3381
|
+
const gqlCacheKey = `${ids.join('-')}-graphql-snapshot`;
|
|
3382
|
+
const gqlResp = await cacheFetch(gqlCacheKey, () => octokitGraphql(`
|
|
3383
|
+
query($identifiers: [SecurityAdvisoryIdentifierFilter!]!) {
|
|
3384
|
+
securityAdvisories(first: ${ids.length}, identifiers: $identifiers) {
|
|
3385
|
+
nodes {
|
|
3386
|
+
ghsaId
|
|
3387
|
+
cveId
|
|
3388
|
+
summary
|
|
3389
|
+
severity
|
|
3390
|
+
publishedAt
|
|
3391
|
+
withdrawnAt
|
|
3392
|
+
references {
|
|
3393
|
+
url
|
|
3394
|
+
}
|
|
3395
|
+
vulnerabilities(first: 10) {
|
|
3396
|
+
nodes {
|
|
3397
|
+
package {
|
|
3398
|
+
ecosystem
|
|
3399
|
+
name
|
|
3400
|
+
}
|
|
3401
|
+
vulnerableVersionRange
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
}`, {
|
|
3407
|
+
identifiers: ids.map(id => ({
|
|
3408
|
+
type: 'GHSA',
|
|
3409
|
+
value: id
|
|
3410
|
+
}))
|
|
3411
|
+
}));
|
|
3412
|
+
const advisories = gqlResp?.securityAdvisories?.nodes || [];
|
|
3413
|
+
for (const advisory of advisories) {
|
|
3414
|
+
if (advisory.ghsaId) {
|
|
3415
|
+
results.set(advisory.ghsaId, advisory);
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
// Log any missing advisories
|
|
3420
|
+
for (const id of ids) {
|
|
3421
|
+
if (!results.has(id)) {
|
|
3422
|
+
require$$8.debugFn('notice', `No advisory found for ${id}`);
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
} catch (e) {
|
|
3426
|
+
require$$8.debugFn('error', `Failed to fetch GHSA details: ${e?.message || 'Unknown error'}`);
|
|
3427
|
+
}
|
|
3428
|
+
return results;
|
|
3429
|
+
}
|
|
3463
3430
|
async function cleanupPrs(owner, repo, options) {
|
|
3464
3431
|
const contextualMatches = await getSocketPrsWithContext(owner, repo, options);
|
|
3465
3432
|
if (!contextualMatches.length) {
|
|
@@ -3501,7 +3468,7 @@ async function cleanupPrs(owner, repo, options) {
|
|
|
3501
3468
|
cachesToSave.set(context.cacheKey, context.data);
|
|
3502
3469
|
return null;
|
|
3503
3470
|
} catch (e) {
|
|
3504
|
-
require$$8.debugFn('error', `pr: failed to close ${prRef} for ${prToVersion}\n`, e?.message || '
|
|
3471
|
+
require$$8.debugFn('error', `pr: failed to close ${prRef} for ${prToVersion}\n`, e?.message || 'Unknown error');
|
|
3505
3472
|
}
|
|
3506
3473
|
}
|
|
3507
3474
|
// Update stale PRs.
|
|
@@ -3543,9 +3510,8 @@ async function enablePrAutoMerge({
|
|
|
3543
3510
|
node_id: prId
|
|
3544
3511
|
}) {
|
|
3545
3512
|
const octokitGraphql = getOctokitGraphql();
|
|
3546
|
-
let error;
|
|
3547
3513
|
try {
|
|
3548
|
-
const
|
|
3514
|
+
const gqlResp = await octokitGraphql(`
|
|
3549
3515
|
mutation EnableAutoMerge($pullRequestId: ID!) {
|
|
3550
3516
|
enablePullRequestAutoMerge(input: {
|
|
3551
3517
|
pullRequestId: $pullRequestId,
|
|
@@ -3558,23 +3524,22 @@ async function enablePrAutoMerge({
|
|
|
3558
3524
|
}`, {
|
|
3559
3525
|
pullRequestId: prId
|
|
3560
3526
|
});
|
|
3561
|
-
const respPrNumber =
|
|
3527
|
+
const respPrNumber = gqlResp?.enablePullRequestAutoMerge?.pullRequest?.number;
|
|
3562
3528
|
if (respPrNumber) {
|
|
3563
3529
|
return {
|
|
3564
3530
|
enabled: true
|
|
3565
3531
|
};
|
|
3566
3532
|
}
|
|
3567
3533
|
} catch (e) {
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
};
|
|
3534
|
+
if (e instanceof vendor.GraphqlResponseError && Array.isArray(e.errors) && e.errors.length) {
|
|
3535
|
+
const details = e.errors.map(({
|
|
3536
|
+
message: m
|
|
3537
|
+
}) => m.trim());
|
|
3538
|
+
return {
|
|
3539
|
+
enabled: false,
|
|
3540
|
+
details
|
|
3541
|
+
};
|
|
3542
|
+
}
|
|
3578
3543
|
}
|
|
3579
3544
|
return {
|
|
3580
3545
|
enabled: false
|
|
@@ -3741,6 +3706,61 @@ async function openPr(owner, repo, branch, purl, newVersion, options) {
|
|
|
3741
3706
|
}
|
|
3742
3707
|
return null;
|
|
3743
3708
|
}
|
|
3709
|
+
async function openCoanaPr(owner, repo, branch, ghsaIds, options) {
|
|
3710
|
+
const {
|
|
3711
|
+
baseBranch = 'main',
|
|
3712
|
+
ghsaDetails
|
|
3713
|
+
} = {
|
|
3714
|
+
__proto__: null,
|
|
3715
|
+
...options
|
|
3716
|
+
};
|
|
3717
|
+
const octokit = getOctokit();
|
|
3718
|
+
const vulnCount = ghsaIds.length;
|
|
3719
|
+
const prTitle = vulnCount === 1 ? `Fix for ${ghsaIds[0]}` : `Fixes for ${vulnCount} GHSAs`;
|
|
3720
|
+
let prBody = '';
|
|
3721
|
+
if (vulnCount === 1) {
|
|
3722
|
+
const ghsaId = ghsaIds[0];
|
|
3723
|
+
const details = ghsaDetails?.get(ghsaId);
|
|
3724
|
+
prBody = `[Socket](https://socket.dev/) fix for [${ghsaId}](https://github.com/advisories/${ghsaId}).`;
|
|
3725
|
+
if (details) {
|
|
3726
|
+
const packages = details.vulnerabilities.nodes.map(v => `${v.package.name} (${v.package.ecosystem})`);
|
|
3727
|
+
prBody += ['', '', `**Vulnerability Summary:** ${details.summary}`, '', `**Severity:** ${details.severity}`, '', `**Affected Packages:** ${arrays.joinAnd(packages)}`].join('\n');
|
|
3728
|
+
}
|
|
3729
|
+
} else {
|
|
3730
|
+
prBody = [`[Socket](https://socket.dev/) fixes for ${vulnCount} GHSAs.`, '', '**Fixed Vulnerabilities:**', ...ghsaIds.map(id => {
|
|
3731
|
+
const details = ghsaDetails?.get(id);
|
|
3732
|
+
const item = `- [${id}](https://github.com/advisories/${id})`;
|
|
3733
|
+
if (details) {
|
|
3734
|
+
const packages = details.vulnerabilities.nodes.map(v => `${v.package.name}`);
|
|
3735
|
+
return `${item} - ${details.summary} (${arrays.joinAnd(packages)})`;
|
|
3736
|
+
}
|
|
3737
|
+
return item;
|
|
3738
|
+
})].join('\n');
|
|
3739
|
+
}
|
|
3740
|
+
try {
|
|
3741
|
+
const octokitPullsCreateParams = {
|
|
3742
|
+
owner,
|
|
3743
|
+
repo,
|
|
3744
|
+
title: prTitle,
|
|
3745
|
+
head: branch,
|
|
3746
|
+
base: baseBranch,
|
|
3747
|
+
body: prBody
|
|
3748
|
+
};
|
|
3749
|
+
require$$8.debugDir('inspect', {
|
|
3750
|
+
octokitPullsCreateParams
|
|
3751
|
+
});
|
|
3752
|
+
return await octokit.pulls.create(octokitPullsCreateParams);
|
|
3753
|
+
} catch (e) {
|
|
3754
|
+
let message = `Failed to open pull request`;
|
|
3755
|
+
const errors = e instanceof vendor.RequestError ? e.response?.data?.['errors'] : undefined;
|
|
3756
|
+
if (Array.isArray(errors) && errors.length) {
|
|
3757
|
+
const details = errors.map(d => `- ${d.message?.trim() ?? `${d.resource}.${d.field} (${d.code})`}`).join('\n');
|
|
3758
|
+
message += `:\n${details}`;
|
|
3759
|
+
}
|
|
3760
|
+
require$$8.debugFn('error', message);
|
|
3761
|
+
}
|
|
3762
|
+
return null;
|
|
3763
|
+
}
|
|
3744
3764
|
async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()) {
|
|
3745
3765
|
const {
|
|
3746
3766
|
host
|
|
@@ -3823,25 +3843,281 @@ async function getFixEnv() {
|
|
|
3823
3843
|
};
|
|
3824
3844
|
}
|
|
3825
3845
|
|
|
3826
|
-
async function
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
}
|
|
3844
|
-
|
|
3846
|
+
async function coanaFix(fixConfig) {
|
|
3847
|
+
const {
|
|
3848
|
+
autoMerge,
|
|
3849
|
+
cwd,
|
|
3850
|
+
ghsas,
|
|
3851
|
+
limit,
|
|
3852
|
+
orgSlug,
|
|
3853
|
+
spinner
|
|
3854
|
+
} = fixConfig;
|
|
3855
|
+
const fixEnv = await getFixEnv();
|
|
3856
|
+
require$$8.debugDir('inspect', {
|
|
3857
|
+
fixEnv
|
|
3858
|
+
});
|
|
3859
|
+
spinner?.start();
|
|
3860
|
+
const sockSdkCResult = await utils.setupSdk();
|
|
3861
|
+
if (!sockSdkCResult.ok) {
|
|
3862
|
+
return sockSdkCResult;
|
|
3863
|
+
}
|
|
3864
|
+
const sockSdk = sockSdkCResult.data;
|
|
3865
|
+
const supportedFilesCResult = await fetchSupportedScanFileNames();
|
|
3866
|
+
if (!supportedFilesCResult.ok) {
|
|
3867
|
+
return supportedFilesCResult;
|
|
3868
|
+
}
|
|
3869
|
+
const supportedFiles = supportedFilesCResult.data;
|
|
3870
|
+
const scanFilepaths = await utils.getPackageFilesForScan(['.'], supportedFiles, {
|
|
3871
|
+
cwd
|
|
3872
|
+
});
|
|
3873
|
+
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, scanFilepaths), {
|
|
3874
|
+
desc: 'upload manifests'
|
|
3875
|
+
});
|
|
3876
|
+
if (!uploadCResult.ok) {
|
|
3877
|
+
return uploadCResult;
|
|
3878
|
+
}
|
|
3879
|
+
const tarHash = uploadCResult.data.tarHash;
|
|
3880
|
+
if (!tarHash) {
|
|
3881
|
+
spinner?.stop();
|
|
3882
|
+
return {
|
|
3883
|
+
ok: false,
|
|
3884
|
+
message: 'No tar hash returned from Socket API upload-manifest-files endpoint',
|
|
3885
|
+
data: uploadCResult.data
|
|
3886
|
+
};
|
|
3887
|
+
}
|
|
3888
|
+
const isAll = ghsas.length === 1 && (ghsas[0] === 'all' || ghsas[0] === 'auto');
|
|
3889
|
+
const shouldOpenPrs = fixEnv.isCi && fixEnv.repoInfo;
|
|
3890
|
+
if (!shouldOpenPrs) {
|
|
3891
|
+
const ids = isAll ? ['all'] : ghsas.slice(0, limit);
|
|
3892
|
+
if (!ids.length) {
|
|
3893
|
+
spinner?.stop();
|
|
3894
|
+
return {
|
|
3895
|
+
ok: true,
|
|
3896
|
+
data: {
|
|
3897
|
+
fixed: false
|
|
3898
|
+
}
|
|
3899
|
+
};
|
|
3900
|
+
}
|
|
3901
|
+
const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...(isAll ? ['all'] : ghsas), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3902
|
+
cwd,
|
|
3903
|
+
spinner
|
|
3904
|
+
});
|
|
3905
|
+
spinner?.stop();
|
|
3906
|
+
return fixCResult.ok ? {
|
|
3907
|
+
ok: true,
|
|
3908
|
+
data: {
|
|
3909
|
+
fixed: true
|
|
3910
|
+
}
|
|
3911
|
+
} : fixCResult;
|
|
3912
|
+
}
|
|
3913
|
+
let ids;
|
|
3914
|
+
if (isAll) {
|
|
3915
|
+
const foundCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3916
|
+
cwd,
|
|
3917
|
+
spinner
|
|
3918
|
+
});
|
|
3919
|
+
if (foundCResult.ok) {
|
|
3920
|
+
const foundIds = utils.cmdFlagValueToArray(/(?<=Vulnerabilities found:).*/.exec(foundCResult.data));
|
|
3921
|
+
ids = foundIds.slice(0, limit);
|
|
3922
|
+
}
|
|
3923
|
+
} else {
|
|
3924
|
+
ids = ghsas.slice(0, limit);
|
|
3925
|
+
}
|
|
3926
|
+
if (!ids?.length) {
|
|
3927
|
+
require$$8.debugFn('notice', 'miss: no GHSA IDs to process');
|
|
3928
|
+
}
|
|
3929
|
+
if (!fixEnv.repoInfo) {
|
|
3930
|
+
require$$8.debugFn('notice', 'miss: no repo info detected');
|
|
3931
|
+
}
|
|
3932
|
+
if (!ids?.length || !fixEnv.repoInfo) {
|
|
3933
|
+
spinner?.stop();
|
|
3934
|
+
return {
|
|
3935
|
+
ok: true,
|
|
3936
|
+
data: {
|
|
3937
|
+
fixed: false
|
|
3938
|
+
}
|
|
3939
|
+
};
|
|
3940
|
+
}
|
|
3941
|
+
const ghsaDetails = await fetchGhsaDetails(ids);
|
|
3942
|
+
const scanBaseNames = new Set(scanFilepaths.map(p => path.basename(p)));
|
|
3943
|
+
let count = 0;
|
|
3944
|
+
let overallFixed = false;
|
|
3945
|
+
|
|
3946
|
+
// Process each GHSA ID individually, similar to npm-fix/pnpm-fix.
|
|
3947
|
+
ghsaLoop: for (let i = 0, {
|
|
3948
|
+
length
|
|
3949
|
+
} = ids; i < length; i += 1) {
|
|
3950
|
+
const id = ids[i];
|
|
3951
|
+
require$$8.debugFn('notice', `check: ${id}`);
|
|
3952
|
+
|
|
3953
|
+
// Apply fix for single GHSA ID.
|
|
3954
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3955
|
+
const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', id, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3956
|
+
cwd,
|
|
3957
|
+
spinner
|
|
3958
|
+
});
|
|
3959
|
+
if (!fixCResult.ok) {
|
|
3960
|
+
logger.logger.error(`Update failed for ${id}: ${fixCResult.message || 'Unknown error'}`);
|
|
3961
|
+
continue ghsaLoop;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
// Check for modified files after applying the fix.
|
|
3965
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3966
|
+
const unstagedCResult = await utils.gitUnstagedModifiedFiles(cwd);
|
|
3967
|
+
const modifiedFiles = unstagedCResult.ok ? unstagedCResult.data.filter(relPath => scanBaseNames.has(path.basename(relPath))) : [];
|
|
3968
|
+
if (!modifiedFiles.length) {
|
|
3969
|
+
require$$8.debugFn('notice', `skip: no changes for ${id}`);
|
|
3970
|
+
continue ghsaLoop;
|
|
3971
|
+
}
|
|
3972
|
+
overallFixed = true;
|
|
3973
|
+
const branch = `socket/fix/${id}`;
|
|
3974
|
+
try {
|
|
3975
|
+
// Check if branch already exists.
|
|
3976
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3977
|
+
if (await utils.gitRemoteBranchExists(branch, cwd)) {
|
|
3978
|
+
require$$8.debugFn('notice', `skip: remote branch "${branch}" exists`);
|
|
3979
|
+
continue ghsaLoop;
|
|
3980
|
+
}
|
|
3981
|
+
require$$8.debugFn('notice', `pr: creating for ${id}`);
|
|
3982
|
+
const summary = ghsaDetails.get(id)?.summary;
|
|
3983
|
+
const pushed =
|
|
3984
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3985
|
+
(await utils.gitCreateBranch(branch, cwd)) && (
|
|
3986
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3987
|
+
await utils.gitCheckoutBranch(branch, cwd)) && (
|
|
3988
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3989
|
+
await utils.gitCommit(`fix: ${id}${summary ? ` - ${summary}` : ''}`, modifiedFiles, {
|
|
3990
|
+
cwd,
|
|
3991
|
+
email: fixEnv.gitEmail,
|
|
3992
|
+
user: fixEnv.gitUser
|
|
3993
|
+
})) && (
|
|
3994
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3995
|
+
await utils.gitPushBranch(branch, cwd));
|
|
3996
|
+
if (!pushed) {
|
|
3997
|
+
logger.logger.warn(`Push failed for ${id}, skipping PR creation.`);
|
|
3998
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3999
|
+
await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4000
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4001
|
+
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4002
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4003
|
+
await utils.gitDeleteBranch(branch, cwd);
|
|
4004
|
+
continue ghsaLoop;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
// Set up git remote.
|
|
4008
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4009
|
+
await setGitRemoteGithubRepoUrl(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, fixEnv.githubToken, cwd);
|
|
4010
|
+
|
|
4011
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4012
|
+
const prResponse = await openCoanaPr(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, branch,
|
|
4013
|
+
// Single GHSA ID.
|
|
4014
|
+
[id], {
|
|
4015
|
+
baseBranch: fixEnv.baseBranch,
|
|
4016
|
+
cwd,
|
|
4017
|
+
ghsaDetails
|
|
4018
|
+
});
|
|
4019
|
+
if (prResponse) {
|
|
4020
|
+
const {
|
|
4021
|
+
data
|
|
4022
|
+
} = prResponse;
|
|
4023
|
+
const prRef = `PR #${data.number}`;
|
|
4024
|
+
logger.logger.success(`Opened ${prRef} for ${id}.`);
|
|
4025
|
+
if (autoMerge) {
|
|
4026
|
+
logger.logger.indent();
|
|
4027
|
+
spinner?.indent();
|
|
4028
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4029
|
+
const {
|
|
4030
|
+
details,
|
|
4031
|
+
enabled
|
|
4032
|
+
} = await enablePrAutoMerge(data);
|
|
4033
|
+
if (enabled) {
|
|
4034
|
+
logger.logger.info(`Auto-merge enabled for ${prRef}.`);
|
|
4035
|
+
} else {
|
|
4036
|
+
const message = `Failed to enable auto-merge for ${prRef}${details ? `:\n${details.map(d => ` - ${d}`).join('\n')}` : '.'}`;
|
|
4037
|
+
logger.logger.error(message);
|
|
4038
|
+
}
|
|
4039
|
+
logger.logger.dedent();
|
|
4040
|
+
spinner?.dedent();
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
|
|
4044
|
+
// Reset back to base branch for next iteration.
|
|
4045
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4046
|
+
await utils.gitResetAndClean(branch, cwd);
|
|
4047
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4048
|
+
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4049
|
+
} catch (e) {
|
|
4050
|
+
logger.logger.warn(`Unexpected condition: Push failed for ${id}, skipping PR creation.`);
|
|
4051
|
+
require$$8.debugDir('inspect', {
|
|
4052
|
+
error: e
|
|
4053
|
+
});
|
|
4054
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4055
|
+
await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4056
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4057
|
+
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4058
|
+
}
|
|
4059
|
+
count += 1;
|
|
4060
|
+
require$$8.debugFn('notice', `increment: count ${count}/${Math.min(limit, ids.length)}`);
|
|
4061
|
+
if (count >= limit) {
|
|
4062
|
+
break ghsaLoop;
|
|
4063
|
+
}
|
|
4064
|
+
}
|
|
4065
|
+
spinner?.stop();
|
|
4066
|
+
return {
|
|
4067
|
+
ok: true,
|
|
4068
|
+
data: {
|
|
4069
|
+
fixed: overallFixed
|
|
4070
|
+
}
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
|
|
4074
|
+
function getPrsForPurl(fixEnv, partialPurl) {
|
|
4075
|
+
if (!fixEnv) {
|
|
4076
|
+
return [];
|
|
4077
|
+
}
|
|
4078
|
+
const prs = [];
|
|
4079
|
+
const partialPurlObj = utils.getPurlObject(partialPurl);
|
|
4080
|
+
const branchFullName = getSocketBranchFullNameComponent(partialPurlObj);
|
|
4081
|
+
const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj);
|
|
4082
|
+
for (const pr of fixEnv.prs) {
|
|
4083
|
+
const parsedBranch = genericSocketBranchParser(pr.headRefName);
|
|
4084
|
+
if (branchPurlType === parsedBranch?.type && branchFullName === parsedBranch?.fullName) {
|
|
4085
|
+
prs.push(pr);
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
if (require$$8.isDebug('notice,silly')) {
|
|
4089
|
+
const fullName = packages.resolvePackageName(partialPurlObj);
|
|
4090
|
+
if (prs.length) {
|
|
4091
|
+
require$$8.debugFn('notice', `found: ${prs.length} PRs for ${fullName}`);
|
|
4092
|
+
require$$8.debugDir('silly', {
|
|
4093
|
+
prs
|
|
4094
|
+
});
|
|
4095
|
+
} else if (fixEnv.prs.length) {
|
|
4096
|
+
require$$8.debugFn('notice', `miss: 0 PRs found for ${fullName}`);
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
return prs;
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
async function getActualTree(cwd = process.cwd()) {
|
|
4103
|
+
try {
|
|
4104
|
+
// @npmcli/arborist DOES have partial support for pnpm structured node_modules
|
|
4105
|
+
// folders. However, support is iffy resulting in unhappy paths of errors and hangs.
|
|
4106
|
+
// So, to avoid unhappy paths, we restrict our usage to --dry-run loading of the
|
|
4107
|
+
// node_modules folder.
|
|
4108
|
+
const arb = new shadowNpmInject.Arborist({
|
|
4109
|
+
path: cwd,
|
|
4110
|
+
...shadowNpmInject.SAFE_NO_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
4111
|
+
});
|
|
4112
|
+
return {
|
|
4113
|
+
actualTree: await arb.loadActual()
|
|
4114
|
+
};
|
|
4115
|
+
} catch (e) {
|
|
4116
|
+
return {
|
|
4117
|
+
error: e
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
4120
|
+
}
|
|
3845
4121
|
|
|
3846
4122
|
const {
|
|
3847
4123
|
BUN: BUN$4,
|
|
@@ -4415,7 +4691,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4415
4691
|
};
|
|
4416
4692
|
}
|
|
4417
4693
|
|
|
4418
|
-
const CMD_NAME$
|
|
4694
|
+
const CMD_NAME$s = 'socket fix';
|
|
4419
4695
|
function getFixAlertsMapOptions(options = {}) {
|
|
4420
4696
|
return {
|
|
4421
4697
|
__proto__: null,
|
|
@@ -4854,8 +5130,10 @@ async function handleFix({
|
|
|
4854
5130
|
}) {
|
|
4855
5131
|
if (ghsas.length) {
|
|
4856
5132
|
await outputFixResult(await coanaFix({
|
|
5133
|
+
autoMerge,
|
|
4857
5134
|
cwd,
|
|
4858
5135
|
ghsas,
|
|
5136
|
+
limit,
|
|
4859
5137
|
orgSlug,
|
|
4860
5138
|
spinner,
|
|
4861
5139
|
unknownFlags
|
|
@@ -4863,7 +5141,7 @@ async function handleFix({
|
|
|
4863
5141
|
return;
|
|
4864
5142
|
}
|
|
4865
5143
|
const pkgEnvCResult = await utils.detectAndValidatePackageEnvironment(cwd, {
|
|
4866
|
-
cmdName: CMD_NAME$
|
|
5144
|
+
cmdName: CMD_NAME$s,
|
|
4867
5145
|
logger: logger.logger
|
|
4868
5146
|
});
|
|
4869
5147
|
if (!pkgEnvCResult.ok) {
|
|
@@ -4922,24 +5200,24 @@ async function handleFix({
|
|
|
4922
5200
|
}
|
|
4923
5201
|
|
|
4924
5202
|
const {
|
|
4925
|
-
DRY_RUN_NOT_SAVING
|
|
5203
|
+
DRY_RUN_NOT_SAVING: DRY_RUN_NOT_SAVING$1
|
|
4926
5204
|
} = constants;
|
|
4927
|
-
const CMD_NAME$
|
|
5205
|
+
const CMD_NAME$r = 'fix';
|
|
4928
5206
|
const DEFAULT_LIMIT = 10;
|
|
4929
|
-
const description$
|
|
4930
|
-
const hidden$
|
|
5207
|
+
const description$x = 'Update dependencies with "fixable" Socket alerts';
|
|
5208
|
+
const hidden$q = false;
|
|
4931
5209
|
const cmdFix = {
|
|
4932
|
-
description: description$
|
|
4933
|
-
hidden: hidden$
|
|
4934
|
-
run: run$
|
|
5210
|
+
description: description$x,
|
|
5211
|
+
hidden: hidden$q,
|
|
5212
|
+
run: run$I
|
|
4935
5213
|
};
|
|
4936
|
-
async function run$
|
|
5214
|
+
async function run$I(argv, importMeta, {
|
|
4937
5215
|
parentName
|
|
4938
5216
|
}) {
|
|
4939
5217
|
const config = {
|
|
4940
|
-
commandName: CMD_NAME$
|
|
4941
|
-
description: description$
|
|
4942
|
-
hidden: hidden$
|
|
5218
|
+
commandName: CMD_NAME$r,
|
|
5219
|
+
description: description$x,
|
|
5220
|
+
hidden: hidden$q,
|
|
4943
5221
|
flags: {
|
|
4944
5222
|
...flags.commonFlags,
|
|
4945
5223
|
...flags.outputFlags,
|
|
@@ -5021,7 +5299,7 @@ Available styles:
|
|
|
5021
5299
|
$ ${command} [options] [CWD=.]
|
|
5022
5300
|
|
|
5023
5301
|
API Token Requirements
|
|
5024
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
5302
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$r}`)}
|
|
5025
5303
|
|
|
5026
5304
|
Options
|
|
5027
5305
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -5076,7 +5354,7 @@ Available styles:
|
|
|
5076
5354
|
return;
|
|
5077
5355
|
}
|
|
5078
5356
|
if (dryRun) {
|
|
5079
|
-
logger.logger.log(DRY_RUN_NOT_SAVING);
|
|
5357
|
+
logger.logger.log(DRY_RUN_NOT_SAVING$1);
|
|
5080
5358
|
return;
|
|
5081
5359
|
}
|
|
5082
5360
|
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
@@ -5287,9 +5565,9 @@ const config$h = {
|
|
|
5287
5565
|
const cmdInstallCompletion = {
|
|
5288
5566
|
description: config$h.description,
|
|
5289
5567
|
hidden: config$h.hidden,
|
|
5290
|
-
run: run$
|
|
5568
|
+
run: run$H
|
|
5291
5569
|
};
|
|
5292
|
-
async function run$
|
|
5570
|
+
async function run$H(argv, importMeta, {
|
|
5293
5571
|
parentName
|
|
5294
5572
|
}) {
|
|
5295
5573
|
const cli = utils.meowOrExit({
|
|
@@ -5307,9 +5585,9 @@ async function run$G(argv, importMeta, {
|
|
|
5307
5585
|
await handleInstallCompletion(String(targetName));
|
|
5308
5586
|
}
|
|
5309
5587
|
|
|
5310
|
-
const description$
|
|
5588
|
+
const description$w = 'Install Socket CLI tab completion';
|
|
5311
5589
|
const cmdInstall = {
|
|
5312
|
-
description: description$
|
|
5590
|
+
description: description$w,
|
|
5313
5591
|
hidden: false,
|
|
5314
5592
|
async run(argv, importMeta, {
|
|
5315
5593
|
parentName
|
|
@@ -5318,7 +5596,7 @@ const cmdInstall = {
|
|
|
5318
5596
|
completion: cmdInstallCompletion
|
|
5319
5597
|
}, {
|
|
5320
5598
|
argv,
|
|
5321
|
-
description: description$
|
|
5599
|
+
description: description$w,
|
|
5322
5600
|
importMeta,
|
|
5323
5601
|
name: `${parentName} install`
|
|
5324
5602
|
});
|
|
@@ -5370,9 +5648,9 @@ const config$g = {
|
|
|
5370
5648
|
const cmdJson = {
|
|
5371
5649
|
description: config$g.description,
|
|
5372
5650
|
hidden: config$g.hidden,
|
|
5373
|
-
run: run$
|
|
5651
|
+
run: run$G
|
|
5374
5652
|
};
|
|
5375
|
-
async function run$
|
|
5653
|
+
async function run$G(argv, importMeta, {
|
|
5376
5654
|
parentName
|
|
5377
5655
|
}) {
|
|
5378
5656
|
const cli = utils.meowOrExit({
|
|
@@ -5532,21 +5810,21 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5532
5810
|
const {
|
|
5533
5811
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$D
|
|
5534
5812
|
} = constants;
|
|
5535
|
-
const CMD_NAME$
|
|
5536
|
-
const description$
|
|
5537
|
-
const hidden$
|
|
5813
|
+
const CMD_NAME$q = 'login';
|
|
5814
|
+
const description$v = 'Setup Socket CLI with an API token and defaults';
|
|
5815
|
+
const hidden$p = false;
|
|
5538
5816
|
const cmdLogin = {
|
|
5539
|
-
description: description$
|
|
5540
|
-
hidden: hidden$
|
|
5541
|
-
run: run$
|
|
5817
|
+
description: description$v,
|
|
5818
|
+
hidden: hidden$p,
|
|
5819
|
+
run: run$F
|
|
5542
5820
|
};
|
|
5543
|
-
async function run$
|
|
5821
|
+
async function run$F(argv, importMeta, {
|
|
5544
5822
|
parentName
|
|
5545
5823
|
}) {
|
|
5546
5824
|
const config = {
|
|
5547
|
-
commandName: CMD_NAME$
|
|
5548
|
-
description: description$
|
|
5549
|
-
hidden: hidden$
|
|
5825
|
+
commandName: CMD_NAME$q,
|
|
5826
|
+
description: description$v,
|
|
5827
|
+
hidden: hidden$p,
|
|
5550
5828
|
flags: {
|
|
5551
5829
|
...flags.commonFlags,
|
|
5552
5830
|
apiBaseUrl: {
|
|
@@ -5563,7 +5841,7 @@ async function run$E(argv, importMeta, {
|
|
|
5563
5841
|
$ ${command} [options]
|
|
5564
5842
|
|
|
5565
5843
|
API Token Requirements
|
|
5566
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
5844
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$q}`)}
|
|
5567
5845
|
|
|
5568
5846
|
Logs into the Socket API by prompting for an API token
|
|
5569
5847
|
|
|
@@ -5637,9 +5915,9 @@ const config$f = {
|
|
|
5637
5915
|
const cmdLogout = {
|
|
5638
5916
|
description: config$f.description,
|
|
5639
5917
|
hidden: config$f.hidden,
|
|
5640
|
-
run: run$
|
|
5918
|
+
run: run$E
|
|
5641
5919
|
};
|
|
5642
|
-
async function run$
|
|
5920
|
+
async function run$E(argv, importMeta, {
|
|
5643
5921
|
parentName
|
|
5644
5922
|
}) {
|
|
5645
5923
|
const cli = utils.meowOrExit({
|
|
@@ -5951,9 +6229,9 @@ const config$e = {
|
|
|
5951
6229
|
const cmdManifestCdxgen = {
|
|
5952
6230
|
description: config$e.description,
|
|
5953
6231
|
hidden: config$e.hidden,
|
|
5954
|
-
run: run$
|
|
6232
|
+
run: run$D
|
|
5955
6233
|
};
|
|
5956
|
-
async function run$
|
|
6234
|
+
async function run$D(argv, importMeta, {
|
|
5957
6235
|
parentName
|
|
5958
6236
|
}) {
|
|
5959
6237
|
const cli = utils.meowOrExit({
|
|
@@ -6050,9 +6328,9 @@ const config$d = {
|
|
|
6050
6328
|
const cmdManifestAuto = {
|
|
6051
6329
|
description: config$d.description,
|
|
6052
6330
|
hidden: config$d.hidden,
|
|
6053
|
-
run: run$
|
|
6331
|
+
run: run$C
|
|
6054
6332
|
};
|
|
6055
|
-
async function run$
|
|
6333
|
+
async function run$C(argv, importMeta, {
|
|
6056
6334
|
parentName
|
|
6057
6335
|
}) {
|
|
6058
6336
|
const cli = utils.meowOrExit({
|
|
@@ -6165,9 +6443,9 @@ const config$c = {
|
|
|
6165
6443
|
const cmdManifestConda = {
|
|
6166
6444
|
description: config$c.description,
|
|
6167
6445
|
hidden: config$c.hidden,
|
|
6168
|
-
run: run$
|
|
6446
|
+
run: run$B
|
|
6169
6447
|
};
|
|
6170
|
-
async function run$
|
|
6448
|
+
async function run$B(argv, importMeta, {
|
|
6171
6449
|
parentName
|
|
6172
6450
|
}) {
|
|
6173
6451
|
const cli = utils.meowOrExit({
|
|
@@ -6324,9 +6602,9 @@ const config$b = {
|
|
|
6324
6602
|
const cmdManifestGradle = {
|
|
6325
6603
|
description: config$b.description,
|
|
6326
6604
|
hidden: config$b.hidden,
|
|
6327
|
-
run: run$
|
|
6605
|
+
run: run$A
|
|
6328
6606
|
};
|
|
6329
|
-
async function run$
|
|
6607
|
+
async function run$A(argv, importMeta, {
|
|
6330
6608
|
parentName
|
|
6331
6609
|
}) {
|
|
6332
6610
|
const cli = utils.meowOrExit({
|
|
@@ -6483,9 +6761,9 @@ const config$a = {
|
|
|
6483
6761
|
const cmdManifestKotlin = {
|
|
6484
6762
|
description: config$a.description,
|
|
6485
6763
|
hidden: config$a.hidden,
|
|
6486
|
-
run: run$
|
|
6764
|
+
run: run$z
|
|
6487
6765
|
};
|
|
6488
|
-
async function run$
|
|
6766
|
+
async function run$z(argv, importMeta, {
|
|
6489
6767
|
parentName
|
|
6490
6768
|
}) {
|
|
6491
6769
|
const cli = utils.meowOrExit({
|
|
@@ -6649,9 +6927,9 @@ const config$9 = {
|
|
|
6649
6927
|
const cmdManifestScala = {
|
|
6650
6928
|
description: config$9.description,
|
|
6651
6929
|
hidden: config$9.hidden,
|
|
6652
|
-
run: run$
|
|
6930
|
+
run: run$y
|
|
6653
6931
|
};
|
|
6654
|
-
async function run$
|
|
6932
|
+
async function run$y(argv, importMeta, {
|
|
6655
6933
|
parentName
|
|
6656
6934
|
}) {
|
|
6657
6935
|
const cli = utils.meowOrExit({
|
|
@@ -7213,9 +7491,9 @@ const config$8 = {
|
|
|
7213
7491
|
const cmdManifestSetup = {
|
|
7214
7492
|
description: config$8.description,
|
|
7215
7493
|
hidden: config$8.hidden,
|
|
7216
|
-
run: run$
|
|
7494
|
+
run: run$x
|
|
7217
7495
|
};
|
|
7218
|
-
async function run$
|
|
7496
|
+
async function run$x(argv, importMeta, {
|
|
7219
7497
|
parentName
|
|
7220
7498
|
}) {
|
|
7221
7499
|
const cli = utils.meowOrExit({
|
|
@@ -7249,9 +7527,9 @@ const config$7 = {
|
|
|
7249
7527
|
const cmdManifest = {
|
|
7250
7528
|
description: config$7.description,
|
|
7251
7529
|
hidden: config$7.hidden,
|
|
7252
|
-
run: run$
|
|
7530
|
+
run: run$w
|
|
7253
7531
|
};
|
|
7254
|
-
async function run$
|
|
7532
|
+
async function run$w(argv, importMeta, {
|
|
7255
7533
|
parentName
|
|
7256
7534
|
}) {
|
|
7257
7535
|
await utils.meowWithSubcommands({
|
|
@@ -7282,21 +7560,21 @@ const require$3 = require$$5.createRequire(require('node:url').pathToFileURL(__f
|
|
|
7282
7560
|
const {
|
|
7283
7561
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$u
|
|
7284
7562
|
} = constants;
|
|
7285
|
-
const CMD_NAME$
|
|
7286
|
-
const description$
|
|
7287
|
-
const hidden$
|
|
7563
|
+
const CMD_NAME$p = 'npm';
|
|
7564
|
+
const description$u = 'Run npm with the Socket wrapper';
|
|
7565
|
+
const hidden$o = false;
|
|
7288
7566
|
const cmdNpm = {
|
|
7289
|
-
description: description$
|
|
7290
|
-
hidden: hidden$
|
|
7291
|
-
run: run$
|
|
7567
|
+
description: description$u,
|
|
7568
|
+
hidden: hidden$o,
|
|
7569
|
+
run: run$v
|
|
7292
7570
|
};
|
|
7293
|
-
async function run$
|
|
7571
|
+
async function run$v(argv, importMeta, {
|
|
7294
7572
|
parentName
|
|
7295
7573
|
}) {
|
|
7296
7574
|
const config = {
|
|
7297
|
-
commandName: CMD_NAME$
|
|
7298
|
-
description: description$
|
|
7299
|
-
hidden: hidden$
|
|
7575
|
+
commandName: CMD_NAME$p,
|
|
7576
|
+
description: description$u,
|
|
7577
|
+
hidden: hidden$o,
|
|
7300
7578
|
flags: {
|
|
7301
7579
|
...flags.commonFlags
|
|
7302
7580
|
},
|
|
@@ -7305,7 +7583,7 @@ async function run$u(argv, importMeta, {
|
|
|
7305
7583
|
$ ${command} ...
|
|
7306
7584
|
|
|
7307
7585
|
API Token Requirements
|
|
7308
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
7586
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$p}`)}
|
|
7309
7587
|
|
|
7310
7588
|
Note: Everything after "npm" is passed to the npm command.
|
|
7311
7589
|
Only the \`--dry-run\` and \`--help\` flags are caught here.
|
|
@@ -7338,21 +7616,21 @@ const require$2 = require$$5.createRequire(require('node:url').pathToFileURL(__f
|
|
|
7338
7616
|
const {
|
|
7339
7617
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$t
|
|
7340
7618
|
} = constants;
|
|
7341
|
-
const CMD_NAME$
|
|
7342
|
-
const description$
|
|
7343
|
-
const hidden$
|
|
7619
|
+
const CMD_NAME$o = 'npx';
|
|
7620
|
+
const description$t = 'Run npx with the Socket wrapper';
|
|
7621
|
+
const hidden$n = false;
|
|
7344
7622
|
const cmdNpx = {
|
|
7345
|
-
description: description$
|
|
7346
|
-
hidden: hidden$
|
|
7347
|
-
run: run$
|
|
7623
|
+
description: description$t,
|
|
7624
|
+
hidden: hidden$n,
|
|
7625
|
+
run: run$u
|
|
7348
7626
|
};
|
|
7349
|
-
async function run$
|
|
7627
|
+
async function run$u(argv, importMeta, {
|
|
7350
7628
|
parentName
|
|
7351
7629
|
}) {
|
|
7352
7630
|
const config = {
|
|
7353
|
-
commandName: CMD_NAME$
|
|
7354
|
-
description: description$
|
|
7355
|
-
hidden: hidden$
|
|
7631
|
+
commandName: CMD_NAME$o,
|
|
7632
|
+
description: description$t,
|
|
7633
|
+
hidden: hidden$n,
|
|
7356
7634
|
flags: {
|
|
7357
7635
|
...flags.commonFlags
|
|
7358
7636
|
},
|
|
@@ -7361,7 +7639,7 @@ async function run$t(argv, importMeta, {
|
|
|
7361
7639
|
$ ${command} ...
|
|
7362
7640
|
|
|
7363
7641
|
API Token Requirements
|
|
7364
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
7642
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$o}`)}
|
|
7365
7643
|
|
|
7366
7644
|
Note: Everything after "npx" is passed to the npx command.
|
|
7367
7645
|
Only the \`--dry-run\` and \`--help\` flags are caught here.
|
|
@@ -7415,9 +7693,9 @@ const config$6 = {
|
|
|
7415
7693
|
const cmdOops = {
|
|
7416
7694
|
description: config$6.description,
|
|
7417
7695
|
hidden: config$6.hidden,
|
|
7418
|
-
run: run$
|
|
7696
|
+
run: run$t
|
|
7419
7697
|
};
|
|
7420
|
-
async function run$
|
|
7698
|
+
async function run$t(argv, importMeta, {
|
|
7421
7699
|
parentName
|
|
7422
7700
|
}) {
|
|
7423
7701
|
const cli = utils.meowOrExit({
|
|
@@ -7758,7 +8036,7 @@ async function listPackages(pkgEnvDetails, options) {
|
|
|
7758
8036
|
}
|
|
7759
8037
|
}
|
|
7760
8038
|
|
|
7761
|
-
const CMD_NAME$
|
|
8039
|
+
const CMD_NAME$n = 'socket optimize';
|
|
7762
8040
|
|
|
7763
8041
|
const {
|
|
7764
8042
|
BUN,
|
|
@@ -7933,7 +8211,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7933
8211
|
npmExecPath === NPM && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
7934
8212
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
7935
8213
|
spinner?.stop();
|
|
7936
|
-
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$
|
|
8214
|
+
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$n, `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``));
|
|
7937
8215
|
spinner?.start();
|
|
7938
8216
|
}
|
|
7939
8217
|
const overridesDataObjects = [];
|
|
@@ -8164,7 +8442,7 @@ async function applyOptimization(pkgEnvDetails, {
|
|
|
8164
8442
|
const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
|
|
8165
8443
|
if (pkgJsonChanged || pkgEnvDetails.features.npmBuggyOverrides) {
|
|
8166
8444
|
const result = await updateLockfile(pkgEnvDetails, {
|
|
8167
|
-
cmdName: CMD_NAME$
|
|
8445
|
+
cmdName: CMD_NAME$n,
|
|
8168
8446
|
logger: logger.logger,
|
|
8169
8447
|
spinner
|
|
8170
8448
|
});
|
|
@@ -8226,7 +8504,7 @@ async function handleOptimize({
|
|
|
8226
8504
|
prod
|
|
8227
8505
|
}) {
|
|
8228
8506
|
const pkgEnvCResult = await utils.detectAndValidatePackageEnvironment(cwd, {
|
|
8229
|
-
cmdName: CMD_NAME$
|
|
8507
|
+
cmdName: CMD_NAME$n,
|
|
8230
8508
|
logger: logger.logger,
|
|
8231
8509
|
prod
|
|
8232
8510
|
});
|
|
@@ -8251,7 +8529,7 @@ async function handleOptimize({
|
|
|
8251
8529
|
await outputOptimizeResult({
|
|
8252
8530
|
ok: false,
|
|
8253
8531
|
message: 'Unsupported',
|
|
8254
|
-
cause: utils.cmdPrefixMessage(CMD_NAME$
|
|
8532
|
+
cause: utils.cmdPrefixMessage(CMD_NAME$n, `${agent} v${agentVersion} does not support overrides.`)
|
|
8255
8533
|
}, outputKind);
|
|
8256
8534
|
return;
|
|
8257
8535
|
}
|
|
@@ -8265,21 +8543,21 @@ async function handleOptimize({
|
|
|
8265
8543
|
const {
|
|
8266
8544
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$r
|
|
8267
8545
|
} = constants;
|
|
8268
|
-
const CMD_NAME$
|
|
8269
|
-
const description$
|
|
8270
|
-
const hidden$
|
|
8546
|
+
const CMD_NAME$m = 'optimize';
|
|
8547
|
+
const description$s = 'Optimize dependencies with @socketregistry overrides';
|
|
8548
|
+
const hidden$m = false;
|
|
8271
8549
|
const cmdOptimize = {
|
|
8272
|
-
description: description$
|
|
8273
|
-
hidden: hidden$
|
|
8274
|
-
run: run$
|
|
8550
|
+
description: description$s,
|
|
8551
|
+
hidden: hidden$m,
|
|
8552
|
+
run: run$s
|
|
8275
8553
|
};
|
|
8276
|
-
async function run$
|
|
8554
|
+
async function run$s(argv, importMeta, {
|
|
8277
8555
|
parentName
|
|
8278
8556
|
}) {
|
|
8279
8557
|
const config = {
|
|
8280
|
-
commandName: CMD_NAME$
|
|
8281
|
-
description: description$
|
|
8282
|
-
hidden: hidden$
|
|
8558
|
+
commandName: CMD_NAME$m,
|
|
8559
|
+
description: description$s,
|
|
8560
|
+
hidden: hidden$m,
|
|
8283
8561
|
flags: {
|
|
8284
8562
|
...flags.commonFlags,
|
|
8285
8563
|
pin: {
|
|
@@ -8298,7 +8576,7 @@ async function run$r(argv, importMeta, {
|
|
|
8298
8576
|
$ ${command} [options] [CWD=.]
|
|
8299
8577
|
|
|
8300
8578
|
API Token Requirements
|
|
8301
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8579
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$m}`)}
|
|
8302
8580
|
|
|
8303
8581
|
Options
|
|
8304
8582
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8444,21 +8722,21 @@ async function handleDependencies({
|
|
|
8444
8722
|
const {
|
|
8445
8723
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$q
|
|
8446
8724
|
} = constants;
|
|
8447
|
-
const CMD_NAME$
|
|
8448
|
-
const description$
|
|
8449
|
-
const hidden$
|
|
8725
|
+
const CMD_NAME$l = 'dependencies';
|
|
8726
|
+
const description$r = 'Search for any dependency that is being used in your organization';
|
|
8727
|
+
const hidden$l = false;
|
|
8450
8728
|
const cmdOrganizationDependencies = {
|
|
8451
|
-
description: description$
|
|
8452
|
-
hidden: hidden$
|
|
8453
|
-
run: run$
|
|
8729
|
+
description: description$r,
|
|
8730
|
+
hidden: hidden$l,
|
|
8731
|
+
run: run$r
|
|
8454
8732
|
};
|
|
8455
|
-
async function run$
|
|
8733
|
+
async function run$r(argv, importMeta, {
|
|
8456
8734
|
parentName
|
|
8457
8735
|
}) {
|
|
8458
8736
|
const config = {
|
|
8459
|
-
commandName: CMD_NAME$
|
|
8460
|
-
description: description$
|
|
8461
|
-
hidden: hidden$
|
|
8737
|
+
commandName: CMD_NAME$l,
|
|
8738
|
+
description: description$r,
|
|
8739
|
+
hidden: hidden$l,
|
|
8462
8740
|
flags: {
|
|
8463
8741
|
...flags.commonFlags,
|
|
8464
8742
|
limit: {
|
|
@@ -8478,7 +8756,7 @@ async function run$q(argv, importMeta, {
|
|
|
8478
8756
|
${command} [options]
|
|
8479
8757
|
|
|
8480
8758
|
API Token Requirements
|
|
8481
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8759
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$l}`)}
|
|
8482
8760
|
|
|
8483
8761
|
Options
|
|
8484
8762
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8581,21 +8859,21 @@ async function handleLicensePolicy(orgSlug, outputKind) {
|
|
|
8581
8859
|
const {
|
|
8582
8860
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$p
|
|
8583
8861
|
} = constants;
|
|
8584
|
-
const CMD_NAME$
|
|
8585
|
-
const description$
|
|
8586
|
-
const hidden$
|
|
8862
|
+
const CMD_NAME$k = 'license';
|
|
8863
|
+
const description$q = 'Retrieve the license policy of an organization';
|
|
8864
|
+
const hidden$k = false;
|
|
8587
8865
|
const cmdOrganizationPolicyLicense = {
|
|
8588
|
-
description: description$
|
|
8589
|
-
hidden: hidden$
|
|
8590
|
-
run: run$
|
|
8866
|
+
description: description$q,
|
|
8867
|
+
hidden: hidden$k,
|
|
8868
|
+
run: run$q
|
|
8591
8869
|
};
|
|
8592
|
-
async function run$
|
|
8870
|
+
async function run$q(argv, importMeta, {
|
|
8593
8871
|
parentName
|
|
8594
8872
|
}) {
|
|
8595
8873
|
const config = {
|
|
8596
|
-
commandName: CMD_NAME$
|
|
8597
|
-
description: description$
|
|
8598
|
-
hidden: hidden$
|
|
8874
|
+
commandName: CMD_NAME$k,
|
|
8875
|
+
description: description$q,
|
|
8876
|
+
hidden: hidden$k,
|
|
8599
8877
|
flags: {
|
|
8600
8878
|
...flags.commonFlags,
|
|
8601
8879
|
...flags.outputFlags,
|
|
@@ -8614,7 +8892,7 @@ async function run$p(argv, importMeta, {
|
|
|
8614
8892
|
$ ${command} [options]
|
|
8615
8893
|
|
|
8616
8894
|
API Token Requirements
|
|
8617
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8895
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$k}`)}
|
|
8618
8896
|
|
|
8619
8897
|
Options
|
|
8620
8898
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8718,21 +8996,21 @@ async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
|
8718
8996
|
const {
|
|
8719
8997
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$o
|
|
8720
8998
|
} = constants;
|
|
8721
|
-
const CMD_NAME$
|
|
8722
|
-
const description$
|
|
8723
|
-
const hidden$
|
|
8999
|
+
const CMD_NAME$j = 'security';
|
|
9000
|
+
const description$p = 'Retrieve the security policy of an organization';
|
|
9001
|
+
const hidden$j = true;
|
|
8724
9002
|
const cmdOrganizationPolicySecurity = {
|
|
8725
|
-
description: description$
|
|
8726
|
-
hidden: hidden$
|
|
8727
|
-
run: run$
|
|
9003
|
+
description: description$p,
|
|
9004
|
+
hidden: hidden$j,
|
|
9005
|
+
run: run$p
|
|
8728
9006
|
};
|
|
8729
|
-
async function run$
|
|
9007
|
+
async function run$p(argv, importMeta, {
|
|
8730
9008
|
parentName
|
|
8731
9009
|
}) {
|
|
8732
9010
|
const config = {
|
|
8733
|
-
commandName: CMD_NAME$
|
|
8734
|
-
description: description$
|
|
8735
|
-
hidden: hidden$
|
|
9011
|
+
commandName: CMD_NAME$j,
|
|
9012
|
+
description: description$p,
|
|
9013
|
+
hidden: hidden$j,
|
|
8736
9014
|
flags: {
|
|
8737
9015
|
...flags.commonFlags,
|
|
8738
9016
|
...flags.outputFlags,
|
|
@@ -8751,7 +9029,7 @@ async function run$o(argv, importMeta, {
|
|
|
8751
9029
|
$ ${command} [options]
|
|
8752
9030
|
|
|
8753
9031
|
API Token Requirements
|
|
8754
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9032
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$j}`)}
|
|
8755
9033
|
|
|
8756
9034
|
Options
|
|
8757
9035
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8856,21 +9134,21 @@ async function handleOrganizationList(outputKind = 'text') {
|
|
|
8856
9134
|
const {
|
|
8857
9135
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$n
|
|
8858
9136
|
} = constants;
|
|
8859
|
-
const CMD_NAME$
|
|
8860
|
-
const description$
|
|
8861
|
-
const hidden$
|
|
9137
|
+
const CMD_NAME$i = 'list';
|
|
9138
|
+
const description$o = 'List organizations associated with the Socket API token';
|
|
9139
|
+
const hidden$i = false;
|
|
8862
9140
|
const cmdOrganizationList = {
|
|
8863
|
-
description: description$
|
|
8864
|
-
hidden: hidden$
|
|
8865
|
-
run: run$
|
|
9141
|
+
description: description$o,
|
|
9142
|
+
hidden: hidden$i,
|
|
9143
|
+
run: run$o
|
|
8866
9144
|
};
|
|
8867
|
-
async function run$
|
|
9145
|
+
async function run$o(argv, importMeta, {
|
|
8868
9146
|
parentName
|
|
8869
9147
|
}) {
|
|
8870
9148
|
const config = {
|
|
8871
|
-
commandName: CMD_NAME$
|
|
8872
|
-
description: description$
|
|
8873
|
-
hidden: hidden$
|
|
9149
|
+
commandName: CMD_NAME$i,
|
|
9150
|
+
description: description$o,
|
|
9151
|
+
hidden: hidden$i,
|
|
8874
9152
|
flags: {
|
|
8875
9153
|
...flags.commonFlags,
|
|
8876
9154
|
...flags.outputFlags
|
|
@@ -8880,7 +9158,7 @@ async function run$n(argv, importMeta, {
|
|
|
8880
9158
|
$ ${command} [options]
|
|
8881
9159
|
|
|
8882
9160
|
API Token Requirements
|
|
8883
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9161
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$i}`)}
|
|
8884
9162
|
|
|
8885
9163
|
Options
|
|
8886
9164
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8924,9 +9202,9 @@ async function run$n(argv, importMeta, {
|
|
|
8924
9202
|
await handleOrganizationList(outputKind);
|
|
8925
9203
|
}
|
|
8926
9204
|
|
|
8927
|
-
const description$
|
|
9205
|
+
const description$n = 'Organization policy details';
|
|
8928
9206
|
const cmdOrganizationPolicy = {
|
|
8929
|
-
description: description$
|
|
9207
|
+
description: description$n,
|
|
8930
9208
|
// Hidden because it was broken all this time (nobody could be using it)
|
|
8931
9209
|
// and we're not sure if it's useful to anyone in its current state.
|
|
8932
9210
|
// Until we do, we'll hide this to keep the help tidier.
|
|
@@ -8940,7 +9218,7 @@ const cmdOrganizationPolicy = {
|
|
|
8940
9218
|
license: cmdOrganizationPolicyLicense
|
|
8941
9219
|
}, {
|
|
8942
9220
|
argv,
|
|
8943
|
-
description: description$
|
|
9221
|
+
description: description$n,
|
|
8944
9222
|
defaultSub: 'list',
|
|
8945
9223
|
// Backwards compat
|
|
8946
9224
|
importMeta,
|
|
@@ -9020,9 +9298,9 @@ const config$5 = {
|
|
|
9020
9298
|
const cmdOrganizationQuota = {
|
|
9021
9299
|
description: config$5.description,
|
|
9022
9300
|
hidden: config$5.hidden,
|
|
9023
|
-
run: run$
|
|
9301
|
+
run: run$n
|
|
9024
9302
|
};
|
|
9025
|
-
async function run$
|
|
9303
|
+
async function run$n(argv, importMeta, {
|
|
9026
9304
|
parentName
|
|
9027
9305
|
}) {
|
|
9028
9306
|
const cli = utils.meowOrExit({
|
|
@@ -9057,9 +9335,9 @@ async function run$m(argv, importMeta, {
|
|
|
9057
9335
|
await handleQuota(outputKind);
|
|
9058
9336
|
}
|
|
9059
9337
|
|
|
9060
|
-
const description$
|
|
9338
|
+
const description$m = 'Manage Socket organization account details';
|
|
9061
9339
|
const cmdOrganization = {
|
|
9062
|
-
description: description$
|
|
9340
|
+
description: description$m,
|
|
9063
9341
|
hidden: false,
|
|
9064
9342
|
async run(argv, importMeta, {
|
|
9065
9343
|
parentName
|
|
@@ -9088,7 +9366,7 @@ const cmdOrganization = {
|
|
|
9088
9366
|
}
|
|
9089
9367
|
},
|
|
9090
9368
|
argv,
|
|
9091
|
-
description: description$
|
|
9369
|
+
description: description$m,
|
|
9092
9370
|
importMeta,
|
|
9093
9371
|
name: `${parentName} organization`
|
|
9094
9372
|
});
|
|
@@ -9316,21 +9594,21 @@ function parsePackageSpecifiers(ecosystem, pkgs) {
|
|
|
9316
9594
|
const {
|
|
9317
9595
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$l
|
|
9318
9596
|
} = constants;
|
|
9319
|
-
const CMD_NAME$
|
|
9320
|
-
const description$
|
|
9321
|
-
const hidden$
|
|
9597
|
+
const CMD_NAME$h = 'score';
|
|
9598
|
+
const description$l = 'Look up score for one package which reflects all of its transitive dependencies as well';
|
|
9599
|
+
const hidden$h = false;
|
|
9322
9600
|
const cmdPackageScore = {
|
|
9323
|
-
description: description$
|
|
9324
|
-
hidden: hidden$
|
|
9325
|
-
run: run$
|
|
9601
|
+
description: description$l,
|
|
9602
|
+
hidden: hidden$h,
|
|
9603
|
+
run: run$m
|
|
9326
9604
|
};
|
|
9327
|
-
async function run$
|
|
9605
|
+
async function run$m(argv, importMeta, {
|
|
9328
9606
|
parentName
|
|
9329
9607
|
}) {
|
|
9330
9608
|
const config = {
|
|
9331
|
-
commandName: CMD_NAME$
|
|
9332
|
-
description: description$
|
|
9333
|
-
hidden: hidden$
|
|
9609
|
+
commandName: CMD_NAME$h,
|
|
9610
|
+
description: description$l,
|
|
9611
|
+
hidden: hidden$h,
|
|
9334
9612
|
flags: {
|
|
9335
9613
|
...flags.commonFlags,
|
|
9336
9614
|
...flags.outputFlags
|
|
@@ -9340,7 +9618,7 @@ async function run$l(argv, importMeta, {
|
|
|
9340
9618
|
$ ${command} [options] <<ECOSYSTEM> <NAME> | <PURL>>
|
|
9341
9619
|
|
|
9342
9620
|
API Token Requirements
|
|
9343
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9621
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$h}`)}
|
|
9344
9622
|
|
|
9345
9623
|
Options
|
|
9346
9624
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9701,28 +9979,28 @@ async function handlePurlsShallowScore({
|
|
|
9701
9979
|
const {
|
|
9702
9980
|
DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$k
|
|
9703
9981
|
} = constants;
|
|
9704
|
-
const CMD_NAME$
|
|
9705
|
-
const description$
|
|
9706
|
-
const hidden$
|
|
9982
|
+
const CMD_NAME$g = 'shallow';
|
|
9983
|
+
const description$k = 'Look up info regarding one or more packages but not their transitives';
|
|
9984
|
+
const hidden$g = false;
|
|
9707
9985
|
const cmdPackageShallow = {
|
|
9708
|
-
description: description$
|
|
9709
|
-
hidden: hidden$
|
|
9986
|
+
description: description$k,
|
|
9987
|
+
hidden: hidden$g,
|
|
9710
9988
|
alias: {
|
|
9711
9989
|
shallowScore: {
|
|
9712
|
-
description: description$
|
|
9990
|
+
description: description$k,
|
|
9713
9991
|
hidden: true,
|
|
9714
9992
|
argv: []
|
|
9715
9993
|
}
|
|
9716
9994
|
},
|
|
9717
|
-
run: run$
|
|
9995
|
+
run: run$l
|
|
9718
9996
|
};
|
|
9719
|
-
async function run$
|
|
9997
|
+
async function run$l(argv, importMeta, {
|
|
9720
9998
|
parentName
|
|
9721
9999
|
}) {
|
|
9722
10000
|
const config = {
|
|
9723
|
-
commandName: CMD_NAME$
|
|
9724
|
-
description: description$
|
|
9725
|
-
hidden: hidden$
|
|
10001
|
+
commandName: CMD_NAME$g,
|
|
10002
|
+
description: description$k,
|
|
10003
|
+
hidden: hidden$g,
|
|
9726
10004
|
flags: {
|
|
9727
10005
|
...flags.commonFlags,
|
|
9728
10006
|
...flags.outputFlags
|
|
@@ -9732,7 +10010,7 @@ async function run$k(argv, importMeta, {
|
|
|
9732
10010
|
$ ${command} [options] <<ECOSYSTEM> <PKGNAME> [<PKGNAME> ...] | <PURL> [<PURL> ...]>
|
|
9733
10011
|
|
|
9734
10012
|
API Token Requirements
|
|
9735
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
10013
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$g}`)}
|
|
9736
10014
|
|
|
9737
10015
|
Options
|
|
9738
10016
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9806,9 +10084,9 @@ async function run$k(argv, importMeta, {
|
|
|
9806
10084
|
});
|
|
9807
10085
|
}
|
|
9808
10086
|
|
|
9809
|
-
const description$
|
|
10087
|
+
const description$j = 'Look up published package details';
|
|
9810
10088
|
const cmdPackage = {
|
|
9811
|
-
description: description$
|
|
10089
|
+
description: description$j,
|
|
9812
10090
|
hidden: false,
|
|
9813
10091
|
async run(argv, importMeta, {
|
|
9814
10092
|
parentName
|
|
@@ -9819,19 +10097,166 @@ const cmdPackage = {
|
|
|
9819
10097
|
}, {
|
|
9820
10098
|
aliases: {
|
|
9821
10099
|
deep: {
|
|
9822
|
-
description: description$
|
|
10100
|
+
description: description$j,
|
|
9823
10101
|
hidden: true,
|
|
9824
10102
|
argv: ['score']
|
|
9825
10103
|
}
|
|
9826
10104
|
},
|
|
9827
10105
|
argv,
|
|
9828
|
-
description: description$
|
|
10106
|
+
description: description$j,
|
|
9829
10107
|
importMeta,
|
|
9830
10108
|
name: `${parentName} package`
|
|
9831
10109
|
});
|
|
9832
10110
|
}
|
|
9833
10111
|
};
|
|
9834
10112
|
|
|
10113
|
+
async function outputPatchResult(result, outputKind) {
|
|
10114
|
+
if (!result.ok) {
|
|
10115
|
+
process.exitCode = result.code ?? 1;
|
|
10116
|
+
}
|
|
10117
|
+
if (outputKind === 'json') {
|
|
10118
|
+
logger.logger.log(utils.serializeResultJson(result));
|
|
10119
|
+
return;
|
|
10120
|
+
}
|
|
10121
|
+
if (!result.ok) {
|
|
10122
|
+
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
10123
|
+
return;
|
|
10124
|
+
}
|
|
10125
|
+
const {
|
|
10126
|
+
patchedPackages
|
|
10127
|
+
} = result.data;
|
|
10128
|
+
if (patchedPackages.length > 0) {
|
|
10129
|
+
logger.logger.success(`Successfully processed patches for ${patchedPackages.length} package(s):`);
|
|
10130
|
+
for (const pkg of patchedPackages) {
|
|
10131
|
+
logger.logger.success(pkg);
|
|
10132
|
+
}
|
|
10133
|
+
} else {
|
|
10134
|
+
logger.logger.info('No packages found requiring patches');
|
|
10135
|
+
}
|
|
10136
|
+
logger.logger.log('');
|
|
10137
|
+
logger.logger.success('Patch command completed!');
|
|
10138
|
+
}
|
|
10139
|
+
|
|
10140
|
+
async function handlePatch({
|
|
10141
|
+
outputKind,
|
|
10142
|
+
packages,
|
|
10143
|
+
spinner
|
|
10144
|
+
}) {
|
|
10145
|
+
spinner.start('Analyzing dependencies for security patches...');
|
|
10146
|
+
try {
|
|
10147
|
+
// TODO: Implement actual patch logic
|
|
10148
|
+
// This is a stub implementation
|
|
10149
|
+
const result = {
|
|
10150
|
+
ok: true,
|
|
10151
|
+
data: {
|
|
10152
|
+
patchedPackages: packages.length > 0 ? packages : ['example-package']
|
|
10153
|
+
}
|
|
10154
|
+
};
|
|
10155
|
+
spinner.stop();
|
|
10156
|
+
logger.logger.log('');
|
|
10157
|
+
if (packages.length > 0) {
|
|
10158
|
+
logger.logger.info(`Checking patches for: ${packages.join(', ')}`);
|
|
10159
|
+
} else {
|
|
10160
|
+
logger.logger.info('Scanning all dependencies for available patches');
|
|
10161
|
+
}
|
|
10162
|
+
logger.logger.log('');
|
|
10163
|
+
await outputPatchResult(result, outputKind);
|
|
10164
|
+
} catch (e) {
|
|
10165
|
+
spinner.stop();
|
|
10166
|
+
const result = {
|
|
10167
|
+
ok: false,
|
|
10168
|
+
code: 1,
|
|
10169
|
+
message: 'Failed to apply patches',
|
|
10170
|
+
cause: e?.message || 'Unknown error'
|
|
10171
|
+
};
|
|
10172
|
+
await outputPatchResult(result, outputKind);
|
|
10173
|
+
}
|
|
10174
|
+
}
|
|
10175
|
+
|
|
10176
|
+
const {
|
|
10177
|
+
DRY_RUN_NOT_SAVING
|
|
10178
|
+
} = constants;
|
|
10179
|
+
const CMD_NAME$f = 'patch';
|
|
10180
|
+
const description$i = 'Apply CVE patches to dependencies';
|
|
10181
|
+
const hidden$f = true;
|
|
10182
|
+
const cmdPatch = {
|
|
10183
|
+
description: description$i,
|
|
10184
|
+
hidden: hidden$f,
|
|
10185
|
+
run: run$k
|
|
10186
|
+
};
|
|
10187
|
+
async function run$k(argv, importMeta, {
|
|
10188
|
+
parentName
|
|
10189
|
+
}) {
|
|
10190
|
+
const config = {
|
|
10191
|
+
commandName: CMD_NAME$f,
|
|
10192
|
+
description: description$i,
|
|
10193
|
+
hidden: hidden$f,
|
|
10194
|
+
flags: {
|
|
10195
|
+
...flags.commonFlags,
|
|
10196
|
+
...flags.outputFlags,
|
|
10197
|
+
package: {
|
|
10198
|
+
type: 'string',
|
|
10199
|
+
default: [],
|
|
10200
|
+
description: 'Specify packages to patch, as either a comma separated value or as multiple flags',
|
|
10201
|
+
isMultiple: true,
|
|
10202
|
+
shortFlag: 'p'
|
|
10203
|
+
}
|
|
10204
|
+
},
|
|
10205
|
+
help: (command, config) => `
|
|
10206
|
+
Usage
|
|
10207
|
+
$ ${command} [options] [CWD=.]
|
|
10208
|
+
|
|
10209
|
+
API Token Requirements
|
|
10210
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$f}`)}
|
|
10211
|
+
|
|
10212
|
+
Options
|
|
10213
|
+
${utils.getFlagListOutput(config.flags)}
|
|
10214
|
+
|
|
10215
|
+
Examples
|
|
10216
|
+
$ ${command}
|
|
10217
|
+
$ ${command} --package lodash
|
|
10218
|
+
$ ${command} ./proj/tree --package lodash,react
|
|
10219
|
+
`
|
|
10220
|
+
};
|
|
10221
|
+
const cli = utils.meowOrExit({
|
|
10222
|
+
allowUnknownFlags: false,
|
|
10223
|
+
argv,
|
|
10224
|
+
config,
|
|
10225
|
+
importMeta,
|
|
10226
|
+
parentName
|
|
10227
|
+
});
|
|
10228
|
+
const dryRun = !!cli.flags['dryRun'];
|
|
10229
|
+
const outputKind = utils.getOutputKind(cli.flags['json'], cli.flags['markdown']);
|
|
10230
|
+
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
10231
|
+
nook: true,
|
|
10232
|
+
test: !cli.flags['json'] || !cli.flags['markdown'],
|
|
10233
|
+
message: 'The json and markdown flags cannot be both set, pick one',
|
|
10234
|
+
fail: 'omit one'
|
|
10235
|
+
});
|
|
10236
|
+
if (!wasValidInput) {
|
|
10237
|
+
return;
|
|
10238
|
+
}
|
|
10239
|
+
if (dryRun) {
|
|
10240
|
+
logger.logger.log(DRY_RUN_NOT_SAVING);
|
|
10241
|
+
return;
|
|
10242
|
+
}
|
|
10243
|
+
let [cwd = '.'] = cli.input;
|
|
10244
|
+
// Note: path.resolve vs .join:
|
|
10245
|
+
// If given path is absolute then cwd should not affect it.
|
|
10246
|
+
cwd = path.resolve(process.cwd(), cwd);
|
|
10247
|
+
|
|
10248
|
+
// Lazily access constants.spinner.
|
|
10249
|
+
const {
|
|
10250
|
+
spinner
|
|
10251
|
+
} = constants;
|
|
10252
|
+
const packages = Array.isArray(cli.flags['package']) ? cli.flags['package'].flatMap(p => String(p).split(',')) : String(cli.flags['package'] || '').split(',').filter(Boolean);
|
|
10253
|
+
await handlePatch({
|
|
10254
|
+
outputKind,
|
|
10255
|
+
packages,
|
|
10256
|
+
spinner
|
|
10257
|
+
});
|
|
10258
|
+
}
|
|
10259
|
+
|
|
9835
10260
|
async function runRawNpm(argv) {
|
|
9836
10261
|
const spawnPromise = spawn.spawn(utils.getNpmBinPath(), argv, {
|
|
9837
10262
|
// Lazily access constants.WIN32.
|
|
@@ -12093,7 +12518,7 @@ async function testAndDownloadManifestFile({
|
|
|
12093
12518
|
const supportedFilesCResult = await fetchSupportedScanFileNames();
|
|
12094
12519
|
const supportedFiles = supportedFilesCResult.ok ? supportedFilesCResult.data : undefined;
|
|
12095
12520
|
if (!supportedFiles || !utils.isReportSupportedFile(file, supportedFiles)) {
|
|
12096
|
-
require$$8.debugFn('notice', '
|
|
12521
|
+
require$$8.debugFn('notice', 'skip: not a known pattern');
|
|
12097
12522
|
// Not an error.
|
|
12098
12523
|
return {
|
|
12099
12524
|
ok: true,
|
|
@@ -14934,6 +15359,7 @@ const rootCommands = {
|
|
|
14934
15359
|
optimize: cmdOptimize,
|
|
14935
15360
|
organization: cmdOrganization,
|
|
14936
15361
|
package: cmdPackage,
|
|
15362
|
+
patch: cmdPatch,
|
|
14937
15363
|
'raw-npm': cmdRawNpm,
|
|
14938
15364
|
'raw-npx': cmdRawNpx,
|
|
14939
15365
|
repository: cmdRepository,
|
|
@@ -15103,5 +15529,5 @@ void (async () => {
|
|
|
15103
15529
|
await utils.captureException(e);
|
|
15104
15530
|
}
|
|
15105
15531
|
})();
|
|
15106
|
-
//# debugId=
|
|
15532
|
+
//# debugId=dc11ece4-8083-4322-9e08-9883c0bc7831
|
|
15107
15533
|
//# sourceMappingURL=cli.js.map
|