@socketsecurity/cli-with-sentry 1.1.50 → 1.1.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/cli.js +96 -509
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +6 -4
- package/dist/constants.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-reach.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts +1 -0
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/commands/scan/reachability-flags.d.mts.map +1 -1
- package/dist/types/commands.d.mts +1 -1
- package/dist/types/constants.d.mts +1 -0
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts +6 -0
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/editable-json.d.mts +63 -0
- package/dist/types/utils/editable-json.d.mts.map +1 -0
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/utils.js +482 -50
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +13495 -3663
- package/package.json +3 -2
- package/dist/types/commands/patch/handle-patch.d.mts +0 -12
- package/dist/types/commands/patch/handle-patch.d.mts.map +0 -1
- package/dist/types/commands/patch/manifest-schema.d.mts +0 -34
- package/dist/types/commands/patch/manifest-schema.d.mts.map +0 -1
- package/dist/types/commands/patch/output-patch-result.d.mts +0 -5
- package/dist/types/commands/patch/output-patch-result.d.mts.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,6 @@ var registry = require('../external/@socketsecurity/registry');
|
|
|
25
25
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
26
26
|
var require$$12 = require('../external/@socketsecurity/registry/lib/promises');
|
|
27
27
|
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
28
|
-
var require$$0$1 = require('node:crypto');
|
|
29
28
|
var require$$1 = require('node:util');
|
|
30
29
|
var promises = require('node:stream/promises');
|
|
31
30
|
|
|
@@ -325,7 +324,7 @@ async function handleAnalytics({
|
|
|
325
324
|
});
|
|
326
325
|
}
|
|
327
326
|
|
|
328
|
-
const CMD_NAME$
|
|
327
|
+
const CMD_NAME$x = 'analytics';
|
|
329
328
|
const description$F = 'Look up analytics data';
|
|
330
329
|
const hidden$x = false;
|
|
331
330
|
const cmdAnalytics = {
|
|
@@ -337,7 +336,7 @@ async function run$S(argv, importMeta, {
|
|
|
337
336
|
parentName
|
|
338
337
|
}) {
|
|
339
338
|
const config = {
|
|
340
|
-
commandName: CMD_NAME$
|
|
339
|
+
commandName: CMD_NAME$x,
|
|
341
340
|
description: description$F,
|
|
342
341
|
hidden: hidden$x,
|
|
343
342
|
flags: {
|
|
@@ -356,7 +355,7 @@ async function run$S(argv, importMeta, {
|
|
|
356
355
|
$ ${command} [options] [ "org" | "repo" <reponame>] [TIME]
|
|
357
356
|
|
|
358
357
|
API Token Requirements
|
|
359
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
358
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$x}`)}
|
|
360
359
|
|
|
361
360
|
The scope is either org or repo level, defaults to org.
|
|
362
361
|
|
|
@@ -748,7 +747,7 @@ async function handleAuditLog({
|
|
|
748
747
|
});
|
|
749
748
|
}
|
|
750
749
|
|
|
751
|
-
const CMD_NAME$
|
|
750
|
+
const CMD_NAME$w = 'audit-log';
|
|
752
751
|
const description$E = 'Look up the audit log for an organization';
|
|
753
752
|
const hidden$w = false;
|
|
754
753
|
const cmdAuditLog = {
|
|
@@ -760,7 +759,7 @@ async function run$R(argv, importMeta, {
|
|
|
760
759
|
parentName
|
|
761
760
|
}) {
|
|
762
761
|
const config = {
|
|
763
|
-
commandName: CMD_NAME$
|
|
762
|
+
commandName: CMD_NAME$w,
|
|
764
763
|
description: description$E,
|
|
765
764
|
hidden: hidden$w,
|
|
766
765
|
flags: {
|
|
@@ -790,7 +789,7 @@ async function run$R(argv, importMeta, {
|
|
|
790
789
|
$ ${command} [options] [FILTER]
|
|
791
790
|
|
|
792
791
|
API Token Requirements
|
|
793
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
792
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$w}`)}
|
|
794
793
|
|
|
795
794
|
This feature requires an Enterprise Plan. To learn more about getting access
|
|
796
795
|
to this feature and many more, please visit the ${utils.webLink(`${constants.default.SOCKET_WEBSITE_URL}/pricing`, 'Socket pricing page')}.
|
|
@@ -1647,7 +1646,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1647
1646
|
// Build Coana arguments.
|
|
1648
1647
|
const coanaArgs = ['run', analysisTarget, '--output-dir', path.dirname(outputFilePath), '--socket-mode', outputFilePath, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachConcurrency ? ['--concurrency', `${reachabilityOptions.reachConcurrency}`] : []), ...(reachabilityOptions.reachDebug ? ['--debug'] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(reachabilityOptions.reachDisableAnalysisSplitting ? ['--disable-analysis-splitting'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1649
1648
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1650
|
-
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : []), ...(reachabilityOptions.reachUseOnlyPregeneratedSboms ? ['--use-only-pregenerated-sboms'] : [])];
|
|
1649
|
+
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(reachabilityOptions.reachLazyMode ? ['--lazy-mode'] : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : []), ...(reachabilityOptions.reachUseOnlyPregeneratedSboms ? ['--use-only-pregenerated-sboms'] : [])];
|
|
1651
1650
|
|
|
1652
1651
|
// Build environment variables.
|
|
1653
1652
|
const coanaEnv = {};
|
|
@@ -2423,6 +2422,7 @@ async function handleCi(autoManifest) {
|
|
|
2423
2422
|
reachDisableAnalytics: false,
|
|
2424
2423
|
reachEcosystems: [],
|
|
2425
2424
|
reachExcludePaths: [],
|
|
2425
|
+
reachLazyMode: false,
|
|
2426
2426
|
reachSkipCache: false,
|
|
2427
2427
|
reachUseOnlyPregeneratedSboms: false,
|
|
2428
2428
|
reachVersion: undefined,
|
|
@@ -2720,7 +2720,7 @@ async function handleConfigAuto({
|
|
|
2720
2720
|
await outputConfigAuto(key, result, outputKind);
|
|
2721
2721
|
}
|
|
2722
2722
|
|
|
2723
|
-
const CMD_NAME$
|
|
2723
|
+
const CMD_NAME$v = 'auto';
|
|
2724
2724
|
const description$D = 'Automatically discover and set the correct value config item';
|
|
2725
2725
|
const hidden$v = false;
|
|
2726
2726
|
const cmdConfigAuto = {
|
|
@@ -2732,7 +2732,7 @@ async function run$P(argv, importMeta, {
|
|
|
2732
2732
|
parentName
|
|
2733
2733
|
}) {
|
|
2734
2734
|
const config = {
|
|
2735
|
-
commandName: CMD_NAME$
|
|
2735
|
+
commandName: CMD_NAME$v,
|
|
2736
2736
|
description: description$D,
|
|
2737
2737
|
hidden: hidden$v,
|
|
2738
2738
|
flags: {
|
|
@@ -3086,7 +3086,7 @@ async function handleConfigSet({
|
|
|
3086
3086
|
await outputConfigSet(result, outputKind);
|
|
3087
3087
|
}
|
|
3088
3088
|
|
|
3089
|
-
const CMD_NAME$
|
|
3089
|
+
const CMD_NAME$u = 'set';
|
|
3090
3090
|
const description$C = 'Update the value of a local CLI config item';
|
|
3091
3091
|
const hidden$u = false;
|
|
3092
3092
|
const cmdConfigSet = {
|
|
@@ -3098,7 +3098,7 @@ async function run$M(argv, importMeta, {
|
|
|
3098
3098
|
parentName
|
|
3099
3099
|
}) {
|
|
3100
3100
|
const config = {
|
|
3101
|
-
commandName: CMD_NAME$
|
|
3101
|
+
commandName: CMD_NAME$u,
|
|
3102
3102
|
description: description$C,
|
|
3103
3103
|
hidden: hidden$u,
|
|
3104
3104
|
flags: {
|
|
@@ -3213,7 +3213,7 @@ async function handleConfigUnset({
|
|
|
3213
3213
|
await outputConfigUnset(updateResult, outputKind);
|
|
3214
3214
|
}
|
|
3215
3215
|
|
|
3216
|
-
const CMD_NAME$
|
|
3216
|
+
const CMD_NAME$t = 'unset';
|
|
3217
3217
|
const description$B = 'Clear the value of a local CLI config item';
|
|
3218
3218
|
const hidden$t = false;
|
|
3219
3219
|
const cmdConfigUnset = {
|
|
@@ -3225,7 +3225,7 @@ async function run$L(argv, importMeta, {
|
|
|
3225
3225
|
parentName
|
|
3226
3226
|
}) {
|
|
3227
3227
|
const config = {
|
|
3228
|
-
commandName: CMD_NAME$
|
|
3228
|
+
commandName: CMD_NAME$t,
|
|
3229
3229
|
description: description$B,
|
|
3230
3230
|
hidden: hidden$t,
|
|
3231
3231
|
flags: {
|
|
@@ -4281,7 +4281,7 @@ async function handleFix({
|
|
|
4281
4281
|
}), outputKind);
|
|
4282
4282
|
}
|
|
4283
4283
|
|
|
4284
|
-
const CMD_NAME$
|
|
4284
|
+
const CMD_NAME$s = 'fix';
|
|
4285
4285
|
const DEFAULT_LIMIT = 10;
|
|
4286
4286
|
const description$z = 'Fix CVEs in dependencies';
|
|
4287
4287
|
const hidden$s = false;
|
|
@@ -4440,7 +4440,7 @@ async function run$K(argv, importMeta, {
|
|
|
4440
4440
|
parentName
|
|
4441
4441
|
}) {
|
|
4442
4442
|
const config = {
|
|
4443
|
-
commandName: CMD_NAME$
|
|
4443
|
+
commandName: CMD_NAME$s,
|
|
4444
4444
|
description: description$z,
|
|
4445
4445
|
hidden: hidden$s,
|
|
4446
4446
|
flags: {
|
|
@@ -4454,7 +4454,7 @@ async function run$K(argv, importMeta, {
|
|
|
4454
4454
|
$ ${command} [options] [CWD=.]
|
|
4455
4455
|
|
|
4456
4456
|
API Token Requirements
|
|
4457
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
4457
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$s}`)}
|
|
4458
4458
|
|
|
4459
4459
|
Options
|
|
4460
4460
|
${utils.getFlagListOutput({
|
|
@@ -4995,7 +4995,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
4995
4995
|
}
|
|
4996
4996
|
}
|
|
4997
4997
|
|
|
4998
|
-
const CMD_NAME$
|
|
4998
|
+
const CMD_NAME$r = 'login';
|
|
4999
4999
|
const description$x = 'Setup Socket CLI with an API token and defaults';
|
|
5000
5000
|
const hidden$r = false;
|
|
5001
5001
|
const cmdLogin = {
|
|
@@ -5007,7 +5007,7 @@ async function run$H(argv, importMeta, {
|
|
|
5007
5007
|
parentName
|
|
5008
5008
|
}) {
|
|
5009
5009
|
const config = {
|
|
5010
|
-
commandName: CMD_NAME$
|
|
5010
|
+
commandName: CMD_NAME$r,
|
|
5011
5011
|
description: description$x,
|
|
5012
5012
|
hidden: hidden$r,
|
|
5013
5013
|
flags: {
|
|
@@ -5028,7 +5028,7 @@ async function run$H(argv, importMeta, {
|
|
|
5028
5028
|
$ ${command} [options]
|
|
5029
5029
|
|
|
5030
5030
|
API Token Requirements
|
|
5031
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
5031
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$r}`)}
|
|
5032
5032
|
|
|
5033
5033
|
Logs into the Socket API by prompting for an API token
|
|
5034
5034
|
|
|
@@ -6770,7 +6770,7 @@ async function run$y(argv, importMeta, {
|
|
|
6770
6770
|
}
|
|
6771
6771
|
|
|
6772
6772
|
const require$5 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
6773
|
-
const CMD_NAME$
|
|
6773
|
+
const CMD_NAME$q = constants.NPM;
|
|
6774
6774
|
const description$w = 'Wraps npm with Socket security scanning';
|
|
6775
6775
|
const hidden$q = false;
|
|
6776
6776
|
const cmdNpm = {
|
|
@@ -6786,7 +6786,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6786
6786
|
...context
|
|
6787
6787
|
};
|
|
6788
6788
|
const config = {
|
|
6789
|
-
commandName: CMD_NAME$
|
|
6789
|
+
commandName: CMD_NAME$q,
|
|
6790
6790
|
description: description$w,
|
|
6791
6791
|
hidden: hidden$q,
|
|
6792
6792
|
flags: {
|
|
@@ -6797,7 +6797,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6797
6797
|
$ ${command} ...
|
|
6798
6798
|
|
|
6799
6799
|
API Token Requirements
|
|
6800
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
6800
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$q}`)}
|
|
6801
6801
|
|
|
6802
6802
|
Note: Everything after "${constants.NPM}" is passed to the ${constants.NPM} command.
|
|
6803
6803
|
Only the \`${constants.FLAG_DRY_RUN}\` and \`${constants.FLAG_HELP}\` flags are caught here.
|
|
@@ -6856,7 +6856,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6856
6856
|
}
|
|
6857
6857
|
|
|
6858
6858
|
const require$4 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
6859
|
-
const CMD_NAME$
|
|
6859
|
+
const CMD_NAME$p = constants.NPX;
|
|
6860
6860
|
const description$v = 'Wraps npx with Socket security scanning';
|
|
6861
6861
|
const hidden$p = false;
|
|
6862
6862
|
const cmdNpx = {
|
|
@@ -6868,7 +6868,7 @@ async function run$w(argv, importMeta, {
|
|
|
6868
6868
|
parentName
|
|
6869
6869
|
}) {
|
|
6870
6870
|
const config = {
|
|
6871
|
-
commandName: CMD_NAME$
|
|
6871
|
+
commandName: CMD_NAME$p,
|
|
6872
6872
|
description: description$v,
|
|
6873
6873
|
hidden: hidden$p,
|
|
6874
6874
|
flags: {
|
|
@@ -6879,7 +6879,7 @@ async function run$w(argv, importMeta, {
|
|
|
6879
6879
|
$ ${command} ...
|
|
6880
6880
|
|
|
6881
6881
|
API Token Requirements
|
|
6882
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
6882
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$p}`)}
|
|
6883
6883
|
|
|
6884
6884
|
Note: Everything after "${constants.NPX}" is passed to the ${constants.NPX} command.
|
|
6885
6885
|
Only the \`${constants.FLAG_DRY_RUN}\` and \`${constants.FLAG_HELP}\` flags are caught here.
|
|
@@ -7390,7 +7390,7 @@ async function listPackages(pkgEnvDetails, options) {
|
|
|
7390
7390
|
}
|
|
7391
7391
|
}
|
|
7392
7392
|
|
|
7393
|
-
const CMD_NAME$
|
|
7393
|
+
const CMD_NAME$o = 'socket optimize';
|
|
7394
7394
|
|
|
7395
7395
|
const {
|
|
7396
7396
|
BUN,
|
|
@@ -7562,7 +7562,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7562
7562
|
npmExecPath === constants.NPM && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
7563
7563
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
7564
7564
|
spinner?.stop();
|
|
7565
|
-
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$
|
|
7565
|
+
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$o, `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``));
|
|
7566
7566
|
spinner?.start();
|
|
7567
7567
|
}
|
|
7568
7568
|
const overridesDataObjects = [];
|
|
@@ -7790,7 +7790,7 @@ async function applyOptimization(pkgEnvDetails, {
|
|
|
7790
7790
|
const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
|
|
7791
7791
|
if (pkgJsonChanged || pkgEnvDetails.features.npmBuggyOverrides) {
|
|
7792
7792
|
const result = await updateLockfile(pkgEnvDetails, {
|
|
7793
|
-
cmdName: CMD_NAME$
|
|
7793
|
+
cmdName: CMD_NAME$o,
|
|
7794
7794
|
logger: logger.logger,
|
|
7795
7795
|
spinner
|
|
7796
7796
|
});
|
|
@@ -7859,7 +7859,7 @@ async function handleOptimize({
|
|
|
7859
7859
|
prod
|
|
7860
7860
|
});
|
|
7861
7861
|
const pkgEnvCResult = await utils.detectAndValidatePackageEnvironment(cwd, {
|
|
7862
|
-
cmdName: CMD_NAME$
|
|
7862
|
+
cmdName: CMD_NAME$o,
|
|
7863
7863
|
logger: logger.logger,
|
|
7864
7864
|
prod
|
|
7865
7865
|
});
|
|
@@ -7897,7 +7897,7 @@ async function handleOptimize({
|
|
|
7897
7897
|
await outputOptimizeResult({
|
|
7898
7898
|
ok: false,
|
|
7899
7899
|
message: 'Unsupported',
|
|
7900
|
-
cause: utils.cmdPrefixMessage(CMD_NAME$
|
|
7900
|
+
cause: utils.cmdPrefixMessage(CMD_NAME$o, `${agent} v${agentVersion} does not support overrides.`)
|
|
7901
7901
|
}, outputKind);
|
|
7902
7902
|
return;
|
|
7903
7903
|
}
|
|
@@ -7917,7 +7917,7 @@ async function handleOptimize({
|
|
|
7917
7917
|
await outputOptimizeResult(optimizationResult, outputKind);
|
|
7918
7918
|
}
|
|
7919
7919
|
|
|
7920
|
-
const CMD_NAME$
|
|
7920
|
+
const CMD_NAME$n = 'optimize';
|
|
7921
7921
|
const description$u = 'Optimize dependencies with @socketregistry overrides';
|
|
7922
7922
|
const hidden$o = false;
|
|
7923
7923
|
const cmdOptimize = {
|
|
@@ -7929,7 +7929,7 @@ async function run$u(argv, importMeta, {
|
|
|
7929
7929
|
parentName
|
|
7930
7930
|
}) {
|
|
7931
7931
|
const config = {
|
|
7932
|
-
commandName: CMD_NAME$
|
|
7932
|
+
commandName: CMD_NAME$n,
|
|
7933
7933
|
description: description$u,
|
|
7934
7934
|
hidden: hidden$o,
|
|
7935
7935
|
flags: {
|
|
@@ -7950,7 +7950,7 @@ async function run$u(argv, importMeta, {
|
|
|
7950
7950
|
$ ${command} [options] [CWD=.]
|
|
7951
7951
|
|
|
7952
7952
|
API Token Requirements
|
|
7953
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
7953
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$n}`)}
|
|
7954
7954
|
|
|
7955
7955
|
Options
|
|
7956
7956
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8103,7 +8103,7 @@ async function handleDependencies({
|
|
|
8103
8103
|
});
|
|
8104
8104
|
}
|
|
8105
8105
|
|
|
8106
|
-
const CMD_NAME$
|
|
8106
|
+
const CMD_NAME$m = 'dependencies';
|
|
8107
8107
|
const description$t = 'Search for any dependency that is being used in your organization';
|
|
8108
8108
|
const hidden$n = false;
|
|
8109
8109
|
const cmdOrganizationDependencies = {
|
|
@@ -8115,7 +8115,7 @@ async function run$t(argv, importMeta, {
|
|
|
8115
8115
|
parentName
|
|
8116
8116
|
}) {
|
|
8117
8117
|
const config = {
|
|
8118
|
-
commandName: CMD_NAME$
|
|
8118
|
+
commandName: CMD_NAME$m,
|
|
8119
8119
|
description: description$t,
|
|
8120
8120
|
hidden: hidden$n,
|
|
8121
8121
|
flags: {
|
|
@@ -8137,7 +8137,7 @@ async function run$t(argv, importMeta, {
|
|
|
8137
8137
|
${command} [options]
|
|
8138
8138
|
|
|
8139
8139
|
API Token Requirements
|
|
8140
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8140
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$m}`)}
|
|
8141
8141
|
|
|
8142
8142
|
Options
|
|
8143
8143
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8237,7 +8237,7 @@ async function handleLicensePolicy(orgSlug, outputKind) {
|
|
|
8237
8237
|
await outputLicensePolicy(data, outputKind);
|
|
8238
8238
|
}
|
|
8239
8239
|
|
|
8240
|
-
const CMD_NAME$
|
|
8240
|
+
const CMD_NAME$l = 'license';
|
|
8241
8241
|
const description$s = 'Retrieve the license policy of an organization';
|
|
8242
8242
|
const hidden$m = false;
|
|
8243
8243
|
const cmdOrganizationPolicyLicense = {
|
|
@@ -8249,7 +8249,7 @@ async function run$s(argv, importMeta, {
|
|
|
8249
8249
|
parentName
|
|
8250
8250
|
}) {
|
|
8251
8251
|
const config = {
|
|
8252
|
-
commandName: CMD_NAME$
|
|
8252
|
+
commandName: CMD_NAME$l,
|
|
8253
8253
|
description: description$s,
|
|
8254
8254
|
hidden: hidden$m,
|
|
8255
8255
|
flags: {
|
|
@@ -8270,7 +8270,7 @@ async function run$s(argv, importMeta, {
|
|
|
8270
8270
|
$ ${command} [options]
|
|
8271
8271
|
|
|
8272
8272
|
API Token Requirements
|
|
8273
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8273
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$l}`)}
|
|
8274
8274
|
|
|
8275
8275
|
Options
|
|
8276
8276
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8373,7 +8373,7 @@ async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
|
8373
8373
|
await outputSecurityPolicy(data, outputKind);
|
|
8374
8374
|
}
|
|
8375
8375
|
|
|
8376
|
-
const CMD_NAME$
|
|
8376
|
+
const CMD_NAME$k = 'security';
|
|
8377
8377
|
const description$r = 'Retrieve the security policy of an organization';
|
|
8378
8378
|
const hidden$l = true;
|
|
8379
8379
|
const cmdOrganizationPolicySecurity = {
|
|
@@ -8385,7 +8385,7 @@ async function run$r(argv, importMeta, {
|
|
|
8385
8385
|
parentName
|
|
8386
8386
|
}) {
|
|
8387
8387
|
const config = {
|
|
8388
|
-
commandName: CMD_NAME$
|
|
8388
|
+
commandName: CMD_NAME$k,
|
|
8389
8389
|
description: description$r,
|
|
8390
8390
|
hidden: hidden$l,
|
|
8391
8391
|
flags: {
|
|
@@ -8406,7 +8406,7 @@ async function run$r(argv, importMeta, {
|
|
|
8406
8406
|
$ ${command} [options]
|
|
8407
8407
|
|
|
8408
8408
|
API Token Requirements
|
|
8409
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8409
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$k}`)}
|
|
8410
8410
|
|
|
8411
8411
|
Options
|
|
8412
8412
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8518,7 +8518,7 @@ async function handleOrganizationList(outputKind = 'text') {
|
|
|
8518
8518
|
await outputOrganizationList(data, outputKind);
|
|
8519
8519
|
}
|
|
8520
8520
|
|
|
8521
|
-
const CMD_NAME$
|
|
8521
|
+
const CMD_NAME$j = 'list';
|
|
8522
8522
|
const description$q = 'List organizations associated with the Socket API token';
|
|
8523
8523
|
const hidden$k = false;
|
|
8524
8524
|
const cmdOrganizationList = {
|
|
@@ -8530,7 +8530,7 @@ async function run$q(argv, importMeta, {
|
|
|
8530
8530
|
parentName
|
|
8531
8531
|
}) {
|
|
8532
8532
|
const config = {
|
|
8533
|
-
commandName: CMD_NAME$
|
|
8533
|
+
commandName: CMD_NAME$j,
|
|
8534
8534
|
description: description$q,
|
|
8535
8535
|
hidden: hidden$k,
|
|
8536
8536
|
flags: {
|
|
@@ -8542,7 +8542,7 @@ async function run$q(argv, importMeta, {
|
|
|
8542
8542
|
$ ${command} [options]
|
|
8543
8543
|
|
|
8544
8544
|
API Token Requirements
|
|
8545
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8545
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$j}`)}
|
|
8546
8546
|
|
|
8547
8547
|
Options
|
|
8548
8548
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8984,7 +8984,7 @@ function parsePackageSpecifiers(ecosystem, pkgs) {
|
|
|
8984
8984
|
};
|
|
8985
8985
|
}
|
|
8986
8986
|
|
|
8987
|
-
const CMD_NAME$
|
|
8987
|
+
const CMD_NAME$i = 'score';
|
|
8988
8988
|
const description$n = 'Look up score for one package which reflects all of its transitive dependencies as well';
|
|
8989
8989
|
const hidden$j = false;
|
|
8990
8990
|
const cmdPackageScore = {
|
|
@@ -8996,7 +8996,7 @@ async function run$o(argv, importMeta, {
|
|
|
8996
8996
|
parentName
|
|
8997
8997
|
}) {
|
|
8998
8998
|
const config = {
|
|
8999
|
-
commandName: CMD_NAME$
|
|
8999
|
+
commandName: CMD_NAME$i,
|
|
9000
9000
|
description: description$n,
|
|
9001
9001
|
hidden: hidden$j,
|
|
9002
9002
|
flags: {
|
|
@@ -9008,7 +9008,7 @@ async function run$o(argv, importMeta, {
|
|
|
9008
9008
|
$ ${command} [options] <<ECOSYSTEM> <NAME> | <PURL>>
|
|
9009
9009
|
|
|
9010
9010
|
API Token Requirements
|
|
9011
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9011
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$i}`)}
|
|
9012
9012
|
|
|
9013
9013
|
Options
|
|
9014
9014
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9375,7 +9375,7 @@ async function handlePurlsShallowScore({
|
|
|
9375
9375
|
outputPurlsShallowScore(purls, packageData, outputKind);
|
|
9376
9376
|
}
|
|
9377
9377
|
|
|
9378
|
-
const CMD_NAME$
|
|
9378
|
+
const CMD_NAME$h = 'shallow';
|
|
9379
9379
|
const description$m = 'Look up info regarding one or more packages but not their transitives';
|
|
9380
9380
|
const hidden$i = false;
|
|
9381
9381
|
const cmdPackageShallow = {
|
|
@@ -9394,7 +9394,7 @@ async function run$n(argv, importMeta, {
|
|
|
9394
9394
|
parentName
|
|
9395
9395
|
}) {
|
|
9396
9396
|
const config = {
|
|
9397
|
-
commandName: CMD_NAME$
|
|
9397
|
+
commandName: CMD_NAME$h,
|
|
9398
9398
|
description: description$m,
|
|
9399
9399
|
hidden: hidden$i,
|
|
9400
9400
|
flags: {
|
|
@@ -9406,7 +9406,7 @@ async function run$n(argv, importMeta, {
|
|
|
9406
9406
|
$ ${command} [options] <<ECOSYSTEM> <PKGNAME> [<PKGNAME> ...] | <PURL> [<PURL> ...]>
|
|
9407
9407
|
|
|
9408
9408
|
API Token Requirements
|
|
9409
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9409
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$h}`)}
|
|
9410
9410
|
|
|
9411
9411
|
Options
|
|
9412
9412
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9508,472 +9508,48 @@ const cmdPackage = {
|
|
|
9508
9508
|
}
|
|
9509
9509
|
};
|
|
9510
9510
|
|
|
9511
|
-
const
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
vulnerabilities: vendor.record(vendor.string(),
|
|
9520
|
-
// Vulnerability ID like "GHSA-jrhj-2j3q-xf3v"
|
|
9521
|
-
vendor.object({
|
|
9522
|
-
cves: vendor.array(vendor.string()),
|
|
9523
|
-
summary: vendor.string(),
|
|
9524
|
-
severity: vendor.string(),
|
|
9525
|
-
description: vendor.string(),
|
|
9526
|
-
patchExplanation: vendor.string()
|
|
9527
|
-
}))
|
|
9528
|
-
});
|
|
9529
|
-
const PatchManifestSchema = vendor.object({
|
|
9530
|
-
patches: vendor.record(
|
|
9531
|
-
// Package identifier like "npm:simplehttpserver@0.0.6".
|
|
9532
|
-
vendor.string(), PatchRecordSchema)
|
|
9533
|
-
});
|
|
9534
|
-
|
|
9535
|
-
async function outputPatchResult(result, outputKind) {
|
|
9536
|
-
if (!result.ok) {
|
|
9537
|
-
process.exitCode = result.code ?? 1;
|
|
9538
|
-
}
|
|
9539
|
-
if (outputKind === constants.OUTPUT_JSON) {
|
|
9540
|
-
logger.logger.log(utils.serializeResultJson(result));
|
|
9541
|
-
return;
|
|
9542
|
-
}
|
|
9543
|
-
if (!result.ok) {
|
|
9544
|
-
logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
|
|
9545
|
-
return;
|
|
9546
|
-
}
|
|
9511
|
+
const description$k = 'Manage CVE patches for dependencies';
|
|
9512
|
+
const hidden$h = false;
|
|
9513
|
+
const cmdPatch = {
|
|
9514
|
+
description: description$k,
|
|
9515
|
+
hidden: hidden$h,
|
|
9516
|
+
run: run$m
|
|
9517
|
+
};
|
|
9518
|
+
async function run$m(argv, _importMeta, _context) {
|
|
9547
9519
|
const {
|
|
9548
|
-
|
|
9549
|
-
} =
|
|
9550
|
-
logger.logger.log('');
|
|
9551
|
-
if (patched.length) {
|
|
9552
|
-
logger.logger.group(`Successfully processed patches for ${patched.length} ${words.pluralize('package', patched.length)}:`);
|
|
9553
|
-
for (const pkg of patched) {
|
|
9554
|
-
logger.logger.success(pkg);
|
|
9555
|
-
}
|
|
9556
|
-
logger.logger.groupEnd();
|
|
9557
|
-
} else {
|
|
9558
|
-
logger.logger.warn('No packages found requiring patches.');
|
|
9559
|
-
}
|
|
9560
|
-
logger.logger.log('');
|
|
9561
|
-
logger.logger.success('Patch command completed!');
|
|
9562
|
-
}
|
|
9520
|
+
ENV
|
|
9521
|
+
} = constants.default;
|
|
9563
9522
|
|
|
9564
|
-
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
dryRun = false,
|
|
9568
|
-
purlObjs,
|
|
9569
|
-
spinner
|
|
9570
|
-
} = {
|
|
9571
|
-
__proto__: null,
|
|
9572
|
-
...options
|
|
9573
|
-
};
|
|
9574
|
-
const wasSpinning = !!spinner?.isSpinning;
|
|
9575
|
-
spinner?.start();
|
|
9576
|
-
const patchLookup = new Map();
|
|
9577
|
-
for (const patchInfo of patches) {
|
|
9578
|
-
patchLookup.set(patchInfo.purl, patchInfo);
|
|
9579
|
-
}
|
|
9580
|
-
const nmPaths = await findNodeModulesPaths(cwd);
|
|
9581
|
-
spinner?.stop();
|
|
9582
|
-
logger.logger.log(`Found ${nmPaths.length} ${constants.NODE_MODULES} ${words.pluralize('folder', nmPaths.length)}`);
|
|
9583
|
-
logger.logger.group('');
|
|
9584
|
-
spinner?.start();
|
|
9585
|
-
const result = {
|
|
9586
|
-
passed: [],
|
|
9587
|
-
failed: []
|
|
9588
|
-
};
|
|
9589
|
-
for (const nmPath of nmPaths) {
|
|
9590
|
-
// eslint-disable-next-line no-await-in-loop
|
|
9591
|
-
const dirNames = await fs$2.readDirNames(nmPath);
|
|
9592
|
-
for (const dirName of dirNames) {
|
|
9593
|
-
const isScoped = dirName.startsWith('@');
|
|
9594
|
-
const pkgPath = path.join(nmPath, dirName);
|
|
9595
|
-
const pkgSubNames = isScoped ?
|
|
9596
|
-
// eslint-disable-next-line no-await-in-loop
|
|
9597
|
-
await fs$2.readDirNames(pkgPath) : [dirName];
|
|
9598
|
-
for (const pkgSubName of pkgSubNames) {
|
|
9599
|
-
const dirFullName = isScoped ? `${dirName}/${pkgSubName}` : pkgSubName;
|
|
9600
|
-
const pkgPath = path.join(nmPath, dirFullName);
|
|
9601
|
-
// eslint-disable-next-line no-await-in-loop
|
|
9602
|
-
const pkgJson = await packages.readPackageJson(pkgPath, {
|
|
9603
|
-
throws: false
|
|
9604
|
-
});
|
|
9605
|
-
if (!strings.isNonEmptyString(pkgJson?.name) || !strings.isNonEmptyString(pkgJson?.version)) {
|
|
9606
|
-
continue;
|
|
9607
|
-
}
|
|
9608
|
-
const purl = `pkg:npm/${pkgJson.name}@${pkgJson.version}`;
|
|
9609
|
-
const purlObj = utils.getPurlObject(purl, {
|
|
9610
|
-
throws: false
|
|
9611
|
-
});
|
|
9612
|
-
if (!purlObj) {
|
|
9613
|
-
continue;
|
|
9614
|
-
}
|
|
9523
|
+
// Map socket-cli environment to socket-patch options.
|
|
9524
|
+
// Only include properties with defined values (exactOptionalPropertyTypes).
|
|
9525
|
+
const options = {};
|
|
9615
9526
|
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
const patchInfo = patchLookup.get(purl);
|
|
9621
|
-
if (!patchInfo) {
|
|
9622
|
-
continue;
|
|
9623
|
-
}
|
|
9624
|
-
spinner?.stop();
|
|
9625
|
-
logger.logger.log(`Found match: ${pkgJson.name}@${pkgJson.version} at ${pkgPath}`);
|
|
9626
|
-
logger.logger.log(`Patch key: ${patchInfo.key}`);
|
|
9627
|
-
logger.logger.group(`Processing files:`);
|
|
9628
|
-
spinner?.start();
|
|
9629
|
-
let passed = true;
|
|
9630
|
-
for (const {
|
|
9631
|
-
0: fileName,
|
|
9632
|
-
1: fileInfo
|
|
9633
|
-
} of Object.entries(patchInfo.patch.files)) {
|
|
9634
|
-
// eslint-disable-next-line no-await-in-loop
|
|
9635
|
-
const filePatchPassed = await processFilePatch(pkgPath, fileName, fileInfo, socketDir, {
|
|
9636
|
-
dryRun,
|
|
9637
|
-
spinner
|
|
9638
|
-
});
|
|
9639
|
-
if (!filePatchPassed) {
|
|
9640
|
-
passed = false;
|
|
9641
|
-
}
|
|
9642
|
-
}
|
|
9643
|
-
logger.logger.groupEnd();
|
|
9644
|
-
if (passed) {
|
|
9645
|
-
result.passed.push(purl);
|
|
9646
|
-
} else {
|
|
9647
|
-
result.failed.push(purl);
|
|
9648
|
-
}
|
|
9649
|
-
}
|
|
9650
|
-
}
|
|
9527
|
+
// Strip /v0/ suffix from API URL if present.
|
|
9528
|
+
const apiUrl = ENV.SOCKET_CLI_API_BASE_URL?.replace(/\/v0\/?$/, '');
|
|
9529
|
+
if (apiUrl) {
|
|
9530
|
+
options.apiUrl = apiUrl;
|
|
9651
9531
|
}
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
if (wasSpinning) {
|
|
9655
|
-
spinner.start();
|
|
9532
|
+
if (ENV.SOCKET_CLI_API_TOKEN) {
|
|
9533
|
+
options.apiToken = ENV.SOCKET_CLI_API_TOKEN;
|
|
9656
9534
|
}
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
|
|
9660
|
-
/**
|
|
9661
|
-
* Compute SHA256 hash of file contents.
|
|
9662
|
-
*/
|
|
9663
|
-
async function computeSHA256(filepath) {
|
|
9664
|
-
try {
|
|
9665
|
-
const content = await fs$1.promises.readFile(filepath);
|
|
9666
|
-
const hash = require$$0$1.createHash('sha256');
|
|
9667
|
-
hash.update(content);
|
|
9668
|
-
return {
|
|
9669
|
-
ok: true,
|
|
9670
|
-
data: hash.digest('hex')
|
|
9671
|
-
};
|
|
9672
|
-
} catch (e) {
|
|
9673
|
-
return {
|
|
9674
|
-
ok: false,
|
|
9675
|
-
message: 'Failed to compute file hash',
|
|
9676
|
-
cause: `Unable to read file ${filepath}: ${utils.getErrorCause(e)}`
|
|
9677
|
-
};
|
|
9535
|
+
if (ENV.SOCKET_CLI_ORG_SLUG) {
|
|
9536
|
+
options.orgSlug = ENV.SOCKET_CLI_ORG_SLUG;
|
|
9678
9537
|
}
|
|
9679
|
-
|
|
9680
|
-
|
|
9681
|
-
const rootNmPath = await utils.findUp(constants.NODE_MODULES, {
|
|
9682
|
-
cwd,
|
|
9683
|
-
onlyDirectories: true
|
|
9684
|
-
});
|
|
9685
|
-
if (!rootNmPath) {
|
|
9686
|
-
return [];
|
|
9538
|
+
if (ENV.SOCKET_PATCH_PROXY_URL) {
|
|
9539
|
+
options.patchProxyUrl = ENV.SOCKET_PATCH_PROXY_URL;
|
|
9687
9540
|
}
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
cwd: path.dirname(rootNmPath),
|
|
9691
|
-
dot: true,
|
|
9692
|
-
followSymbolicLinks: false,
|
|
9693
|
-
onlyDirectories: true
|
|
9694
|
-
});
|
|
9695
|
-
}
|
|
9696
|
-
async function processFilePatch(pkgPath, fileName, fileInfo, socketDir, options) {
|
|
9697
|
-
const {
|
|
9698
|
-
dryRun,
|
|
9699
|
-
spinner
|
|
9700
|
-
} = {
|
|
9701
|
-
__proto__: null,
|
|
9702
|
-
...options
|
|
9703
|
-
};
|
|
9704
|
-
const wasSpinning = !!spinner?.isSpinning;
|
|
9705
|
-
spinner?.stop();
|
|
9706
|
-
const filepath = path.join(pkgPath, fileName);
|
|
9707
|
-
if (!fs$1.existsSync(filepath)) {
|
|
9708
|
-
logger.logger.log(`File not found: ${fileName}`);
|
|
9709
|
-
if (wasSpinning) {
|
|
9710
|
-
spinner?.start();
|
|
9711
|
-
}
|
|
9712
|
-
return false;
|
|
9541
|
+
if (ENV.SOCKET_CLI_API_PROXY) {
|
|
9542
|
+
options.httpProxy = ENV.SOCKET_CLI_API_PROXY;
|
|
9713
9543
|
}
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
logger.logger.log(`Failed to compute hash for: ${fileName}: ${currentHashResult.cause || currentHashResult.message}`);
|
|
9717
|
-
if (wasSpinning) {
|
|
9718
|
-
spinner?.start();
|
|
9719
|
-
}
|
|
9720
|
-
return false;
|
|
9544
|
+
if (ENV.SOCKET_CLI_DEBUG) {
|
|
9545
|
+
options.debug = ENV.SOCKET_CLI_DEBUG;
|
|
9721
9546
|
}
|
|
9722
|
-
if (currentHashResult.data === fileInfo.afterHash) {
|
|
9723
|
-
logger.logger.success(`File already patched: ${fileName}`);
|
|
9724
|
-
logger.logger.group();
|
|
9725
|
-
logger.logger.log(`Current hash: ${currentHashResult.data}`);
|
|
9726
|
-
logger.logger.groupEnd();
|
|
9727
|
-
if (wasSpinning) {
|
|
9728
|
-
spinner?.start();
|
|
9729
|
-
}
|
|
9730
|
-
return true;
|
|
9731
|
-
}
|
|
9732
|
-
if (currentHashResult.data !== fileInfo.beforeHash) {
|
|
9733
|
-
logger.logger.fail(`File hash mismatch: ${fileName}`);
|
|
9734
|
-
logger.logger.group();
|
|
9735
|
-
logger.logger.log(`Expected: ${fileInfo.beforeHash}`);
|
|
9736
|
-
logger.logger.log(`Current: ${currentHashResult.data}`);
|
|
9737
|
-
logger.logger.log(`Target: ${fileInfo.afterHash}`);
|
|
9738
|
-
logger.logger.groupEnd();
|
|
9739
|
-
if (wasSpinning) {
|
|
9740
|
-
spinner?.start();
|
|
9741
|
-
}
|
|
9742
|
-
return false;
|
|
9743
|
-
}
|
|
9744
|
-
logger.logger.success(`File matches expected hash: ${fileName}`);
|
|
9745
|
-
logger.logger.group();
|
|
9746
|
-
logger.logger.log(`Current hash: ${currentHashResult.data}`);
|
|
9747
|
-
logger.logger.log(`Ready to patch to: ${fileInfo.afterHash}`);
|
|
9748
|
-
logger.logger.group();
|
|
9749
|
-
if (dryRun) {
|
|
9750
|
-
logger.logger.log(`(dry run - no changes made)`);
|
|
9751
|
-
logger.logger.groupEnd();
|
|
9752
|
-
logger.logger.groupEnd();
|
|
9753
|
-
if (wasSpinning) {
|
|
9754
|
-
spinner?.start();
|
|
9755
|
-
}
|
|
9756
|
-
return false;
|
|
9757
|
-
}
|
|
9758
|
-
const blobPath = path.join(socketDir, 'blobs', fileInfo.afterHash);
|
|
9759
|
-
if (!fs$1.existsSync(blobPath)) {
|
|
9760
|
-
logger.logger.fail(`Error: Patch file not found at ${blobPath}`);
|
|
9761
|
-
logger.logger.groupEnd();
|
|
9762
|
-
logger.logger.groupEnd();
|
|
9763
|
-
if (wasSpinning) {
|
|
9764
|
-
spinner?.start();
|
|
9765
|
-
}
|
|
9766
|
-
return false;
|
|
9767
|
-
}
|
|
9768
|
-
spinner?.start();
|
|
9769
|
-
let result = true;
|
|
9770
|
-
try {
|
|
9771
|
-
await fs$1.promises.copyFile(blobPath, filepath);
|
|
9772
|
-
|
|
9773
|
-
// Verify the hash after copying to ensure file integrity.
|
|
9774
|
-
const verifyHashResult = await computeSHA256(filepath);
|
|
9775
|
-
if (!verifyHashResult.ok) {
|
|
9776
|
-
logger.logger.error(`Failed to verify hash after patch: ${verifyHashResult.cause || verifyHashResult.message}`);
|
|
9777
|
-
result = false;
|
|
9778
|
-
} else if (verifyHashResult.data !== fileInfo.afterHash) {
|
|
9779
|
-
logger.logger.error(`Hash verification failed after patch`);
|
|
9780
|
-
logger.logger.group();
|
|
9781
|
-
logger.logger.log(`Expected: ${fileInfo.afterHash}`);
|
|
9782
|
-
logger.logger.log(`Got: ${verifyHashResult.data}`);
|
|
9783
|
-
logger.logger.groupEnd();
|
|
9784
|
-
result = false;
|
|
9785
|
-
} else {
|
|
9786
|
-
logger.logger.success(`Patch applied successfully`);
|
|
9787
|
-
}
|
|
9788
|
-
} catch (e) {
|
|
9789
|
-
logger.logger.error('Error applying patch');
|
|
9790
|
-
require$$9.debugDir('error', e);
|
|
9791
|
-
result = false;
|
|
9792
|
-
}
|
|
9793
|
-
logger.logger.groupEnd();
|
|
9794
|
-
logger.logger.groupEnd();
|
|
9795
|
-
spinner?.stop();
|
|
9796
|
-
if (wasSpinning) {
|
|
9797
|
-
spinner?.start();
|
|
9798
|
-
}
|
|
9799
|
-
return result;
|
|
9800
|
-
}
|
|
9801
|
-
async function handlePatch({
|
|
9802
|
-
cwd,
|
|
9803
|
-
dryRun,
|
|
9804
|
-
outputKind,
|
|
9805
|
-
purlObjs,
|
|
9806
|
-
spinner
|
|
9807
|
-
}) {
|
|
9808
|
-
try {
|
|
9809
|
-
const dotSocketDirPath = path.join(cwd, constants.DOT_SOCKET_DIR);
|
|
9810
|
-
const manifestPath = path.join(dotSocketDirPath, constants.MANIFEST_JSON);
|
|
9811
|
-
const manifestContent = await fs$1.promises.readFile(manifestPath, constants.UTF8);
|
|
9812
|
-
const manifestData = JSON.parse(manifestContent);
|
|
9813
|
-
const purls = purlObjs.map(String);
|
|
9814
|
-
const validated = PatchManifestSchema.parse(manifestData);
|
|
9815
|
-
|
|
9816
|
-
// Parse PURLs and group by ecosystem.
|
|
9817
|
-
const patchesByEcosystem = new Map();
|
|
9818
|
-
for (const {
|
|
9819
|
-
0: key,
|
|
9820
|
-
1: patch
|
|
9821
|
-
} of Object.entries(validated.patches)) {
|
|
9822
|
-
const purl = utils.normalizePurl(key);
|
|
9823
|
-
if (purls.length && !purls.includes(purl)) {
|
|
9824
|
-
continue;
|
|
9825
|
-
}
|
|
9826
|
-
const purlObj = utils.getPurlObject(purl, {
|
|
9827
|
-
throws: false
|
|
9828
|
-
});
|
|
9829
|
-
if (!purlObj) {
|
|
9830
|
-
continue;
|
|
9831
|
-
}
|
|
9832
|
-
let patches = patchesByEcosystem.get(purlObj.type);
|
|
9833
|
-
if (!Array.isArray(patches)) {
|
|
9834
|
-
patches = [];
|
|
9835
|
-
patchesByEcosystem.set(purlObj.type, patches);
|
|
9836
|
-
}
|
|
9837
|
-
patches.push({
|
|
9838
|
-
key,
|
|
9839
|
-
patch,
|
|
9840
|
-
purl,
|
|
9841
|
-
purlObj
|
|
9842
|
-
});
|
|
9843
|
-
}
|
|
9844
|
-
if (purls.length) {
|
|
9845
|
-
spinner.start(`Checking patches for: ${arrays.joinAnd(purls)}`);
|
|
9846
|
-
} else {
|
|
9847
|
-
spinner.start('Scanning all dependencies for available patches');
|
|
9848
|
-
}
|
|
9849
|
-
const patched = [];
|
|
9850
|
-
const npmPatches = patchesByEcosystem.get(constants.NPM);
|
|
9851
|
-
if (npmPatches) {
|
|
9852
|
-
const patchingResults = await applyNpmPatches(dotSocketDirPath, npmPatches, {
|
|
9853
|
-
cwd,
|
|
9854
|
-
dryRun,
|
|
9855
|
-
purlObjs,
|
|
9856
|
-
spinner
|
|
9857
|
-
});
|
|
9858
|
-
patched.push(...patchingResults.passed);
|
|
9859
|
-
}
|
|
9860
|
-
spinner.stop();
|
|
9861
|
-
await outputPatchResult({
|
|
9862
|
-
ok: true,
|
|
9863
|
-
data: {
|
|
9864
|
-
patched
|
|
9865
|
-
}
|
|
9866
|
-
}, outputKind);
|
|
9867
|
-
} catch (e) {
|
|
9868
|
-
spinner.stop();
|
|
9869
|
-
let message = 'Failed to apply patches';
|
|
9870
|
-
let cause = utils.getErrorCause(e);
|
|
9871
|
-
if (e instanceof SyntaxError) {
|
|
9872
|
-
message = `Invalid JSON in ${constants.MANIFEST_JSON}`;
|
|
9873
|
-
cause = e.message;
|
|
9874
|
-
} else if (e instanceof Error && 'issues' in e) {
|
|
9875
|
-
message = 'Schema validation failed';
|
|
9876
|
-
cause = String(e);
|
|
9877
|
-
}
|
|
9878
|
-
await outputPatchResult({
|
|
9879
|
-
ok: false,
|
|
9880
|
-
code: 1,
|
|
9881
|
-
message,
|
|
9882
|
-
cause
|
|
9883
|
-
}, outputKind);
|
|
9884
|
-
}
|
|
9885
|
-
}
|
|
9886
9547
|
|
|
9887
|
-
|
|
9888
|
-
const
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
description: description$k,
|
|
9892
|
-
hidden: hidden$h,
|
|
9893
|
-
run: run$m
|
|
9894
|
-
};
|
|
9895
|
-
async function run$m(argv, importMeta, {
|
|
9896
|
-
parentName
|
|
9897
|
-
}) {
|
|
9898
|
-
const config = {
|
|
9899
|
-
commandName: CMD_NAME$h,
|
|
9900
|
-
description: description$k,
|
|
9901
|
-
hidden: hidden$h,
|
|
9902
|
-
flags: {
|
|
9903
|
-
...flags.commonFlags,
|
|
9904
|
-
...flags.outputFlags,
|
|
9905
|
-
purl: {
|
|
9906
|
-
type: 'string',
|
|
9907
|
-
default: [],
|
|
9908
|
-
description: 'Specify purls to patch, as either a comma separated value or as multiple flags',
|
|
9909
|
-
isMultiple: true,
|
|
9910
|
-
shortFlag: 'p'
|
|
9911
|
-
}
|
|
9912
|
-
},
|
|
9913
|
-
help: (command, config) => `
|
|
9914
|
-
Usage
|
|
9915
|
-
$ ${command} [options] [CWD=.]
|
|
9916
|
-
|
|
9917
|
-
API Token Requirements
|
|
9918
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$h}`)}
|
|
9919
|
-
|
|
9920
|
-
Options
|
|
9921
|
-
${utils.getFlagListOutput(config.flags)}
|
|
9922
|
-
|
|
9923
|
-
Examples
|
|
9924
|
-
$ ${command}
|
|
9925
|
-
$ ${command} --package lodash
|
|
9926
|
-
$ ${command} ./path/to/project --package lodash,react
|
|
9927
|
-
`
|
|
9928
|
-
};
|
|
9929
|
-
const cli = utils.meowOrExit({
|
|
9930
|
-
argv,
|
|
9931
|
-
config,
|
|
9932
|
-
parentName,
|
|
9933
|
-
importMeta
|
|
9934
|
-
}, {
|
|
9935
|
-
allowUnknownFlags: false
|
|
9936
|
-
});
|
|
9937
|
-
const {
|
|
9938
|
-
dryRun,
|
|
9939
|
-
json,
|
|
9940
|
-
markdown
|
|
9941
|
-
} = cli.flags;
|
|
9942
|
-
const outputKind = utils.getOutputKind(json, markdown);
|
|
9943
|
-
const wasValidInput = utils.checkCommandInput(outputKind, {
|
|
9944
|
-
nook: true,
|
|
9945
|
-
test: !json || !markdown,
|
|
9946
|
-
message: 'The json and markdown flags cannot be both set, pick one',
|
|
9947
|
-
fail: 'omit one'
|
|
9948
|
-
});
|
|
9949
|
-
if (!wasValidInput) {
|
|
9950
|
-
return;
|
|
9548
|
+
// Forward all arguments to socket-patch.
|
|
9549
|
+
const exitCode = await vendor.runExports.runPatch([...argv], options);
|
|
9550
|
+
if (exitCode !== 0) {
|
|
9551
|
+
process.exitCode = exitCode;
|
|
9951
9552
|
}
|
|
9952
|
-
let [cwd = '.'] = cli.input;
|
|
9953
|
-
// Note: path.resolve vs .join:
|
|
9954
|
-
// If given path is absolute then cwd should not affect it.
|
|
9955
|
-
cwd = path.resolve(process.cwd(), cwd);
|
|
9956
|
-
const dotSocketDirPath = path.join(cwd, constants.DOT_SOCKET_DIR);
|
|
9957
|
-
if (!fs$1.existsSync(dotSocketDirPath)) {
|
|
9958
|
-
throw new utils.InputError(`No ${constants.DOT_SOCKET_DIR} directory found in current directory`);
|
|
9959
|
-
}
|
|
9960
|
-
const manifestPath = path.join(dotSocketDirPath, constants.MANIFEST_JSON);
|
|
9961
|
-
if (!fs$1.existsSync(manifestPath)) {
|
|
9962
|
-
throw new utils.InputError(`No ${constants.MANIFEST_JSON} found in ${constants.DOT_SOCKET_DIR} directory`);
|
|
9963
|
-
}
|
|
9964
|
-
const {
|
|
9965
|
-
spinner
|
|
9966
|
-
} = constants.default;
|
|
9967
|
-
const purlObjs = arrays.arrayUnique(utils.cmdFlagValueToArray(cli.flags['purl'])).map(p => utils.getPurlObject(p, {
|
|
9968
|
-
throws: false
|
|
9969
|
-
})).filter(Boolean);
|
|
9970
|
-
await handlePatch({
|
|
9971
|
-
cwd,
|
|
9972
|
-
dryRun,
|
|
9973
|
-
outputKind,
|
|
9974
|
-
purlObjs,
|
|
9975
|
-
spinner
|
|
9976
|
-
});
|
|
9977
9553
|
}
|
|
9978
9554
|
|
|
9979
9555
|
const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
|
|
@@ -11251,6 +10827,12 @@ const reachabilityFlags = {
|
|
|
11251
10827
|
isMultiple: true,
|
|
11252
10828
|
description: 'List of paths to exclude from reachability analysis, as either a comma separated value or as multiple flags.'
|
|
11253
10829
|
},
|
|
10830
|
+
reachLazyMode: {
|
|
10831
|
+
type: 'boolean',
|
|
10832
|
+
default: false,
|
|
10833
|
+
description: 'Enable lazy mode for reachability analysis.',
|
|
10834
|
+
hidden: true
|
|
10835
|
+
},
|
|
11254
10836
|
reachSkipCache: {
|
|
11255
10837
|
type: 'boolean',
|
|
11256
10838
|
default: false,
|
|
@@ -11503,6 +11085,7 @@ async function run$d(argv, importMeta, {
|
|
|
11503
11085
|
reachDebug,
|
|
11504
11086
|
reachDisableAnalysisSplitting,
|
|
11505
11087
|
reachDisableAnalytics,
|
|
11088
|
+
reachLazyMode,
|
|
11506
11089
|
reachSkipCache,
|
|
11507
11090
|
reachUseOnlyPregeneratedSboms,
|
|
11508
11091
|
reachVersion,
|
|
@@ -11634,7 +11217,7 @@ async function run$d(argv, importMeta, {
|
|
|
11634
11217
|
const isUsingNonDefaultConcurrency = reachConcurrency !== reachabilityFlags['reachConcurrency']?.default;
|
|
11635
11218
|
const isUsingNonDefaultAnalytics = reachDisableAnalytics !== reachabilityFlags['reachDisableAnalytics']?.default;
|
|
11636
11219
|
const isUsingNonDefaultVersion = reachVersion !== reachabilityFlags['reachVersion']?.default;
|
|
11637
|
-
const isUsingAnyReachabilityFlags = hasReachEcosystems || hasReachExcludePaths || isUsingNonDefaultAnalytics || isUsingNonDefaultConcurrency || isUsingNonDefaultMemoryLimit || isUsingNonDefaultTimeout || isUsingNonDefaultVersion || reachDisableAnalysisSplitting || reachSkipCache || reachUseOnlyPregeneratedSboms;
|
|
11220
|
+
const isUsingAnyReachabilityFlags = hasReachEcosystems || hasReachExcludePaths || isUsingNonDefaultAnalytics || isUsingNonDefaultConcurrency || isUsingNonDefaultMemoryLimit || isUsingNonDefaultTimeout || isUsingNonDefaultVersion || reachDisableAnalysisSplitting || reachLazyMode || reachSkipCache || reachUseOnlyPregeneratedSboms;
|
|
11638
11221
|
|
|
11639
11222
|
// Validate target constraints when --reach is enabled.
|
|
11640
11223
|
const reachTargetValidation = reach ? await validateReachabilityTarget(targets, cwd) : {
|
|
@@ -11727,6 +11310,7 @@ async function run$d(argv, importMeta, {
|
|
|
11727
11310
|
reachDisableAnalytics: Boolean(reachDisableAnalytics),
|
|
11728
11311
|
reachEcosystems,
|
|
11729
11312
|
reachExcludePaths,
|
|
11313
|
+
reachLazyMode: Boolean(reachLazyMode),
|
|
11730
11314
|
reachSkipCache: Boolean(reachSkipCache),
|
|
11731
11315
|
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
|
|
11732
11316
|
reachVersion,
|
|
@@ -12377,6 +11961,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
12377
11961
|
reachDisableAnalytics: false,
|
|
12378
11962
|
reachEcosystems: [],
|
|
12379
11963
|
reachExcludePaths: [],
|
|
11964
|
+
reachLazyMode: false,
|
|
12380
11965
|
reachSkipCache: false,
|
|
12381
11966
|
reachUseOnlyPregeneratedSboms: false,
|
|
12382
11967
|
reachVersion: undefined,
|
|
@@ -13666,6 +13251,7 @@ async function run$7(argv, importMeta, {
|
|
|
13666
13251
|
reachDebug,
|
|
13667
13252
|
reachDisableAnalysisSplitting,
|
|
13668
13253
|
reachDisableAnalytics,
|
|
13254
|
+
reachLazyMode,
|
|
13669
13255
|
reachSkipCache,
|
|
13670
13256
|
reachUseOnlyPregeneratedSboms,
|
|
13671
13257
|
reachVersion
|
|
@@ -13766,6 +13352,7 @@ async function run$7(argv, importMeta, {
|
|
|
13766
13352
|
reachDisableAnalytics: Boolean(reachDisableAnalytics),
|
|
13767
13353
|
reachEcosystems,
|
|
13768
13354
|
reachExcludePaths,
|
|
13355
|
+
reachLazyMode: Boolean(reachLazyMode),
|
|
13769
13356
|
reachSkipCache: Boolean(reachSkipCache),
|
|
13770
13357
|
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
|
|
13771
13358
|
reachVersion
|
|
@@ -15680,5 +15267,5 @@ process.on('unhandledRejection', async (reason, promise) => {
|
|
|
15680
15267
|
// eslint-disable-next-line n/no-process-exit
|
|
15681
15268
|
process.exit(1);
|
|
15682
15269
|
});
|
|
15683
|
-
//# debugId=
|
|
15270
|
+
//# debugId=90b6bd73-b1dd-42e8-a3d1-d309882d77f4
|
|
15684
15271
|
//# sourceMappingURL=cli.js.map
|