socket 1.0.82 → 1.0.84
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 +149 -95
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/agent-fix.d.mts +5 -1
- package/dist/types/commands/fix/agent-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/utils/api.d.mts +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/utils.js +23 -23
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -446,7 +446,7 @@ async function run$P(argv, importMeta, {
|
|
|
446
446
|
test: hasApiToken,
|
|
447
447
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
448
448
|
pass: 'ok',
|
|
449
|
-
fail: 'missing API token'
|
|
449
|
+
fail: 'missing Socket API token'
|
|
450
450
|
});
|
|
451
451
|
if (!wasValidInput) {
|
|
452
452
|
return;
|
|
@@ -860,7 +860,7 @@ async function run$O(argv, importMeta, {
|
|
|
860
860
|
test: hasApiToken,
|
|
861
861
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
862
862
|
pass: 'ok',
|
|
863
|
-
fail: 'missing API token'
|
|
863
|
+
fail: 'missing Socket API token'
|
|
864
864
|
}, {
|
|
865
865
|
nook: true,
|
|
866
866
|
test: !json || !markdown,
|
|
@@ -1033,8 +1033,8 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
1033
1033
|
updateScan('received invalid JSON response');
|
|
1034
1034
|
return {
|
|
1035
1035
|
ok: false,
|
|
1036
|
-
message: 'Invalid API response',
|
|
1037
|
-
cause: 'The API responded with at least one line that was not valid JSON. Please report if this persists.'
|
|
1036
|
+
message: 'Invalid Socket API response',
|
|
1037
|
+
cause: 'The Socket API responded with at least one line that was not valid JSON. Please report if this persists.'
|
|
1038
1038
|
};
|
|
1039
1039
|
}
|
|
1040
1040
|
async function fetchSecurityPolicy() {
|
|
@@ -1044,18 +1044,18 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
1044
1044
|
}
|
|
1045
1045
|
updateProgress();
|
|
1046
1046
|
const [scan, securityPolicy] = await Promise.all([fetchScanResult().catch(e => {
|
|
1047
|
-
updateScan('failure; unknown blocking
|
|
1047
|
+
updateScan('failure; unknown blocking error occurred');
|
|
1048
1048
|
return {
|
|
1049
1049
|
ok: false,
|
|
1050
|
-
message: '
|
|
1051
|
-
cause: `
|
|
1050
|
+
message: 'Socket API error',
|
|
1051
|
+
cause: `Error requesting scan: ${e?.message || '(no error message found)'}${e?.cause ? ` (cause: ${e.cause})` : ''}`
|
|
1052
1052
|
};
|
|
1053
1053
|
}), fetchSecurityPolicy().catch(e => {
|
|
1054
|
-
updatePolicy('failure; unknown blocking
|
|
1054
|
+
updatePolicy('failure; unknown blocking error occurred');
|
|
1055
1055
|
return {
|
|
1056
1056
|
ok: false,
|
|
1057
|
-
message: '
|
|
1058
|
-
cause: `
|
|
1057
|
+
message: 'Socket API error',
|
|
1058
|
+
cause: `Error requesting policy: ${e?.message || '(no error message found)'}${e?.cause ? ` (cause: ${e.cause})` : ''}`
|
|
1059
1059
|
};
|
|
1060
1060
|
})]).finally(() => {
|
|
1061
1061
|
finishedFetching = true;
|
|
@@ -2156,7 +2156,7 @@ const config$K = {
|
|
|
2156
2156
|
accept or reject a current build. When the scan does not pass your security
|
|
2157
2157
|
policy, the exit code will be non-zero.
|
|
2158
2158
|
|
|
2159
|
-
It will use the default org for the
|
|
2159
|
+
It will use the default org for the Socket API token.
|
|
2160
2160
|
|
|
2161
2161
|
The --autoManifest flag does the same as the one from \`socket scan create\`
|
|
2162
2162
|
but is not enabled by default since the CI is less likely to be set up with
|
|
@@ -3802,13 +3802,13 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3802
3802
|
return basename === 'package.json' || basename === pkgEnvDetails.lockName;
|
|
3803
3803
|
}) : [];
|
|
3804
3804
|
};
|
|
3805
|
-
const handleInstallFail =
|
|
3805
|
+
const handleInstallFail = error => {
|
|
3806
3806
|
cleanupInfoEntriesLoop();
|
|
3807
3807
|
spinner?.stop();
|
|
3808
3808
|
return {
|
|
3809
3809
|
ok: false,
|
|
3810
3810
|
message: 'Install failed',
|
|
3811
|
-
cause:
|
|
3811
|
+
cause: `${pkgEnvDetails.agent} install failed${error ? `; ${error}` : ''}`
|
|
3812
3812
|
};
|
|
3813
3813
|
};
|
|
3814
3814
|
const hasModifiedFiles = async (cwd = process.cwd()) => {
|
|
@@ -3863,21 +3863,26 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3863
3863
|
// eslint-disable-next-line no-await-in-loop
|
|
3864
3864
|
await utils.removeNodeModules(cwd);
|
|
3865
3865
|
}
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3866
|
+
if (fixEnv.isCi && fs$1.existsSync(path.join(rootPath, 'node_modules'))) {
|
|
3867
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3868
|
+
actualTree = await getActualTree(cwd);
|
|
3869
|
+
} else {
|
|
3870
|
+
// eslint-disable-next-line no-await-in-loop
|
|
3871
|
+
const installResult = await installer(pkgEnvDetails, {
|
|
3872
|
+
cwd,
|
|
3873
|
+
spinner
|
|
3874
|
+
});
|
|
3875
|
+
const maybeActualTree = installResult.actualTree;
|
|
3876
|
+
if (!maybeActualTree) {
|
|
3877
|
+
// Exit early if install fails.
|
|
3878
|
+
return handleInstallFail(installResult.error);
|
|
3879
|
+
}
|
|
3875
3880
|
actualTree = maybeActualTree;
|
|
3876
3881
|
}
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3882
|
+
if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
|
|
3883
|
+
// Exit early if lockfile is missing.
|
|
3884
|
+
return handleInstallFail(new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`));
|
|
3885
|
+
}
|
|
3881
3886
|
}
|
|
3882
3887
|
const oldVersions = arrays.arrayUnique(shadowNpmInject.findPackageNodes(actualTree, name).map(n => n.version).filter(Boolean));
|
|
3883
3888
|
if (!oldVersions.length) {
|
|
@@ -3994,11 +3999,18 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
3994
3999
|
let errored = false;
|
|
3995
4000
|
try {
|
|
3996
4001
|
// eslint-disable-next-line no-await-in-loop
|
|
3997
|
-
const
|
|
4002
|
+
const installResult = await installer(pkgEnvDetails, {
|
|
3998
4003
|
cwd,
|
|
3999
4004
|
spinner
|
|
4000
4005
|
});
|
|
4001
|
-
|
|
4006
|
+
const maybeActualTree = installResult.actualTree;
|
|
4007
|
+
if (!maybeActualTree) {
|
|
4008
|
+
errored = true;
|
|
4009
|
+
error = installResult.error;
|
|
4010
|
+
} else if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
|
|
4011
|
+
errored = true;
|
|
4012
|
+
error = new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`);
|
|
4013
|
+
} else {
|
|
4002
4014
|
actualTree = maybeActualTree;
|
|
4003
4015
|
// eslint-disable-next-line no-await-in-loop
|
|
4004
4016
|
await afterInstall(editablePkgJson, packument, oldVersion, newVersion, vulnerableVersionRange, fixConfig);
|
|
@@ -4012,8 +4024,6 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4012
4024
|
}
|
|
4013
4025
|
spinner?.success(`Fixed ${name} in ${workspace}.`);
|
|
4014
4026
|
seenVersions.add(newVersion);
|
|
4015
|
-
} else {
|
|
4016
|
-
errored = true;
|
|
4017
4027
|
}
|
|
4018
4028
|
} catch (e) {
|
|
4019
4029
|
error = e;
|
|
@@ -4049,16 +4059,21 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4049
4059
|
// eslint-disable-next-line no-await-in-loop
|
|
4050
4060
|
await utils.gitDeleteBranch(branch, cwd);
|
|
4051
4061
|
// eslint-disable-next-line no-await-in-loop
|
|
4052
|
-
const
|
|
4062
|
+
const installResult = await installer(pkgEnvDetails, {
|
|
4053
4063
|
cwd,
|
|
4054
4064
|
spinner
|
|
4055
4065
|
});
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4066
|
+
const maybeActualTree = installResult.actualTree;
|
|
4067
|
+
if (!maybeActualTree) {
|
|
4068
|
+
// Exit early if install fails.
|
|
4069
|
+
return handleInstallFail(installResult.error);
|
|
4059
4070
|
}
|
|
4060
|
-
|
|
4061
|
-
|
|
4071
|
+
if (!fs$1.existsSync(pkgEnvDetails.lockPath)) {
|
|
4072
|
+
// Exit early if lockfile is missing.
|
|
4073
|
+
return handleInstallFail(new Error(`Missing lockfile at ${pkgEnvDetails.lockPath}`));
|
|
4074
|
+
}
|
|
4075
|
+
actualTree = maybeActualTree;
|
|
4076
|
+
continue infosLoop;
|
|
4062
4077
|
}
|
|
4063
4078
|
seenBranches.add(branch);
|
|
4064
4079
|
|
|
@@ -4112,15 +4127,17 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4112
4127
|
// eslint-disable-next-line no-await-in-loop
|
|
4113
4128
|
await utils.gitCheckoutBranch(fixEnv.baseBranch, cwd);
|
|
4114
4129
|
// eslint-disable-next-line no-await-in-loop
|
|
4115
|
-
const
|
|
4130
|
+
const installResult = await installer(pkgEnvDetails, {
|
|
4116
4131
|
cwd,
|
|
4117
4132
|
spinner
|
|
4118
4133
|
});
|
|
4119
4134
|
spinner?.stop();
|
|
4135
|
+
const maybeActualTree = installResult.actualTree;
|
|
4120
4136
|
if (maybeActualTree) {
|
|
4121
4137
|
actualTree = maybeActualTree;
|
|
4122
4138
|
} else {
|
|
4123
4139
|
errored = true;
|
|
4140
|
+
error = installResult.error;
|
|
4124
4141
|
}
|
|
4125
4142
|
}
|
|
4126
4143
|
if (errored) {
|
|
@@ -4133,17 +4150,17 @@ async function agentFix(pkgEnvDetails, actualTree, alertsMap, installer, {
|
|
|
4133
4150
|
ignoreWhitespace: true
|
|
4134
4151
|
})]);
|
|
4135
4152
|
// eslint-disable-next-line no-await-in-loop
|
|
4136
|
-
const
|
|
4153
|
+
const installResult = await installer(pkgEnvDetails, {
|
|
4137
4154
|
cwd,
|
|
4138
4155
|
spinner
|
|
4139
4156
|
});
|
|
4140
4157
|
spinner?.stop();
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
} else {
|
|
4158
|
+
const maybeActualTree = installResult.actualTree;
|
|
4159
|
+
if (!maybeActualTree) {
|
|
4144
4160
|
// Exit early if install fails.
|
|
4145
|
-
return handleInstallFail();
|
|
4161
|
+
return handleInstallFail(installResult.error);
|
|
4146
4162
|
}
|
|
4163
|
+
actualTree = maybeActualTree;
|
|
4147
4164
|
}
|
|
4148
4165
|
return {
|
|
4149
4166
|
ok: false,
|
|
@@ -4245,6 +4262,7 @@ async function install$1(pkgEnvDetails, options) {
|
|
|
4245
4262
|
require$$6.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
4246
4263
|
const isSpinning = spinner?.isSpinning;
|
|
4247
4264
|
spinner?.stop();
|
|
4265
|
+
let error;
|
|
4248
4266
|
let errored = false;
|
|
4249
4267
|
try {
|
|
4250
4268
|
await utils.runAgentInstall(pkgEnvDetails, {
|
|
@@ -4253,27 +4271,37 @@ async function install$1(pkgEnvDetails, options) {
|
|
|
4253
4271
|
stdio: useDebug ? 'inherit' : 'ignore'
|
|
4254
4272
|
});
|
|
4255
4273
|
} catch (e) {
|
|
4274
|
+
errored = true;
|
|
4275
|
+
error = e;
|
|
4256
4276
|
require$$6.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
4257
4277
|
require$$6.debugDir('inspect', {
|
|
4258
|
-
error
|
|
4278
|
+
error
|
|
4259
4279
|
});
|
|
4260
|
-
errored = true;
|
|
4261
4280
|
}
|
|
4262
|
-
let actualTree =
|
|
4281
|
+
let actualTree = undefined;
|
|
4263
4282
|
if (!errored) {
|
|
4264
4283
|
try {
|
|
4265
4284
|
actualTree = await getActualTree(cwd);
|
|
4266
4285
|
} catch (e) {
|
|
4286
|
+
errored = true;
|
|
4287
|
+
error = e;
|
|
4267
4288
|
require$$6.debugFn('error', 'caught: Arborist error');
|
|
4268
4289
|
require$$6.debugDir('inspect', {
|
|
4269
|
-
error
|
|
4290
|
+
error
|
|
4270
4291
|
});
|
|
4271
4292
|
}
|
|
4272
4293
|
}
|
|
4273
4294
|
if (isSpinning) {
|
|
4274
4295
|
spinner.start();
|
|
4275
4296
|
}
|
|
4276
|
-
return
|
|
4297
|
+
return {
|
|
4298
|
+
...(actualTree ? {
|
|
4299
|
+
actualTree
|
|
4300
|
+
} : undefined),
|
|
4301
|
+
...(errored ? {
|
|
4302
|
+
error
|
|
4303
|
+
} : undefined)
|
|
4304
|
+
};
|
|
4277
4305
|
}
|
|
4278
4306
|
async function npmFix(pkgEnvDetails, fixConfig) {
|
|
4279
4307
|
const {
|
|
@@ -4290,25 +4318,39 @@ async function npmFix(pkgEnvDetails, fixConfig) {
|
|
|
4290
4318
|
if (purls.length) {
|
|
4291
4319
|
alertsMap = await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions());
|
|
4292
4320
|
} else {
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4321
|
+
let arb;
|
|
4322
|
+
try {
|
|
4323
|
+
arb = new shadowNpmInject.Arborist({
|
|
4324
|
+
path: pkgEnvDetails.pkgPath,
|
|
4325
|
+
...flatConfig,
|
|
4326
|
+
...shadowNpmInject.SAFE_WITH_SAVE_ARBORIST_REIFY_OPTIONS_OVERRIDES
|
|
4327
|
+
});
|
|
4328
|
+
// Calling arb.reify() creates the arb.diff object, nulls-out arb.idealTree,
|
|
4329
|
+
// and populates arb.actualTree.
|
|
4330
|
+
actualTree = await arb.reify();
|
|
4331
|
+
} catch (e) {
|
|
4332
|
+
spinner?.stop();
|
|
4333
|
+
require$$6.debugFn('error', 'caught: await arb.reify() error');
|
|
4334
|
+
require$$6.debugDir('inspect', {
|
|
4335
|
+
error: e
|
|
4336
|
+
});
|
|
4337
|
+
return {
|
|
4338
|
+
ok: false,
|
|
4339
|
+
message: 'Arborist error',
|
|
4340
|
+
cause: e?.message || 'Unknown Arborist error.'
|
|
4341
|
+
};
|
|
4342
|
+
}
|
|
4301
4343
|
alertsMap = await shadowNpmInject.getAlertsMapFromArborist(arb, getFixAlertsMapOptions());
|
|
4302
4344
|
}
|
|
4303
4345
|
} catch (e) {
|
|
4304
4346
|
spinner?.stop();
|
|
4305
|
-
require$$6.debugFn('error', 'caught: PURL API');
|
|
4347
|
+
require$$6.debugFn('error', 'caught: Socket batch PURL API error');
|
|
4306
4348
|
require$$6.debugDir('inspect', {
|
|
4307
4349
|
error: e
|
|
4308
4350
|
});
|
|
4309
4351
|
return {
|
|
4310
4352
|
ok: false,
|
|
4311
|
-
message: 'API
|
|
4353
|
+
message: 'Socket API error',
|
|
4312
4354
|
cause: e?.message || 'Unknown Socket batch PURL API error.'
|
|
4313
4355
|
};
|
|
4314
4356
|
}
|
|
@@ -4411,6 +4453,7 @@ async function install(pkgEnvDetails, options) {
|
|
|
4411
4453
|
require$$6.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
4412
4454
|
const isSpinning = spinner?.isSpinning;
|
|
4413
4455
|
spinner?.stop();
|
|
4456
|
+
let error;
|
|
4414
4457
|
let errored = false;
|
|
4415
4458
|
try {
|
|
4416
4459
|
await utils.runAgentInstall(pkgEnvDetails, {
|
|
@@ -4419,27 +4462,37 @@ async function install(pkgEnvDetails, options) {
|
|
|
4419
4462
|
stdio: require$$6.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
4420
4463
|
});
|
|
4421
4464
|
} catch (e) {
|
|
4465
|
+
errored = true;
|
|
4466
|
+
error = e;
|
|
4422
4467
|
require$$6.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
4423
4468
|
require$$6.debugDir('inspect', {
|
|
4424
|
-
error
|
|
4469
|
+
error
|
|
4425
4470
|
});
|
|
4426
|
-
errored = true;
|
|
4427
4471
|
}
|
|
4428
|
-
let actualTree =
|
|
4472
|
+
let actualTree = undefined;
|
|
4429
4473
|
if (!errored) {
|
|
4430
4474
|
try {
|
|
4431
4475
|
actualTree = await getActualTree(cwd);
|
|
4432
4476
|
} catch (e) {
|
|
4477
|
+
errored = true;
|
|
4478
|
+
error = e;
|
|
4433
4479
|
require$$6.debugFn('error', 'caught: Arborist error');
|
|
4434
4480
|
require$$6.debugDir('inspect', {
|
|
4435
|
-
error
|
|
4481
|
+
error
|
|
4436
4482
|
});
|
|
4437
4483
|
}
|
|
4438
4484
|
}
|
|
4439
4485
|
if (isSpinning) {
|
|
4440
4486
|
spinner.start();
|
|
4441
4487
|
}
|
|
4442
|
-
return
|
|
4488
|
+
return {
|
|
4489
|
+
...(actualTree ? {
|
|
4490
|
+
actualTree
|
|
4491
|
+
} : undefined),
|
|
4492
|
+
...(errored ? {
|
|
4493
|
+
error
|
|
4494
|
+
} : undefined)
|
|
4495
|
+
};
|
|
4443
4496
|
}
|
|
4444
4497
|
async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
4445
4498
|
const {
|
|
@@ -4454,11 +4507,12 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4454
4507
|
// Update pnpm-lock.yaml if its version is older than what the installed pnpm
|
|
4455
4508
|
// produces.
|
|
4456
4509
|
if (pkgEnvDetails.agentVersion.major >= 10 && (utils.parsePnpmLockfileVersion(lockfile?.lockfileVersion)?.major ?? 0) <= 6) {
|
|
4457
|
-
const
|
|
4510
|
+
const installResult = await install(pkgEnvDetails, {
|
|
4458
4511
|
args: ['--lockfile-only'],
|
|
4459
4512
|
cwd,
|
|
4460
4513
|
spinner
|
|
4461
4514
|
});
|
|
4515
|
+
const maybeActualTree = installResult.actualTree;
|
|
4462
4516
|
if (maybeActualTree) {
|
|
4463
4517
|
lockSrc = (await utils.readLockfile(pkgEnvDetails.lockPath)) ?? '';
|
|
4464
4518
|
} else {
|
|
@@ -4487,13 +4541,13 @@ async function pnpmFix(pkgEnvDetails, fixConfig) {
|
|
|
4487
4541
|
alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getFixAlertsMapOptions()) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getFixAlertsMapOptions());
|
|
4488
4542
|
} catch (e) {
|
|
4489
4543
|
spinner?.stop();
|
|
4490
|
-
require$$6.debugFn('error', 'caught: PURL API');
|
|
4544
|
+
require$$6.debugFn('error', 'caught: Socket batch PURL API error');
|
|
4491
4545
|
require$$6.debugDir('inspect', {
|
|
4492
4546
|
error: e
|
|
4493
4547
|
});
|
|
4494
4548
|
return {
|
|
4495
4549
|
ok: false,
|
|
4496
|
-
message: 'API
|
|
4550
|
+
message: 'Socket API error',
|
|
4497
4551
|
cause: e?.message || 'Unknown Socket batch PURL API error.'
|
|
4498
4552
|
};
|
|
4499
4553
|
}
|
|
@@ -5152,7 +5206,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5152
5206
|
apiBaseUrl ??= utils.getConfigValueOrUndef('apiBaseUrl') ?? undefined;
|
|
5153
5207
|
apiProxy ??= utils.getConfigValueOrUndef('apiProxy') ?? undefined;
|
|
5154
5208
|
const apiTokenInput = await prompts.password({
|
|
5155
|
-
message: `Enter your ${vendor.terminalLinkExports('Socket.dev API
|
|
5209
|
+
message: `Enter your ${vendor.terminalLinkExports('Socket.dev API token', 'https://docs.socket.dev/docs/api-keys')} (leave blank for a public key)`
|
|
5156
5210
|
});
|
|
5157
5211
|
if (apiTokenInput === undefined) {
|
|
5158
5212
|
logger.logger.fail('Canceled by user');
|
|
@@ -5186,7 +5240,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
5186
5240
|
organizations
|
|
5187
5241
|
} = orgsCResult.data;
|
|
5188
5242
|
const orgSlugs = Object.values(organizations).map(obj => obj.slug);
|
|
5189
|
-
logger.logger.success(`API
|
|
5243
|
+
logger.logger.success(`API token verified: ${orgSlugs}`);
|
|
5190
5244
|
const enforcedChoices = Object.values(organizations).filter(org => org?.plan === 'enterprise').map(org => ({
|
|
5191
5245
|
name: org.name ?? 'undefined',
|
|
5192
5246
|
value: org.id
|
|
@@ -5301,7 +5355,7 @@ const config$E = {
|
|
|
5301
5355
|
API Token Requirements
|
|
5302
5356
|
- Quota: 1 unit
|
|
5303
5357
|
|
|
5304
|
-
Logs into the Socket API by prompting for an API
|
|
5358
|
+
Logs into the Socket API by prompting for an API token
|
|
5305
5359
|
|
|
5306
5360
|
Options
|
|
5307
5361
|
${utils.getFlagListOutput(config.flags)}
|
|
@@ -8220,7 +8274,7 @@ async function run$q(argv, importMeta, {
|
|
|
8220
8274
|
test: hasApiToken,
|
|
8221
8275
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
8222
8276
|
pass: 'ok',
|
|
8223
|
-
fail: 'missing API token'
|
|
8277
|
+
fail: 'missing Socket API token'
|
|
8224
8278
|
});
|
|
8225
8279
|
if (!wasValidInput) {
|
|
8226
8280
|
return;
|
|
@@ -8360,7 +8414,7 @@ async function run$p(argv, importMeta, {
|
|
|
8360
8414
|
test: hasApiToken,
|
|
8361
8415
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
8362
8416
|
pass: 'ok',
|
|
8363
|
-
fail: 'missing API token'
|
|
8417
|
+
fail: 'missing Socket API token'
|
|
8364
8418
|
});
|
|
8365
8419
|
if (!wasValidInput) {
|
|
8366
8420
|
return;
|
|
@@ -8499,7 +8553,7 @@ async function run$o(argv, importMeta, {
|
|
|
8499
8553
|
test: hasApiToken,
|
|
8500
8554
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
8501
8555
|
pass: 'ok',
|
|
8502
|
-
fail: 'missing API token'
|
|
8556
|
+
fail: 'missing Socket API token'
|
|
8503
8557
|
});
|
|
8504
8558
|
if (!wasValidInput) {
|
|
8505
8559
|
return;
|
|
@@ -8541,7 +8595,7 @@ async function outputOrganizationList(result, outputKind = 'text') {
|
|
|
8541
8595
|
mw3 = Math.max(mw3, o.plan.length);
|
|
8542
8596
|
}
|
|
8543
8597
|
logger.logger.log('# Organizations\n');
|
|
8544
|
-
logger.logger.log(`List of organizations associated with your API
|
|
8598
|
+
logger.logger.log(`List of organizations associated with your API token, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8545
8599
|
logger.logger.log(`| Name${' '.repeat(mw1 - 4)} | ID${' '.repeat(mw2 - 2)} | Plan${' '.repeat(mw3 - 4)} |`);
|
|
8546
8600
|
logger.logger.log(`| ${'-'.repeat(mw1)} | ${'-'.repeat(mw2)} | ${'-'.repeat(mw3)} |`);
|
|
8547
8601
|
for (const o of organizations) {
|
|
@@ -8552,7 +8606,7 @@ async function outputOrganizationList(result, outputKind = 'text') {
|
|
|
8552
8606
|
}
|
|
8553
8607
|
default:
|
|
8554
8608
|
{
|
|
8555
|
-
logger.logger.log(`List of organizations associated with your API
|
|
8609
|
+
logger.logger.log(`List of organizations associated with your API token, starting with: ${vendor.yoctocolorsCjsExports.italic(visibleTokenPrefix)}\n`);
|
|
8556
8610
|
// Just dump
|
|
8557
8611
|
for (const o of organizations) {
|
|
8558
8612
|
logger.logger.log(`- Name: ${vendor.yoctocolorsCjsExports.bold(o.name ?? 'undefined')}, ID: ${vendor.yoctocolorsCjsExports.bold(o.id)}, Plan: ${vendor.yoctocolorsCjsExports.bold(o.plan)}`);
|
|
@@ -8571,7 +8625,7 @@ const {
|
|
|
8571
8625
|
} = constants;
|
|
8572
8626
|
const config$n = {
|
|
8573
8627
|
commandName: 'list',
|
|
8574
|
-
description: 'List organizations associated with the API
|
|
8628
|
+
description: 'List organizations associated with the Socket API token',
|
|
8575
8629
|
hidden: false,
|
|
8576
8630
|
flags: {
|
|
8577
8631
|
...flags.commonFlags,
|
|
@@ -8624,7 +8678,7 @@ async function run$n(argv, importMeta, {
|
|
|
8624
8678
|
test: hasApiToken,
|
|
8625
8679
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
8626
8680
|
pass: 'ok',
|
|
8627
|
-
fail: 'missing API token'
|
|
8681
|
+
fail: 'missing Socket API token'
|
|
8628
8682
|
});
|
|
8629
8683
|
if (!wasValidInput) {
|
|
8630
8684
|
return;
|
|
@@ -8711,7 +8765,7 @@ const {
|
|
|
8711
8765
|
} = constants;
|
|
8712
8766
|
const config$m = {
|
|
8713
8767
|
commandName: 'quota',
|
|
8714
|
-
description: 'List organizations associated with the API
|
|
8768
|
+
description: 'List organizations associated with the Socket API token',
|
|
8715
8769
|
hidden: true,
|
|
8716
8770
|
flags: {
|
|
8717
8771
|
...flags.commonFlags,
|
|
@@ -8758,7 +8812,7 @@ async function run$m(argv, importMeta, {
|
|
|
8758
8812
|
test: hasApiToken,
|
|
8759
8813
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
8760
8814
|
pass: 'ok',
|
|
8761
|
-
fail: 'missing API token'
|
|
8815
|
+
fail: 'missing Socket API token'
|
|
8762
8816
|
});
|
|
8763
8817
|
if (!wasValidInput) {
|
|
8764
8818
|
return;
|
|
@@ -9122,7 +9176,7 @@ async function run$l(argv, importMeta, {
|
|
|
9122
9176
|
test: hasApiToken,
|
|
9123
9177
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
9124
9178
|
pass: 'ok',
|
|
9125
|
-
fail: 'missing API token'
|
|
9179
|
+
fail: 'missing Socket API token'
|
|
9126
9180
|
});
|
|
9127
9181
|
if (!wasValidInput) {
|
|
9128
9182
|
return;
|
|
@@ -9825,7 +9879,7 @@ async function run$h(argv, importMeta, {
|
|
|
9825
9879
|
test: hasApiToken,
|
|
9826
9880
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
9827
9881
|
pass: 'ok',
|
|
9828
|
-
fail: 'missing API token'
|
|
9882
|
+
fail: 'missing Socket API token'
|
|
9829
9883
|
});
|
|
9830
9884
|
if (!wasValidInput) {
|
|
9831
9885
|
return;
|
|
@@ -9964,7 +10018,7 @@ async function run$g(argv, importMeta, {
|
|
|
9964
10018
|
test: hasApiToken,
|
|
9965
10019
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
9966
10020
|
pass: 'ok',
|
|
9967
|
-
fail: 'missing API token'
|
|
10021
|
+
fail: 'missing Socket API token'
|
|
9968
10022
|
});
|
|
9969
10023
|
if (!wasValidInput) {
|
|
9970
10024
|
return;
|
|
@@ -10258,7 +10312,7 @@ async function run$f(argv, importMeta, {
|
|
|
10258
10312
|
test: hasApiToken,
|
|
10259
10313
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
10260
10314
|
pass: 'ok',
|
|
10261
|
-
fail: 'missing API token'
|
|
10315
|
+
fail: 'missing Socket API token'
|
|
10262
10316
|
}, {
|
|
10263
10317
|
nook: true,
|
|
10264
10318
|
test: direction === 'asc' || direction === 'desc',
|
|
@@ -10461,7 +10515,7 @@ async function run$e(argv, importMeta, {
|
|
|
10461
10515
|
test: hasApiToken,
|
|
10462
10516
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
10463
10517
|
pass: 'ok',
|
|
10464
|
-
fail: 'missing API token'
|
|
10518
|
+
fail: 'missing Socket API token'
|
|
10465
10519
|
});
|
|
10466
10520
|
if (!wasValidInput) {
|
|
10467
10521
|
return;
|
|
@@ -10632,7 +10686,7 @@ async function run$d(argv, importMeta, {
|
|
|
10632
10686
|
test: hasApiToken,
|
|
10633
10687
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
10634
10688
|
pass: 'ok',
|
|
10635
|
-
fail: 'missing API token'
|
|
10689
|
+
fail: 'missing Socket API token'
|
|
10636
10690
|
});
|
|
10637
10691
|
if (!wasValidInput) {
|
|
10638
10692
|
return;
|
|
@@ -11125,7 +11179,7 @@ async function run$b(argv, importMeta, {
|
|
|
11125
11179
|
test: hasApiToken,
|
|
11126
11180
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
11127
11181
|
pass: 'ok',
|
|
11128
|
-
fail: 'missing API token'
|
|
11182
|
+
fail: 'missing Socket API token'
|
|
11129
11183
|
});
|
|
11130
11184
|
if (!wasValidInput) {
|
|
11131
11185
|
return;
|
|
@@ -11440,7 +11494,7 @@ async function run$a(argv, importMeta, {
|
|
|
11440
11494
|
test: hasApiToken,
|
|
11441
11495
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
11442
11496
|
pass: 'ok',
|
|
11443
|
-
fail: 'missing API token'
|
|
11497
|
+
fail: 'missing Socket API token'
|
|
11444
11498
|
});
|
|
11445
11499
|
if (!wasValidInput) {
|
|
11446
11500
|
return;
|
|
@@ -12282,7 +12336,7 @@ async function run$9(argv, importMeta, {
|
|
|
12282
12336
|
}, {
|
|
12283
12337
|
nook: true,
|
|
12284
12338
|
test: hasSocketApiToken,
|
|
12285
|
-
message: 'This command requires an API token for access',
|
|
12339
|
+
message: 'This command requires an Socket API token for access',
|
|
12286
12340
|
pass: 'ok',
|
|
12287
12341
|
fail: 'missing (try `socket login`)'
|
|
12288
12342
|
}, {
|
|
@@ -12556,7 +12610,7 @@ async function run$8(argv, importMeta, {
|
|
|
12556
12610
|
test: hasApiToken,
|
|
12557
12611
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
12558
12612
|
pass: 'ok',
|
|
12559
|
-
fail: 'missing API token'
|
|
12613
|
+
fail: 'missing Socket API token'
|
|
12560
12614
|
}, {
|
|
12561
12615
|
nook: true,
|
|
12562
12616
|
test: !branchFlag || !branchArg,
|
|
@@ -12718,7 +12772,7 @@ async function run$7(argv, importMeta, {
|
|
|
12718
12772
|
test: hasApiToken,
|
|
12719
12773
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
12720
12774
|
pass: 'ok',
|
|
12721
|
-
fail: 'missing API token'
|
|
12775
|
+
fail: 'missing Socket API token'
|
|
12722
12776
|
});
|
|
12723
12777
|
if (!wasValidInput) {
|
|
12724
12778
|
return;
|
|
@@ -12963,7 +13017,7 @@ async function run$5(argv, importMeta, {
|
|
|
12963
13017
|
test: hasApiToken,
|
|
12964
13018
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
12965
13019
|
pass: 'ok',
|
|
12966
|
-
fail: 'missing API token'
|
|
13020
|
+
fail: 'missing Socket API token'
|
|
12967
13021
|
});
|
|
12968
13022
|
if (!wasValidInput) {
|
|
12969
13023
|
return;
|
|
@@ -13182,7 +13236,7 @@ async function configureScan(config, cwd = process.cwd()) {
|
|
|
13182
13236
|
return notCanceled();
|
|
13183
13237
|
}
|
|
13184
13238
|
async function configureGithub(config) {
|
|
13185
|
-
// Do not store the
|
|
13239
|
+
// Do not store the GitHub API token. Just leads to a security rabbit hole.
|
|
13186
13240
|
|
|
13187
13241
|
const all = await prompts.select({
|
|
13188
13242
|
message: '(--all) Do you by default want to fetch all repos from the GitHub API and scan all known repos?',
|
|
@@ -13382,8 +13436,8 @@ async function fetchScan(orgSlug, scanId) {
|
|
|
13382
13436
|
}
|
|
13383
13437
|
return {
|
|
13384
13438
|
ok: false,
|
|
13385
|
-
message: 'Invalid API response',
|
|
13386
|
-
cause: 'The API responded with at least one line that was not valid JSON. Please report if this persists.'
|
|
13439
|
+
message: 'Invalid Socket API response',
|
|
13440
|
+
cause: 'The Socket API responded with at least one line that was not valid JSON. Please report if this persists.'
|
|
13387
13441
|
};
|
|
13388
13442
|
}
|
|
13389
13443
|
|
|
@@ -13577,7 +13631,7 @@ async function run$3(argv, importMeta, {
|
|
|
13577
13631
|
test: hasApiToken,
|
|
13578
13632
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
13579
13633
|
pass: 'ok',
|
|
13580
|
-
fail: 'missing API token'
|
|
13634
|
+
fail: 'missing Socket API token'
|
|
13581
13635
|
}, {
|
|
13582
13636
|
nook: true,
|
|
13583
13637
|
test: !stream || !!json,
|
|
@@ -14014,7 +14068,7 @@ async function run$2(argv, importMeta, {
|
|
|
14014
14068
|
test: hasApiToken,
|
|
14015
14069
|
message: 'You need to be logged in to use this command. See `socket login`.',
|
|
14016
14070
|
pass: 'ok',
|
|
14017
|
-
fail: 'missing API token'
|
|
14071
|
+
fail: 'missing Socket API token'
|
|
14018
14072
|
});
|
|
14019
14073
|
if (!wasValidInput) {
|
|
14020
14074
|
return;
|
|
@@ -14630,5 +14684,5 @@ void (async () => {
|
|
|
14630
14684
|
await utils.captureException(e);
|
|
14631
14685
|
}
|
|
14632
14686
|
})();
|
|
14633
|
-
//# debugId=
|
|
14687
|
+
//# debugId=537e02e0-17da-42ea-8417-fef153f5f5ca
|
|
14634
14688
|
//# sourceMappingURL=cli.js.map
|