@socketsecurity/cli-with-sentry 1.0.21 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +435 -403
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +14 -8
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-inject.js +63 -4
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/fix/agent-fix.d.mts +3 -5
- package/dist/types/commands/fix/agent-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/fix-branch-helpers.d.mts +3 -4
- package/dist/types/commands/fix/fix-branch-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/fix-env-helpers.d.mts +9 -9
- package/dist/types/commands/fix/fix-env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/git.d.mts +1 -0
- package/dist/types/commands/fix/git.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/{open-pr.d.mts → pull-request.d.mts} +11 -6
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -0
- package/dist/types/commands/fix/shared.d.mts +1 -2
- package/dist/types/commands/fix/shared.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-gradle.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-kotlin.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-scala.d.mts.map +1 -1
- package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
- package/dist/types/commands/repository/fetch-list-all-repos.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/setup-scan-config.d.mts.map +1 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +1 -1
- package/dist/types/constants.d.mts +2 -0
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts +0 -1
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/npm-config.d.mts +14 -0
- package/dist/types/utils/npm-config.d.mts.map +1 -0
- package/dist/types/utils/npm-paths.d.mts +2 -2
- package/dist/types/utils/npm-paths.d.mts.map +1 -1
- package/dist/types/utils/output-formatting.d.mts +3 -2
- package/dist/types/utils/output-formatting.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts +1 -2
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/types/utils/socketjson.d.mts.map +1 -1
- package/dist/utils.js +172 -86
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +66974 -66974
- package/external/@coana-tech/cli/cli.mjs +60278 -55993
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/input.js +10 -2
- package/external/@socketsecurity/registry/external/@inquirer/password.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/search.js +1 -1
- package/external/@socketsecurity/registry/external/@inquirer/select.js +1 -1
- package/external/@socketsecurity/registry/external/browserslist.js +572 -570
- package/external/@socketsecurity/registry/external/debug.js +1163 -0
- package/external/@socketsecurity/registry/lib/constants/env.js +9 -4
- package/external/@socketsecurity/registry/lib/debug.js +139 -47
- package/external/@socketsecurity/registry/lib/logger.js +2 -2
- package/external/@socketsecurity/registry/lib/packages.js +1 -2
- package/external/@socketsecurity/registry/lib/prompts.js +1 -1
- package/package.json +22 -22
- package/dist/types/commands/fix/open-pr.d.mts.map +0 -1
- package/dist/types/shadow/npm/proc-log/index.d.mts +0 -3
- package/dist/types/shadow/npm/proc-log/index.d.mts.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -22,8 +22,8 @@ var sorts = require('../external/@socketsecurity/registry/lib/sorts');
|
|
|
22
22
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
23
23
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
24
24
|
var regexps = require('../external/@socketsecurity/registry/lib/regexps');
|
|
25
|
-
var shadowNpmInject = require('./shadow-npm-inject.js');
|
|
26
25
|
var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
|
|
26
|
+
var shadowNpmInject = require('./shadow-npm-inject.js');
|
|
27
27
|
var objects = require('../external/@socketsecurity/registry/lib/objects');
|
|
28
28
|
var shadowNpmBin = require('./shadow-npm-bin.js');
|
|
29
29
|
var require$$7 = require('../external/@socketsecurity/registry/lib/promises');
|
|
@@ -333,7 +333,7 @@ const config$P = {
|
|
|
333
333
|
The TIME argument must be number 7, 30, or 90 and defaults to 30.
|
|
334
334
|
|
|
335
335
|
Options
|
|
336
|
-
${utils.getFlagListOutput(flags
|
|
336
|
+
${utils.getFlagListOutput(flags)}
|
|
337
337
|
|
|
338
338
|
Examples
|
|
339
339
|
$ ${command} org 7
|
|
@@ -591,7 +591,10 @@ ${table}
|
|
|
591
591
|
} catch (e) {
|
|
592
592
|
process.exitCode = 1;
|
|
593
593
|
logger.logger.fail('There was a problem converting the logs to Markdown, please try the `--json` flag');
|
|
594
|
-
debug.debugFn('
|
|
594
|
+
debug.debugFn('error', 'caught: unexpected error');
|
|
595
|
+
debug.debugDir('inspect', {
|
|
596
|
+
error: e
|
|
597
|
+
});
|
|
595
598
|
return 'Failed to generate the markdown report';
|
|
596
599
|
}
|
|
597
600
|
}
|
|
@@ -776,7 +779,7 @@ const config$O = {
|
|
|
776
779
|
The page arg should be a positive integer, offset 1. Defaults to 1.
|
|
777
780
|
|
|
778
781
|
Options
|
|
779
|
-
${utils.getFlagListOutput(config.flags
|
|
782
|
+
${utils.getFlagListOutput(config.flags)}
|
|
780
783
|
|
|
781
784
|
Examples
|
|
782
785
|
$ ${command}
|
|
@@ -863,7 +866,7 @@ async function run$O(argv, importMeta, {
|
|
|
863
866
|
async function getDefaultOrgSlug() {
|
|
864
867
|
const defaultOrgResult = utils.getConfigValueOrUndef('defaultOrg');
|
|
865
868
|
if (defaultOrgResult) {
|
|
866
|
-
debug.debugFn('use: default org', defaultOrgResult);
|
|
869
|
+
debug.debugFn('notice', 'use: default org', defaultOrgResult);
|
|
867
870
|
return {
|
|
868
871
|
ok: true,
|
|
869
872
|
data: defaultOrgResult
|
|
@@ -895,7 +898,7 @@ async function getDefaultOrgSlug() {
|
|
|
895
898
|
data: `Was unable to determine the default organization for the current API token. Unable to continue.`
|
|
896
899
|
};
|
|
897
900
|
}
|
|
898
|
-
debug.debugFn('resolve: org', slug);
|
|
901
|
+
debug.debugFn('notice', 'resolve: org', slug);
|
|
899
902
|
return {
|
|
900
903
|
ok: true,
|
|
901
904
|
message: 'Retrieved default org from server',
|
|
@@ -999,7 +1002,10 @@ async function fetchReportData(orgSlug, scanId, includeLicensePolicy) {
|
|
|
999
1002
|
return JSON.parse(line);
|
|
1000
1003
|
} catch {
|
|
1001
1004
|
ok = false;
|
|
1002
|
-
debug.debugFn('fail: parse NDJSON
|
|
1005
|
+
debug.debugFn('error', 'fail: parse NDJSON');
|
|
1006
|
+
debug.debugDir('inspect', {
|
|
1007
|
+
line
|
|
1008
|
+
});
|
|
1003
1009
|
return;
|
|
1004
1010
|
}
|
|
1005
1011
|
});
|
|
@@ -1497,28 +1503,28 @@ sockJson, cwd = process.cwd()) {
|
|
|
1497
1503
|
sbt: false
|
|
1498
1504
|
};
|
|
1499
1505
|
if (sockJson?.defaults?.manifest?.sbt?.disabled) {
|
|
1500
|
-
debug.debugLog('[DEBUG] - sbt auto-detection is disabled in socket.json');
|
|
1506
|
+
debug.debugLog('notice', '[DEBUG] - sbt auto-detection is disabled in socket.json');
|
|
1501
1507
|
} else if (fs$1.existsSync(path.join(cwd, 'build.sbt'))) {
|
|
1502
|
-
debug.debugLog('[DEBUG] - Detected a Scala sbt build file');
|
|
1508
|
+
debug.debugLog('notice', '[DEBUG] - Detected a Scala sbt build file');
|
|
1503
1509
|
output.sbt = true;
|
|
1504
1510
|
output.count += 1;
|
|
1505
1511
|
}
|
|
1506
1512
|
if (sockJson?.defaults?.manifest?.gradle?.disabled) {
|
|
1507
|
-
debug.debugLog('[DEBUG] - gradle auto-detection is disabled in socket.json');
|
|
1513
|
+
debug.debugLog('notice', '[DEBUG] - gradle auto-detection is disabled in socket.json');
|
|
1508
1514
|
} else if (fs$1.existsSync(path.join(cwd, 'gradlew'))) {
|
|
1509
|
-
debug.debugLog('[DEBUG] - Detected a gradle build file');
|
|
1515
|
+
debug.debugLog('notice', '[DEBUG] - Detected a gradle build file');
|
|
1510
1516
|
output.gradle = true;
|
|
1511
1517
|
output.count += 1;
|
|
1512
1518
|
}
|
|
1513
1519
|
if (sockJson?.defaults?.manifest?.conda?.disabled) {
|
|
1514
|
-
debug.debugLog('[DEBUG] - conda auto-detection is disabled in socket.json');
|
|
1520
|
+
debug.debugLog('notice', '[DEBUG] - conda auto-detection is disabled in socket.json');
|
|
1515
1521
|
} else {
|
|
1516
1522
|
const envyml = path.join(cwd, 'environment.yml');
|
|
1517
1523
|
const hasEnvyml = fs$1.existsSync(envyml);
|
|
1518
1524
|
const envyaml = path.join(cwd, 'environment.yaml');
|
|
1519
1525
|
const hasEnvyaml = !hasEnvyml && fs$1.existsSync(envyaml);
|
|
1520
1526
|
if (hasEnvyml || hasEnvyaml) {
|
|
1521
|
-
debug.debugLog('[DEBUG] - Detected an environment.yml Conda file');
|
|
1527
|
+
debug.debugLog('notice', '[DEBUG] - Detected an environment.yml Conda file');
|
|
1522
1528
|
output.conda = true;
|
|
1523
1529
|
output.count += 1;
|
|
1524
1530
|
}
|
|
@@ -2103,7 +2109,7 @@ const config$N = {
|
|
|
2103
2109
|
$ ${command} [options]
|
|
2104
2110
|
|
|
2105
2111
|
Options
|
|
2106
|
-
${utils.getFlagListOutput(config$N.flags
|
|
2112
|
+
${utils.getFlagListOutput(config$N.flags)}
|
|
2107
2113
|
|
|
2108
2114
|
This command is intended to use in CI runs to allow automated systems to
|
|
2109
2115
|
accept or reject a current build. When the scan does not pass your security
|
|
@@ -2395,7 +2401,7 @@ const config$M = {
|
|
|
2395
2401
|
$ ${command} [options] KEY
|
|
2396
2402
|
|
|
2397
2403
|
Options
|
|
2398
|
-
${utils.getFlagListOutput(config.flags
|
|
2404
|
+
${utils.getFlagListOutput(config.flags)}
|
|
2399
2405
|
|
|
2400
2406
|
Attempt to automatically discover the correct value for given config KEY.
|
|
2401
2407
|
|
|
@@ -2516,7 +2522,7 @@ const config$L = {
|
|
|
2516
2522
|
config then the value will come from that override.
|
|
2517
2523
|
|
|
2518
2524
|
Options
|
|
2519
|
-
${utils.getFlagListOutput(config.flags
|
|
2525
|
+
${utils.getFlagListOutput(config.flags)}
|
|
2520
2526
|
|
|
2521
2527
|
KEY is an enum. Valid keys:
|
|
2522
2528
|
|
|
@@ -2659,7 +2665,7 @@ const config$K = {
|
|
|
2659
2665
|
$ ${command} [options]
|
|
2660
2666
|
|
|
2661
2667
|
Options
|
|
2662
|
-
${utils.getFlagListOutput(config.flags
|
|
2668
|
+
${utils.getFlagListOutput(config.flags)}
|
|
2663
2669
|
|
|
2664
2670
|
Examples
|
|
2665
2671
|
$ ${command}
|
|
@@ -2760,7 +2766,7 @@ const config$J = {
|
|
|
2760
2766
|
$ ${command} [options] <KEY> <VALUE>
|
|
2761
2767
|
|
|
2762
2768
|
Options
|
|
2763
|
-
${utils.getFlagListOutput(config.flags
|
|
2769
|
+
${utils.getFlagListOutput(config.flags)}
|
|
2764
2770
|
|
|
2765
2771
|
This is a crude way of updating the local configuration for this CLI tool.
|
|
2766
2772
|
|
|
@@ -2886,7 +2892,7 @@ const config$I = {
|
|
|
2886
2892
|
$ ${command} [options] <KEY> <VALUE>
|
|
2887
2893
|
|
|
2888
2894
|
Options
|
|
2889
|
-
${utils.getFlagListOutput(config.flags
|
|
2895
|
+
${utils.getFlagListOutput(config.flags)}
|
|
2890
2896
|
|
|
2891
2897
|
Removes a value from a config key, allowing the default value to be used
|
|
2892
2898
|
for it instead.
|
|
@@ -2992,6 +2998,7 @@ function createSocketBranchParser(options) {
|
|
|
2992
2998
|
};
|
|
2993
2999
|
};
|
|
2994
3000
|
}
|
|
3001
|
+
const genericSocketBranchParser = createSocketBranchParser();
|
|
2995
3002
|
async function getBaseGitBranch(cwd = process.cwd()) {
|
|
2996
3003
|
// Lazily access constants.ENV properties.
|
|
2997
3004
|
const {
|
|
@@ -3024,17 +3031,17 @@ async function getBaseGitBranch(cwd = process.cwd()) {
|
|
|
3024
3031
|
}
|
|
3025
3032
|
function getSocketBranchFullNameComponent(pkgName) {
|
|
3026
3033
|
const purlObj = utils.getPurlObject(typeof pkgName === 'string' && !pkgName.startsWith('pkg:') ? vendor.packageurlJsExports.PackageURL.fromString(`pkg:unknown/${pkgName}`) : pkgName);
|
|
3027
|
-
const
|
|
3028
|
-
return `${
|
|
3034
|
+
const branchMaybeNamespace = purlObj.namespace ? `${formatBranchName(purlObj.namespace)}--` : '';
|
|
3035
|
+
return `${branchMaybeNamespace}${formatBranchName(purlObj.name)}`;
|
|
3029
3036
|
}
|
|
3030
3037
|
function getSocketBranchName(purl, newVersion, workspace) {
|
|
3031
3038
|
const purlObj = utils.getPurlObject(purl);
|
|
3032
|
-
const
|
|
3033
|
-
const
|
|
3034
|
-
const
|
|
3035
|
-
const
|
|
3036
|
-
const
|
|
3037
|
-
return `socket/${
|
|
3039
|
+
const branchType = getSocketBranchPurlTypeComponent(purlObj);
|
|
3040
|
+
const branchWorkspace = getSocketBranchWorkspaceComponent(workspace);
|
|
3041
|
+
const branchFullName = getSocketBranchFullNameComponent(purlObj);
|
|
3042
|
+
const branchVersion = getSocketBranchPackageVersionComponent(purlObj.version);
|
|
3043
|
+
const branchNewVersion = formatBranchName(newVersion);
|
|
3044
|
+
return `socket/${branchType}/${branchWorkspace}/${branchFullName}_${branchVersion}_${branchNewVersion}`;
|
|
3038
3045
|
}
|
|
3039
3046
|
function getSocketBranchPackageVersionComponent(version) {
|
|
3040
3047
|
const purlObj = utils.getPurlObject(typeof version === 'string' && !version.startsWith('pkg:') ? vendor.packageurlJsExports.PackageURL.fromString(`pkg:unknown/unknown@${version}`) : version);
|
|
@@ -3112,7 +3119,7 @@ async function gitCreateAndPushBranch(branch, commitMsg, filepaths, options) {
|
|
|
3112
3119
|
await spawn.spawn('git', ['push', '--force', '--set-upstream', 'origin', branch], stdioIgnoreOptions);
|
|
3113
3120
|
return true;
|
|
3114
3121
|
} catch (e) {
|
|
3115
|
-
debug.debugFn(`
|
|
3122
|
+
debug.debugFn('error', `caught: git push --force --set-upstream origin ${branch} failed\n`, e);
|
|
3116
3123
|
}
|
|
3117
3124
|
try {
|
|
3118
3125
|
// Will throw with exit code 1 if branch does not exist.
|
|
@@ -3146,9 +3153,15 @@ async function gitRepoInfo(cwd = process.cwd()) {
|
|
|
3146
3153
|
};
|
|
3147
3154
|
}
|
|
3148
3155
|
} catch {}
|
|
3149
|
-
debug.debugFn('git: unmatched git remote URL format'
|
|
3156
|
+
debug.debugFn('error', 'git: unmatched git remote URL format');
|
|
3157
|
+
debug.debugDir('inspect', {
|
|
3158
|
+
remoteUrl
|
|
3159
|
+
});
|
|
3150
3160
|
} catch (e) {
|
|
3151
|
-
debug.debugFn('
|
|
3161
|
+
debug.debugFn('error', 'caught: `git remote get-url origin` failed');
|
|
3162
|
+
debug.debugDir('inspect', {
|
|
3163
|
+
error: e
|
|
3164
|
+
});
|
|
3152
3165
|
}
|
|
3153
3166
|
return null;
|
|
3154
3167
|
}
|
|
@@ -3174,7 +3187,10 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
3174
3187
|
try {
|
|
3175
3188
|
await spawn.spawn('git', ['config', prop, value], stdioIgnoreOptions);
|
|
3176
3189
|
} catch (e) {
|
|
3177
|
-
debug.debugFn(`
|
|
3190
|
+
debug.debugFn('error', `caught: git config ${prop} ${value} failed`);
|
|
3191
|
+
debug.debugDir('inspect', {
|
|
3192
|
+
error: e
|
|
3193
|
+
});
|
|
3178
3194
|
}
|
|
3179
3195
|
}
|
|
3180
3196
|
}));
|
|
@@ -3213,7 +3229,10 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
3213
3229
|
data: rawRelPaths.map(relPath => path$1.normalizePath(relPath))
|
|
3214
3230
|
};
|
|
3215
3231
|
} catch (e) {
|
|
3216
|
-
debug.debugFn('
|
|
3232
|
+
debug.debugFn('error', 'caught: git diff --name-only failed');
|
|
3233
|
+
debug.debugDir('inspect', {
|
|
3234
|
+
error: e
|
|
3235
|
+
});
|
|
3217
3236
|
return {
|
|
3218
3237
|
ok: false,
|
|
3219
3238
|
message: 'Git Error',
|
|
@@ -3222,41 +3241,32 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
3222
3241
|
}
|
|
3223
3242
|
}
|
|
3224
3243
|
|
|
3225
|
-
function
|
|
3226
|
-
if (!
|
|
3244
|
+
function getPrsForPurl(fixEnv, partialPurl) {
|
|
3245
|
+
if (!fixEnv) {
|
|
3227
3246
|
return [];
|
|
3228
3247
|
}
|
|
3229
|
-
const
|
|
3248
|
+
const prs = [];
|
|
3230
3249
|
const partialPurlObj = utils.getPurlObject(partialPurl);
|
|
3231
3250
|
const branchFullName = getSocketBranchFullNameComponent(partialPurlObj);
|
|
3232
3251
|
const branchPurlType = getSocketBranchPurlTypeComponent(partialPurlObj);
|
|
3233
|
-
for (const pr of
|
|
3234
|
-
const parsedBranch =
|
|
3252
|
+
for (const pr of fixEnv.prs) {
|
|
3253
|
+
const parsedBranch = genericSocketBranchParser(pr.headRefName);
|
|
3235
3254
|
if (branchPurlType === parsedBranch?.type && branchFullName === parsedBranch?.fullName) {
|
|
3236
|
-
|
|
3255
|
+
prs.push(pr);
|
|
3237
3256
|
}
|
|
3238
3257
|
}
|
|
3239
|
-
if (debug.isDebug()) {
|
|
3258
|
+
if (debug.isDebug('notice,inspect')) {
|
|
3240
3259
|
const fullName = packages.resolvePackageName(partialPurlObj);
|
|
3241
|
-
if (
|
|
3242
|
-
debug.debugFn(`found: ${
|
|
3243
|
-
|
|
3244
|
-
|
|
3260
|
+
if (prs.length) {
|
|
3261
|
+
debug.debugFn('notice', `found: ${prs.length} PRs for ${fullName}`);
|
|
3262
|
+
debug.debugDir('inspect', {
|
|
3263
|
+
prs
|
|
3264
|
+
});
|
|
3265
|
+
} else if (fixEnv.prs.length) {
|
|
3266
|
+
debug.debugFn('notice', `miss: 0 PRs found for ${fullName}`);
|
|
3245
3267
|
}
|
|
3246
3268
|
}
|
|
3247
|
-
return
|
|
3248
|
-
}
|
|
3249
|
-
|
|
3250
|
-
async function getActualTree(cwd = process.cwd()) {
|
|
3251
|
-
// @npmcli/arborist DOES have partial support for pnpm structured node_modules
|
|
3252
|
-
// folders. However, support is iffy resulting in unhappy path errors and hangs.
|
|
3253
|
-
// So, to avoid the unhappy path, we restrict our usage to --dry-run loading
|
|
3254
|
-
// of the node_modules folder.
|
|
3255
|
-
const arb = new shadowNpmInject.Arborist({
|
|
3256
|
-
path: cwd,
|
|
3257
|
-
...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
3258
|
-
});
|
|
3259
|
-
return await arb.loadActual();
|
|
3269
|
+
return prs;
|
|
3260
3270
|
}
|
|
3261
3271
|
|
|
3262
3272
|
let _octokit;
|
|
@@ -3267,10 +3277,12 @@ function getOctokit() {
|
|
|
3267
3277
|
SOCKET_CLI_GITHUB_TOKEN
|
|
3268
3278
|
} = constants.ENV;
|
|
3269
3279
|
if (!SOCKET_CLI_GITHUB_TOKEN) {
|
|
3270
|
-
debug.debugFn('miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
3280
|
+
debug.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
3271
3281
|
}
|
|
3272
3282
|
_octokit = new vendor.Octokit({
|
|
3273
|
-
auth: SOCKET_CLI_GITHUB_TOKEN
|
|
3283
|
+
auth: SOCKET_CLI_GITHUB_TOKEN,
|
|
3284
|
+
// Lazily access constants.ENV.GITHUB_API_URL.
|
|
3285
|
+
baseUrl: constants.ENV.GITHUB_API_URL
|
|
3274
3286
|
});
|
|
3275
3287
|
}
|
|
3276
3288
|
return _octokit;
|
|
@@ -3283,7 +3295,7 @@ function getOctokitGraphql() {
|
|
|
3283
3295
|
SOCKET_CLI_GITHUB_TOKEN
|
|
3284
3296
|
} = constants.ENV;
|
|
3285
3297
|
if (!SOCKET_CLI_GITHUB_TOKEN) {
|
|
3286
|
-
debug.debugFn('miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
3298
|
+
debug.debugFn('notice', 'miss: SOCKET_CLI_GITHUB_TOKEN env var');
|
|
3287
3299
|
}
|
|
3288
3300
|
_octokitGraphql = vendor.graphql2.defaults({
|
|
3289
3301
|
headers: {
|
|
@@ -3333,8 +3345,8 @@ async function writeCache(key, data) {
|
|
|
3333
3345
|
}
|
|
3334
3346
|
await fs$2.writeJson(cacheJsonPath, data);
|
|
3335
3347
|
}
|
|
3336
|
-
async function
|
|
3337
|
-
const contextualMatches = await
|
|
3348
|
+
async function cleanupPrs(owner, repo, options) {
|
|
3349
|
+
const contextualMatches = await getSocketPrsWithContext(owner, repo, options);
|
|
3338
3350
|
if (!contextualMatches.length) {
|
|
3339
3351
|
return [];
|
|
3340
3352
|
}
|
|
@@ -3367,14 +3379,14 @@ async function cleanupOpenPrs(owner, repo, options) {
|
|
|
3367
3379
|
pull_number: prNum,
|
|
3368
3380
|
state: 'closed'
|
|
3369
3381
|
});
|
|
3370
|
-
debug.debugFn(`close: ${prRef} for ${prToVersion}`);
|
|
3382
|
+
debug.debugFn('notice', `close: ${prRef} for ${prToVersion}`);
|
|
3371
3383
|
// Remove entry from parent object.
|
|
3372
3384
|
context.parent.splice(context.index, 1);
|
|
3373
3385
|
// Mark cache to be saved.
|
|
3374
3386
|
cachesToSave.set(context.cacheKey, context.data);
|
|
3375
3387
|
return null;
|
|
3376
3388
|
} catch (e) {
|
|
3377
|
-
debug.debugFn(`fail: close ${prRef} for ${prToVersion}\n`, e?.message || 'unknown error');
|
|
3389
|
+
debug.debugFn('error', `fail: close ${prRef} for ${prToVersion}\n`, e?.message || 'unknown error');
|
|
3378
3390
|
}
|
|
3379
3391
|
}
|
|
3380
3392
|
// Update stale PRs.
|
|
@@ -3387,7 +3399,7 @@ async function cleanupOpenPrs(owner, repo, options) {
|
|
|
3387
3399
|
base: match.headRefName,
|
|
3388
3400
|
head: match.baseRefName
|
|
3389
3401
|
});
|
|
3390
|
-
debug.debugFn('update: stale', prRef);
|
|
3402
|
+
debug.debugFn('notice', 'update: stale', prRef);
|
|
3391
3403
|
// Update entry entry.
|
|
3392
3404
|
if (context.apiType === 'graphql') {
|
|
3393
3405
|
context.entry.mergeStateStatus = 'CLEAN';
|
|
@@ -3398,7 +3410,7 @@ async function cleanupOpenPrs(owner, repo, options) {
|
|
|
3398
3410
|
cachesToSave.set(context.cacheKey, context.data);
|
|
3399
3411
|
} catch (e) {
|
|
3400
3412
|
const message = e?.message || 'Unknown error';
|
|
3401
|
-
debug.debugFn(`fail: update ${prRef} - ${message}`);
|
|
3413
|
+
debug.debugFn('error', `fail: update ${prRef} - ${message}`);
|
|
3402
3414
|
}
|
|
3403
3415
|
}
|
|
3404
3416
|
return match;
|
|
@@ -3442,8 +3454,8 @@ async function enablePrAutoMerge({
|
|
|
3442
3454
|
}
|
|
3443
3455
|
if (error instanceof vendor.GraphqlResponseError && Array.isArray(error.errors) && error.errors.length) {
|
|
3444
3456
|
const details = error.errors.map(({
|
|
3445
|
-
message
|
|
3446
|
-
}) =>
|
|
3457
|
+
message: m
|
|
3458
|
+
}) => m.trim());
|
|
3447
3459
|
return {
|
|
3448
3460
|
enabled: false,
|
|
3449
3461
|
details
|
|
@@ -3453,30 +3465,30 @@ async function enablePrAutoMerge({
|
|
|
3453
3465
|
enabled: false
|
|
3454
3466
|
};
|
|
3455
3467
|
}
|
|
3456
|
-
async function
|
|
3457
|
-
return (await
|
|
3468
|
+
async function getSocketPrs(owner, repo, options) {
|
|
3469
|
+
return (await getSocketPrsWithContext(owner, repo, options)).map(d => d.match);
|
|
3458
3470
|
}
|
|
3459
|
-
async function
|
|
3460
|
-
const
|
|
3471
|
+
async function getSocketPrsWithContext(owner, repo, options) {
|
|
3472
|
+
const {
|
|
3473
|
+
author,
|
|
3474
|
+
states: statesValue = 'all'
|
|
3475
|
+
} = {
|
|
3461
3476
|
__proto__: null,
|
|
3462
|
-
...
|
|
3477
|
+
...options
|
|
3463
3478
|
};
|
|
3464
|
-
const {
|
|
3465
|
-
author
|
|
3466
|
-
} = options;
|
|
3467
3479
|
const checkAuthor = strings.isNonEmptyString(author);
|
|
3468
3480
|
const octokit = getOctokit();
|
|
3469
3481
|
const octokitGraphql = getOctokitGraphql();
|
|
3470
|
-
const branchPattern = getSocketBranchPattern(options);
|
|
3471
3482
|
const contextualMatches = [];
|
|
3483
|
+
const states = (typeof statesValue === 'string' ? statesValue.toLowerCase() === 'all' ? ['OPEN', 'CLOSED', 'MERGED'] : [statesValue] : statesValue).map(s => s.toUpperCase());
|
|
3472
3484
|
try {
|
|
3473
3485
|
// Optimistically fetch only the first 50 open PRs using GraphQL to minimize
|
|
3474
3486
|
// API quota usage. Fallback to REST if no matching PRs are found.
|
|
3475
3487
|
const gqlCacheKey = `${repo}-pr-graphql-snapshot`;
|
|
3476
3488
|
const gqlResp = await cacheFetch(gqlCacheKey, () => octokitGraphql(`
|
|
3477
|
-
query($owner: String!, $repo: String!) {
|
|
3489
|
+
query($owner: String!, $repo: String!, $states: [PullRequestState!]) {
|
|
3478
3490
|
repository(owner: $owner, name: $repo) {
|
|
3479
|
-
pullRequests(first: 50, states:
|
|
3491
|
+
pullRequests(first: 50, states: $states, orderBy: {field: CREATED_AT, direction: DESC}) {
|
|
3480
3492
|
nodes {
|
|
3481
3493
|
author {
|
|
3482
3494
|
login
|
|
@@ -3485,6 +3497,7 @@ async function getOpenSocketPrsWithContext(owner, repo, options_) {
|
|
|
3485
3497
|
headRefName
|
|
3486
3498
|
mergeStateStatus
|
|
3487
3499
|
number
|
|
3500
|
+
state
|
|
3488
3501
|
title
|
|
3489
3502
|
}
|
|
3490
3503
|
}
|
|
@@ -3492,7 +3505,8 @@ async function getOpenSocketPrsWithContext(owner, repo, options_) {
|
|
|
3492
3505
|
}
|
|
3493
3506
|
`, {
|
|
3494
3507
|
owner,
|
|
3495
|
-
repo
|
|
3508
|
+
repo,
|
|
3509
|
+
states
|
|
3496
3510
|
}));
|
|
3497
3511
|
const nodes = gqlResp?.repository?.pullRequests?.nodes ?? [];
|
|
3498
3512
|
for (let i = 0, {
|
|
@@ -3501,8 +3515,8 @@ async function getOpenSocketPrsWithContext(owner, repo, options_) {
|
|
|
3501
3515
|
const node = nodes[i];
|
|
3502
3516
|
const login = node.author?.login;
|
|
3503
3517
|
const matchesAuthor = checkAuthor ? login === author : true;
|
|
3504
|
-
const
|
|
3505
|
-
if (matchesAuthor &&
|
|
3518
|
+
const parsedBranch = genericSocketBranchParser(node.headRefName);
|
|
3519
|
+
if (matchesAuthor && parsedBranch) {
|
|
3506
3520
|
contextualMatches.push({
|
|
3507
3521
|
context: {
|
|
3508
3522
|
apiType: 'graphql',
|
|
@@ -3514,7 +3528,8 @@ async function getOpenSocketPrsWithContext(owner, repo, options_) {
|
|
|
3514
3528
|
},
|
|
3515
3529
|
match: {
|
|
3516
3530
|
...node,
|
|
3517
|
-
author: login ?? '<unknown>'
|
|
3531
|
+
author: login ?? '<unknown>',
|
|
3532
|
+
parsedBranch
|
|
3518
3533
|
}
|
|
3519
3534
|
});
|
|
3520
3535
|
}
|
|
@@ -3525,44 +3540,52 @@ async function getOpenSocketPrsWithContext(owner, repo, options_) {
|
|
|
3525
3540
|
}
|
|
3526
3541
|
|
|
3527
3542
|
// Fallback to REST if GraphQL found no matching PRs.
|
|
3528
|
-
let
|
|
3529
|
-
const cacheKey = `${repo}-
|
|
3543
|
+
let allPrs;
|
|
3544
|
+
const cacheKey = `${repo}-pull-requests`;
|
|
3530
3545
|
try {
|
|
3531
|
-
|
|
3546
|
+
allPrs = await cacheFetch(cacheKey, async () => await octokit.paginate(octokit.pulls.list, {
|
|
3532
3547
|
owner,
|
|
3533
3548
|
repo,
|
|
3534
|
-
state: '
|
|
3549
|
+
state: 'all',
|
|
3535
3550
|
per_page: 100
|
|
3536
3551
|
}));
|
|
3537
3552
|
} catch {}
|
|
3538
|
-
if (!
|
|
3553
|
+
if (!allPrs) {
|
|
3539
3554
|
return contextualMatches;
|
|
3540
3555
|
}
|
|
3541
3556
|
for (let i = 0, {
|
|
3542
3557
|
length
|
|
3543
|
-
} =
|
|
3544
|
-
const pr =
|
|
3558
|
+
} = allPrs; i < length; i += 1) {
|
|
3559
|
+
const pr = allPrs[i];
|
|
3545
3560
|
const login = pr.user?.login;
|
|
3561
|
+
const headRefName = pr.head.ref;
|
|
3546
3562
|
const matchesAuthor = checkAuthor ? login === author : true;
|
|
3547
|
-
const
|
|
3548
|
-
if (matchesAuthor &&
|
|
3563
|
+
const parsedBranch = genericSocketBranchParser(headRefName);
|
|
3564
|
+
if (matchesAuthor && parsedBranch) {
|
|
3565
|
+
// Upper cased mergeable_state is equivalent to mergeStateStatus.
|
|
3566
|
+
// https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
|
|
3567
|
+
const mergeStateStatus = pr.mergeable_state?.toUpperCase?.() ?? 'UNKNOWN';
|
|
3568
|
+
// The REST API does not have a distinct merged state for pull requests.
|
|
3569
|
+
// Instead, a merged pull request is represented as a closed pull request
|
|
3570
|
+
// with a non-null merged_at timestamp.
|
|
3571
|
+
const state = pr.merged_at ? 'MERGED' : pr.state.toUpperCase();
|
|
3549
3572
|
contextualMatches.push({
|
|
3550
3573
|
context: {
|
|
3551
3574
|
apiType: 'rest',
|
|
3552
3575
|
cacheKey,
|
|
3553
|
-
data:
|
|
3576
|
+
data: allPrs,
|
|
3554
3577
|
entry: pr,
|
|
3555
3578
|
index: i,
|
|
3556
|
-
parent:
|
|
3579
|
+
parent: allPrs
|
|
3557
3580
|
},
|
|
3558
3581
|
match: {
|
|
3559
3582
|
author: login ?? '<unknown>',
|
|
3560
3583
|
baseRefName: pr.base.ref,
|
|
3561
|
-
headRefName
|
|
3562
|
-
|
|
3563
|
-
// https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request
|
|
3564
|
-
mergeStateStatus: pr.mergeable_state?.toUpperCase?.() ?? 'UNKNOWN',
|
|
3584
|
+
headRefName,
|
|
3585
|
+
mergeStateStatus,
|
|
3565
3586
|
number: pr.number,
|
|
3587
|
+
parsedBranch,
|
|
3588
|
+
state,
|
|
3566
3589
|
title: pr.title
|
|
3567
3590
|
}
|
|
3568
3591
|
});
|
|
@@ -3596,37 +3619,88 @@ async function openPr(owner, repo, branch, purl, newVersion, options) {
|
|
|
3596
3619
|
const details = errors.map(d => `- ${d.message?.trim() ?? `${d.resource}.${d.field} (${d.code})`}`).join('\n');
|
|
3597
3620
|
message += `:\n${details}`;
|
|
3598
3621
|
}
|
|
3599
|
-
debug.debugFn(message);
|
|
3622
|
+
debug.debugFn('error', message);
|
|
3600
3623
|
}
|
|
3601
3624
|
return null;
|
|
3602
3625
|
}
|
|
3603
|
-
async function prExistForBranch(owner, repo, branch) {
|
|
3604
|
-
const octokit = getOctokit();
|
|
3605
|
-
try {
|
|
3606
|
-
const {
|
|
3607
|
-
data: prs
|
|
3608
|
-
} = await octokit.pulls.list({
|
|
3609
|
-
owner,
|
|
3610
|
-
repo,
|
|
3611
|
-
head: `${owner}:${branch}`,
|
|
3612
|
-
state: 'open',
|
|
3613
|
-
per_page: 1
|
|
3614
|
-
});
|
|
3615
|
-
return prs.length > 0;
|
|
3616
|
-
} catch {}
|
|
3617
|
-
return false;
|
|
3618
|
-
}
|
|
3619
3626
|
async function setGitRemoteGithubRepoUrl(owner, repo, token, cwd = process.cwd()) {
|
|
3620
3627
|
const stdioIgnoreOptions = {
|
|
3621
3628
|
cwd,
|
|
3622
3629
|
stdio: 'ignore'
|
|
3623
3630
|
};
|
|
3624
|
-
const
|
|
3631
|
+
const {
|
|
3632
|
+
host
|
|
3633
|
+
} = new URL(constants.ENV.GITHUB_SERVER_URL);
|
|
3634
|
+
const url = `https://x-access-token:${token}@${host}/${owner}/${repo}`;
|
|
3625
3635
|
try {
|
|
3626
3636
|
await spawn.spawn('git', ['remote', 'set-url', 'origin', url], stdioIgnoreOptions);
|
|
3627
3637
|
} catch (e) {
|
|
3628
|
-
debug.debugFn('
|
|
3638
|
+
debug.debugFn('error', 'caught: unexpected error');
|
|
3639
|
+
debug.debugDir('inspect', {
|
|
3640
|
+
error: e
|
|
3641
|
+
});
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
function ciRepoInfo() {
|
|
3646
|
+
// Lazily access constants.ENV.GITHUB_REPOSITORY.
|
|
3647
|
+
const {
|
|
3648
|
+
GITHUB_REPOSITORY
|
|
3649
|
+
} = constants.ENV;
|
|
3650
|
+
if (!GITHUB_REPOSITORY) {
|
|
3651
|
+
debug.debugFn('notice', 'miss: GITHUB_REPOSITORY env var');
|
|
3629
3652
|
}
|
|
3653
|
+
const ownerSlashRepo = GITHUB_REPOSITORY;
|
|
3654
|
+
const slashIndex = ownerSlashRepo.indexOf('/');
|
|
3655
|
+
if (slashIndex === -1) {
|
|
3656
|
+
return null;
|
|
3657
|
+
}
|
|
3658
|
+
return {
|
|
3659
|
+
owner: ownerSlashRepo.slice(0, slashIndex),
|
|
3660
|
+
repo: ownerSlashRepo.slice(slashIndex + 1)
|
|
3661
|
+
};
|
|
3662
|
+
}
|
|
3663
|
+
async function getFixEnv() {
|
|
3664
|
+
const baseBranch = await getBaseGitBranch();
|
|
3665
|
+
const gitEmail = constants.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
3666
|
+
const gitUser = constants.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
3667
|
+
const githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
3668
|
+
const isCi = !!(constants.ENV.CI && gitEmail && gitUser && githubToken);
|
|
3669
|
+
let repoInfo = null;
|
|
3670
|
+
if (isCi) {
|
|
3671
|
+
repoInfo = ciRepoInfo();
|
|
3672
|
+
}
|
|
3673
|
+
if (!repoInfo) {
|
|
3674
|
+
if (isCi) {
|
|
3675
|
+
debug.debugFn('notice', 'falling back to `git remote get-url origin`');
|
|
3676
|
+
}
|
|
3677
|
+
repoInfo = await gitRepoInfo();
|
|
3678
|
+
}
|
|
3679
|
+
const prs = isCi && repoInfo ? await getSocketPrs(repoInfo.owner, repoInfo.repo, {
|
|
3680
|
+
author: gitUser,
|
|
3681
|
+
states: 'all'
|
|
3682
|
+
}) : [];
|
|
3683
|
+
return {
|
|
3684
|
+
baseBranch,
|
|
3685
|
+
gitEmail,
|
|
3686
|
+
githubToken,
|
|
3687
|
+
gitUser,
|
|
3688
|
+
isCi,
|
|
3689
|
+
prs,
|
|
3690
|
+
repoInfo
|
|
3691
|
+
};
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
async function getActualTree(cwd = process.cwd()) {
|
|
3695
|
+
// @npmcli/arborist DOES have partial support for pnpm structured node_modules
|
|
3696
|
+
// folders. However, support is iffy resulting in unhappy path errors and hangs.
|
|
3697
|
+
// So, to avoid the unhappy path, we restrict our usage to --dry-run loading
|
|
3698
|
+
// of the node_modules folder.
|
|
3699
|
+
const arb = new shadowNpmInject.Arborist({
|
|
3700
|
+
path: cwd,
|
|
3701
|
+
...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
3702
|
+
});
|
|
3703
|
+
return await arb.loadActual();
|
|
3630
3704
|
}
|
|
3631
3705
|
|
|
3632
3706
|
const {
|
|
@@ -3717,10 +3791,11 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3717
3791
|
// eslint-disable-next-line sort-destructure-keys/sort-destructure-keys
|
|
3718
3792
|
afterInstall = noopHandler,
|
|
3719
3793
|
revertInstall = noopHandler
|
|
3720
|
-
},
|
|
3794
|
+
}, fixConfig) {
|
|
3721
3795
|
const {
|
|
3722
3796
|
pkgPath: rootPath
|
|
3723
3797
|
} = pkgEnvDetails;
|
|
3798
|
+
const fixEnv = await getFixEnv();
|
|
3724
3799
|
const {
|
|
3725
3800
|
autoMerge,
|
|
3726
3801
|
cwd,
|
|
@@ -3733,17 +3808,19 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3733
3808
|
} = fixConfig;
|
|
3734
3809
|
let count = 0;
|
|
3735
3810
|
const infoByPartialPurl = utils.getCveInfoFromAlertsMap(alertsMap, {
|
|
3736
|
-
|
|
3811
|
+
exclude: {
|
|
3812
|
+
upgradable: true
|
|
3813
|
+
}
|
|
3737
3814
|
});
|
|
3738
3815
|
if (!infoByPartialPurl) {
|
|
3739
3816
|
spinner?.stop();
|
|
3740
3817
|
logger.logger.info('No fixable vulns found.');
|
|
3741
3818
|
if (alertsMap.size) {
|
|
3742
|
-
debug.
|
|
3819
|
+
debug.debugDir('inspect', {
|
|
3743
3820
|
alertsMap
|
|
3744
3821
|
});
|
|
3745
3822
|
} else {
|
|
3746
|
-
debug.debugFn('inspect
|
|
3823
|
+
debug.debugFn('inspect', '{ alertsMap: Map(0) {} }');
|
|
3747
3824
|
}
|
|
3748
3825
|
return {
|
|
3749
3826
|
ok: true,
|
|
@@ -3752,8 +3829,17 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3752
3829
|
}
|
|
3753
3830
|
};
|
|
3754
3831
|
}
|
|
3755
|
-
if (debug.isDebug()) {
|
|
3756
|
-
|
|
3832
|
+
if (debug.isDebug('notice,inspect')) {
|
|
3833
|
+
spinner?.stop();
|
|
3834
|
+
const partialPurls = Array.from(infoByPartialPurl.keys());
|
|
3835
|
+
const {
|
|
3836
|
+
length: purlsCount
|
|
3837
|
+
} = partialPurls;
|
|
3838
|
+
debug.debugFn('notice', `found: ${purlsCount} ${words.pluralize('PURL', purlsCount)} with CVEs`);
|
|
3839
|
+
debug.debugDir('inspect', {
|
|
3840
|
+
partialPurls
|
|
3841
|
+
});
|
|
3842
|
+
spinner?.start();
|
|
3757
3843
|
}
|
|
3758
3844
|
|
|
3759
3845
|
// Lazily access constants.packumentCache.
|
|
@@ -3788,13 +3874,14 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3788
3874
|
const name = packages.resolvePackageName(partialPurlObj);
|
|
3789
3875
|
const infos = Array.from(infoEntry[1].values());
|
|
3790
3876
|
if (!infos.length) {
|
|
3877
|
+
debug.debugFn('notice', `miss: CVEs expected, but not found, for ${name}`);
|
|
3791
3878
|
continue infoEntriesLoop;
|
|
3792
3879
|
}
|
|
3793
|
-
logger.logger.log(`Processing vulns for ${name}
|
|
3880
|
+
logger.logger.log(`Processing vulns for ${name}`);
|
|
3794
3881
|
logger.logger.indent();
|
|
3795
3882
|
spinner?.indent();
|
|
3796
3883
|
if (registry.getManifestData(partialPurlObj.type, name)) {
|
|
3797
|
-
debug.debugFn(`found: Socket Optimize variant for ${name}`);
|
|
3884
|
+
debug.debugFn('notice', `found: Socket Optimize variant for ${name}`);
|
|
3798
3885
|
}
|
|
3799
3886
|
// eslint-disable-next-line no-await-in-loop
|
|
3800
3887
|
const packument = await packages.fetchPackagePackument(name);
|
|
@@ -3803,8 +3890,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3803
3890
|
cleanupInfoEntriesLoop();
|
|
3804
3891
|
continue infoEntriesLoop;
|
|
3805
3892
|
}
|
|
3806
|
-
const activeBranches = getActiveBranchesForPackage(ciEnv, infoEntry[0], openPrs);
|
|
3807
3893
|
const availableVersions = Object.keys(packument.versions);
|
|
3894
|
+
const prs = getPrsForPurl(fixEnv, infoEntry[0]);
|
|
3808
3895
|
const warningsForAfter = new Set();
|
|
3809
3896
|
|
|
3810
3897
|
// eslint-disable-next-line no-unused-labels
|
|
@@ -3816,15 +3903,14 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3816
3903
|
const pkgPath = path.dirname(pkgJsonPath);
|
|
3817
3904
|
const isWorkspaceRoot = pkgJsonPath === pkgEnvDetails.editablePkgJson.filename;
|
|
3818
3905
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
3819
|
-
const branchWorkspace =
|
|
3820
|
-
|
|
3906
|
+
const branchWorkspace = fixEnv.isCi ? getSocketBranchWorkspaceComponent(workspace) : '';
|
|
3821
3907
|
// actualTree may not be defined on the first iteration of pkgJsonPathsLoop.
|
|
3822
3908
|
if (!actualTree) {
|
|
3823
|
-
if (!
|
|
3909
|
+
if (!fixEnv.isCi) {
|
|
3824
3910
|
// eslint-disable-next-line no-await-in-loop
|
|
3825
3911
|
await utils.removeNodeModules(cwd);
|
|
3826
3912
|
}
|
|
3827
|
-
const maybeActualTree =
|
|
3913
|
+
const maybeActualTree = fixEnv.isCi && fs$1.existsSync(path.join(rootPath, 'node_modules')) ?
|
|
3828
3914
|
// eslint-disable-next-line no-await-in-loop
|
|
3829
3915
|
await getActualTree(cwd) :
|
|
3830
3916
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -3845,7 +3931,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3845
3931
|
}
|
|
3846
3932
|
const oldVersions = arrays.arrayUnique(shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version).filter(Boolean));
|
|
3847
3933
|
if (!oldVersions.length) {
|
|
3848
|
-
debug.debugFn(`skip: ${name} not found\n`);
|
|
3934
|
+
debug.debugFn('notice', `skip: ${name} not found\n`);
|
|
3849
3935
|
// Skip to next package.
|
|
3850
3936
|
cleanupInfoEntriesLoop();
|
|
3851
3937
|
continue infoEntriesLoop;
|
|
@@ -3860,8 +3946,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3860
3946
|
const seenVersions = new Set();
|
|
3861
3947
|
let hasAnnouncedWorkspace = false;
|
|
3862
3948
|
let workspaceLogCallCount = logger.logger.logCallCount;
|
|
3863
|
-
if (debug.isDebug()) {
|
|
3864
|
-
debug.debugFn(`check: workspace ${workspace}`);
|
|
3949
|
+
if (debug.isDebug('notice')) {
|
|
3950
|
+
debug.debugFn('notice', `check: workspace ${workspace}`);
|
|
3865
3951
|
hasAnnouncedWorkspace = true;
|
|
3866
3952
|
workspaceLogCallCount = logger.logger.logCallCount;
|
|
3867
3953
|
}
|
|
@@ -3870,7 +3956,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3870
3956
|
const oldPurl = utils.idToPurl(oldId, partialPurlObj.type);
|
|
3871
3957
|
const node = shadowNpmInject.findPackageNode(actualTree, name, oldVersion);
|
|
3872
3958
|
if (!node) {
|
|
3873
|
-
debug.debugFn(`skip: ${oldId} not found`);
|
|
3959
|
+
debug.debugFn('notice', `skip: ${oldId} not found`);
|
|
3874
3960
|
continue oldVersionsLoop;
|
|
3875
3961
|
}
|
|
3876
3962
|
infosLoop: for (const {
|
|
@@ -3890,11 +3976,25 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3890
3976
|
continue infosLoop;
|
|
3891
3977
|
}
|
|
3892
3978
|
if (vendor.semverExports.gte(oldVersion, newVersion)) {
|
|
3893
|
-
debug.debugFn(`skip: ${oldId} is >= ${newVersion}`);
|
|
3979
|
+
debug.debugFn('silly', `skip: ${oldId} is >= ${newVersion}`);
|
|
3894
3980
|
continue infosLoop;
|
|
3895
3981
|
}
|
|
3896
|
-
|
|
3897
|
-
|
|
3982
|
+
const branch = getSocketBranchName(oldPurl, newVersion, workspace);
|
|
3983
|
+
const pr = prs.find(({
|
|
3984
|
+
parsedBranch: b
|
|
3985
|
+
}) => b.workspace === branchWorkspace && b.newVersion === newVersion);
|
|
3986
|
+
if (pr) {
|
|
3987
|
+
debug.debugFn('notice', `skip: PR #${pr.number} for ${name} exists`);
|
|
3988
|
+
if (++count >= limit) {
|
|
3989
|
+
cleanupInfoEntriesLoop();
|
|
3990
|
+
break infoEntriesLoop;
|
|
3991
|
+
}
|
|
3992
|
+
continue infosLoop;
|
|
3993
|
+
}
|
|
3994
|
+
if (fixEnv.isCi && (
|
|
3995
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3996
|
+
await gitRemoteBranchExists(branch, cwd))) {
|
|
3997
|
+
debug.debugFn('notice', `skip: remote branch "${branch}" exists`);
|
|
3898
3998
|
if (++count >= limit) {
|
|
3899
3999
|
cleanupInfoEntriesLoop();
|
|
3900
4000
|
break infoEntriesLoop;
|
|
@@ -3913,17 +4013,26 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3913
4013
|
}
|
|
3914
4014
|
|
|
3915
4015
|
// eslint-disable-next-line no-await-in-loop
|
|
3916
|
-
await beforeInstall(editablePkgJson,
|
|
4016
|
+
await beforeInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
|
|
3917
4017
|
shadowNpmInject.updatePackageJsonFromNode(editablePkgJson, actualTree, node, newVersion, rangeStyle);
|
|
4018
|
+
|
|
3918
4019
|
// eslint-disable-next-line no-await-in-loop
|
|
3919
|
-
|
|
4020
|
+
await editablePkgJson.save({
|
|
3920
4021
|
ignoreWhitespace: true
|
|
3921
|
-
})
|
|
3922
|
-
|
|
4022
|
+
});
|
|
4023
|
+
|
|
4024
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4025
|
+
const unstagedCResult = await gitUnstagedModifiedFiles(cwd);
|
|
4026
|
+
const moddedFilepaths = unstagedCResult.ok ? unstagedCResult.data.filter(filepath => {
|
|
4027
|
+
const basename = path.basename(filepath);
|
|
4028
|
+
return basename === 'package.json' || basename === pkgEnvDetails.lockName;
|
|
4029
|
+
}) : [];
|
|
4030
|
+
if (!moddedFilepaths.length) {
|
|
4031
|
+
logger.logger.warn('Unexpected condition: Nothing to commit, skipping PR creation.');
|
|
3923
4032
|
// Reset things just in case.
|
|
3924
|
-
if (
|
|
4033
|
+
if (fixEnv.isCi) {
|
|
3925
4034
|
// eslint-disable-next-line no-await-in-loop
|
|
3926
|
-
await gitResetAndClean(
|
|
4035
|
+
await gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
3927
4036
|
}
|
|
3928
4037
|
continue infosLoop;
|
|
3929
4038
|
}
|
|
@@ -3948,7 +4057,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3948
4057
|
if (maybeActualTree && maybeLockSrc) {
|
|
3949
4058
|
actualTree = maybeActualTree;
|
|
3950
4059
|
// eslint-disable-next-line no-await-in-loop
|
|
3951
|
-
await afterInstall(editablePkgJson,
|
|
4060
|
+
await afterInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
|
|
3952
4061
|
if (test) {
|
|
3953
4062
|
spinner?.info(`Testing ${newId} in ${workspace}.`);
|
|
3954
4063
|
// eslint-disable-next-line no-await-in-loop
|
|
@@ -3969,47 +4078,18 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3969
4078
|
spinner?.stop();
|
|
3970
4079
|
|
|
3971
4080
|
// Check repoInfo to make TypeScript happy.
|
|
3972
|
-
if (!errored &&
|
|
4081
|
+
if (!errored && fixEnv.isCi && fixEnv.repoInfo) {
|
|
3973
4082
|
try {
|
|
3974
|
-
// eslint-disable-next-line no-await-in-loop
|
|
3975
|
-
const unstagedCResult = await gitUnstagedModifiedFiles(cwd);
|
|
3976
|
-
if (!unstagedCResult.ok) {
|
|
3977
|
-
logger.logger.warn('Unexpected condition: Nothing to commit, skipping PR creation.');
|
|
3978
|
-
continue;
|
|
3979
|
-
}
|
|
3980
|
-
const moddedFilepaths = unstagedCResult.data.filter(filepath => {
|
|
3981
|
-
const basename = path.basename(filepath);
|
|
3982
|
-
return basename === 'package.json' || basename === pkgEnvDetails.lockName;
|
|
3983
|
-
});
|
|
3984
|
-
if (!moddedFilepaths.length) {
|
|
3985
|
-
logger.logger.warn('Unexpected condition: Nothing to commit, skipping PR creation.');
|
|
3986
|
-
continue infosLoop;
|
|
3987
|
-
}
|
|
3988
|
-
const branch = getSocketBranchName(oldPurl, newVersion, workspace);
|
|
3989
|
-
let skipPr = false;
|
|
3990
4083
|
if (
|
|
3991
4084
|
// eslint-disable-next-line no-await-in-loop
|
|
3992
|
-
await prExistForBranch(ciEnv.repoInfo.owner, ciEnv.repoInfo.repo, branch)) {
|
|
3993
|
-
skipPr = true;
|
|
3994
|
-
debug.debugFn(`skip: branch "${branch}" exists`);
|
|
3995
|
-
}
|
|
3996
|
-
// eslint-disable-next-line no-await-in-loop
|
|
3997
|
-
else if (await gitRemoteBranchExists(branch, cwd)) {
|
|
3998
|
-
skipPr = true;
|
|
3999
|
-
debug.debugFn(`skip: remote branch "${branch}" exists`);
|
|
4000
|
-
} else if (
|
|
4001
|
-
// eslint-disable-next-line no-await-in-loop
|
|
4002
4085
|
!(await gitCreateAndPushBranch(branch, getSocketCommitMessage(oldPurl, newVersion, workspace), moddedFilepaths, {
|
|
4003
4086
|
cwd,
|
|
4004
|
-
email:
|
|
4005
|
-
user:
|
|
4087
|
+
email: fixEnv.gitEmail,
|
|
4088
|
+
user: fixEnv.gitUser
|
|
4006
4089
|
}))) {
|
|
4007
|
-
skipPr = true;
|
|
4008
4090
|
logger.logger.warn('Unexpected condition: Push failed, skipping PR creation.');
|
|
4009
|
-
}
|
|
4010
|
-
if (skipPr) {
|
|
4011
4091
|
// eslint-disable-next-line no-await-in-loop
|
|
4012
|
-
await gitResetAndClean(
|
|
4092
|
+
await gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4013
4093
|
// eslint-disable-next-line no-await-in-loop
|
|
4014
4094
|
const maybeActualTree = await installer(pkgEnvDetails, {
|
|
4015
4095
|
cwd,
|
|
@@ -4027,14 +4107,14 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4027
4107
|
}
|
|
4028
4108
|
|
|
4029
4109
|
// eslint-disable-next-line no-await-in-loop
|
|
4030
|
-
await Promise.allSettled([setGitRemoteGithubRepoUrl(
|
|
4110
|
+
await Promise.allSettled([setGitRemoteGithubRepoUrl(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, fixEnv.githubToken, cwd), cleanupPrs(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, {
|
|
4031
4111
|
newVersion,
|
|
4032
4112
|
purl: oldPurl,
|
|
4033
4113
|
workspace
|
|
4034
4114
|
})]);
|
|
4035
4115
|
// eslint-disable-next-line no-await-in-loop
|
|
4036
|
-
const prResponse = await openPr(
|
|
4037
|
-
baseBranch:
|
|
4116
|
+
const prResponse = await openPr(fixEnv.repoInfo.owner, fixEnv.repoInfo.repo, branch, oldPurl, newVersion, {
|
|
4117
|
+
baseBranch: fixEnv.baseBranch,
|
|
4038
4118
|
cwd,
|
|
4039
4119
|
workspace
|
|
4040
4120
|
});
|
|
@@ -4067,10 +4147,10 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4067
4147
|
errored = true;
|
|
4068
4148
|
}
|
|
4069
4149
|
}
|
|
4070
|
-
if (
|
|
4150
|
+
if (fixEnv.isCi) {
|
|
4071
4151
|
spinner?.start();
|
|
4072
4152
|
// eslint-disable-next-line no-await-in-loop
|
|
4073
|
-
await gitResetAndClean(
|
|
4153
|
+
await gitResetAndClean(fixEnv.baseBranch, cwd);
|
|
4074
4154
|
// eslint-disable-next-line no-await-in-loop
|
|
4075
4155
|
const maybeActualTree = await installer(pkgEnvDetails, {
|
|
4076
4156
|
cwd,
|
|
@@ -4084,10 +4164,10 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4084
4164
|
}
|
|
4085
4165
|
}
|
|
4086
4166
|
if (errored) {
|
|
4087
|
-
if (!
|
|
4167
|
+
if (!fixEnv.isCi) {
|
|
4088
4168
|
spinner?.start();
|
|
4089
4169
|
// eslint-disable-next-line no-await-in-loop
|
|
4090
|
-
await revertInstall(editablePkgJson,
|
|
4170
|
+
await revertInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
|
|
4091
4171
|
// eslint-disable-next-line no-await-in-loop
|
|
4092
4172
|
await Promise.all([utils.removeNodeModules(cwd), editablePkgJson.save({
|
|
4093
4173
|
ignoreWhitespace: true
|
|
@@ -4111,8 +4191,7 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4111
4191
|
cause: `Update failed for ${oldId} in ${workspace}${error ? '; ' + error : ''}`
|
|
4112
4192
|
};
|
|
4113
4193
|
}
|
|
4114
|
-
debug.debugFn('
|
|
4115
|
-
debug.debugFn('increment: count', count + 1);
|
|
4194
|
+
debug.debugFn('notice', 'increment: count', count + 1);
|
|
4116
4195
|
if (++count >= limit) {
|
|
4117
4196
|
cleanupInfoEntriesLoop();
|
|
4118
4197
|
break infoEntriesLoop;
|
|
@@ -4142,57 +4221,8 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4142
4221
|
};
|
|
4143
4222
|
}
|
|
4144
4223
|
|
|
4145
|
-
async function getEnvRepoInfo(cwd) {
|
|
4146
|
-
// Lazily access constants.ENV.GITHUB_REPOSITORY.
|
|
4147
|
-
const {
|
|
4148
|
-
GITHUB_REPOSITORY
|
|
4149
|
-
} = constants.ENV;
|
|
4150
|
-
if (!GITHUB_REPOSITORY) {
|
|
4151
|
-
debug.debugFn('miss: GITHUB_REPOSITORY env var');
|
|
4152
|
-
}
|
|
4153
|
-
const ownerSlashRepo = GITHUB_REPOSITORY;
|
|
4154
|
-
const slashIndex = ownerSlashRepo.indexOf('/');
|
|
4155
|
-
if (slashIndex !== -1) {
|
|
4156
|
-
return {
|
|
4157
|
-
owner: ownerSlashRepo.slice(0, slashIndex),
|
|
4158
|
-
repo: ownerSlashRepo.slice(slashIndex + 1)
|
|
4159
|
-
};
|
|
4160
|
-
}
|
|
4161
|
-
return await gitRepoInfo(cwd);
|
|
4162
|
-
}
|
|
4163
|
-
async function getCiEnv() {
|
|
4164
|
-
const gitEmail = constants.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
4165
|
-
const gitUser = constants.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
4166
|
-
const githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
4167
|
-
const isCi = !!(constants.ENV.CI && gitEmail && gitUser && githubToken);
|
|
4168
|
-
if (!isCi) {
|
|
4169
|
-
return null;
|
|
4170
|
-
}
|
|
4171
|
-
const baseBranch = await getBaseGitBranch();
|
|
4172
|
-
if (!baseBranch) {
|
|
4173
|
-
return null;
|
|
4174
|
-
}
|
|
4175
|
-
const repoInfo = await getEnvRepoInfo();
|
|
4176
|
-
if (!repoInfo) {
|
|
4177
|
-
return null;
|
|
4178
|
-
}
|
|
4179
|
-
return {
|
|
4180
|
-
gitEmail,
|
|
4181
|
-
gitUser,
|
|
4182
|
-
githubToken,
|
|
4183
|
-
repoInfo,
|
|
4184
|
-
baseBranch,
|
|
4185
|
-
branchParser: createSocketBranchParser()
|
|
4186
|
-
};
|
|
4187
|
-
}
|
|
4188
|
-
async function getOpenPrsForEnvironment(env) {
|
|
4189
|
-
return env ? await getOpenSocketPrs(env.repoInfo.owner, env.repoInfo.repo, {
|
|
4190
|
-
author: env.gitUser
|
|
4191
|
-
}) : [];
|
|
4192
|
-
}
|
|
4193
|
-
|
|
4194
4224
|
const CMD_NAME$1 = 'socket fix';
|
|
4195
|
-
function
|
|
4225
|
+
function getFixAlertsMapOptions(options = {}) {
|
|
4196
4226
|
return {
|
|
4197
4227
|
__proto__: null,
|
|
4198
4228
|
consolidate: true,
|
|
@@ -4221,7 +4251,7 @@ async function install$1(pkgEnvDetails, options) {
|
|
|
4221
4251
|
await utils.runAgentInstall(pkgEnvDetails, {
|
|
4222
4252
|
args,
|
|
4223
4253
|
spinner,
|
|
4224
|
-
stdio: debug.isDebug() ? 'inherit' : 'ignore'
|
|
4254
|
+
stdio: debug.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4225
4255
|
});
|
|
4226
4256
|
return await getActualTree(cwd);
|
|
4227
4257
|
} catch {}
|
|
@@ -4229,59 +4259,35 @@ async function install$1(pkgEnvDetails, options) {
|
|
|
4229
4259
|
}
|
|
4230
4260
|
async function npmFix(pkgEnvDetails, fixConfig) {
|
|
4231
4261
|
const {
|
|
4232
|
-
limit,
|
|
4233
4262
|
purls,
|
|
4234
4263
|
spinner
|
|
4235
4264
|
} = fixConfig;
|
|
4236
4265
|
spinner?.start();
|
|
4237
|
-
|
|
4238
|
-
const openPrs = ciEnv ? await getOpenPrsForEnvironment(ciEnv) : [];
|
|
4266
|
+
let arb;
|
|
4239
4267
|
let actualTree;
|
|
4240
4268
|
let alertsMap;
|
|
4241
4269
|
try {
|
|
4242
4270
|
if (purls.length) {
|
|
4243
|
-
alertsMap = await utils.getAlertsMapFromPurls(purls,
|
|
4244
|
-
limit: Math.max(limit, openPrs.length)
|
|
4245
|
-
}));
|
|
4271
|
+
alertsMap = await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions());
|
|
4246
4272
|
} else {
|
|
4247
|
-
const
|
|
4248
|
-
|
|
4249
|
-
argv: [],
|
|
4250
|
-
cwd: process.cwd(),
|
|
4251
|
-
definitions: vendor.definitionsExports.definitions,
|
|
4252
|
-
// Lazily access constants.execPath.
|
|
4253
|
-
execPath: constants.execPath,
|
|
4254
|
-
env: {
|
|
4255
|
-
...process.env
|
|
4256
|
-
},
|
|
4257
|
-
flatten: vendor.definitionsExports.flatten,
|
|
4258
|
-
npmPath,
|
|
4259
|
-
platform: process.platform,
|
|
4260
|
-
shorthands: vendor.definitionsExports.shorthands
|
|
4273
|
+
const flatConfig = await utils.getNpmConfig({
|
|
4274
|
+
npmVersion: pkgEnvDetails.agentVersion
|
|
4261
4275
|
});
|
|
4262
|
-
|
|
4263
|
-
const flatConfig = {
|
|
4264
|
-
__proto__: null,
|
|
4265
|
-
...config.flat
|
|
4266
|
-
};
|
|
4267
|
-
flatConfig.nodeVersion = constants.NODE_VERSION;
|
|
4268
|
-
flatConfig.npmVersion = pkgEnvDetails.agentVersion.toString();
|
|
4269
|
-
flatConfig.npmCommand = 'install';
|
|
4270
|
-
const arb = new shadowNpmInject.Arborist({
|
|
4276
|
+
arb = new shadowNpmInject.Arborist({
|
|
4271
4277
|
path: pkgEnvDetails.pkgPath,
|
|
4272
|
-
...flatConfig
|
|
4273
|
-
...shadowNpmInject.SAFE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
4278
|
+
...flatConfig
|
|
4274
4279
|
});
|
|
4275
4280
|
actualTree = await arb.reify();
|
|
4276
4281
|
// Calling arb.reify() creates the arb.diff object, nulls-out arb.idealTree,
|
|
4277
4282
|
// and populates arb.actualTree.
|
|
4278
|
-
alertsMap = await shadowNpmInject.getAlertsMapFromArborist(arb,
|
|
4279
|
-
limit: Math.max(limit, openPrs.length)
|
|
4280
|
-
}));
|
|
4283
|
+
alertsMap = await shadowNpmInject.getAlertsMapFromArborist(arb, getFixAlertsMapOptions());
|
|
4281
4284
|
}
|
|
4282
4285
|
} catch (e) {
|
|
4283
4286
|
spinner?.stop();
|
|
4284
|
-
debug.debugFn('
|
|
4287
|
+
debug.debugFn('error', 'caught: PURL API');
|
|
4288
|
+
debug.debugDir('inspect', {
|
|
4289
|
+
error: e
|
|
4290
|
+
});
|
|
4285
4291
|
return {
|
|
4286
4292
|
ok: false,
|
|
4287
4293
|
message: 'API Error',
|
|
@@ -4290,7 +4296,7 @@ async function npmFix(pkgEnvDetails, fixConfig) {
|
|
|
4290
4296
|
}
|
|
4291
4297
|
let revertData;
|
|
4292
4298
|
return await agentFix(pkgEnvDetails, actualTree, alertsMap, install$1, {
|
|
4293
|
-
async beforeInstall(editablePkgJson) {
|
|
4299
|
+
async beforeInstall(editablePkgJson, packument, oldVersion, newVersion) {
|
|
4294
4300
|
revertData = {
|
|
4295
4301
|
...(editablePkgJson.content.dependencies && {
|
|
4296
4302
|
dependencies: {
|
|
@@ -4308,13 +4314,19 @@ async function npmFix(pkgEnvDetails, fixConfig) {
|
|
|
4308
4314
|
}
|
|
4309
4315
|
})
|
|
4310
4316
|
};
|
|
4317
|
+
const idealTree = await arb.buildIdealTree();
|
|
4318
|
+
const node = shadowNpmInject.findPackageNode(idealTree, packument.name, oldVersion);
|
|
4319
|
+
if (node) {
|
|
4320
|
+
shadowNpmInject.updateNode(node, newVersion, packument.versions[newVersion]);
|
|
4321
|
+
await arb.reify();
|
|
4322
|
+
}
|
|
4311
4323
|
},
|
|
4312
4324
|
async revertInstall(editablePkgJson) {
|
|
4313
4325
|
if (revertData) {
|
|
4314
4326
|
editablePkgJson.update(revertData);
|
|
4315
4327
|
}
|
|
4316
4328
|
}
|
|
4317
|
-
},
|
|
4329
|
+
}, fixConfig);
|
|
4318
4330
|
}
|
|
4319
4331
|
|
|
4320
4332
|
async function outputFixResult(result, outputKind) {
|
|
@@ -4356,7 +4368,7 @@ async function install(pkgEnvDetails, options) {
|
|
|
4356
4368
|
// https://github.com/pnpm/pnpm/issues/6778
|
|
4357
4369
|
'--config.confirmModulesPurge=false'],
|
|
4358
4370
|
spinner,
|
|
4359
|
-
stdio: debug.isDebug() ? 'inherit' : 'ignore'
|
|
4371
|
+
stdio: debug.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4360
4372
|
});
|
|
4361
4373
|
return await getActualTree(cwd);
|
|
4362
4374
|
} catch {}
|
|
@@ -4365,7 +4377,6 @@ async function install(pkgEnvDetails, options) {
|
|
|
4365
4377
|
async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
4366
4378
|
const {
|
|
4367
4379
|
cwd,
|
|
4368
|
-
limit,
|
|
4369
4380
|
purls,
|
|
4370
4381
|
spinner
|
|
4371
4382
|
} = fixConfig;
|
|
@@ -4403,18 +4414,15 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4403
4414
|
cause: 'Required pnpm-lock.yaml not found or usable'
|
|
4404
4415
|
};
|
|
4405
4416
|
}
|
|
4406
|
-
const ciEnv = await getCiEnv();
|
|
4407
|
-
const openPrs = ciEnv ? await getOpenPrsForEnvironment(ciEnv) : [];
|
|
4408
4417
|
let alertsMap;
|
|
4409
4418
|
try {
|
|
4410
|
-
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls,
|
|
4411
|
-
limit: Math.max(limit, openPrs.length)
|
|
4412
|
-
})) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getAlertsMapOptions({
|
|
4413
|
-
limit: Math.max(limit, openPrs.length)
|
|
4414
|
-
}));
|
|
4419
|
+
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions()) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getFixAlertsMapOptions());
|
|
4415
4420
|
} catch (e) {
|
|
4416
4421
|
spinner?.stop();
|
|
4417
|
-
debug.debugFn('
|
|
4422
|
+
debug.debugFn('error', 'caught: PURL API');
|
|
4423
|
+
debug.debugDir('inspect', {
|
|
4424
|
+
error: e
|
|
4425
|
+
});
|
|
4418
4426
|
return {
|
|
4419
4427
|
ok: false,
|
|
4420
4428
|
message: 'API Error',
|
|
@@ -4425,14 +4433,14 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4425
4433
|
let revertOverrides;
|
|
4426
4434
|
let revertOverridesSrc;
|
|
4427
4435
|
return await agentFix(pkgEnvDetails, actualTree, alertsMap, install, {
|
|
4428
|
-
async beforeInstall(editablePkgJson,
|
|
4436
|
+
async beforeInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, options) {
|
|
4429
4437
|
const isWorkspaceRoot = editablePkgJson.path === pkgEnvDetails.editablePkgJson.filename;
|
|
4430
4438
|
// Get current overrides for revert logic.
|
|
4431
4439
|
const {
|
|
4432
4440
|
overrides: oldOverrides
|
|
4433
4441
|
} = getOverridesDataPnpm(pkgEnvDetails, editablePkgJson.content);
|
|
4434
4442
|
const oldPnpmSection = editablePkgJson.content[PNPM$7];
|
|
4435
|
-
const overrideKey = `${name}@${vulnerableVersionRange}`;
|
|
4443
|
+
const overrideKey = `${packument.name}@${vulnerableVersionRange}`;
|
|
4436
4444
|
revertOverrides = undefined;
|
|
4437
4445
|
revertOverridesSrc = utils.extractOverridesFromPnpmLockSrc(lockSrc);
|
|
4438
4446
|
if (isWorkspaceRoot) {
|
|
@@ -4496,7 +4504,7 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4496
4504
|
editablePkgJson.update(revertData);
|
|
4497
4505
|
}
|
|
4498
4506
|
}
|
|
4499
|
-
},
|
|
4507
|
+
}, fixConfig);
|
|
4500
4508
|
}
|
|
4501
4509
|
|
|
4502
4510
|
const {
|
|
@@ -4532,7 +4540,8 @@ async function handleFix({
|
|
|
4532
4540
|
ghsas = utils.cmdFlagValueToArray(/(?<=Vulnerabilities found: )[^\n]+/.exec(autoCResult.data)?.[0]);
|
|
4533
4541
|
ghsasCount = ghsas.length;
|
|
4534
4542
|
} else {
|
|
4535
|
-
debug.debugFn('
|
|
4543
|
+
debug.debugFn('error', 'fail: Coana CLI');
|
|
4544
|
+
debug.debugDir('inspect', {
|
|
4536
4545
|
message: autoCResult.message,
|
|
4537
4546
|
cause: autoCResult.cause
|
|
4538
4547
|
});
|
|
@@ -4549,7 +4558,8 @@ async function handleFix({
|
|
|
4549
4558
|
});
|
|
4550
4559
|
spinner?.stop();
|
|
4551
4560
|
if (!applyFixesCResult.ok) {
|
|
4552
|
-
debug.debugFn('
|
|
4561
|
+
debug.debugFn('error', 'fail: Coana CLI');
|
|
4562
|
+
debug.debugDir('inspect', {
|
|
4553
4563
|
message: applyFixesCResult.message,
|
|
4554
4564
|
cause: applyFixesCResult.cause
|
|
4555
4565
|
});
|
|
@@ -4690,7 +4700,7 @@ const config$H = {
|
|
|
4690
4700
|
$ ${command} [options] [CWD=.]
|
|
4691
4701
|
|
|
4692
4702
|
Options
|
|
4693
|
-
${utils.getFlagListOutput(config.flags
|
|
4703
|
+
${utils.getFlagListOutput(config.flags)}
|
|
4694
4704
|
|
|
4695
4705
|
Examples
|
|
4696
4706
|
$ ${command}
|
|
@@ -4819,9 +4829,9 @@ async function setupTabCompletion(targetName) {
|
|
|
4819
4829
|
|
|
4820
4830
|
// Target dir is something like ~/.local/share/socket/settings/completion (linux)
|
|
4821
4831
|
const targetDir = path.dirname(targetPath);
|
|
4822
|
-
debug.debugFn('target: path + dir', targetPath, targetDir);
|
|
4832
|
+
debug.debugFn('notice', 'target: path + dir', targetPath, targetDir);
|
|
4823
4833
|
if (!fs$1.existsSync(targetDir)) {
|
|
4824
|
-
debug.debugFn('create: target dir');
|
|
4834
|
+
debug.debugFn('notice', 'create: target dir');
|
|
4825
4835
|
fs$1.mkdirSync(targetDir, {
|
|
4826
4836
|
recursive: true
|
|
4827
4837
|
});
|
|
@@ -4921,7 +4931,7 @@ const config$G = {
|
|
|
4921
4931
|
different alias for socket on your system.
|
|
4922
4932
|
|
|
4923
4933
|
Options
|
|
4924
|
-
${utils.getFlagListOutput(config.flags
|
|
4934
|
+
${utils.getFlagListOutput(config.flags)}
|
|
4925
4935
|
|
|
4926
4936
|
Examples
|
|
4927
4937
|
|
|
@@ -5190,7 +5200,7 @@ const config$E = {
|
|
|
5190
5200
|
Logs into the Socket API by prompting for an API key
|
|
5191
5201
|
|
|
5192
5202
|
Options
|
|
5193
|
-
${utils.getFlagListOutput(config.flags
|
|
5203
|
+
${utils.getFlagListOutput(config.flags)}
|
|
5194
5204
|
|
|
5195
5205
|
Examples
|
|
5196
5206
|
$ ${command}
|
|
@@ -5419,6 +5429,8 @@ const arrayToLower = arg => arg.map(toLower);
|
|
|
5419
5429
|
// [choices: "appsec", "research", "operational", "threat-modeling", "license-compliance", "generic", "machine-learning",
|
|
5420
5430
|
// "ml", "deep-learning", "ml-deep", "ml-tiny"] [default: "generic"]
|
|
5421
5431
|
// --exclude Additional glob pattern(s) to ignore [array]
|
|
5432
|
+
// --export-proto Serialize and export BOM as protobuf binary. [boolean] [default: false]
|
|
5433
|
+
// --proto-bin-file Path for the serialized protobuf binary. [default: "bom.cdx"]
|
|
5422
5434
|
// --include-formulation Generate formulation section with git metadata and build tools. Defaults to false.
|
|
5423
5435
|
// [boolean] [default: false]
|
|
5424
5436
|
// --include-crypto Include crypto libraries as components. [boolean] [default: false]
|
|
@@ -5474,7 +5486,7 @@ const yargsConfig = {
|
|
|
5474
5486
|
//'deps-slices-file': 'deps.slices.json', // hidden
|
|
5475
5487
|
//evidence: false,
|
|
5476
5488
|
//'exclude-type': [],
|
|
5477
|
-
//'export-proto':
|
|
5489
|
+
//'export-proto': false,
|
|
5478
5490
|
//'fail-on-error': isSecureMode,
|
|
5479
5491
|
//'feature-flags': [], // hidden
|
|
5480
5492
|
//'include-crypto': false,
|
|
@@ -5485,7 +5497,7 @@ const yargsConfig = {
|
|
|
5485
5497
|
//output: 'bom.json',
|
|
5486
5498
|
//profile: 'generic',
|
|
5487
5499
|
//'project-version': '',
|
|
5488
|
-
//'proto-bin-file': 'bom.cdx',
|
|
5500
|
+
//'proto-bin-file': 'bom.cdx',
|
|
5489
5501
|
//recurse: true,
|
|
5490
5502
|
//'skip-dt-tls-check': false,
|
|
5491
5503
|
//'semantics-slices-file': 'semantics.slices.json',
|
|
@@ -5537,9 +5549,7 @@ const yargsConfig = {
|
|
|
5537
5549
|
}],
|
|
5538
5550
|
boolean: ['auto-compositions', 'babel', 'banner',
|
|
5539
5551
|
// hidden
|
|
5540
|
-
'deep', 'evidence', 'export-proto',
|
|
5541
|
-
// hidden
|
|
5542
|
-
'fail-on-error', 'generate-key-and-sign', 'help', 'include-crypto', 'include-formulation', 'install-deps', 'json-pretty', 'print', 'recurse', 'required-only', 'resolve-class', 'skip-dt-tls-check', 'server', 'validate', 'version',
|
|
5552
|
+
'deep', 'evidence', 'export-proto', 'fail-on-error', 'generate-key-and-sign', 'help', 'include-crypto', 'include-formulation', 'install-deps', 'json-pretty', 'print', 'recurse', 'required-only', 'resolve-class', 'skip-dt-tls-check', 'server', 'validate', 'version',
|
|
5543
5553
|
// The --yes flag and -y alias map to the corresponding flag and alias of npx.
|
|
5544
5554
|
// https://docs.npmjs.com/cli/v7/commands/npx#compatibility-with-older-npx-versions
|
|
5545
5555
|
'yes'],
|
|
@@ -5553,9 +5563,7 @@ const yargsConfig = {
|
|
|
5553
5563
|
// number
|
|
5554
5564
|
'openapi-spec-file',
|
|
5555
5565
|
// hidden
|
|
5556
|
-
'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'proto-bin-file',
|
|
5557
|
-
// hidden
|
|
5558
|
-
'reachables-slices-file',
|
|
5566
|
+
'output', 'parent-project-id', 'profile', 'project-group', 'project-name', 'project-version', 'project-id', 'proto-bin-file', 'reachables-slices-file',
|
|
5559
5567
|
// hidden
|
|
5560
5568
|
'semantics-slices-file',
|
|
5561
5569
|
// hidden
|
|
@@ -5647,7 +5655,7 @@ const config$B = {
|
|
|
5647
5655
|
$ ${command} [options] [CWD=.]
|
|
5648
5656
|
|
|
5649
5657
|
Options
|
|
5650
|
-
${utils.getFlagListOutput(config.flags
|
|
5658
|
+
${utils.getFlagListOutput(config.flags)}
|
|
5651
5659
|
|
|
5652
5660
|
Tries to figure out what language your target repo uses. If it finds a
|
|
5653
5661
|
supported case then it will try to generate the manifest file for that
|
|
@@ -5697,7 +5705,9 @@ async function run$B(argv, importMeta, {
|
|
|
5697
5705
|
}
|
|
5698
5706
|
const sockJson = await utils.readOrDefaultSocketJson(cwd);
|
|
5699
5707
|
const detected = await detectManifestActions(sockJson, cwd);
|
|
5700
|
-
debug.
|
|
5708
|
+
debug.debugDir('inspect', {
|
|
5709
|
+
detected
|
|
5710
|
+
});
|
|
5701
5711
|
if (cli.flags['dryRun']) {
|
|
5702
5712
|
logger.logger.log(DRY_RUN_BAILING_NOW$A);
|
|
5703
5713
|
return;
|
|
@@ -5765,7 +5775,7 @@ const config$A = {
|
|
|
5765
5775
|
contents of a file to have it processed.
|
|
5766
5776
|
|
|
5767
5777
|
Options
|
|
5768
|
-
${utils.getFlagListOutput(config.flags
|
|
5778
|
+
${utils.getFlagListOutput(config.flags)}
|
|
5769
5779
|
|
|
5770
5780
|
Examples
|
|
5771
5781
|
|
|
@@ -5905,7 +5915,7 @@ const config$z = {
|
|
|
5905
5915
|
$ ${command} [options] [CWD=.]
|
|
5906
5916
|
|
|
5907
5917
|
Options
|
|
5908
|
-
${utils.getFlagListOutput(config.flags
|
|
5918
|
+
${utils.getFlagListOutput(config.flags)}
|
|
5909
5919
|
|
|
5910
5920
|
Uses gradle, preferably through your local project \`gradlew\`, to generate a
|
|
5911
5921
|
\`pom.xml\` file for each task. If you have no \`gradlew\` you can try the
|
|
@@ -5962,7 +5972,7 @@ async function run$z(argv, importMeta, {
|
|
|
5962
5972
|
// If given path is absolute then cwd should not affect it.
|
|
5963
5973
|
cwd = path.resolve(process.cwd(), cwd);
|
|
5964
5974
|
const sockJson = await utils.readOrDefaultSocketJson(cwd);
|
|
5965
|
-
debug.debugFn('override: socket.json gradle', sockJson?.defaults?.manifest?.gradle);
|
|
5975
|
+
debug.debugFn('inspect', 'override: socket.json gradle', sockJson?.defaults?.manifest?.gradle);
|
|
5966
5976
|
|
|
5967
5977
|
// Set defaults for any flag/arg that is not given. Check socket.json first.
|
|
5968
5978
|
if (!bin) {
|
|
@@ -6062,7 +6072,7 @@ const config$y = {
|
|
|
6062
6072
|
$ ${command} [options] [CWD=.]
|
|
6063
6073
|
|
|
6064
6074
|
Options
|
|
6065
|
-
${utils.getFlagListOutput(config.flags
|
|
6075
|
+
${utils.getFlagListOutput(config.flags)}
|
|
6066
6076
|
|
|
6067
6077
|
Uses gradle, preferably through your local project \`gradlew\`, to generate a
|
|
6068
6078
|
\`pom.xml\` file for each task. If you have no \`gradlew\` you can try the
|
|
@@ -6119,7 +6129,7 @@ async function run$y(argv, importMeta, {
|
|
|
6119
6129
|
// If given path is absolute then cwd should not affect it.
|
|
6120
6130
|
cwd = path.resolve(process.cwd(), cwd);
|
|
6121
6131
|
const sockJson = await utils.readOrDefaultSocketJson(cwd);
|
|
6122
|
-
debug.debugFn('override: socket.json gradle', sockJson?.defaults?.manifest?.gradle);
|
|
6132
|
+
debug.debugFn('inspect', 'override: socket.json gradle', sockJson?.defaults?.manifest?.gradle);
|
|
6123
6133
|
|
|
6124
6134
|
// Set defaults for any flag/arg that is not given. Check socket.json first.
|
|
6125
6135
|
if (!bin) {
|
|
@@ -6221,7 +6231,7 @@ const config$x = {
|
|
|
6221
6231
|
$ ${command} [options] [CWD=.]
|
|
6222
6232
|
|
|
6223
6233
|
Options
|
|
6224
|
-
${utils.getFlagListOutput(config.flags
|
|
6234
|
+
${utils.getFlagListOutput(config.flags)}
|
|
6225
6235
|
|
|
6226
6236
|
Uses \`sbt makePom\` to generate a \`pom.xml\` from your \`build.sbt\` file.
|
|
6227
6237
|
This xml file is the dependency manifest (like a package.json
|
|
@@ -6285,7 +6295,7 @@ async function run$x(argv, importMeta, {
|
|
|
6285
6295
|
// If given path is absolute then cwd should not affect it.
|
|
6286
6296
|
cwd = path.resolve(process.cwd(), cwd);
|
|
6287
6297
|
const sockJson = await utils.readOrDefaultSocketJson(cwd);
|
|
6288
|
-
debug.debugFn('override: socket.json sbt', sockJson?.defaults?.manifest?.sbt);
|
|
6298
|
+
debug.debugFn('inspect', 'override: socket.json sbt', sockJson?.defaults?.manifest?.sbt);
|
|
6289
6299
|
|
|
6290
6300
|
// Set defaults for any flag/arg that is not given. Check socket.json first.
|
|
6291
6301
|
if (!bin) {
|
|
@@ -6379,7 +6389,9 @@ async function outputManifestSetup(result) {
|
|
|
6379
6389
|
|
|
6380
6390
|
async function setupManifestConfig(cwd, defaultOnReadError = false) {
|
|
6381
6391
|
const detected = await detectManifestActions(null, cwd);
|
|
6382
|
-
debug.
|
|
6392
|
+
debug.debugDir('inspect', {
|
|
6393
|
+
detected
|
|
6394
|
+
});
|
|
6383
6395
|
|
|
6384
6396
|
// - repeat
|
|
6385
6397
|
// - give the user an option to configure one of the supported targets
|
|
@@ -6526,15 +6538,15 @@ async function setupConda(config) {
|
|
|
6526
6538
|
} else {
|
|
6527
6539
|
config.disabled = true;
|
|
6528
6540
|
}
|
|
6529
|
-
const
|
|
6530
|
-
if (
|
|
6541
|
+
const infile = await askForInputFile(config.infile || 'environment.yml');
|
|
6542
|
+
if (infile === undefined) {
|
|
6531
6543
|
return canceledByUser$1();
|
|
6532
|
-
} else if (
|
|
6544
|
+
} else if (infile === '-') {
|
|
6533
6545
|
config.stdin = true;
|
|
6534
6546
|
} else {
|
|
6535
6547
|
delete config.stdin;
|
|
6536
|
-
if (
|
|
6537
|
-
config.infile =
|
|
6548
|
+
if (infile) {
|
|
6549
|
+
config.infile = infile;
|
|
6538
6550
|
} else {
|
|
6539
6551
|
delete config.infile;
|
|
6540
6552
|
}
|
|
@@ -6557,8 +6569,8 @@ async function setupConda(config) {
|
|
|
6557
6569
|
config.stdout = true;
|
|
6558
6570
|
} else {
|
|
6559
6571
|
delete config.stdout;
|
|
6560
|
-
if (out
|
|
6561
|
-
config.outfile = out
|
|
6572
|
+
if (out) {
|
|
6573
|
+
config.outfile = out;
|
|
6562
6574
|
} else {
|
|
6563
6575
|
delete config.outfile;
|
|
6564
6576
|
}
|
|
@@ -6578,8 +6590,8 @@ async function setupGradle(config) {
|
|
|
6578
6590
|
const bin = await askForBin(config.bin || './gradlew');
|
|
6579
6591
|
if (bin === undefined) {
|
|
6580
6592
|
return canceledByUser$1();
|
|
6581
|
-
} else if (bin
|
|
6582
|
-
config.bin = bin
|
|
6593
|
+
} else if (bin) {
|
|
6594
|
+
config.bin = bin;
|
|
6583
6595
|
} else {
|
|
6584
6596
|
delete config.bin;
|
|
6585
6597
|
}
|
|
@@ -6591,8 +6603,8 @@ async function setupGradle(config) {
|
|
|
6591
6603
|
});
|
|
6592
6604
|
if (opts === undefined) {
|
|
6593
6605
|
return canceledByUser$1();
|
|
6594
|
-
} else if (opts
|
|
6595
|
-
config.gradleOpts = opts
|
|
6606
|
+
} else if (opts) {
|
|
6607
|
+
config.gradleOpts = opts;
|
|
6596
6608
|
} else {
|
|
6597
6609
|
delete config.gradleOpts;
|
|
6598
6610
|
}
|
|
@@ -6610,8 +6622,8 @@ async function setupSbt(config) {
|
|
|
6610
6622
|
const bin = await askForBin(config.bin || 'sbt');
|
|
6611
6623
|
if (bin === undefined) {
|
|
6612
6624
|
return canceledByUser$1();
|
|
6613
|
-
} else if (bin
|
|
6614
|
-
config.bin = bin
|
|
6625
|
+
} else if (bin) {
|
|
6626
|
+
config.bin = bin;
|
|
6615
6627
|
} else {
|
|
6616
6628
|
delete config.bin;
|
|
6617
6629
|
}
|
|
@@ -6623,8 +6635,8 @@ async function setupSbt(config) {
|
|
|
6623
6635
|
});
|
|
6624
6636
|
if (opts === undefined) {
|
|
6625
6637
|
return canceledByUser$1();
|
|
6626
|
-
} else if (opts
|
|
6627
|
-
config.sbtOpts = opts
|
|
6638
|
+
} else if (opts) {
|
|
6639
|
+
config.sbtOpts = opts;
|
|
6628
6640
|
} else {
|
|
6629
6641
|
delete config.sbtOpts;
|
|
6630
6642
|
}
|
|
@@ -6646,8 +6658,8 @@ async function setupSbt(config) {
|
|
|
6646
6658
|
config.stdout = true;
|
|
6647
6659
|
} else {
|
|
6648
6660
|
delete config.stdout;
|
|
6649
|
-
if (out
|
|
6650
|
-
config.outfile = out
|
|
6661
|
+
if (out) {
|
|
6662
|
+
config.outfile = out;
|
|
6651
6663
|
} else {
|
|
6652
6664
|
delete config.outfile;
|
|
6653
6665
|
}
|
|
@@ -6788,7 +6800,7 @@ const config$w = {
|
|
|
6788
6800
|
$ ${command} [CWD=.]
|
|
6789
6801
|
|
|
6790
6802
|
Options
|
|
6791
|
-
${utils.getFlagListOutput(config.flags
|
|
6803
|
+
${utils.getFlagListOutput(config.flags)}
|
|
6792
6804
|
|
|
6793
6805
|
This command will try to detect all supported ecosystems in given CWD. Then
|
|
6794
6806
|
it starts a configurator where you can setup default values for certain flags
|
|
@@ -7602,7 +7614,10 @@ async function updateLockfile(pkgEnvDetails, options) {
|
|
|
7602
7614
|
}
|
|
7603
7615
|
} catch (e) {
|
|
7604
7616
|
spinner?.stop();
|
|
7605
|
-
debug.debugFn('fail: update
|
|
7617
|
+
debug.debugFn('error', 'fail: update');
|
|
7618
|
+
debug.debugDir('inspect', {
|
|
7619
|
+
error: e
|
|
7620
|
+
});
|
|
7606
7621
|
return {
|
|
7607
7622
|
ok: false,
|
|
7608
7623
|
message: 'Update failed',
|
|
@@ -7761,7 +7776,7 @@ const config$r = {
|
|
|
7761
7776
|
$ ${command} [options] [CWD=.]
|
|
7762
7777
|
|
|
7763
7778
|
Options
|
|
7764
|
-
${utils.getFlagListOutput(config.flags
|
|
7779
|
+
${utils.getFlagListOutput(config.flags)}
|
|
7765
7780
|
|
|
7766
7781
|
Examples
|
|
7767
7782
|
$ ${command}
|
|
@@ -7928,7 +7943,7 @@ const config$q = {
|
|
|
7928
7943
|
- Permissions: none (does need token with access to target org)
|
|
7929
7944
|
|
|
7930
7945
|
Options
|
|
7931
|
-
${utils.getFlagListOutput(config.flags
|
|
7946
|
+
${utils.getFlagListOutput(config.flags)}
|
|
7932
7947
|
|
|
7933
7948
|
Examples
|
|
7934
7949
|
${command}
|
|
@@ -8052,7 +8067,7 @@ const config$p = {
|
|
|
8052
8067
|
- Permissions: license-policy:read
|
|
8053
8068
|
|
|
8054
8069
|
Options
|
|
8055
|
-
${utils.getFlagListOutput(config$p.flags
|
|
8070
|
+
${utils.getFlagListOutput(config$p.flags)}
|
|
8056
8071
|
|
|
8057
8072
|
Your API token will need the \`license-policy:read\` permission otherwise
|
|
8058
8073
|
the request will fail with an authentication error.
|
|
@@ -8180,7 +8195,7 @@ const config$o = {
|
|
|
8180
8195
|
- Permissions: security-policy:read
|
|
8181
8196
|
|
|
8182
8197
|
Options
|
|
8183
|
-
${utils.getFlagListOutput(config$o.flags
|
|
8198
|
+
${utils.getFlagListOutput(config$o.flags)}
|
|
8184
8199
|
|
|
8185
8200
|
Your API token will need the \`security-policy:read\` permission otherwise
|
|
8186
8201
|
the request will fail with an authentication error.
|
|
@@ -8321,7 +8336,7 @@ const config$n = {
|
|
|
8321
8336
|
- Permissions: none (does need a token)
|
|
8322
8337
|
|
|
8323
8338
|
Options
|
|
8324
|
-
${utils.getFlagListOutput(config$n.flags
|
|
8339
|
+
${utils.getFlagListOutput(config$n.flags)}
|
|
8325
8340
|
|
|
8326
8341
|
Examples
|
|
8327
8342
|
$ ${command}
|
|
@@ -8449,7 +8464,7 @@ const config$m = {
|
|
|
8449
8464
|
$ ${command} [options]
|
|
8450
8465
|
|
|
8451
8466
|
Options
|
|
8452
|
-
${utils.getFlagListOutput(config$m.flags
|
|
8467
|
+
${utils.getFlagListOutput(config$m.flags)}
|
|
8453
8468
|
|
|
8454
8469
|
Examples
|
|
8455
8470
|
$ ${command}
|
|
@@ -8775,7 +8790,7 @@ const config$l = {
|
|
|
8775
8790
|
- Permissions: packages:list
|
|
8776
8791
|
|
|
8777
8792
|
Options
|
|
8778
|
-
${utils.getFlagListOutput(config.flags
|
|
8793
|
+
${utils.getFlagListOutput(config.flags)}
|
|
8779
8794
|
|
|
8780
8795
|
Show deep scoring details for one package. The score will reflect the package
|
|
8781
8796
|
itself, any of its dependencies, and any of its transitive dependencies.
|
|
@@ -8922,7 +8937,7 @@ function formatReportCard(artifact, color) {
|
|
|
8922
8937
|
};
|
|
8923
8938
|
const alertString = getAlertString(artifact.alerts, !color);
|
|
8924
8939
|
if (!artifact.ecosystem) {
|
|
8925
|
-
debug.debugFn('miss: artifact ecosystem', artifact);
|
|
8940
|
+
debug.debugFn('notice', 'miss: artifact ecosystem', artifact);
|
|
8926
8941
|
}
|
|
8927
8942
|
const purl = `pkg:${artifact.ecosystem}/${artifact.name}${artifact.version ? '@' + artifact.version : ''}`;
|
|
8928
8943
|
return ['Package: ' + (color ? vendor.yoctocolorsCjsExports.bold(purl) : purl), '', ...Object.entries(scoreResult).map(score => `- ${score[0]}:`.padEnd(20, ' ') + ` ${formatScore(score[1], !color, true)}`), alertString].join('\n');
|
|
@@ -9126,7 +9141,7 @@ const config$k = {
|
|
|
9126
9141
|
- Permissions: packages:list
|
|
9127
9142
|
|
|
9128
9143
|
Options
|
|
9129
|
-
${utils.getFlagListOutput(config.flags
|
|
9144
|
+
${utils.getFlagListOutput(config.flags)}
|
|
9130
9145
|
|
|
9131
9146
|
Show scoring details for one or more packages purely based on their own package.
|
|
9132
9147
|
This means that any dependency scores are not reflected by the score. You can
|
|
@@ -9480,7 +9495,7 @@ const config$h = {
|
|
|
9480
9495
|
The REPO name should be a "slug". Follows the same naming convention as GitHub.
|
|
9481
9496
|
|
|
9482
9497
|
Options
|
|
9483
|
-
${utils.getFlagListOutput(config.flags
|
|
9498
|
+
${utils.getFlagListOutput(config.flags)}
|
|
9484
9499
|
|
|
9485
9500
|
Examples
|
|
9486
9501
|
$ ${command} test-repo
|
|
@@ -9612,7 +9627,7 @@ const config$g = {
|
|
|
9612
9627
|
- Permissions: repo:delete
|
|
9613
9628
|
|
|
9614
9629
|
Options
|
|
9615
|
-
${utils.getFlagListOutput(config.flags
|
|
9630
|
+
${utils.getFlagListOutput(config.flags)}
|
|
9616
9631
|
|
|
9617
9632
|
Examples
|
|
9618
9633
|
$ ${command} test-repo
|
|
@@ -9700,19 +9715,22 @@ async function fetchListAllRepos({
|
|
|
9700
9715
|
};
|
|
9701
9716
|
}
|
|
9702
9717
|
// eslint-disable-next-line no-await-in-loop
|
|
9703
|
-
const
|
|
9718
|
+
const orgRepoListCResult = await utils.handleApiCall(sockSdk.getOrgRepoList(orgSlug, {
|
|
9704
9719
|
sort,
|
|
9705
9720
|
direction,
|
|
9706
9721
|
per_page: String(100),
|
|
9707
9722
|
// max
|
|
9708
9723
|
page: String(nextPage)
|
|
9709
9724
|
}), 'list of repositories');
|
|
9710
|
-
if (!
|
|
9711
|
-
debug.debugFn('fail: fetch repo
|
|
9712
|
-
|
|
9725
|
+
if (!orgRepoListCResult.ok) {
|
|
9726
|
+
debug.debugFn('error', 'fail: fetch repo');
|
|
9727
|
+
debug.debugDir('inspect', {
|
|
9728
|
+
orgRepoListCResult
|
|
9729
|
+
});
|
|
9730
|
+
return orgRepoListCResult;
|
|
9713
9731
|
}
|
|
9714
|
-
|
|
9715
|
-
nextPage =
|
|
9732
|
+
orgRepoListCResult.data.results.forEach(row => rows.push(row));
|
|
9733
|
+
nextPage = orgRepoListCResult.data.nextPage ?? -1;
|
|
9716
9734
|
}
|
|
9717
9735
|
return {
|
|
9718
9736
|
ok: true,
|
|
@@ -9890,7 +9908,7 @@ const config$f = {
|
|
|
9890
9908
|
- Permissions: repo:list
|
|
9891
9909
|
|
|
9892
9910
|
Options
|
|
9893
|
-
${utils.getFlagListOutput(config.flags
|
|
9911
|
+
${utils.getFlagListOutput(config.flags)}
|
|
9894
9912
|
|
|
9895
9913
|
Examples
|
|
9896
9914
|
$ ${command}
|
|
@@ -10076,7 +10094,7 @@ const config$e = {
|
|
|
10076
10094
|
- Permissions: repo:update
|
|
10077
10095
|
|
|
10078
10096
|
Options
|
|
10079
|
-
${utils.getFlagListOutput(config.flags
|
|
10097
|
+
${utils.getFlagListOutput(config.flags)}
|
|
10080
10098
|
|
|
10081
10099
|
Examples
|
|
10082
10100
|
$ ${command} test-repo
|
|
@@ -10233,7 +10251,7 @@ const config$d = {
|
|
|
10233
10251
|
- Permissions: repo:list
|
|
10234
10252
|
|
|
10235
10253
|
Options
|
|
10236
|
-
${utils.getFlagListOutput(config.flags
|
|
10254
|
+
${utils.getFlagListOutput(config.flags)}
|
|
10237
10255
|
|
|
10238
10256
|
Examples
|
|
10239
10257
|
$ ${command} test-repo
|
|
@@ -10444,7 +10462,7 @@ const config$c = {
|
|
|
10444
10462
|
- Permissions: full-scans:create
|
|
10445
10463
|
|
|
10446
10464
|
Options
|
|
10447
|
-
${utils.getFlagListOutput(config.flags
|
|
10465
|
+
${utils.getFlagListOutput(config.flags)}
|
|
10448
10466
|
|
|
10449
10467
|
Uploads the specified dependency manifest files for Go, Gradle, JavaScript,
|
|
10450
10468
|
Kotlin, Python, and Scala. Files like "package.json" and "requirements.txt".
|
|
@@ -10732,7 +10750,7 @@ const config$b = {
|
|
|
10732
10750
|
- Permissions: full-scans:delete
|
|
10733
10751
|
|
|
10734
10752
|
Options
|
|
10735
|
-
${utils.getFlagListOutput(config.flags
|
|
10753
|
+
${utils.getFlagListOutput(config.flags)}
|
|
10736
10754
|
|
|
10737
10755
|
Examples
|
|
10738
10756
|
$ ${command} 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -11032,7 +11050,7 @@ const config$a = {
|
|
|
11032
11050
|
added/removed list (similar to diffing two files with git).
|
|
11033
11051
|
|
|
11034
11052
|
Options
|
|
11035
|
-
${utils.getFlagListOutput(config.flags
|
|
11053
|
+
${utils.getFlagListOutput(config.flags)}
|
|
11036
11054
|
|
|
11037
11055
|
Examples
|
|
11038
11056
|
$ ${command} aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
|
|
@@ -11128,7 +11146,7 @@ async function createScanFromGithub({
|
|
|
11128
11146
|
outputKind,
|
|
11129
11147
|
repos
|
|
11130
11148
|
}) {
|
|
11131
|
-
let targetRepos = repos.trim().split(',').map(
|
|
11149
|
+
let targetRepos = repos.trim().split(',').map(r => r.trim()).filter(Boolean);
|
|
11132
11150
|
if (all || targetRepos.length === 0) {
|
|
11133
11151
|
// Fetch from Socket API
|
|
11134
11152
|
const result = await fetchListAllRepos({
|
|
@@ -11141,7 +11159,7 @@ async function createScanFromGithub({
|
|
|
11141
11159
|
}
|
|
11142
11160
|
targetRepos = result.data.results.map(obj => obj.slug || '');
|
|
11143
11161
|
}
|
|
11144
|
-
targetRepos = targetRepos.map(
|
|
11162
|
+
targetRepos = targetRepos.map(s => s.trim()).filter(Boolean);
|
|
11145
11163
|
logger.logger.info(`Have ${targetRepos.length} repo names to Scan!`);
|
|
11146
11164
|
logger.logger.log('');
|
|
11147
11165
|
if (!targetRepos.filter(Boolean).length) {
|
|
@@ -11253,7 +11271,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
11253
11271
|
};
|
|
11254
11272
|
}
|
|
11255
11273
|
const tmpDir = fs$1.mkdtempSync(path.join(os.tmpdir(), repoSlug));
|
|
11256
|
-
debug.debugFn('init: temp dir for scan root', tmpDir);
|
|
11274
|
+
debug.debugFn('notice', 'init: temp dir for scan root', tmpDir);
|
|
11257
11275
|
const downloadResult = await testAndDownloadManifestFiles({
|
|
11258
11276
|
files,
|
|
11259
11277
|
tmpDir,
|
|
@@ -11366,9 +11384,9 @@ async function testAndDownloadManifestFile({
|
|
|
11366
11384
|
repoApiUrl,
|
|
11367
11385
|
tmpDir
|
|
11368
11386
|
}) {
|
|
11369
|
-
debug.debugFn('testing: file', file);
|
|
11387
|
+
debug.debugFn('notice', 'testing: file', file);
|
|
11370
11388
|
if (!SUPPORTED_FILE_PATTERNS.some(regex => regex.test(file))) {
|
|
11371
|
-
debug.debugFn(' - skip: not a known pattern');
|
|
11389
|
+
debug.debugFn('notice', ' - skip: not a known pattern');
|
|
11372
11390
|
// Not an error.
|
|
11373
11391
|
return {
|
|
11374
11392
|
ok: true,
|
|
@@ -11377,7 +11395,7 @@ async function testAndDownloadManifestFile({
|
|
|
11377
11395
|
}
|
|
11378
11396
|
};
|
|
11379
11397
|
}
|
|
11380
|
-
debug.debugFn('found: manifest file, going to attempt to download it;', file);
|
|
11398
|
+
debug.debugFn('notice', 'found: manifest file, going to attempt to download it;', file);
|
|
11381
11399
|
const result = await downloadManifestFile({
|
|
11382
11400
|
file,
|
|
11383
11401
|
tmpDir,
|
|
@@ -11399,18 +11417,18 @@ async function downloadManifestFile({
|
|
|
11399
11417
|
repoApiUrl,
|
|
11400
11418
|
tmpDir
|
|
11401
11419
|
}) {
|
|
11402
|
-
debug.debugFn('request: download url from GitHub');
|
|
11420
|
+
debug.debugFn('notice', 'request: download url from GitHub');
|
|
11403
11421
|
const fileUrl = `${repoApiUrl}/contents/${file}?ref=${defaultBranch}`;
|
|
11404
|
-
debug.debugFn('url: file', fileUrl);
|
|
11422
|
+
debug.debugFn('inspect', 'url: file', fileUrl);
|
|
11405
11423
|
const downloadUrlResponse = await fetch(fileUrl, {
|
|
11406
11424
|
method: 'GET',
|
|
11407
11425
|
headers: {
|
|
11408
11426
|
Authorization: `Bearer ${githubToken}`
|
|
11409
11427
|
}
|
|
11410
11428
|
});
|
|
11411
|
-
debug.debugFn('complete: request');
|
|
11429
|
+
debug.debugFn('notice', 'complete: request');
|
|
11412
11430
|
const downloadUrlText = await downloadUrlResponse.text();
|
|
11413
|
-
debug.debugFn('response: raw download url', downloadUrlText);
|
|
11431
|
+
debug.debugFn('inspect', 'response: raw download url', downloadUrlText);
|
|
11414
11432
|
let downloadUrl;
|
|
11415
11433
|
try {
|
|
11416
11434
|
downloadUrl = JSON.parse(downloadUrlText).download_url;
|
|
@@ -11423,7 +11441,7 @@ async function downloadManifestFile({
|
|
|
11423
11441
|
};
|
|
11424
11442
|
}
|
|
11425
11443
|
const localPath = path.join(tmpDir, file);
|
|
11426
|
-
debug.debugFn('download: manifest file started', downloadUrl, '->', localPath);
|
|
11444
|
+
debug.debugFn('notice', 'download: manifest file started', downloadUrl, '->', localPath);
|
|
11427
11445
|
|
|
11428
11446
|
// Now stream the file to that file...
|
|
11429
11447
|
const result = await streamDownloadWithFetch(localPath, downloadUrl);
|
|
@@ -11432,7 +11450,7 @@ async function downloadManifestFile({
|
|
|
11432
11450
|
logger.logger.fail(`Failed to download manifest file, skipping to next file. File: ${file}`);
|
|
11433
11451
|
return result;
|
|
11434
11452
|
}
|
|
11435
|
-
debug.debugFn('download: manifest file completed');
|
|
11453
|
+
debug.debugFn('notice', 'download: manifest file completed');
|
|
11436
11454
|
return {
|
|
11437
11455
|
ok: true,
|
|
11438
11456
|
data: undefined
|
|
@@ -11484,8 +11502,9 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
|
|
|
11484
11502
|
};
|
|
11485
11503
|
} catch (error) {
|
|
11486
11504
|
logger.logger.fail('An error was thrown while trying to download a manifest file... url:', downloadUrl);
|
|
11487
|
-
debug.debugFn('
|
|
11488
|
-
|
|
11505
|
+
debug.debugFn('inspect', {
|
|
11506
|
+
error
|
|
11507
|
+
});
|
|
11489
11508
|
|
|
11490
11509
|
// If an error occurs and fileStream was created, attempt to clean up.
|
|
11491
11510
|
if (fs$1.existsSync(localPath)) {
|
|
@@ -11507,7 +11526,7 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
|
|
|
11507
11526
|
// If error was due to bad HTTP status
|
|
11508
11527
|
detailedError += ` (HTTP Status: ${response.status} ${response.statusText})`;
|
|
11509
11528
|
}
|
|
11510
|
-
debug.debugFn(detailedError);
|
|
11529
|
+
debug.debugFn('error', detailedError);
|
|
11511
11530
|
return {
|
|
11512
11531
|
ok: false,
|
|
11513
11532
|
message: 'Download Failed',
|
|
@@ -11524,14 +11543,14 @@ async function getLastCommitDetails({
|
|
|
11524
11543
|
}) {
|
|
11525
11544
|
logger.logger.info(`Requesting last commit for default branch ${defaultBranch} for ${orgGithub}/${repoSlug}...`);
|
|
11526
11545
|
const commitApiUrl = `${repoApiUrl}/commits?sha=${defaultBranch}&per_page=1`;
|
|
11527
|
-
debug.debugFn('url: commit', commitApiUrl);
|
|
11546
|
+
debug.debugFn('inspect', 'url: commit', commitApiUrl);
|
|
11528
11547
|
const commitResponse = await fetch(commitApiUrl, {
|
|
11529
11548
|
headers: {
|
|
11530
11549
|
Authorization: `Bearer ${githubToken}`
|
|
11531
11550
|
}
|
|
11532
11551
|
});
|
|
11533
11552
|
const commitText = await commitResponse.text();
|
|
11534
|
-
debug.debugFn('response: commit', commitText);
|
|
11553
|
+
debug.debugFn('inspect', 'response: commit', commitText);
|
|
11535
11554
|
let lastCommit;
|
|
11536
11555
|
try {
|
|
11537
11556
|
lastCommit = JSON.parse(commitText)?.[0];
|
|
@@ -11618,7 +11637,7 @@ async function getRepoDetails({
|
|
|
11618
11637
|
repoSlug
|
|
11619
11638
|
}) {
|
|
11620
11639
|
const repoApiUrl = `${githubApiUrl}/repos/${orgGithub}/${repoSlug}`;
|
|
11621
|
-
debug.debugFn('url: repo', repoApiUrl);
|
|
11640
|
+
debug.debugFn('inspect', 'url: repo', repoApiUrl);
|
|
11622
11641
|
const repoDetailsResponse = await fetch(repoApiUrl, {
|
|
11623
11642
|
method: 'GET',
|
|
11624
11643
|
headers: {
|
|
@@ -11627,7 +11646,7 @@ async function getRepoDetails({
|
|
|
11627
11646
|
});
|
|
11628
11647
|
logger.logger.success(`Request completed.`);
|
|
11629
11648
|
const repoDetailsText = await repoDetailsResponse.text();
|
|
11630
|
-
debug.debugFn('response: repo', repoDetailsText);
|
|
11649
|
+
debug.debugFn('inspect', 'response: repo', repoDetailsText);
|
|
11631
11650
|
let repoDetails;
|
|
11632
11651
|
try {
|
|
11633
11652
|
repoDetails = JSON.parse(repoDetailsText);
|
|
@@ -11666,7 +11685,7 @@ async function getRepoBranchTree({
|
|
|
11666
11685
|
}) {
|
|
11667
11686
|
logger.logger.info(`Requesting default branch file tree; branch \`${defaultBranch}\`, repo \`${orgGithub}/${repoSlug}\`...`);
|
|
11668
11687
|
const treeApiUrl = `${repoApiUrl}/git/trees/${defaultBranch}?recursive=1`;
|
|
11669
|
-
debug.debugFn('url: tree', treeApiUrl);
|
|
11688
|
+
debug.debugFn('inspect', 'url: tree', treeApiUrl);
|
|
11670
11689
|
const treeResponse = await fetch(treeApiUrl, {
|
|
11671
11690
|
method: 'GET',
|
|
11672
11691
|
headers: {
|
|
@@ -11674,7 +11693,7 @@ async function getRepoBranchTree({
|
|
|
11674
11693
|
}
|
|
11675
11694
|
});
|
|
11676
11695
|
const treeText = await treeResponse.text();
|
|
11677
|
-
debug.debugFn('response: tree', treeText);
|
|
11696
|
+
debug.debugFn('inspect', 'response: tree', treeText);
|
|
11678
11697
|
let treeDetails;
|
|
11679
11698
|
try {
|
|
11680
11699
|
treeDetails = JSON.parse(treeText);
|
|
@@ -11703,7 +11722,7 @@ async function getRepoBranchTree({
|
|
|
11703
11722
|
};
|
|
11704
11723
|
}
|
|
11705
11724
|
if (!treeDetails.tree || !Array.isArray(treeDetails.tree)) {
|
|
11706
|
-
debug.debugFn('treeDetails.tree:', treeDetails.tree);
|
|
11725
|
+
debug.debugFn('inspect', 'treeDetails.tree:', treeDetails.tree);
|
|
11707
11726
|
return {
|
|
11708
11727
|
ok: false,
|
|
11709
11728
|
message: `Tree response for default branch ${defaultBranch} for ${orgGithub}/${repoSlug} was not a list`
|
|
@@ -11814,7 +11833,7 @@ const config$9 = {
|
|
|
11814
11833
|
You can use \`socket scan setup\` to configure certain repo flag defaults.
|
|
11815
11834
|
|
|
11816
11835
|
Options
|
|
11817
|
-
${utils.getFlagListOutput(config.flags
|
|
11836
|
+
${utils.getFlagListOutput(config.flags)}
|
|
11818
11837
|
|
|
11819
11838
|
Examples
|
|
11820
11839
|
$ ${command}
|
|
@@ -12130,7 +12149,7 @@ const config$8 = {
|
|
|
12130
12149
|
\`--branch\` to filter by branch across all repos).
|
|
12131
12150
|
|
|
12132
12151
|
Options
|
|
12133
|
-
${utils.getFlagListOutput(config.flags
|
|
12152
|
+
${utils.getFlagListOutput(config.flags)}
|
|
12134
12153
|
|
|
12135
12154
|
Examples
|
|
12136
12155
|
$ ${command}
|
|
@@ -12288,7 +12307,7 @@ const config$7 = {
|
|
|
12288
12307
|
- Permissions: full-scans:list
|
|
12289
12308
|
|
|
12290
12309
|
Options
|
|
12291
|
-
${utils.getFlagListOutput(config.flags
|
|
12310
|
+
${utils.getFlagListOutput(config.flags)}
|
|
12292
12311
|
|
|
12293
12312
|
Examples
|
|
12294
12313
|
$ ${command} 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -12407,7 +12426,7 @@ const config$6 = {
|
|
|
12407
12426
|
$ ${command} [options] [CWD=.]
|
|
12408
12427
|
|
|
12409
12428
|
Options
|
|
12410
|
-
${utils.getFlagListOutput(config.flags
|
|
12429
|
+
${utils.getFlagListOutput(config.flags)}
|
|
12411
12430
|
|
|
12412
12431
|
Examples
|
|
12413
12432
|
$ ${command}
|
|
@@ -12505,7 +12524,7 @@ const config$5 = {
|
|
|
12505
12524
|
- Permissions: full-scans:list security-policy:read
|
|
12506
12525
|
|
|
12507
12526
|
Options
|
|
12508
|
-
${utils.getFlagListOutput(config.flags
|
|
12527
|
+
${utils.getFlagListOutput(config.flags)}
|
|
12509
12528
|
|
|
12510
12529
|
When no output path is given the contents is sent to stdout.
|
|
12511
12530
|
|
|
@@ -12722,10 +12741,10 @@ async function configureScan(config) {
|
|
|
12722
12741
|
if (defaultRepoName === undefined) {
|
|
12723
12742
|
return canceledByUser();
|
|
12724
12743
|
}
|
|
12725
|
-
if (defaultRepoName
|
|
12744
|
+
if (defaultRepoName) {
|
|
12726
12745
|
// Even if it's 'socket-default-repository' store it because if we change
|
|
12727
12746
|
// this default then an existing user probably would not expect the change?
|
|
12728
|
-
config.repo = defaultRepoName
|
|
12747
|
+
config.repo = defaultRepoName;
|
|
12729
12748
|
} else {
|
|
12730
12749
|
delete config.repo;
|
|
12731
12750
|
}
|
|
@@ -12738,10 +12757,10 @@ async function configureScan(config) {
|
|
|
12738
12757
|
if (defaultBranchName === undefined) {
|
|
12739
12758
|
return canceledByUser();
|
|
12740
12759
|
}
|
|
12741
|
-
if (defaultBranchName
|
|
12760
|
+
if (defaultBranchName) {
|
|
12742
12761
|
// Even if it's 'socket-default-branch' store it because if we change
|
|
12743
12762
|
// this default then an existing user probably would not expect the change?
|
|
12744
|
-
config.branch = defaultBranchName
|
|
12763
|
+
config.branch = defaultBranchName;
|
|
12745
12764
|
} else {
|
|
12746
12765
|
delete config.branch;
|
|
12747
12766
|
}
|
|
@@ -12841,23 +12860,27 @@ async function configureGithub(config) {
|
|
|
12841
12860
|
if (defaultRepos === undefined) {
|
|
12842
12861
|
return canceledByUser();
|
|
12843
12862
|
}
|
|
12844
|
-
if (defaultRepos
|
|
12845
|
-
config.repos = defaultRepos
|
|
12863
|
+
if (defaultRepos) {
|
|
12864
|
+
config.repos = defaultRepos;
|
|
12846
12865
|
} else {
|
|
12847
12866
|
delete config.repos;
|
|
12848
12867
|
}
|
|
12849
12868
|
}
|
|
12850
12869
|
const defaultGithubApiUrl = await prompts.input({
|
|
12851
12870
|
message: '(--githubApiUrl) Do you want to override the default github url?',
|
|
12852
|
-
default: config.githubApiUrl ||
|
|
12871
|
+
default: config.githubApiUrl ||
|
|
12872
|
+
// Lazily access constants.ENV.GITHUB_API_URL.
|
|
12873
|
+
constants.ENV.GITHUB_API_URL,
|
|
12853
12874
|
required: false
|
|
12854
12875
|
// validate: async string => bool
|
|
12855
12876
|
});
|
|
12856
12877
|
if (defaultGithubApiUrl === undefined) {
|
|
12857
12878
|
return canceledByUser();
|
|
12858
12879
|
}
|
|
12859
|
-
if (defaultGithubApiUrl
|
|
12860
|
-
|
|
12880
|
+
if (defaultGithubApiUrl &&
|
|
12881
|
+
// Lazily access constants.ENV.GITHUB_API_URL.
|
|
12882
|
+
defaultGithubApiUrl !== constants.ENV.GITHUB_API_URL) {
|
|
12883
|
+
config.githubApiUrl = defaultGithubApiUrl;
|
|
12861
12884
|
} else {
|
|
12862
12885
|
delete config.githubApiUrl;
|
|
12863
12886
|
}
|
|
@@ -12870,8 +12893,8 @@ async function configureGithub(config) {
|
|
|
12870
12893
|
if (defaultOrgGithub === undefined) {
|
|
12871
12894
|
return canceledByUser();
|
|
12872
12895
|
}
|
|
12873
|
-
if (defaultOrgGithub
|
|
12874
|
-
config.orgGithub = defaultOrgGithub
|
|
12896
|
+
if (defaultOrgGithub) {
|
|
12897
|
+
config.orgGithub = defaultOrgGithub;
|
|
12875
12898
|
} else {
|
|
12876
12899
|
delete config.orgGithub;
|
|
12877
12900
|
}
|
|
@@ -12921,7 +12944,7 @@ const config$4 = {
|
|
|
12921
12944
|
$ ${command} [options] [CWD=.]
|
|
12922
12945
|
|
|
12923
12946
|
Options
|
|
12924
|
-
${utils.getFlagListOutput(config.flags
|
|
12947
|
+
${utils.getFlagListOutput(config.flags)}
|
|
12925
12948
|
|
|
12926
12949
|
Interactive configurator to create a local json file in the target directory
|
|
12927
12950
|
that helps to set flag defaults for \`socket scan create\`.
|
|
@@ -12983,7 +13006,10 @@ async function fetchScan(orgSlug, scanId) {
|
|
|
12983
13006
|
return JSON.parse(line);
|
|
12984
13007
|
} catch {
|
|
12985
13008
|
ok = false;
|
|
12986
|
-
debug.debugFn('fail: parse NDJSON
|
|
13009
|
+
debug.debugFn('error', 'fail: parse NDJSON');
|
|
13010
|
+
debug.debugDir('inspect', {
|
|
13011
|
+
line
|
|
13012
|
+
});
|
|
12987
13013
|
return null;
|
|
12988
13014
|
}
|
|
12989
13015
|
});
|
|
@@ -13126,7 +13152,7 @@ const config$3 = {
|
|
|
13126
13152
|
When no output path is given the contents is sent to stdout.
|
|
13127
13153
|
|
|
13128
13154
|
Options
|
|
13129
|
-
${utils.getFlagListOutput(config.flags
|
|
13155
|
+
${utils.getFlagListOutput(config.flags)}
|
|
13130
13156
|
|
|
13131
13157
|
Examples
|
|
13132
13158
|
$ ${command} 000aaaa1-0000-0a0a-00a0-00a0000000a0
|
|
@@ -13488,7 +13514,7 @@ const config$2 = {
|
|
|
13488
13514
|
sales@socket.dev if you are interested in purchasing this access.
|
|
13489
13515
|
|
|
13490
13516
|
Options
|
|
13491
|
-
${utils.getFlagListOutput(config.flags
|
|
13517
|
+
${utils.getFlagListOutput(config.flags)}
|
|
13492
13518
|
|
|
13493
13519
|
Valid ecosystems:
|
|
13494
13520
|
|
|
@@ -13749,7 +13775,7 @@ const config$1 = {
|
|
|
13749
13775
|
tab completion that is registered for it in bash.
|
|
13750
13776
|
|
|
13751
13777
|
Options
|
|
13752
|
-
${utils.getFlagListOutput(config.flags
|
|
13778
|
+
${utils.getFlagListOutput(config.flags)}
|
|
13753
13779
|
|
|
13754
13780
|
Examples
|
|
13755
13781
|
|
|
@@ -13863,7 +13889,10 @@ Do you want to install "safe npm" (this will create an alias to the socket-npm c
|
|
|
13863
13889
|
}
|
|
13864
13890
|
}
|
|
13865
13891
|
} catch (e) {
|
|
13866
|
-
debug.debugFn('fail: setup tab completion
|
|
13892
|
+
debug.debugFn('error', 'fail: setup tab completion');
|
|
13893
|
+
debug.debugDir('inspect', {
|
|
13894
|
+
error: e
|
|
13895
|
+
});
|
|
13867
13896
|
// Ignore. Skip tab completion setup.
|
|
13868
13897
|
}
|
|
13869
13898
|
if (!updatedTabCompletion) {
|
|
@@ -13943,7 +13972,7 @@ const config = {
|
|
|
13943
13972
|
$ ${command} <"on" | "off">
|
|
13944
13973
|
|
|
13945
13974
|
Options
|
|
13946
|
-
${utils.getFlagListOutput(config.flags
|
|
13975
|
+
${utils.getFlagListOutput(config.flags)}
|
|
13947
13976
|
|
|
13948
13977
|
While enabled, the wrapper makes it so that when you call npm/npx on your
|
|
13949
13978
|
machine, it will automatically actually run \`socket npm\` / \`socket npx\`
|
|
@@ -14177,8 +14206,10 @@ void (async () => {
|
|
|
14177
14206
|
});
|
|
14178
14207
|
} catch (e) {
|
|
14179
14208
|
process.exitCode = 1;
|
|
14180
|
-
debug.debugFn('Uncaught error (BAD!):');
|
|
14181
|
-
debug.
|
|
14209
|
+
debug.debugFn('error', 'Uncaught error (BAD!):');
|
|
14210
|
+
debug.debugDir('inspect', {
|
|
14211
|
+
error: e
|
|
14212
|
+
});
|
|
14182
14213
|
|
|
14183
14214
|
// Try to parse the flags, find out if --json or --markdown is set.
|
|
14184
14215
|
let isJson = false;
|
|
@@ -14220,12 +14251,13 @@ void (async () => {
|
|
|
14220
14251
|
logger.logger.error('\n'); // Any-spinner-newline
|
|
14221
14252
|
logger.logger.fail(utils.failMsgWithBadge(errorTitle, errorMessage));
|
|
14222
14253
|
if (errorBody) {
|
|
14223
|
-
|
|
14224
|
-
|
|
14254
|
+
debug.debugDir('inspect', {
|
|
14255
|
+
errorBody
|
|
14256
|
+
});
|
|
14225
14257
|
}
|
|
14226
14258
|
}
|
|
14227
14259
|
await utils.captureException(e);
|
|
14228
14260
|
}
|
|
14229
14261
|
})();
|
|
14230
|
-
//# debugId=
|
|
14262
|
+
//# debugId=3366e965-b082-456e-8e60-114997e8eaf0
|
|
14231
14263
|
//# sourceMappingURL=cli.js.map
|