@socketsecurity/cli-with-sentry 1.1.50 → 1.1.52
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 +16 -0
- package/dist/cli.js +213 -554
- 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/fetch-default-org-slug.d.mts +1 -1
- package/dist/types/commands/ci/fetch-default-org-slug.d.mts.map +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts +6 -2
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/types.d.mts +1 -0
- package/dist/types/commands/fix/types.d.mts.map +1 -1
- package/dist/types/commands/organization/fetch-organization-list.d.mts +1 -0
- package/dist/types/commands/organization/fetch-organization-list.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/fetch-supported-scan-file-names.d.mts +1 -0
- package/dist/types/commands/scan/fetch-supported-scan-file-names.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/api.d.mts +1 -0
- package/dist/types/utils/api.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/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/utils.js +512 -67
- 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')}.
|
|
@@ -946,7 +945,8 @@ async function fetchCreateOrgFullScan(packagePaths, orgSlug, config, options) {
|
|
|
946
945
|
async function fetchSupportedScanFileNames(options) {
|
|
947
946
|
const {
|
|
948
947
|
sdkOpts,
|
|
949
|
-
spinner
|
|
948
|
+
spinner,
|
|
949
|
+
silence = false
|
|
950
950
|
} = {
|
|
951
951
|
__proto__: null,
|
|
952
952
|
...options
|
|
@@ -958,7 +958,8 @@ async function fetchSupportedScanFileNames(options) {
|
|
|
958
958
|
const sockSdk = sockSdkCResult.data;
|
|
959
959
|
return await utils.handleApiCall(sockSdk.getSupportedScanFiles(), {
|
|
960
960
|
description: 'supported scan file types',
|
|
961
|
-
spinner
|
|
961
|
+
spinner,
|
|
962
|
+
silence
|
|
962
963
|
});
|
|
963
964
|
}
|
|
964
965
|
|
|
@@ -1647,7 +1648,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1647
1648
|
// Build Coana arguments.
|
|
1648
1649
|
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
1650
|
// 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'] : [])];
|
|
1651
|
+
...(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
1652
|
|
|
1652
1653
|
// Build environment variables.
|
|
1653
1654
|
const coanaEnv = {};
|
|
@@ -2423,6 +2424,7 @@ async function handleCi(autoManifest) {
|
|
|
2423
2424
|
reachDisableAnalytics: false,
|
|
2424
2425
|
reachEcosystems: [],
|
|
2425
2426
|
reachExcludePaths: [],
|
|
2427
|
+
reachLazyMode: false,
|
|
2426
2428
|
reachSkipCache: false,
|
|
2427
2429
|
reachUseOnlyPregeneratedSboms: false,
|
|
2428
2430
|
reachVersion: undefined,
|
|
@@ -2720,7 +2722,7 @@ async function handleConfigAuto({
|
|
|
2720
2722
|
await outputConfigAuto(key, result, outputKind);
|
|
2721
2723
|
}
|
|
2722
2724
|
|
|
2723
|
-
const CMD_NAME$
|
|
2725
|
+
const CMD_NAME$v = 'auto';
|
|
2724
2726
|
const description$D = 'Automatically discover and set the correct value config item';
|
|
2725
2727
|
const hidden$v = false;
|
|
2726
2728
|
const cmdConfigAuto = {
|
|
@@ -2732,7 +2734,7 @@ async function run$P(argv, importMeta, {
|
|
|
2732
2734
|
parentName
|
|
2733
2735
|
}) {
|
|
2734
2736
|
const config = {
|
|
2735
|
-
commandName: CMD_NAME$
|
|
2737
|
+
commandName: CMD_NAME$v,
|
|
2736
2738
|
description: description$D,
|
|
2737
2739
|
hidden: hidden$v,
|
|
2738
2740
|
flags: {
|
|
@@ -3086,7 +3088,7 @@ async function handleConfigSet({
|
|
|
3086
3088
|
await outputConfigSet(result, outputKind);
|
|
3087
3089
|
}
|
|
3088
3090
|
|
|
3089
|
-
const CMD_NAME$
|
|
3091
|
+
const CMD_NAME$u = 'set';
|
|
3090
3092
|
const description$C = 'Update the value of a local CLI config item';
|
|
3091
3093
|
const hidden$u = false;
|
|
3092
3094
|
const cmdConfigSet = {
|
|
@@ -3098,7 +3100,7 @@ async function run$M(argv, importMeta, {
|
|
|
3098
3100
|
parentName
|
|
3099
3101
|
}) {
|
|
3100
3102
|
const config = {
|
|
3101
|
-
commandName: CMD_NAME$
|
|
3103
|
+
commandName: CMD_NAME$u,
|
|
3102
3104
|
description: description$C,
|
|
3103
3105
|
hidden: hidden$u,
|
|
3104
3106
|
flags: {
|
|
@@ -3213,7 +3215,7 @@ async function handleConfigUnset({
|
|
|
3213
3215
|
await outputConfigUnset(updateResult, outputKind);
|
|
3214
3216
|
}
|
|
3215
3217
|
|
|
3216
|
-
const CMD_NAME$
|
|
3218
|
+
const CMD_NAME$t = 'unset';
|
|
3217
3219
|
const description$B = 'Clear the value of a local CLI config item';
|
|
3218
3220
|
const hidden$t = false;
|
|
3219
3221
|
const cmdConfigUnset = {
|
|
@@ -3225,7 +3227,7 @@ async function run$L(argv, importMeta, {
|
|
|
3225
3227
|
parentName
|
|
3226
3228
|
}) {
|
|
3227
3229
|
const config = {
|
|
3228
|
-
commandName: CMD_NAME$
|
|
3230
|
+
commandName: CMD_NAME$t,
|
|
3229
3231
|
description: description$B,
|
|
3230
3232
|
hidden: hidden$t,
|
|
3231
3233
|
flags: {
|
|
@@ -3730,6 +3732,7 @@ async function discoverGhsaIds(orgSlug, tarHash, options) {
|
|
|
3730
3732
|
const {
|
|
3731
3733
|
cwd = process.cwd(),
|
|
3732
3734
|
ecosystems,
|
|
3735
|
+
silence = false,
|
|
3733
3736
|
spinner
|
|
3734
3737
|
} = {
|
|
3735
3738
|
__proto__: null,
|
|
@@ -3737,7 +3740,7 @@ async function discoverGhsaIds(orgSlug, tarHash, options) {
|
|
|
3737
3740
|
};
|
|
3738
3741
|
const foundCResult = await utils.spawnCoanaDlx(['find-vulnerabilities', cwd, '--manifests-tar-hash', tarHash, ...(ecosystems?.length ? ['--purl-types', ...ecosystems] : [])], orgSlug, {
|
|
3739
3742
|
cwd,
|
|
3740
|
-
spinner,
|
|
3743
|
+
spinner: silence ? undefined : spinner,
|
|
3741
3744
|
coanaVersion: options?.coanaVersion
|
|
3742
3745
|
}, {
|
|
3743
3746
|
stdio: 'pipe'
|
|
@@ -3771,20 +3774,24 @@ async function coanaFix(fixConfig) {
|
|
|
3771
3774
|
outputFile,
|
|
3772
3775
|
prLimit,
|
|
3773
3776
|
showAffectedDirectDependencies,
|
|
3777
|
+
silence,
|
|
3774
3778
|
spinner
|
|
3775
3779
|
} = fixConfig;
|
|
3776
3780
|
const fixEnv = await getFixEnv();
|
|
3777
3781
|
require$$9.debugDir('inspect', {
|
|
3778
3782
|
fixEnv
|
|
3779
3783
|
});
|
|
3780
|
-
|
|
3784
|
+
if (!silence) {
|
|
3785
|
+
spinner?.start();
|
|
3786
|
+
}
|
|
3781
3787
|
const sockSdkCResult = await utils.setupSdk();
|
|
3782
3788
|
if (!sockSdkCResult.ok) {
|
|
3783
3789
|
return sockSdkCResult;
|
|
3784
3790
|
}
|
|
3785
3791
|
const sockSdk = sockSdkCResult.data;
|
|
3786
3792
|
const supportedFilesCResult = await fetchSupportedScanFileNames({
|
|
3787
|
-
spinner
|
|
3793
|
+
spinner: silence ? undefined : spinner,
|
|
3794
|
+
silence
|
|
3788
3795
|
});
|
|
3789
3796
|
if (!supportedFilesCResult.ok) {
|
|
3790
3797
|
return supportedFilesCResult;
|
|
@@ -3798,14 +3805,17 @@ async function coanaFix(fixConfig) {
|
|
|
3798
3805
|
const filepathsToUpload = scanFilepaths.filter(p => path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON);
|
|
3799
3806
|
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, filepathsToUpload, cwd), {
|
|
3800
3807
|
description: 'upload manifests',
|
|
3801
|
-
spinner
|
|
3808
|
+
spinner,
|
|
3809
|
+
silence
|
|
3802
3810
|
});
|
|
3803
3811
|
if (!uploadCResult.ok) {
|
|
3804
3812
|
return uploadCResult;
|
|
3805
3813
|
}
|
|
3806
3814
|
const tarHash = uploadCResult.data.tarHash;
|
|
3807
3815
|
if (!tarHash) {
|
|
3808
|
-
|
|
3816
|
+
if (!silence) {
|
|
3817
|
+
spinner?.stop();
|
|
3818
|
+
}
|
|
3809
3819
|
return {
|
|
3810
3820
|
ok: false,
|
|
3811
3821
|
message: 'No tar hash returned from Socket API upload-manifest-files endpoint',
|
|
@@ -3816,12 +3826,12 @@ async function coanaFix(fixConfig) {
|
|
|
3816
3826
|
const shouldOpenPrs = fixEnv.isCi && fixEnv.repoInfo;
|
|
3817
3827
|
if (!shouldOpenPrs) {
|
|
3818
3828
|
// In local mode, if neither --all nor --id is provided, show deprecation warning.
|
|
3819
|
-
if (shouldDiscoverGhsaIds && !all) {
|
|
3829
|
+
if (!silence && shouldDiscoverGhsaIds && !all) {
|
|
3820
3830
|
logger.logger.warn('Implicit --all is deprecated in local mode and will be removed in a future release. Please use --all explicitly.');
|
|
3821
3831
|
}
|
|
3822
3832
|
|
|
3823
3833
|
// Inform user about local mode when fixes will be applied.
|
|
3824
|
-
if (applyFixes && ghsas.length) {
|
|
3834
|
+
if (!silence && applyFixes && ghsas.length) {
|
|
3825
3835
|
const envCheck = checkCiEnvVars();
|
|
3826
3836
|
if (envCheck.present.length) {
|
|
3827
3837
|
// Some CI vars are set but not all - show what's missing.
|
|
@@ -3839,10 +3849,13 @@ async function coanaFix(fixConfig) {
|
|
|
3839
3849
|
coanaVersion,
|
|
3840
3850
|
cwd,
|
|
3841
3851
|
ecosystems,
|
|
3852
|
+
silence,
|
|
3842
3853
|
spinner
|
|
3843
3854
|
}) : ghsas;
|
|
3844
3855
|
if (ids.length === 0) {
|
|
3845
|
-
|
|
3856
|
+
if (!silence) {
|
|
3857
|
+
spinner?.stop();
|
|
3858
|
+
}
|
|
3846
3859
|
return {
|
|
3847
3860
|
ok: true,
|
|
3848
3861
|
data: {
|
|
@@ -3858,10 +3871,12 @@ async function coanaFix(fixConfig) {
|
|
|
3858
3871
|
const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...ids, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(exclude.length ? ['--exclude', ...exclude] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(!applyFixes ? [constants.FLAG_DRY_RUN] : []), '--output-file', tmpFile, ...(debug ? ['--debug'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3859
3872
|
coanaVersion,
|
|
3860
3873
|
cwd,
|
|
3861
|
-
spinner,
|
|
3862
|
-
stdio: 'inherit'
|
|
3874
|
+
spinner: silence ? undefined : spinner,
|
|
3875
|
+
stdio: silence ? 'pipe' : 'inherit'
|
|
3863
3876
|
});
|
|
3864
|
-
|
|
3877
|
+
if (!silence) {
|
|
3878
|
+
spinner?.stop();
|
|
3879
|
+
}
|
|
3865
3880
|
if (!fixCResult.ok) {
|
|
3866
3881
|
return fixCResult;
|
|
3867
3882
|
}
|
|
@@ -3873,7 +3888,9 @@ async function coanaFix(fixConfig) {
|
|
|
3873
3888
|
|
|
3874
3889
|
// Copy to outputFile if provided.
|
|
3875
3890
|
if (outputFile) {
|
|
3876
|
-
|
|
3891
|
+
if (!silence) {
|
|
3892
|
+
logger.logger.info(`Copying fixes result to ${outputFile}`);
|
|
3893
|
+
}
|
|
3877
3894
|
const tmpContent = await fs$1.promises.readFile(tmpFile, 'utf8');
|
|
3878
3895
|
await fs$1.promises.writeFile(outputFile, tmpContent, 'utf8');
|
|
3879
3896
|
}
|
|
@@ -3919,6 +3936,7 @@ async function coanaFix(fixConfig) {
|
|
|
3919
3936
|
coanaVersion,
|
|
3920
3937
|
cwd,
|
|
3921
3938
|
ecosystems,
|
|
3939
|
+
silence,
|
|
3922
3940
|
spinner
|
|
3923
3941
|
}) : ghsas).slice(0, adjustedPrLimit);
|
|
3924
3942
|
}
|
|
@@ -3929,7 +3947,9 @@ async function coanaFix(fixConfig) {
|
|
|
3929
3947
|
require$$9.debugFn('notice', 'miss: no repo info detected');
|
|
3930
3948
|
}
|
|
3931
3949
|
if (!ids?.length || !fixEnv.repoInfo) {
|
|
3932
|
-
|
|
3950
|
+
if (!silence) {
|
|
3951
|
+
spinner?.stop();
|
|
3952
|
+
}
|
|
3933
3953
|
return {
|
|
3934
3954
|
ok: true,
|
|
3935
3955
|
data: {
|
|
@@ -3956,11 +3976,13 @@ async function coanaFix(fixConfig) {
|
|
|
3956
3976
|
const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ghsaId, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(exclude.length ? ['--exclude', ...exclude] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(debug ? ['--debug'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
|
|
3957
3977
|
coanaVersion,
|
|
3958
3978
|
cwd,
|
|
3959
|
-
spinner,
|
|
3960
|
-
stdio: 'inherit'
|
|
3979
|
+
spinner: silence ? undefined : spinner,
|
|
3980
|
+
stdio: silence ? 'pipe' : 'inherit'
|
|
3961
3981
|
});
|
|
3962
3982
|
if (!fixCResult.ok) {
|
|
3963
|
-
|
|
3983
|
+
if (!silence) {
|
|
3984
|
+
logger.logger.error(`Update failed for ${ghsaId}: ${utils.getErrorCause(fixCResult)}`);
|
|
3985
|
+
}
|
|
3964
3986
|
continue ghsaLoop;
|
|
3965
3987
|
}
|
|
3966
3988
|
|
|
@@ -3983,7 +4005,9 @@ async function coanaFix(fixConfig) {
|
|
|
3983
4005
|
});
|
|
3984
4006
|
if (existingOpenPrs.length > 0) {
|
|
3985
4007
|
const prNum = existingOpenPrs[0].number;
|
|
3986
|
-
|
|
4008
|
+
if (!silence) {
|
|
4009
|
+
logger.logger.info(`PR #${prNum} already exists for ${ghsaId}, skipping.`);
|
|
4010
|
+
}
|
|
3987
4011
|
require$$9.debugFn('notice', `skip: open PR #${prNum} exists for ${ghsaId}`);
|
|
3988
4012
|
continue ghsaLoop;
|
|
3989
4013
|
}
|
|
@@ -4001,7 +4025,9 @@ async function coanaFix(fixConfig) {
|
|
|
4001
4025
|
|
|
4002
4026
|
// Check for GitHub token before doing any git operations.
|
|
4003
4027
|
if (!fixEnv.githubToken) {
|
|
4004
|
-
|
|
4028
|
+
if (!silence) {
|
|
4029
|
+
logger.logger.error('Cannot create pull request: SOCKET_CLI_GITHUB_TOKEN environment variable is not set.\n' + 'Set SOCKET_CLI_GITHUB_TOKEN or GITHUB_TOKEN to enable PR creation.');
|
|
4030
|
+
}
|
|
4005
4031
|
require$$9.debugFn('error', `skip: missing GitHub token for ${ghsaId}`);
|
|
4006
4032
|
continue ghsaLoop;
|
|
4007
4033
|
}
|
|
@@ -4022,7 +4048,9 @@ async function coanaFix(fixConfig) {
|
|
|
4022
4048
|
// eslint-disable-next-line no-await-in-loop
|
|
4023
4049
|
await utils.gitPushBranch(branch, cwd));
|
|
4024
4050
|
if (!pushed) {
|
|
4025
|
-
|
|
4051
|
+
if (!silence) {
|
|
4052
|
+
logger.logger.warn(`Push failed for ${ghsaId}, skipping PR creation.`);
|
|
4053
|
+
}
|
|
4026
4054
|
// eslint-disable-next-line no-await-in-loop
|
|
4027
4055
|
await utils.gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4028
4056
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4049,23 +4077,29 @@ async function coanaFix(fixConfig) {
|
|
|
4049
4077
|
data
|
|
4050
4078
|
} = prResult.pr;
|
|
4051
4079
|
const prRef = `PR #${data.number}`;
|
|
4052
|
-
|
|
4080
|
+
if (!silence) {
|
|
4081
|
+
logger.logger.success(`Opened ${prRef} for ${ghsaId}.`);
|
|
4082
|
+
}
|
|
4053
4083
|
if (autopilot) {
|
|
4054
|
-
|
|
4055
|
-
|
|
4084
|
+
if (!silence) {
|
|
4085
|
+
logger.logger.indent();
|
|
4086
|
+
spinner?.indent();
|
|
4087
|
+
}
|
|
4056
4088
|
// eslint-disable-next-line no-await-in-loop
|
|
4057
4089
|
const {
|
|
4058
4090
|
details,
|
|
4059
4091
|
enabled
|
|
4060
4092
|
} = await utils.enablePrAutoMerge(data);
|
|
4061
|
-
if (
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4093
|
+
if (!silence) {
|
|
4094
|
+
if (enabled) {
|
|
4095
|
+
logger.logger.info(`Auto-merge enabled for ${prRef}.`);
|
|
4096
|
+
} else {
|
|
4097
|
+
const message = `Failed to enable auto-merge for ${prRef}${details ? `:\n${details.map(d => ` - ${d}`).join('\n')}` : '.'}`;
|
|
4098
|
+
logger.logger.error(message);
|
|
4099
|
+
}
|
|
4100
|
+
logger.logger.dedent();
|
|
4101
|
+
spinner?.dedent();
|
|
4066
4102
|
}
|
|
4067
|
-
logger.logger.dedent();
|
|
4068
|
-
spinner?.dedent();
|
|
4069
4103
|
}
|
|
4070
4104
|
|
|
4071
4105
|
// Clean up local branch only - keep remote branch for PR merge.
|
|
@@ -4074,22 +4108,32 @@ async function coanaFix(fixConfig) {
|
|
|
4074
4108
|
} else {
|
|
4075
4109
|
// Handle PR creation failures.
|
|
4076
4110
|
if (prResult.reason === 'already_exists') {
|
|
4077
|
-
|
|
4111
|
+
if (!silence) {
|
|
4112
|
+
logger.logger.info(`PR already exists for ${ghsaId} (this should not happen due to earlier check).`);
|
|
4113
|
+
}
|
|
4078
4114
|
// Don't delete branch - PR exists and needs it.
|
|
4079
4115
|
} else if (prResult.reason === 'validation_error') {
|
|
4080
|
-
|
|
4116
|
+
if (!silence) {
|
|
4117
|
+
logger.logger.error(`Failed to create PR for ${ghsaId}:\n${prResult.details}`);
|
|
4118
|
+
}
|
|
4081
4119
|
// eslint-disable-next-line no-await-in-loop
|
|
4082
4120
|
await cleanupFailedPrBranches(branch, cwd);
|
|
4083
4121
|
} else if (prResult.reason === 'permission_denied') {
|
|
4084
|
-
|
|
4122
|
+
if (!silence) {
|
|
4123
|
+
logger.logger.error(`Failed to create PR for ${ghsaId}: Permission denied. Check SOCKET_CLI_GITHUB_TOKEN permissions.`);
|
|
4124
|
+
}
|
|
4085
4125
|
// eslint-disable-next-line no-await-in-loop
|
|
4086
4126
|
await cleanupFailedPrBranches(branch, cwd);
|
|
4087
4127
|
} else if (prResult.reason === 'network_error') {
|
|
4088
|
-
|
|
4128
|
+
if (!silence) {
|
|
4129
|
+
logger.logger.error(`Failed to create PR for ${ghsaId}: Network error. Please try again.`);
|
|
4130
|
+
}
|
|
4089
4131
|
// eslint-disable-next-line no-await-in-loop
|
|
4090
4132
|
await cleanupFailedPrBranches(branch, cwd);
|
|
4091
4133
|
} else {
|
|
4092
|
-
|
|
4134
|
+
if (!silence) {
|
|
4135
|
+
logger.logger.error(`Failed to create PR for ${ghsaId}: ${prResult.error.message}`);
|
|
4136
|
+
}
|
|
4093
4137
|
// eslint-disable-next-line no-await-in-loop
|
|
4094
4138
|
await cleanupFailedPrBranches(branch, cwd);
|
|
4095
4139
|
}
|
|
@@ -4101,7 +4145,9 @@ async function coanaFix(fixConfig) {
|
|
|
4101
4145
|
// eslint-disable-next-line no-await-in-loop
|
|
4102
4146
|
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4103
4147
|
} catch (e) {
|
|
4104
|
-
|
|
4148
|
+
if (!silence) {
|
|
4149
|
+
logger.logger.warn(`Unexpected condition: Push failed for ${ghsaId}, skipping PR creation.`);
|
|
4150
|
+
}
|
|
4105
4151
|
require$$9.debugDir('error', e);
|
|
4106
4152
|
// Clean up branches (push may have succeeded before error).
|
|
4107
4153
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -4119,7 +4165,9 @@ async function coanaFix(fixConfig) {
|
|
|
4119
4165
|
break ghsaLoop;
|
|
4120
4166
|
}
|
|
4121
4167
|
}
|
|
4122
|
-
|
|
4168
|
+
if (!silence) {
|
|
4169
|
+
spinner?.stop();
|
|
4170
|
+
}
|
|
4123
4171
|
return {
|
|
4124
4172
|
ok: true,
|
|
4125
4173
|
data: {
|
|
@@ -4150,7 +4198,13 @@ const CVE_FORMAT_REGEXP = /^CVE-\d{4}-\d{4,}$/;
|
|
|
4150
4198
|
* Converts mixed CVE/GHSA/PURL IDs to GHSA IDs only.
|
|
4151
4199
|
* Filters out invalid IDs and logs conversion results.
|
|
4152
4200
|
*/
|
|
4153
|
-
async function convertIdsToGhsas(ids) {
|
|
4201
|
+
async function convertIdsToGhsas(ids, options) {
|
|
4202
|
+
const {
|
|
4203
|
+
silence = false
|
|
4204
|
+
} = {
|
|
4205
|
+
__proto__: null,
|
|
4206
|
+
...options
|
|
4207
|
+
};
|
|
4154
4208
|
require$$9.debugFn('notice', `Converting ${ids.length} IDs to GHSA format`);
|
|
4155
4209
|
require$$9.debugDir('inspect', {
|
|
4156
4210
|
ids
|
|
@@ -4177,17 +4231,21 @@ async function convertIdsToGhsas(ids) {
|
|
|
4177
4231
|
const conversionResult = await utils.convertCveToGhsa(trimmedId);
|
|
4178
4232
|
if (conversionResult.ok) {
|
|
4179
4233
|
validGhsas.push(conversionResult.data);
|
|
4180
|
-
|
|
4234
|
+
if (!silence) {
|
|
4235
|
+
logger.logger.info(`Converted ${trimmedId} to ${conversionResult.data}`);
|
|
4236
|
+
}
|
|
4181
4237
|
} else {
|
|
4182
4238
|
errors.push(`${trimmedId}: ${conversionResult.message}`);
|
|
4183
4239
|
}
|
|
4184
4240
|
} else if (trimmedId.startsWith('pkg:')) {
|
|
4185
|
-
// Convert PURL to GHSAs
|
|
4241
|
+
// Convert PURL to GHSAs.
|
|
4186
4242
|
// eslint-disable-next-line no-await-in-loop
|
|
4187
4243
|
const conversionResult = await utils.convertPurlToGhsas(trimmedId);
|
|
4188
4244
|
if (conversionResult.ok && conversionResult.data.length) {
|
|
4189
4245
|
validGhsas.push(...conversionResult.data);
|
|
4190
|
-
|
|
4246
|
+
if (!silence) {
|
|
4247
|
+
logger.logger.info(`Converted ${trimmedId} to ${conversionResult.data.length} GHSA(s): ${arrays.joinAnd(conversionResult.data)}`);
|
|
4248
|
+
}
|
|
4191
4249
|
} else {
|
|
4192
4250
|
errors.push(`${trimmedId}: ${conversionResult.message || 'No GHSAs found'}`);
|
|
4193
4251
|
}
|
|
@@ -4197,7 +4255,9 @@ async function convertIdsToGhsas(ids) {
|
|
|
4197
4255
|
}
|
|
4198
4256
|
}
|
|
4199
4257
|
if (errors.length) {
|
|
4200
|
-
|
|
4258
|
+
if (!silence) {
|
|
4259
|
+
logger.logger.warn(`Skipped ${errors.length} invalid IDs:\n${errors.map(e => ` - ${e}`).join('\n')}`);
|
|
4260
|
+
}
|
|
4201
4261
|
require$$9.debugDir('inspect', {
|
|
4202
4262
|
errors
|
|
4203
4263
|
});
|
|
@@ -4229,6 +4289,7 @@ async function handleFix({
|
|
|
4229
4289
|
prLimit,
|
|
4230
4290
|
rangeStyle,
|
|
4231
4291
|
showAffectedDirectDependencies,
|
|
4292
|
+
silence,
|
|
4232
4293
|
spinner,
|
|
4233
4294
|
unknownFlags
|
|
4234
4295
|
}) {
|
|
@@ -4253,6 +4314,7 @@ async function handleFix({
|
|
|
4253
4314
|
prLimit,
|
|
4254
4315
|
rangeStyle,
|
|
4255
4316
|
showAffectedDirectDependencies,
|
|
4317
|
+
silence,
|
|
4256
4318
|
unknownFlags
|
|
4257
4319
|
});
|
|
4258
4320
|
await outputFixResult(await coanaFix({
|
|
@@ -4266,7 +4328,9 @@ async function handleFix({
|
|
|
4266
4328
|
ecosystems,
|
|
4267
4329
|
exclude,
|
|
4268
4330
|
// Convert mixed CVE/GHSA/PURL inputs to GHSA IDs only.
|
|
4269
|
-
ghsas: await convertIdsToGhsas(ghsas
|
|
4331
|
+
ghsas: await convertIdsToGhsas(ghsas, {
|
|
4332
|
+
silence
|
|
4333
|
+
}),
|
|
4270
4334
|
include,
|
|
4271
4335
|
minimumReleaseAge,
|
|
4272
4336
|
minSatisfying,
|
|
@@ -4276,12 +4340,13 @@ async function handleFix({
|
|
|
4276
4340
|
prLimit,
|
|
4277
4341
|
rangeStyle,
|
|
4278
4342
|
showAffectedDirectDependencies,
|
|
4343
|
+
silence,
|
|
4279
4344
|
spinner,
|
|
4280
4345
|
unknownFlags
|
|
4281
4346
|
}), outputKind);
|
|
4282
4347
|
}
|
|
4283
4348
|
|
|
4284
|
-
const CMD_NAME$
|
|
4349
|
+
const CMD_NAME$s = 'fix';
|
|
4285
4350
|
const DEFAULT_LIMIT = 10;
|
|
4286
4351
|
const description$z = 'Fix CVEs in dependencies';
|
|
4287
4352
|
const hidden$s = false;
|
|
@@ -4386,6 +4451,11 @@ Available styles:
|
|
|
4386
4451
|
type: 'boolean',
|
|
4387
4452
|
default: false,
|
|
4388
4453
|
description: 'List the direct dependencies responsible for introducing transitive vulnerabilities and list the updates required to resolve the vulnerabilities'
|
|
4454
|
+
},
|
|
4455
|
+
silence: {
|
|
4456
|
+
type: 'boolean',
|
|
4457
|
+
default: false,
|
|
4458
|
+
description: 'Silence all output except the final result'
|
|
4389
4459
|
}
|
|
4390
4460
|
};
|
|
4391
4461
|
const hiddenFlags = {
|
|
@@ -4440,7 +4510,7 @@ async function run$K(argv, importMeta, {
|
|
|
4440
4510
|
parentName
|
|
4441
4511
|
}) {
|
|
4442
4512
|
const config = {
|
|
4443
|
-
commandName: CMD_NAME$
|
|
4513
|
+
commandName: CMD_NAME$s,
|
|
4444
4514
|
description: description$z,
|
|
4445
4515
|
hidden: hidden$s,
|
|
4446
4516
|
flags: {
|
|
@@ -4454,7 +4524,7 @@ async function run$K(argv, importMeta, {
|
|
|
4454
4524
|
$ ${command} [options] [CWD=.]
|
|
4455
4525
|
|
|
4456
4526
|
API Token Requirements
|
|
4457
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
4527
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$s}`)}
|
|
4458
4528
|
|
|
4459
4529
|
Options
|
|
4460
4530
|
${utils.getFlagListOutput({
|
|
@@ -4511,6 +4581,7 @@ async function run$K(argv, importMeta, {
|
|
|
4511
4581
|
prLimit,
|
|
4512
4582
|
rangeStyle,
|
|
4513
4583
|
showAffectedDirectDependencies,
|
|
4584
|
+
silence,
|
|
4514
4585
|
// We patched in this feature with `npx custompatch meow` at
|
|
4515
4586
|
// socket-cli/patches/meow#13.2.0.patch.
|
|
4516
4587
|
unknownFlags = []
|
|
@@ -4559,7 +4630,7 @@ async function run$K(argv, importMeta, {
|
|
|
4559
4630
|
logger.logger.log(constants.default.DRY_RUN_NOT_SAVING);
|
|
4560
4631
|
return;
|
|
4561
4632
|
}
|
|
4562
|
-
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
4633
|
+
const orgSlugCResult = await utils.getDefaultOrgSlug(silence);
|
|
4563
4634
|
if (!orgSlugCResult.ok) {
|
|
4564
4635
|
process.exitCode = orgSlugCResult.code ?? 1;
|
|
4565
4636
|
logger.logger.fail(`${constants.ERROR_UNABLE_RESOLVE_ORG}.\nEnsure a Socket API token is specified for the organization using the SOCKET_CLI_API_TOKEN environment variable.`);
|
|
@@ -4596,6 +4667,7 @@ async function run$K(argv, importMeta, {
|
|
|
4596
4667
|
prLimit,
|
|
4597
4668
|
rangeStyle,
|
|
4598
4669
|
showAffectedDirectDependencies,
|
|
4670
|
+
silence,
|
|
4599
4671
|
spinner,
|
|
4600
4672
|
unknownFlags
|
|
4601
4673
|
});
|
|
@@ -4995,7 +5067,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
4995
5067
|
}
|
|
4996
5068
|
}
|
|
4997
5069
|
|
|
4998
|
-
const CMD_NAME$
|
|
5070
|
+
const CMD_NAME$r = 'login';
|
|
4999
5071
|
const description$x = 'Setup Socket CLI with an API token and defaults';
|
|
5000
5072
|
const hidden$r = false;
|
|
5001
5073
|
const cmdLogin = {
|
|
@@ -5007,7 +5079,7 @@ async function run$H(argv, importMeta, {
|
|
|
5007
5079
|
parentName
|
|
5008
5080
|
}) {
|
|
5009
5081
|
const config = {
|
|
5010
|
-
commandName: CMD_NAME$
|
|
5082
|
+
commandName: CMD_NAME$r,
|
|
5011
5083
|
description: description$x,
|
|
5012
5084
|
hidden: hidden$r,
|
|
5013
5085
|
flags: {
|
|
@@ -5028,7 +5100,7 @@ async function run$H(argv, importMeta, {
|
|
|
5028
5100
|
$ ${command} [options]
|
|
5029
5101
|
|
|
5030
5102
|
API Token Requirements
|
|
5031
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
5103
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$r}`)}
|
|
5032
5104
|
|
|
5033
5105
|
Logs into the Socket API by prompting for an API token
|
|
5034
5106
|
|
|
@@ -6770,7 +6842,7 @@ async function run$y(argv, importMeta, {
|
|
|
6770
6842
|
}
|
|
6771
6843
|
|
|
6772
6844
|
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$
|
|
6845
|
+
const CMD_NAME$q = constants.NPM;
|
|
6774
6846
|
const description$w = 'Wraps npm with Socket security scanning';
|
|
6775
6847
|
const hidden$q = false;
|
|
6776
6848
|
const cmdNpm = {
|
|
@@ -6786,7 +6858,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6786
6858
|
...context
|
|
6787
6859
|
};
|
|
6788
6860
|
const config = {
|
|
6789
|
-
commandName: CMD_NAME$
|
|
6861
|
+
commandName: CMD_NAME$q,
|
|
6790
6862
|
description: description$w,
|
|
6791
6863
|
hidden: hidden$q,
|
|
6792
6864
|
flags: {
|
|
@@ -6797,7 +6869,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6797
6869
|
$ ${command} ...
|
|
6798
6870
|
|
|
6799
6871
|
API Token Requirements
|
|
6800
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
6872
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$q}`)}
|
|
6801
6873
|
|
|
6802
6874
|
Note: Everything after "${constants.NPM}" is passed to the ${constants.NPM} command.
|
|
6803
6875
|
Only the \`${constants.FLAG_DRY_RUN}\` and \`${constants.FLAG_HELP}\` flags are caught here.
|
|
@@ -6856,7 +6928,7 @@ async function run$x(argv, importMeta, context) {
|
|
|
6856
6928
|
}
|
|
6857
6929
|
|
|
6858
6930
|
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$
|
|
6931
|
+
const CMD_NAME$p = constants.NPX;
|
|
6860
6932
|
const description$v = 'Wraps npx with Socket security scanning';
|
|
6861
6933
|
const hidden$p = false;
|
|
6862
6934
|
const cmdNpx = {
|
|
@@ -6868,7 +6940,7 @@ async function run$w(argv, importMeta, {
|
|
|
6868
6940
|
parentName
|
|
6869
6941
|
}) {
|
|
6870
6942
|
const config = {
|
|
6871
|
-
commandName: CMD_NAME$
|
|
6943
|
+
commandName: CMD_NAME$p,
|
|
6872
6944
|
description: description$v,
|
|
6873
6945
|
hidden: hidden$p,
|
|
6874
6946
|
flags: {
|
|
@@ -6879,7 +6951,7 @@ async function run$w(argv, importMeta, {
|
|
|
6879
6951
|
$ ${command} ...
|
|
6880
6952
|
|
|
6881
6953
|
API Token Requirements
|
|
6882
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
6954
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$p}`)}
|
|
6883
6955
|
|
|
6884
6956
|
Note: Everything after "${constants.NPX}" is passed to the ${constants.NPX} command.
|
|
6885
6957
|
Only the \`${constants.FLAG_DRY_RUN}\` and \`${constants.FLAG_HELP}\` flags are caught here.
|
|
@@ -7390,7 +7462,7 @@ async function listPackages(pkgEnvDetails, options) {
|
|
|
7390
7462
|
}
|
|
7391
7463
|
}
|
|
7392
7464
|
|
|
7393
|
-
const CMD_NAME$
|
|
7465
|
+
const CMD_NAME$o = 'socket optimize';
|
|
7394
7466
|
|
|
7395
7467
|
const {
|
|
7396
7468
|
BUN,
|
|
@@ -7562,7 +7634,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
7562
7634
|
npmExecPath === constants.NPM && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
7563
7635
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
7564
7636
|
spinner?.stop();
|
|
7565
|
-
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$
|
|
7637
|
+
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$o, `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``));
|
|
7566
7638
|
spinner?.start();
|
|
7567
7639
|
}
|
|
7568
7640
|
const overridesDataObjects = [];
|
|
@@ -7790,7 +7862,7 @@ async function applyOptimization(pkgEnvDetails, {
|
|
|
7790
7862
|
const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
|
|
7791
7863
|
if (pkgJsonChanged || pkgEnvDetails.features.npmBuggyOverrides) {
|
|
7792
7864
|
const result = await updateLockfile(pkgEnvDetails, {
|
|
7793
|
-
cmdName: CMD_NAME$
|
|
7865
|
+
cmdName: CMD_NAME$o,
|
|
7794
7866
|
logger: logger.logger,
|
|
7795
7867
|
spinner
|
|
7796
7868
|
});
|
|
@@ -7859,7 +7931,7 @@ async function handleOptimize({
|
|
|
7859
7931
|
prod
|
|
7860
7932
|
});
|
|
7861
7933
|
const pkgEnvCResult = await utils.detectAndValidatePackageEnvironment(cwd, {
|
|
7862
|
-
cmdName: CMD_NAME$
|
|
7934
|
+
cmdName: CMD_NAME$o,
|
|
7863
7935
|
logger: logger.logger,
|
|
7864
7936
|
prod
|
|
7865
7937
|
});
|
|
@@ -7897,7 +7969,7 @@ async function handleOptimize({
|
|
|
7897
7969
|
await outputOptimizeResult({
|
|
7898
7970
|
ok: false,
|
|
7899
7971
|
message: 'Unsupported',
|
|
7900
|
-
cause: utils.cmdPrefixMessage(CMD_NAME$
|
|
7972
|
+
cause: utils.cmdPrefixMessage(CMD_NAME$o, `${agent} v${agentVersion} does not support overrides.`)
|
|
7901
7973
|
}, outputKind);
|
|
7902
7974
|
return;
|
|
7903
7975
|
}
|
|
@@ -7917,7 +7989,7 @@ async function handleOptimize({
|
|
|
7917
7989
|
await outputOptimizeResult(optimizationResult, outputKind);
|
|
7918
7990
|
}
|
|
7919
7991
|
|
|
7920
|
-
const CMD_NAME$
|
|
7992
|
+
const CMD_NAME$n = 'optimize';
|
|
7921
7993
|
const description$u = 'Optimize dependencies with @socketregistry overrides';
|
|
7922
7994
|
const hidden$o = false;
|
|
7923
7995
|
const cmdOptimize = {
|
|
@@ -7929,7 +8001,7 @@ async function run$u(argv, importMeta, {
|
|
|
7929
8001
|
parentName
|
|
7930
8002
|
}) {
|
|
7931
8003
|
const config = {
|
|
7932
|
-
commandName: CMD_NAME$
|
|
8004
|
+
commandName: CMD_NAME$n,
|
|
7933
8005
|
description: description$u,
|
|
7934
8006
|
hidden: hidden$o,
|
|
7935
8007
|
flags: {
|
|
@@ -7950,7 +8022,7 @@ async function run$u(argv, importMeta, {
|
|
|
7950
8022
|
$ ${command} [options] [CWD=.]
|
|
7951
8023
|
|
|
7952
8024
|
API Token Requirements
|
|
7953
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8025
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$n}`)}
|
|
7954
8026
|
|
|
7955
8027
|
Options
|
|
7956
8028
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8103,7 +8175,7 @@ async function handleDependencies({
|
|
|
8103
8175
|
});
|
|
8104
8176
|
}
|
|
8105
8177
|
|
|
8106
|
-
const CMD_NAME$
|
|
8178
|
+
const CMD_NAME$m = 'dependencies';
|
|
8107
8179
|
const description$t = 'Search for any dependency that is being used in your organization';
|
|
8108
8180
|
const hidden$n = false;
|
|
8109
8181
|
const cmdOrganizationDependencies = {
|
|
@@ -8115,7 +8187,7 @@ async function run$t(argv, importMeta, {
|
|
|
8115
8187
|
parentName
|
|
8116
8188
|
}) {
|
|
8117
8189
|
const config = {
|
|
8118
|
-
commandName: CMD_NAME$
|
|
8190
|
+
commandName: CMD_NAME$m,
|
|
8119
8191
|
description: description$t,
|
|
8120
8192
|
hidden: hidden$n,
|
|
8121
8193
|
flags: {
|
|
@@ -8137,7 +8209,7 @@ async function run$t(argv, importMeta, {
|
|
|
8137
8209
|
${command} [options]
|
|
8138
8210
|
|
|
8139
8211
|
API Token Requirements
|
|
8140
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8212
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$m}`)}
|
|
8141
8213
|
|
|
8142
8214
|
Options
|
|
8143
8215
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8237,7 +8309,7 @@ async function handleLicensePolicy(orgSlug, outputKind) {
|
|
|
8237
8309
|
await outputLicensePolicy(data, outputKind);
|
|
8238
8310
|
}
|
|
8239
8311
|
|
|
8240
|
-
const CMD_NAME$
|
|
8312
|
+
const CMD_NAME$l = 'license';
|
|
8241
8313
|
const description$s = 'Retrieve the license policy of an organization';
|
|
8242
8314
|
const hidden$m = false;
|
|
8243
8315
|
const cmdOrganizationPolicyLicense = {
|
|
@@ -8249,7 +8321,7 @@ async function run$s(argv, importMeta, {
|
|
|
8249
8321
|
parentName
|
|
8250
8322
|
}) {
|
|
8251
8323
|
const config = {
|
|
8252
|
-
commandName: CMD_NAME$
|
|
8324
|
+
commandName: CMD_NAME$l,
|
|
8253
8325
|
description: description$s,
|
|
8254
8326
|
hidden: hidden$m,
|
|
8255
8327
|
flags: {
|
|
@@ -8270,7 +8342,7 @@ async function run$s(argv, importMeta, {
|
|
|
8270
8342
|
$ ${command} [options]
|
|
8271
8343
|
|
|
8272
8344
|
API Token Requirements
|
|
8273
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8345
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$l}`)}
|
|
8274
8346
|
|
|
8275
8347
|
Options
|
|
8276
8348
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8373,7 +8445,7 @@ async function handleSecurityPolicy(orgSlug, outputKind) {
|
|
|
8373
8445
|
await outputSecurityPolicy(data, outputKind);
|
|
8374
8446
|
}
|
|
8375
8447
|
|
|
8376
|
-
const CMD_NAME$
|
|
8448
|
+
const CMD_NAME$k = 'security';
|
|
8377
8449
|
const description$r = 'Retrieve the security policy of an organization';
|
|
8378
8450
|
const hidden$l = true;
|
|
8379
8451
|
const cmdOrganizationPolicySecurity = {
|
|
@@ -8385,7 +8457,7 @@ async function run$r(argv, importMeta, {
|
|
|
8385
8457
|
parentName
|
|
8386
8458
|
}) {
|
|
8387
8459
|
const config = {
|
|
8388
|
-
commandName: CMD_NAME$
|
|
8460
|
+
commandName: CMD_NAME$k,
|
|
8389
8461
|
description: description$r,
|
|
8390
8462
|
hidden: hidden$l,
|
|
8391
8463
|
flags: {
|
|
@@ -8406,7 +8478,7 @@ async function run$r(argv, importMeta, {
|
|
|
8406
8478
|
$ ${command} [options]
|
|
8407
8479
|
|
|
8408
8480
|
API Token Requirements
|
|
8409
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8481
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$k}`)}
|
|
8410
8482
|
|
|
8411
8483
|
Options
|
|
8412
8484
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8518,7 +8590,7 @@ async function handleOrganizationList(outputKind = 'text') {
|
|
|
8518
8590
|
await outputOrganizationList(data, outputKind);
|
|
8519
8591
|
}
|
|
8520
8592
|
|
|
8521
|
-
const CMD_NAME$
|
|
8593
|
+
const CMD_NAME$j = 'list';
|
|
8522
8594
|
const description$q = 'List organizations associated with the Socket API token';
|
|
8523
8595
|
const hidden$k = false;
|
|
8524
8596
|
const cmdOrganizationList = {
|
|
@@ -8530,7 +8602,7 @@ async function run$q(argv, importMeta, {
|
|
|
8530
8602
|
parentName
|
|
8531
8603
|
}) {
|
|
8532
8604
|
const config = {
|
|
8533
|
-
commandName: CMD_NAME$
|
|
8605
|
+
commandName: CMD_NAME$j,
|
|
8534
8606
|
description: description$q,
|
|
8535
8607
|
hidden: hidden$k,
|
|
8536
8608
|
flags: {
|
|
@@ -8542,7 +8614,7 @@ async function run$q(argv, importMeta, {
|
|
|
8542
8614
|
$ ${command} [options]
|
|
8543
8615
|
|
|
8544
8616
|
API Token Requirements
|
|
8545
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
8617
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$j}`)}
|
|
8546
8618
|
|
|
8547
8619
|
Options
|
|
8548
8620
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8984,7 +9056,7 @@ function parsePackageSpecifiers(ecosystem, pkgs) {
|
|
|
8984
9056
|
};
|
|
8985
9057
|
}
|
|
8986
9058
|
|
|
8987
|
-
const CMD_NAME$
|
|
9059
|
+
const CMD_NAME$i = 'score';
|
|
8988
9060
|
const description$n = 'Look up score for one package which reflects all of its transitive dependencies as well';
|
|
8989
9061
|
const hidden$j = false;
|
|
8990
9062
|
const cmdPackageScore = {
|
|
@@ -8996,7 +9068,7 @@ async function run$o(argv, importMeta, {
|
|
|
8996
9068
|
parentName
|
|
8997
9069
|
}) {
|
|
8998
9070
|
const config = {
|
|
8999
|
-
commandName: CMD_NAME$
|
|
9071
|
+
commandName: CMD_NAME$i,
|
|
9000
9072
|
description: description$n,
|
|
9001
9073
|
hidden: hidden$j,
|
|
9002
9074
|
flags: {
|
|
@@ -9008,7 +9080,7 @@ async function run$o(argv, importMeta, {
|
|
|
9008
9080
|
$ ${command} [options] <<ECOSYSTEM> <NAME> | <PURL>>
|
|
9009
9081
|
|
|
9010
9082
|
API Token Requirements
|
|
9011
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9083
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$i}`)}
|
|
9012
9084
|
|
|
9013
9085
|
Options
|
|
9014
9086
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9375,7 +9447,7 @@ async function handlePurlsShallowScore({
|
|
|
9375
9447
|
outputPurlsShallowScore(purls, packageData, outputKind);
|
|
9376
9448
|
}
|
|
9377
9449
|
|
|
9378
|
-
const CMD_NAME$
|
|
9450
|
+
const CMD_NAME$h = 'shallow';
|
|
9379
9451
|
const description$m = 'Look up info regarding one or more packages but not their transitives';
|
|
9380
9452
|
const hidden$i = false;
|
|
9381
9453
|
const cmdPackageShallow = {
|
|
@@ -9394,7 +9466,7 @@ async function run$n(argv, importMeta, {
|
|
|
9394
9466
|
parentName
|
|
9395
9467
|
}) {
|
|
9396
9468
|
const config = {
|
|
9397
|
-
commandName: CMD_NAME$
|
|
9469
|
+
commandName: CMD_NAME$h,
|
|
9398
9470
|
description: description$m,
|
|
9399
9471
|
hidden: hidden$i,
|
|
9400
9472
|
flags: {
|
|
@@ -9406,7 +9478,7 @@ async function run$n(argv, importMeta, {
|
|
|
9406
9478
|
$ ${command} [options] <<ECOSYSTEM> <PKGNAME> [<PKGNAME> ...] | <PURL> [<PURL> ...]>
|
|
9407
9479
|
|
|
9408
9480
|
API Token Requirements
|
|
9409
|
-
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$
|
|
9481
|
+
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$h}`)}
|
|
9410
9482
|
|
|
9411
9483
|
Options
|
|
9412
9484
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -9508,472 +9580,48 @@ const cmdPackage = {
|
|
|
9508
9580
|
}
|
|
9509
9581
|
};
|
|
9510
9582
|
|
|
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
|
-
}
|
|
9583
|
+
const description$k = 'Manage CVE patches for dependencies';
|
|
9584
|
+
const hidden$h = false;
|
|
9585
|
+
const cmdPatch = {
|
|
9586
|
+
description: description$k,
|
|
9587
|
+
hidden: hidden$h,
|
|
9588
|
+
run: run$m
|
|
9589
|
+
};
|
|
9590
|
+
async function run$m(argv, _importMeta, _context) {
|
|
9547
9591
|
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
|
-
}
|
|
9592
|
+
ENV
|
|
9593
|
+
} = constants.default;
|
|
9563
9594
|
|
|
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
|
-
}
|
|
9595
|
+
// Map socket-cli environment to socket-patch options.
|
|
9596
|
+
// Only include properties with defined values (exactOptionalPropertyTypes).
|
|
9597
|
+
const options = {};
|
|
9615
9598
|
|
|
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
|
-
}
|
|
9599
|
+
// Strip /v0/ suffix from API URL if present.
|
|
9600
|
+
const apiUrl = ENV.SOCKET_CLI_API_BASE_URL?.replace(/\/v0\/?$/, '');
|
|
9601
|
+
if (apiUrl) {
|
|
9602
|
+
options.apiUrl = apiUrl;
|
|
9651
9603
|
}
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
if (wasSpinning) {
|
|
9655
|
-
spinner.start();
|
|
9604
|
+
if (ENV.SOCKET_CLI_API_TOKEN) {
|
|
9605
|
+
options.apiToken = ENV.SOCKET_CLI_API_TOKEN;
|
|
9656
9606
|
}
|
|
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
|
-
};
|
|
9678
|
-
}
|
|
9679
|
-
}
|
|
9680
|
-
async function findNodeModulesPaths(cwd) {
|
|
9681
|
-
const rootNmPath = await utils.findUp(constants.NODE_MODULES, {
|
|
9682
|
-
cwd,
|
|
9683
|
-
onlyDirectories: true
|
|
9684
|
-
});
|
|
9685
|
-
if (!rootNmPath) {
|
|
9686
|
-
return [];
|
|
9687
|
-
}
|
|
9688
|
-
return await vendor.outExports.glob([`**/${constants.NODE_MODULES}`], {
|
|
9689
|
-
absolute: true,
|
|
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;
|
|
9607
|
+
if (ENV.SOCKET_CLI_ORG_SLUG) {
|
|
9608
|
+
options.orgSlug = ENV.SOCKET_CLI_ORG_SLUG;
|
|
9713
9609
|
}
|
|
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;
|
|
9721
|
-
}
|
|
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;
|
|
9610
|
+
if (ENV.SOCKET_PATCH_PROXY_URL) {
|
|
9611
|
+
options.patchProxyUrl = ENV.SOCKET_PATCH_PROXY_URL;
|
|
9731
9612
|
}
|
|
9732
|
-
if (
|
|
9733
|
-
|
|
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;
|
|
9613
|
+
if (ENV.SOCKET_CLI_API_PROXY) {
|
|
9614
|
+
options.httpProxy = ENV.SOCKET_CLI_API_PROXY;
|
|
9743
9615
|
}
|
|
9744
|
-
|
|
9745
|
-
|
|
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);
|
|
9616
|
+
if (ENV.SOCKET_CLI_DEBUG) {
|
|
9617
|
+
options.debug = ENV.SOCKET_CLI_DEBUG;
|
|
9884
9618
|
}
|
|
9885
|
-
}
|
|
9886
|
-
|
|
9887
|
-
const CMD_NAME$h = 'patch';
|
|
9888
|
-
const description$k = 'Apply CVE patches to dependencies';
|
|
9889
|
-
const hidden$h = true;
|
|
9890
|
-
const cmdPatch = {
|
|
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
9619
|
|
|
9917
|
-
|
|
9918
|
-
|
|
9919
|
-
|
|
9920
|
-
|
|
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;
|
|
9620
|
+
// Forward all arguments to socket-patch.
|
|
9621
|
+
const exitCode = await vendor.runExports.runPatch([...argv], options);
|
|
9622
|
+
if (exitCode !== 0) {
|
|
9623
|
+
process.exitCode = exitCode;
|
|
9951
9624
|
}
|
|
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
9625
|
}
|
|
9978
9626
|
|
|
9979
9627
|
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 +10899,12 @@ const reachabilityFlags = {
|
|
|
11251
10899
|
isMultiple: true,
|
|
11252
10900
|
description: 'List of paths to exclude from reachability analysis, as either a comma separated value or as multiple flags.'
|
|
11253
10901
|
},
|
|
10902
|
+
reachLazyMode: {
|
|
10903
|
+
type: 'boolean',
|
|
10904
|
+
default: false,
|
|
10905
|
+
description: 'Enable lazy mode for reachability analysis.',
|
|
10906
|
+
hidden: true
|
|
10907
|
+
},
|
|
11254
10908
|
reachSkipCache: {
|
|
11255
10909
|
type: 'boolean',
|
|
11256
10910
|
default: false,
|
|
@@ -11503,6 +11157,7 @@ async function run$d(argv, importMeta, {
|
|
|
11503
11157
|
reachDebug,
|
|
11504
11158
|
reachDisableAnalysisSplitting,
|
|
11505
11159
|
reachDisableAnalytics,
|
|
11160
|
+
reachLazyMode,
|
|
11506
11161
|
reachSkipCache,
|
|
11507
11162
|
reachUseOnlyPregeneratedSboms,
|
|
11508
11163
|
reachVersion,
|
|
@@ -11634,7 +11289,7 @@ async function run$d(argv, importMeta, {
|
|
|
11634
11289
|
const isUsingNonDefaultConcurrency = reachConcurrency !== reachabilityFlags['reachConcurrency']?.default;
|
|
11635
11290
|
const isUsingNonDefaultAnalytics = reachDisableAnalytics !== reachabilityFlags['reachDisableAnalytics']?.default;
|
|
11636
11291
|
const isUsingNonDefaultVersion = reachVersion !== reachabilityFlags['reachVersion']?.default;
|
|
11637
|
-
const isUsingAnyReachabilityFlags = hasReachEcosystems || hasReachExcludePaths || isUsingNonDefaultAnalytics || isUsingNonDefaultConcurrency || isUsingNonDefaultMemoryLimit || isUsingNonDefaultTimeout || isUsingNonDefaultVersion || reachDisableAnalysisSplitting || reachSkipCache || reachUseOnlyPregeneratedSboms;
|
|
11292
|
+
const isUsingAnyReachabilityFlags = hasReachEcosystems || hasReachExcludePaths || isUsingNonDefaultAnalytics || isUsingNonDefaultConcurrency || isUsingNonDefaultMemoryLimit || isUsingNonDefaultTimeout || isUsingNonDefaultVersion || reachDisableAnalysisSplitting || reachLazyMode || reachSkipCache || reachUseOnlyPregeneratedSboms;
|
|
11638
11293
|
|
|
11639
11294
|
// Validate target constraints when --reach is enabled.
|
|
11640
11295
|
const reachTargetValidation = reach ? await validateReachabilityTarget(targets, cwd) : {
|
|
@@ -11727,6 +11382,7 @@ async function run$d(argv, importMeta, {
|
|
|
11727
11382
|
reachDisableAnalytics: Boolean(reachDisableAnalytics),
|
|
11728
11383
|
reachEcosystems,
|
|
11729
11384
|
reachExcludePaths,
|
|
11385
|
+
reachLazyMode: Boolean(reachLazyMode),
|
|
11730
11386
|
reachSkipCache: Boolean(reachSkipCache),
|
|
11731
11387
|
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
|
|
11732
11388
|
reachVersion,
|
|
@@ -12377,6 +12033,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
12377
12033
|
reachDisableAnalytics: false,
|
|
12378
12034
|
reachEcosystems: [],
|
|
12379
12035
|
reachExcludePaths: [],
|
|
12036
|
+
reachLazyMode: false,
|
|
12380
12037
|
reachSkipCache: false,
|
|
12381
12038
|
reachUseOnlyPregeneratedSboms: false,
|
|
12382
12039
|
reachVersion: undefined,
|
|
@@ -13666,6 +13323,7 @@ async function run$7(argv, importMeta, {
|
|
|
13666
13323
|
reachDebug,
|
|
13667
13324
|
reachDisableAnalysisSplitting,
|
|
13668
13325
|
reachDisableAnalytics,
|
|
13326
|
+
reachLazyMode,
|
|
13669
13327
|
reachSkipCache,
|
|
13670
13328
|
reachUseOnlyPregeneratedSboms,
|
|
13671
13329
|
reachVersion
|
|
@@ -13766,6 +13424,7 @@ async function run$7(argv, importMeta, {
|
|
|
13766
13424
|
reachDisableAnalytics: Boolean(reachDisableAnalytics),
|
|
13767
13425
|
reachEcosystems,
|
|
13768
13426
|
reachExcludePaths,
|
|
13427
|
+
reachLazyMode: Boolean(reachLazyMode),
|
|
13769
13428
|
reachSkipCache: Boolean(reachSkipCache),
|
|
13770
13429
|
reachUseOnlyPregeneratedSboms: Boolean(reachUseOnlyPregeneratedSboms),
|
|
13771
13430
|
reachVersion
|
|
@@ -15680,5 +15339,5 @@ process.on('unhandledRejection', async (reason, promise) => {
|
|
|
15680
15339
|
// eslint-disable-next-line n/no-process-exit
|
|
15681
15340
|
process.exit(1);
|
|
15682
15341
|
});
|
|
15683
|
-
//# debugId=
|
|
15342
|
+
//# debugId=5b7cab4d-0164-4136-aa68-598e06dbdd58
|
|
15684
15343
|
//# sourceMappingURL=cli.js.map
|