@socketsecurity/cli-with-sentry 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +426 -0
- package/bin/cli.js +3 -1
- package/dist/cli.js +362 -400
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +211 -19
- package/dist/constants.js.map +1 -1
- package/dist/flags.js +3 -3
- package/dist/flags.js.map +1 -1
- package/dist/instrument-with-sentry.js +8 -8
- package/dist/instrument-with-sentry.js.map +1 -1
- package/dist/shadow-npm-bin.js +14 -14
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-npm-inject.js +16 -16
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
- package/dist/types/commands/optimize/add-overrides.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/handle-patch.d.mts +9 -2
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/output-patch-result.d.mts +1 -1
- package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-github.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
- package/dist/types/commands/scan/generate-report.d.mts +9 -8
- package/dist/types/commands/scan/generate-report.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts +5 -2
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-scan-report.d.mts +7 -5
- package/dist/types/commands/scan/handle-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/output-scan-report.d.mts +10 -8
- package/dist/types/commands/scan/output-scan-report.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/commands/scan/types.d.mts +3 -0
- package/dist/types/commands/scan/types.d.mts.map +1 -0
- package/dist/types/constants.d.mts +99 -46
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +1 -17
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/shadow/npm/bin.d.mts +4 -3
- package/dist/types/shadow/npm/bin.d.mts.map +1 -1
- package/dist/types/utils/coana.d.mts.map +1 -1
- package/dist/types/utils/ecosystem.d.mts.map +1 -1
- package/dist/types/utils/get-output-kind.d.mts.map +1 -1
- package/dist/types/utils/glob.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/purl.d.mts +25 -9
- package/dist/types/utils/purl.d.mts.map +1 -1
- package/dist/types/utils/spec.d.mts.map +1 -1
- package/dist/utils.js +120 -102
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +222 -4598
- package/external/@socketsecurity/registry/lib/constants/env.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/ext-cjs.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-cts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-dts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-js.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-lockb.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-md.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-mjs.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-mts.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/index.js +82 -83
- package/external/@socketsecurity/registry/lib/constants/ipc-promise.js +4 -5
- package/external/@socketsecurity/registry/lib/constants/node-debug-flags.js +9 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/json.js +11 -0
- package/external/@socketsecurity/registry/lib/strings.js +16 -0
- package/package.json +13 -12
- package/external/@socketsecurity/registry/lib/constants/socket-public-api-key.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/tap.js +0 -3
- /package/external/@socketsecurity/registry/lib/constants/{ipc.js → ipc-object.js} +0 -0
package/dist/cli.js
CHANGED
|
@@ -12,12 +12,12 @@ var constants = require('./constants.js');
|
|
|
12
12
|
var flags = require('./flags.js');
|
|
13
13
|
var path = require('node:path');
|
|
14
14
|
var words = require('../external/@socketsecurity/registry/lib/words');
|
|
15
|
+
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
15
16
|
var prompts = require('../external/@socketsecurity/registry/lib/prompts');
|
|
16
17
|
var fs$1 = require('node:fs');
|
|
17
18
|
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
18
19
|
var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
|
|
19
20
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
20
|
-
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
21
21
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
22
22
|
var shadowNpmBin = require('./shadow-npm-bin.js');
|
|
23
23
|
var require$$11 = require('../external/@socketsecurity/registry/lib/objects');
|
|
@@ -148,7 +148,7 @@ ${utils.mdTableStringNumber('Name', 'Counts', data['top_five_alert_types'])}
|
|
|
148
148
|
function displayAnalyticsScreen(data) {
|
|
149
149
|
const ScreenWidget = /*@__PURE__*/require$5('../external/blessed/lib/widgets/screen.js');
|
|
150
150
|
const screen = new ScreenWidget({
|
|
151
|
-
...constants.blessedOptions
|
|
151
|
+
...constants.default.blessedOptions
|
|
152
152
|
});
|
|
153
153
|
const GridLayout = /*@__PURE__*/require$5('../external/blessed-contrib/lib/layout/grid.js');
|
|
154
154
|
const grid = new GridLayout({
|
|
@@ -444,7 +444,7 @@ async function run$Q(argv, importMeta, {
|
|
|
444
444
|
return;
|
|
445
445
|
}
|
|
446
446
|
if (dryRun) {
|
|
447
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
447
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
448
448
|
return;
|
|
449
449
|
}
|
|
450
450
|
return await handleAnalytics({
|
|
@@ -555,7 +555,7 @@ async function outputAsJson(auditLogs, {
|
|
|
555
555
|
ok: true,
|
|
556
556
|
data: {
|
|
557
557
|
desc: 'Audit logs for given query',
|
|
558
|
-
generated: constants.ENV.VITEST ? constants.REDACTED : new Date().toISOString(),
|
|
558
|
+
generated: constants.default.ENV.VITEST ? constants.default.REDACTED : new Date().toISOString(),
|
|
559
559
|
logType,
|
|
560
560
|
nextPage: auditLogs.data.nextPage,
|
|
561
561
|
org: orgSlug,
|
|
@@ -600,7 +600,7 @@ These are the Socket.dev audit logs as per requested query.
|
|
|
600
600
|
- page: ${page}
|
|
601
601
|
- next page: ${auditLogs.nextPage}
|
|
602
602
|
- per page: ${perPage}
|
|
603
|
-
- generated: ${constants.ENV.VITEST ? constants.REDACTED : new Date().toISOString()}
|
|
603
|
+
- generated: ${constants.default.ENV.VITEST ? constants.default.REDACTED : new Date().toISOString()}
|
|
604
604
|
|
|
605
605
|
${table}
|
|
606
606
|
`;
|
|
@@ -622,7 +622,7 @@ async function outputWithBlessed(data, orgSlug) {
|
|
|
622
622
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
623
623
|
const ScreenWidget = /*@__PURE__*/require$4('../external/blessed/lib/widgets/screen.js');
|
|
624
624
|
const screen = new ScreenWidget({
|
|
625
|
-
...constants.blessedOptions
|
|
625
|
+
...constants.default.blessedOptions
|
|
626
626
|
});
|
|
627
627
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
628
628
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
@@ -785,7 +785,7 @@ async function run$P(argv, importMeta, {
|
|
|
785
785
|
${utils.getFlagApiRequirementsOutput(`${parentName}:${CMD_NAME$v}`)}
|
|
786
786
|
|
|
787
787
|
This feature requires an Enterprise Plan. To learn more about getting access
|
|
788
|
-
to this feature and many more, please visit ${constants.SOCKET_WEBSITE_URL}/pricing
|
|
788
|
+
to this feature and many more, please visit ${constants.default.SOCKET_WEBSITE_URL}/pricing
|
|
789
789
|
|
|
790
790
|
The type FILTER arg is an enum. Defaults to any. It should be one of these:
|
|
791
791
|
associateLabel, cancelInvitation, changeMemberRole, changePlanSubscriptionSeats,
|
|
@@ -858,7 +858,7 @@ async function run$P(argv, importMeta, {
|
|
|
858
858
|
return;
|
|
859
859
|
}
|
|
860
860
|
if (dryRun) {
|
|
861
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
861
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
862
862
|
return;
|
|
863
863
|
}
|
|
864
864
|
await handleAuditLog({
|
|
@@ -980,7 +980,7 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
980
980
|
let finishedFetching = false;
|
|
981
981
|
const {
|
|
982
982
|
spinner
|
|
983
|
-
} = constants;
|
|
983
|
+
} = constants.default;
|
|
984
984
|
function updateScan(desc) {
|
|
985
985
|
scanStatus = desc;
|
|
986
986
|
updateProgress();
|
|
@@ -1081,7 +1081,9 @@ async function fetchScanData(orgSlug, scanId, options) {
|
|
|
1081
1081
|
};
|
|
1082
1082
|
}
|
|
1083
1083
|
|
|
1084
|
-
|
|
1084
|
+
const UNKNOWN_VALUE = '<unknown>';
|
|
1085
|
+
|
|
1086
|
+
// Note: The returned cResult will only be ok:false when the generation
|
|
1085
1087
|
// failed. It won't reflect the healthy state.
|
|
1086
1088
|
function generateReport(scan, securityPolicy, {
|
|
1087
1089
|
fold,
|
|
@@ -1129,15 +1131,15 @@ function generateReport(scan, securityPolicy, {
|
|
|
1129
1131
|
scan.forEach(artifact => {
|
|
1130
1132
|
const {
|
|
1131
1133
|
alerts,
|
|
1132
|
-
name: pkgName =
|
|
1134
|
+
name: pkgName = UNKNOWN_VALUE,
|
|
1133
1135
|
type: ecosystem,
|
|
1134
|
-
version =
|
|
1136
|
+
version = UNKNOWN_VALUE
|
|
1135
1137
|
} = artifact;
|
|
1136
1138
|
alerts?.forEach(alert => {
|
|
1137
1139
|
const alertName = alert.type; // => policy[type]
|
|
1138
1140
|
const action = securityRules[alertName]?.action || '';
|
|
1139
1141
|
switch (action) {
|
|
1140
|
-
case
|
|
1142
|
+
case constants.default.REPORT_LEVEL_ERROR:
|
|
1141
1143
|
{
|
|
1142
1144
|
healthy = false;
|
|
1143
1145
|
if (!short) {
|
|
@@ -1145,31 +1147,31 @@ function generateReport(scan, securityPolicy, {
|
|
|
1145
1147
|
}
|
|
1146
1148
|
break;
|
|
1147
1149
|
}
|
|
1148
|
-
case
|
|
1150
|
+
case constants.default.REPORT_LEVEL_WARN:
|
|
1149
1151
|
{
|
|
1150
|
-
if (!short && reportLevel !==
|
|
1152
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1151
1153
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1152
1154
|
}
|
|
1153
1155
|
break;
|
|
1154
1156
|
}
|
|
1155
|
-
case
|
|
1157
|
+
case constants.default.REPORT_LEVEL_MONITOR:
|
|
1156
1158
|
{
|
|
1157
|
-
if (!short && reportLevel !==
|
|
1159
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_WARN && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1158
1160
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1159
1161
|
}
|
|
1160
1162
|
break;
|
|
1161
1163
|
}
|
|
1162
|
-
case
|
|
1164
|
+
case constants.default.REPORT_LEVEL_IGNORE:
|
|
1163
1165
|
{
|
|
1164
|
-
if (!short && reportLevel !==
|
|
1166
|
+
if (!short && reportLevel !== constants.default.REPORT_LEVEL_MONITOR && reportLevel !== constants.default.REPORT_LEVEL_WARN && reportLevel !== constants.default.REPORT_LEVEL_ERROR) {
|
|
1165
1167
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1166
1168
|
}
|
|
1167
1169
|
break;
|
|
1168
1170
|
}
|
|
1169
|
-
case
|
|
1171
|
+
case constants.default.REPORT_LEVEL_DEFER:
|
|
1170
1172
|
{
|
|
1171
1173
|
// Not sure but ignore for now. Defer to later ;)
|
|
1172
|
-
if (!short && reportLevel ===
|
|
1174
|
+
if (!short && reportLevel === constants.default.REPORT_LEVEL_DEFER) {
|
|
1173
1175
|
addAlert(artifact, violations, fold, ecosystem, pkgName, version, alert, action);
|
|
1174
1176
|
}
|
|
1175
1177
|
break;
|
|
@@ -1218,46 +1220,46 @@ function createLeaf(art, alert, policyAction) {
|
|
|
1218
1220
|
};
|
|
1219
1221
|
return leaf;
|
|
1220
1222
|
}
|
|
1221
|
-
function addAlert(art, violations,
|
|
1223
|
+
function addAlert(art, violations, fold, ecosystem, pkgName, version, alert, policyAction) {
|
|
1222
1224
|
if (!violations.has(ecosystem)) {
|
|
1223
1225
|
violations.set(ecosystem, new Map());
|
|
1224
1226
|
}
|
|
1225
|
-
const
|
|
1226
|
-
if (
|
|
1227
|
-
const existing =
|
|
1227
|
+
const ecoMap = violations.get(ecosystem);
|
|
1228
|
+
if (fold === constants.default.FOLD_SETTING_PKG) {
|
|
1229
|
+
const existing = ecoMap.get(pkgName);
|
|
1228
1230
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1229
|
-
|
|
1231
|
+
ecoMap.set(pkgName, createLeaf(art, alert, policyAction));
|
|
1230
1232
|
}
|
|
1231
1233
|
} else {
|
|
1232
|
-
if (!
|
|
1233
|
-
|
|
1234
|
+
if (!ecoMap.has(pkgName)) {
|
|
1235
|
+
ecoMap.set(pkgName, new Map());
|
|
1234
1236
|
}
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
const existing =
|
|
1237
|
+
const pkgMap = ecoMap.get(pkgName);
|
|
1238
|
+
if (fold === constants.default.FOLD_SETTING_VERSION) {
|
|
1239
|
+
const existing = pkgMap.get(version);
|
|
1238
1240
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1239
|
-
|
|
1241
|
+
pkgMap.set(version, createLeaf(art, alert, policyAction));
|
|
1240
1242
|
}
|
|
1241
1243
|
} else {
|
|
1242
|
-
if (!
|
|
1243
|
-
|
|
1244
|
+
if (!pkgMap.has(version)) {
|
|
1245
|
+
pkgMap.set(version, new Map());
|
|
1244
1246
|
}
|
|
1245
|
-
const file = alert.file ||
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
const existing =
|
|
1247
|
+
const file = alert.file || UNKNOWN_VALUE;
|
|
1248
|
+
const verMap = pkgMap.get(version);
|
|
1249
|
+
if (fold === constants.default.FOLD_SETTING_FILE) {
|
|
1250
|
+
const existing = verMap.get(file);
|
|
1249
1251
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1250
|
-
|
|
1252
|
+
verMap.set(file, createLeaf(art, alert, policyAction));
|
|
1251
1253
|
}
|
|
1252
1254
|
} else {
|
|
1253
|
-
if (!
|
|
1254
|
-
|
|
1255
|
+
if (!verMap.has(file)) {
|
|
1256
|
+
verMap.set(file, new Map());
|
|
1255
1257
|
}
|
|
1256
1258
|
const key = `${alert.type} at ${alert.start}:${alert.end}`;
|
|
1257
|
-
const
|
|
1258
|
-
const existing =
|
|
1259
|
+
const fileMap = verMap.get(file);
|
|
1260
|
+
const existing = fileMap.get(key);
|
|
1259
1261
|
if (!existing || isStricterPolicy(existing.policy, policyAction)) {
|
|
1260
|
-
|
|
1262
|
+
fileMap.set(key, createLeaf(art, alert, policyAction));
|
|
1261
1263
|
}
|
|
1262
1264
|
}
|
|
1263
1265
|
}
|
|
@@ -1265,34 +1267,34 @@ function addAlert(art, violations, foldSetting, ecosystem, pkgName, version, ale
|
|
|
1265
1267
|
}
|
|
1266
1268
|
function isStricterPolicy(was, is) {
|
|
1267
1269
|
// error > warn > monitor > ignore > defer > {unknown}
|
|
1268
|
-
if (was ===
|
|
1270
|
+
if (was === constants.default.REPORT_LEVEL_ERROR) {
|
|
1269
1271
|
return false;
|
|
1270
1272
|
}
|
|
1271
|
-
if (is ===
|
|
1273
|
+
if (is === constants.default.REPORT_LEVEL_ERROR) {
|
|
1272
1274
|
return true;
|
|
1273
1275
|
}
|
|
1274
|
-
if (was ===
|
|
1276
|
+
if (was === constants.default.REPORT_LEVEL_WARN) {
|
|
1275
1277
|
return false;
|
|
1276
1278
|
}
|
|
1277
|
-
if (is ===
|
|
1279
|
+
if (is === constants.default.REPORT_LEVEL_WARN) {
|
|
1278
1280
|
return false;
|
|
1279
1281
|
}
|
|
1280
|
-
if (was ===
|
|
1282
|
+
if (was === constants.default.REPORT_LEVEL_MONITOR) {
|
|
1281
1283
|
return false;
|
|
1282
1284
|
}
|
|
1283
|
-
if (is ===
|
|
1285
|
+
if (is === constants.default.REPORT_LEVEL_MONITOR) {
|
|
1284
1286
|
return false;
|
|
1285
1287
|
}
|
|
1286
|
-
if (was ===
|
|
1288
|
+
if (was === constants.default.REPORT_LEVEL_IGNORE) {
|
|
1287
1289
|
return false;
|
|
1288
1290
|
}
|
|
1289
|
-
if (is ===
|
|
1291
|
+
if (is === constants.default.REPORT_LEVEL_IGNORE) {
|
|
1290
1292
|
return false;
|
|
1291
1293
|
}
|
|
1292
|
-
if (was ===
|
|
1294
|
+
if (was === constants.default.REPORT_LEVEL_DEFER) {
|
|
1293
1295
|
return false;
|
|
1294
1296
|
}
|
|
1295
|
-
if (is ===
|
|
1297
|
+
if (is === constants.default.REPORT_LEVEL_DEFER) {
|
|
1296
1298
|
return false;
|
|
1297
1299
|
}
|
|
1298
1300
|
// unreachable?
|
|
@@ -1300,7 +1302,7 @@ function isStricterPolicy(was, is) {
|
|
|
1300
1302
|
}
|
|
1301
1303
|
|
|
1302
1304
|
async function outputScanReport(result, {
|
|
1303
|
-
|
|
1305
|
+
filepath,
|
|
1304
1306
|
fold,
|
|
1305
1307
|
includeLicensePolicy,
|
|
1306
1308
|
orgSlug,
|
|
@@ -1313,7 +1315,7 @@ async function outputScanReport(result, {
|
|
|
1313
1315
|
process.exitCode = result.code ?? 1;
|
|
1314
1316
|
}
|
|
1315
1317
|
if (!result.ok) {
|
|
1316
|
-
if (outputKind ===
|
|
1318
|
+
if (outputKind === constants.JSON) {
|
|
1317
1319
|
logger.logger.log(utils.serializeResultJson(result));
|
|
1318
1320
|
return;
|
|
1319
1321
|
}
|
|
@@ -1326,14 +1328,14 @@ async function outputScanReport(result, {
|
|
|
1326
1328
|
fold,
|
|
1327
1329
|
reportLevel,
|
|
1328
1330
|
short,
|
|
1329
|
-
spinner: constants.spinner
|
|
1331
|
+
spinner: constants.default.spinner
|
|
1330
1332
|
});
|
|
1331
1333
|
if (!scanReport.ok) {
|
|
1332
1334
|
// Note: this means generation failed, it does not reflect the healthy state
|
|
1333
1335
|
process.exitCode = scanReport.code ?? 1;
|
|
1334
1336
|
|
|
1335
1337
|
// If report generation somehow failed then .data should not be set.
|
|
1336
|
-
if (outputKind ===
|
|
1338
|
+
if (outputKind === constants.JSON) {
|
|
1337
1339
|
logger.logger.log(utils.serializeResultJson(scanReport));
|
|
1338
1340
|
return;
|
|
1339
1341
|
}
|
|
@@ -1347,22 +1349,22 @@ async function outputScanReport(result, {
|
|
|
1347
1349
|
// return
|
|
1348
1350
|
// }
|
|
1349
1351
|
|
|
1350
|
-
if (outputKind ===
|
|
1352
|
+
if (outputKind === constants.JSON || outputKind === constants.TEXT && filepath && filepath.endsWith(constants.EXT_JSON)) {
|
|
1351
1353
|
const json = short ? utils.serializeResultJson(scanReport) : toJsonReport(scanReport.data, includeLicensePolicy);
|
|
1352
|
-
if (
|
|
1353
|
-
logger.logger.log('Writing json report to',
|
|
1354
|
-
return await fs.writeFile(
|
|
1354
|
+
if (filepath && filepath !== '-') {
|
|
1355
|
+
logger.logger.log('Writing json report to', filepath);
|
|
1356
|
+
return await fs.writeFile(filepath, json);
|
|
1355
1357
|
}
|
|
1356
1358
|
logger.logger.log(json);
|
|
1357
1359
|
return;
|
|
1358
1360
|
}
|
|
1359
|
-
if (outputKind === 'markdown' ||
|
|
1361
|
+
if (outputKind === 'markdown' || filepath && filepath.endsWith('.md')) {
|
|
1360
1362
|
const md = short ? `healthy = ${scanReport.data.healthy}` : toMarkdownReport(scanReport.data,
|
|
1361
1363
|
// not short so must be regular report
|
|
1362
1364
|
includeLicensePolicy);
|
|
1363
|
-
if (
|
|
1364
|
-
logger.logger.log('Writing markdown report to',
|
|
1365
|
-
return await fs.writeFile(
|
|
1365
|
+
if (filepath && filepath !== '-') {
|
|
1366
|
+
logger.logger.log('Writing markdown report to', filepath);
|
|
1367
|
+
return await fs.writeFile(filepath, md);
|
|
1366
1368
|
}
|
|
1367
1369
|
logger.logger.log(md);
|
|
1368
1370
|
logger.logger.log('');
|
|
@@ -1389,6 +1391,8 @@ function toJsonReport(report, includeLicensePolicy) {
|
|
|
1389
1391
|
});
|
|
1390
1392
|
}
|
|
1391
1393
|
function toMarkdownReport(report, includeLicensePolicy) {
|
|
1394
|
+
const reportLevel = report.options.reportLevel;
|
|
1395
|
+
const alertFolding = report.options.fold === constants.default.FOLD_SETTING_NONE ? 'none' : `up to ${report.options.fold}`;
|
|
1392
1396
|
const flatData = Array.from(utils.walkNestedMap(report.alerts)).map(({
|
|
1393
1397
|
keys,
|
|
1394
1398
|
value
|
|
@@ -1404,10 +1408,11 @@ function toMarkdownReport(report, includeLicensePolicy) {
|
|
|
1404
1408
|
Package: keys[1] || '<unknown>',
|
|
1405
1409
|
'Introduced by': keys[2] || '<unknown>',
|
|
1406
1410
|
url,
|
|
1407
|
-
'Manifest file':
|
|
1411
|
+
'Manifest file': arrays.joinAnd(manifest),
|
|
1408
1412
|
Policy: policy
|
|
1409
1413
|
};
|
|
1410
1414
|
});
|
|
1415
|
+
const minPolicyLevel = reportLevel === constants.default.REPORT_LEVEL_DEFER ? 'everything' : reportLevel;
|
|
1411
1416
|
const md = `
|
|
1412
1417
|
# Scan Policy Report
|
|
1413
1418
|
|
|
@@ -1424,13 +1429,13 @@ Configuration used to generate this report:
|
|
|
1424
1429
|
|
|
1425
1430
|
- Organization: ${report.orgSlug}
|
|
1426
1431
|
- Scan ID: ${report.scanId}
|
|
1427
|
-
- Alert folding: ${
|
|
1428
|
-
- Minimal policy level for alert to be included in report: ${
|
|
1432
|
+
- Alert folding: ${alertFolding}
|
|
1433
|
+
- Minimal policy level for alert to be included in report: ${minPolicyLevel}
|
|
1429
1434
|
- Include license alerts: ${includeLicensePolicy ? 'yes' : 'no'}
|
|
1430
1435
|
|
|
1431
1436
|
## Alerts
|
|
1432
1437
|
|
|
1433
|
-
${report.alerts.size ? `All the alerts from the scan with a policy set to at least "${
|
|
1438
|
+
${report.alerts.size ? `All the alerts from the scan with a policy set to at least "${reportLevel}".` : `The scan contained no alerts with a policy set to at least "${reportLevel}".`}
|
|
1434
1439
|
|
|
1435
1440
|
${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'Package', 'Introduced by', 'url', 'Manifest file'])}
|
|
1436
1441
|
`.trim() + '\n';
|
|
@@ -1438,7 +1443,7 @@ ${!report.alerts.size ? '' : utils.mdTable(flatData, ['Policy', 'Alert Type', 'P
|
|
|
1438
1443
|
}
|
|
1439
1444
|
|
|
1440
1445
|
async function handleScanReport({
|
|
1441
|
-
|
|
1446
|
+
filepath,
|
|
1442
1447
|
fold,
|
|
1443
1448
|
includeLicensePolicy,
|
|
1444
1449
|
orgSlug,
|
|
@@ -1451,7 +1456,7 @@ async function handleScanReport({
|
|
|
1451
1456
|
includeLicensePolicy
|
|
1452
1457
|
});
|
|
1453
1458
|
await outputScanReport(scanDataCResult, {
|
|
1454
|
-
|
|
1459
|
+
filepath,
|
|
1455
1460
|
fold,
|
|
1456
1461
|
scanId: scanId,
|
|
1457
1462
|
includeLicensePolicy,
|
|
@@ -1466,7 +1471,7 @@ async function outputCreateNewScan(result, options) {
|
|
|
1466
1471
|
const {
|
|
1467
1472
|
interactive = false,
|
|
1468
1473
|
outputKind = 'text',
|
|
1469
|
-
spinner = constants.spinner
|
|
1474
|
+
spinner = constants.default.spinner
|
|
1470
1475
|
} = {
|
|
1471
1476
|
__proto__: null,
|
|
1472
1477
|
...options
|
|
@@ -1576,7 +1581,7 @@ async function performReachabilityAnalysis(options) {
|
|
|
1576
1581
|
|
|
1577
1582
|
// Exclude any .socket.facts.json files that happen to be in the scan
|
|
1578
1583
|
// folder before the analysis was run.
|
|
1579
|
-
const filepathsToUpload = packagePaths.filter(p => path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON);
|
|
1584
|
+
const filepathsToUpload = packagePaths.filter(p => path.basename(p).toLowerCase() !== constants.default.DOT_SOCKET_DOT_FACTS_JSON);
|
|
1580
1585
|
spinner?.start('Uploading manifests for reachability analysis...');
|
|
1581
1586
|
const uploadCResult = await utils.handleApiCall(sockSdk.uploadManifestFiles(orgSlug, filepathsToUpload), {
|
|
1582
1587
|
desc: 'upload manifests',
|
|
@@ -1607,27 +1612,25 @@ async function performReachabilityAnalysis(options) {
|
|
|
1607
1612
|
spinner?.infoAndStop('Running reachability analysis with Coana...');
|
|
1608
1613
|
|
|
1609
1614
|
// Build Coana arguments.
|
|
1610
|
-
const coanaArgs = ['run', cwd, '--output-dir', cwd, '--socket-mode', constants.DOT_SOCKET_DOT_FACTS_JSON, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1615
|
+
const coanaArgs = ['run', cwd, '--output-dir', cwd, '--socket-mode', constants.default.DOT_SOCKET_DOT_FACTS_JSON, '--disable-report-submission', ...(reachabilityOptions.reachAnalysisTimeout ? ['--analysis-timeout', `${reachabilityOptions.reachAnalysisTimeout}`] : []), ...(reachabilityOptions.reachAnalysisMemoryLimit ? ['--memory-limit', `${reachabilityOptions.reachAnalysisMemoryLimit}`] : []), ...(reachabilityOptions.reachDisableAnalytics ? ['--disable-analytics-sharing'] : []), ...(tarHash ? ['--run-without-docker', '--manifests-tar-hash', tarHash] : []),
|
|
1611
1616
|
// Empty reachEcosystems implies scanning all ecosystems.
|
|
1612
1617
|
...(reachabilityOptions.reachEcosystems.length ? ['--purl-types', ...reachabilityOptions.reachEcosystems] : []), ...(reachabilityOptions.reachExcludePaths.length ? ['--exclude-dirs', ...reachabilityOptions.reachExcludePaths] : []), ...(reachabilityOptions.reachSkipCache ? ['--skip-cache-usage'] : [])];
|
|
1613
1618
|
|
|
1614
1619
|
// Build environment variables.
|
|
1615
|
-
const
|
|
1616
|
-
...process.env
|
|
1617
|
-
};
|
|
1620
|
+
const coanaEnv = {};
|
|
1618
1621
|
// do not pass default repo and branch name to coana to avoid mixing
|
|
1619
1622
|
// buckets (cached configuration) from projects that are likely very different.
|
|
1620
|
-
if (repoName && repoName !== constants.SOCKET_DEFAULT_REPOSITORY) {
|
|
1621
|
-
|
|
1623
|
+
if (repoName && repoName !== constants.default.SOCKET_DEFAULT_REPOSITORY) {
|
|
1624
|
+
coanaEnv['SOCKET_REPO_NAME'] = repoName;
|
|
1622
1625
|
}
|
|
1623
|
-
if (branchName && branchName !== constants.SOCKET_DEFAULT_BRANCH) {
|
|
1624
|
-
|
|
1626
|
+
if (branchName && branchName !== constants.default.SOCKET_DEFAULT_BRANCH) {
|
|
1627
|
+
coanaEnv['SOCKET_BRANCH_NAME'] = branchName;
|
|
1625
1628
|
}
|
|
1626
1629
|
|
|
1627
1630
|
// Run Coana with the manifests tar hash.
|
|
1628
1631
|
const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
|
|
1629
1632
|
cwd,
|
|
1630
|
-
env,
|
|
1633
|
+
env: coanaEnv,
|
|
1631
1634
|
spinner,
|
|
1632
1635
|
stdio: 'inherit'
|
|
1633
1636
|
});
|
|
@@ -1639,8 +1642,8 @@ async function performReachabilityAnalysis(options) {
|
|
|
1639
1642
|
ok: true,
|
|
1640
1643
|
data: {
|
|
1641
1644
|
// Use the DOT_SOCKET_DOT_FACTS_JSON file for the scan.
|
|
1642
|
-
reachabilityReport: constants.DOT_SOCKET_DOT_FACTS_JSON,
|
|
1643
|
-
tier1ReachabilityScanId: utils.extractTier1ReachabilityScanId(constants.DOT_SOCKET_DOT_FACTS_JSON)
|
|
1645
|
+
reachabilityReport: constants.default.DOT_SOCKET_DOT_FACTS_JSON,
|
|
1646
|
+
tier1ReachabilityScanId: utils.extractTier1ReachabilityScanId(constants.default.DOT_SOCKET_DOT_FACTS_JSON)
|
|
1644
1647
|
}
|
|
1645
1648
|
} : coanaResult;
|
|
1646
1649
|
}
|
|
@@ -1720,7 +1723,7 @@ async function convertGradleToMaven({
|
|
|
1720
1723
|
// .socket folder. We could do a socket.pom.gz with all the poms, although
|
|
1721
1724
|
// I'd prefer something plain-text if it is to be committed.
|
|
1722
1725
|
// Note: init.gradle will be exported by .config/rollup.dist.config.mjs
|
|
1723
|
-
const initLocation = path.join(constants.distPath, 'init.gradle');
|
|
1726
|
+
const initLocation = path.join(constants.default.distPath, 'init.gradle');
|
|
1724
1727
|
const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom'];
|
|
1725
1728
|
if (verbose) {
|
|
1726
1729
|
logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs);
|
|
@@ -1764,7 +1767,7 @@ async function convertGradleToMaven({
|
|
|
1764
1767
|
async function execGradleWithSpinner(bin, commandArgs, cwd) {
|
|
1765
1768
|
const {
|
|
1766
1769
|
spinner
|
|
1767
|
-
} = constants;
|
|
1770
|
+
} = constants.default;
|
|
1768
1771
|
let pass = false;
|
|
1769
1772
|
try {
|
|
1770
1773
|
logger.logger.info('(Running gradle can take a while, it depends on how long gradlew has to run)');
|
|
@@ -1808,7 +1811,7 @@ async function convertSbtToMaven({
|
|
|
1808
1811
|
|
|
1809
1812
|
const {
|
|
1810
1813
|
spinner
|
|
1811
|
-
} = constants;
|
|
1814
|
+
} = constants.default;
|
|
1812
1815
|
logger.logger.group('sbt2maven:');
|
|
1813
1816
|
logger.logger.info(`- executing: \`${bin}\``);
|
|
1814
1817
|
logger.logger.info(`- src dir: \`${cwd}\``);
|
|
@@ -2142,6 +2145,7 @@ async function handleCreateNewScan({
|
|
|
2142
2145
|
readOnly,
|
|
2143
2146
|
repoName,
|
|
2144
2147
|
report,
|
|
2148
|
+
reportLevel,
|
|
2145
2149
|
targets,
|
|
2146
2150
|
tmp
|
|
2147
2151
|
}) {
|
|
@@ -2159,7 +2163,7 @@ async function handleCreateNewScan({
|
|
|
2159
2163
|
}
|
|
2160
2164
|
const {
|
|
2161
2165
|
spinner
|
|
2162
|
-
} = constants;
|
|
2166
|
+
} = constants.default;
|
|
2163
2167
|
const supportedFilesCResult = await fetchSupportedScanFileNames({
|
|
2164
2168
|
spinner
|
|
2165
2169
|
});
|
|
@@ -2223,7 +2227,7 @@ async function handleCreateNewScan({
|
|
|
2223
2227
|
scanPaths = [...packagePaths.filter(
|
|
2224
2228
|
// Ensure the .socket.facts.json isn't duplicated in case it happened
|
|
2225
2229
|
// to be in the scan folder before the analysis was run.
|
|
2226
|
-
p => path.basename(p).toLowerCase() !== constants.DOT_SOCKET_DOT_FACTS_JSON), ...(reachabilityReport ? [reachabilityReport] : [])];
|
|
2230
|
+
p => path.basename(p).toLowerCase() !== constants.default.DOT_SOCKET_DOT_FACTS_JSON), ...(reachabilityReport ? [reachabilityReport] : [])];
|
|
2227
2231
|
tier1ReachabilityScanId = reachResult.data?.tier1ReachabilityScanId;
|
|
2228
2232
|
}
|
|
2229
2233
|
const fullScanCResult = await fetchCreateOrgFullScan(scanPaths, orgSlug, {
|
|
@@ -2246,12 +2250,12 @@ async function handleCreateNewScan({
|
|
|
2246
2250
|
if (report && fullScanCResult.ok) {
|
|
2247
2251
|
if (scanId) {
|
|
2248
2252
|
await handleScanReport({
|
|
2249
|
-
|
|
2250
|
-
fold:
|
|
2253
|
+
filepath: '-',
|
|
2254
|
+
fold: constants.default.FOLD_SETTING_VERSION,
|
|
2251
2255
|
includeLicensePolicy: true,
|
|
2252
2256
|
orgSlug,
|
|
2253
2257
|
outputKind,
|
|
2254
|
-
reportLevel
|
|
2258
|
+
reportLevel,
|
|
2255
2259
|
scanId,
|
|
2256
2260
|
short: false
|
|
2257
2261
|
});
|
|
@@ -2313,6 +2317,7 @@ async function handleCi(autoManifest) {
|
|
|
2313
2317
|
repoName,
|
|
2314
2318
|
readOnly: false,
|
|
2315
2319
|
report: true,
|
|
2320
|
+
reportLevel: constants.default.REPORT_LEVEL_ERROR,
|
|
2316
2321
|
targets: ['.'],
|
|
2317
2322
|
// Don't set 'tmp' when 'pendingHead' is true.
|
|
2318
2323
|
tmp: false
|
|
@@ -2370,7 +2375,7 @@ async function run$O(argv, importMeta, {
|
|
|
2370
2375
|
});
|
|
2371
2376
|
const dryRun = !!cli.flags['dryRun'];
|
|
2372
2377
|
if (dryRun) {
|
|
2373
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2378
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2374
2379
|
return;
|
|
2375
2380
|
}
|
|
2376
2381
|
await handleCi(Boolean(cli.flags['autoManifest']));
|
|
@@ -2663,7 +2668,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
2663
2668
|
return;
|
|
2664
2669
|
}
|
|
2665
2670
|
if (dryRun) {
|
|
2666
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2671
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2667
2672
|
return;
|
|
2668
2673
|
}
|
|
2669
2674
|
await handleConfigAuto({
|
|
@@ -2771,7 +2776,7 @@ async function run$M(argv, importMeta, {
|
|
|
2771
2776
|
return;
|
|
2772
2777
|
}
|
|
2773
2778
|
if (dryRun) {
|
|
2774
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2779
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2775
2780
|
return;
|
|
2776
2781
|
}
|
|
2777
2782
|
await handleConfigGet({
|
|
@@ -2903,7 +2908,7 @@ async function run$L(argv, importMeta, {
|
|
|
2903
2908
|
return;
|
|
2904
2909
|
}
|
|
2905
2910
|
if (dryRun) {
|
|
2906
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
2911
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
2907
2912
|
return;
|
|
2908
2913
|
}
|
|
2909
2914
|
await outputConfigList({
|
|
@@ -3027,7 +3032,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
3027
3032
|
return;
|
|
3028
3033
|
}
|
|
3029
3034
|
if (dryRun) {
|
|
3030
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
3035
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
3031
3036
|
return;
|
|
3032
3037
|
}
|
|
3033
3038
|
await handleConfigSet({
|
|
@@ -3139,7 +3144,7 @@ ${utils.getSupportedConfigEntries().map(([key, desc]) => ` - ${key} -- ${des
|
|
|
3139
3144
|
return;
|
|
3140
3145
|
}
|
|
3141
3146
|
if (dryRun) {
|
|
3142
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
3147
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
3143
3148
|
return;
|
|
3144
3149
|
}
|
|
3145
3150
|
await handleConfigUnset({
|
|
@@ -3186,14 +3191,14 @@ function getSocketFixPullRequestBody(ghsaIds, ghsaDetails) {
|
|
|
3186
3191
|
if (vulnCount === 1) {
|
|
3187
3192
|
const ghsaId = ghsaIds[0];
|
|
3188
3193
|
const details = ghsaDetails?.get(ghsaId);
|
|
3189
|
-
const body = `[Socket](${constants.SOCKET_WEBSITE_URL}) fix for [${ghsaId}](${GITHUB_ADVISORIES_URL}/${ghsaId}).`;
|
|
3194
|
+
const body = `[Socket](${constants.default.SOCKET_WEBSITE_URL}) fix for [${ghsaId}](${GITHUB_ADVISORIES_URL}/${ghsaId}).`;
|
|
3190
3195
|
if (!details) {
|
|
3191
3196
|
return body;
|
|
3192
3197
|
}
|
|
3193
3198
|
const packages = details.vulnerabilities.nodes.map(v => `${v.package.name} (${v.package.ecosystem})`);
|
|
3194
3199
|
return [body, '', '', `**Vulnerability Summary:** ${details.summary}`, '', `**Severity:** ${details.severity}`, '', `**Affected Packages:** ${arrays.joinAnd(packages)}`].join('\n');
|
|
3195
3200
|
}
|
|
3196
|
-
return [`[Socket](${constants.SOCKET_WEBSITE_URL}) fixes for ${vulnCount} GHSAs.`, '', '**Fixed Vulnerabilities:**', ...ghsaIds.map(id => {
|
|
3201
|
+
return [`[Socket](${constants.default.SOCKET_WEBSITE_URL}) fixes for ${vulnCount} GHSAs.`, '', '**Fixed Vulnerabilities:**', ...ghsaIds.map(id => {
|
|
3197
3202
|
const details = ghsaDetails?.get(id);
|
|
3198
3203
|
const item = `- [${id}](${GITHUB_ADVISORIES_URL}/${id})`;
|
|
3199
3204
|
if (details) {
|
|
@@ -3373,7 +3378,7 @@ async function getSocketPrsWithContext(owner, repo, options) {
|
|
|
3373
3378
|
function ciRepoInfo() {
|
|
3374
3379
|
const {
|
|
3375
3380
|
GITHUB_REPOSITORY
|
|
3376
|
-
} = constants.ENV;
|
|
3381
|
+
} = constants.default.ENV;
|
|
3377
3382
|
if (!GITHUB_REPOSITORY) {
|
|
3378
3383
|
require$$9.debugFn('notice', 'miss: GITHUB_REPOSITORY env var');
|
|
3379
3384
|
}
|
|
@@ -3389,18 +3394,18 @@ function ciRepoInfo() {
|
|
|
3389
3394
|
}
|
|
3390
3395
|
async function getFixEnv() {
|
|
3391
3396
|
const baseBranch = await utils.getBaseBranch();
|
|
3392
|
-
const gitEmail = constants.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
3393
|
-
const gitUser = constants.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
3394
|
-
const githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
3395
|
-
const isCi = !!(constants.ENV.CI && gitEmail && gitUser && githubToken);
|
|
3397
|
+
const gitEmail = constants.default.ENV.SOCKET_CLI_GIT_USER_EMAIL;
|
|
3398
|
+
const gitUser = constants.default.ENV.SOCKET_CLI_GIT_USER_NAME;
|
|
3399
|
+
const githubToken = constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN;
|
|
3400
|
+
const isCi = !!(constants.default.ENV.CI && gitEmail && gitUser && githubToken);
|
|
3396
3401
|
if (
|
|
3397
3402
|
// If isCi is false,
|
|
3398
3403
|
!isCi && (
|
|
3399
3404
|
// but some CI checks are passing,
|
|
3400
|
-
constants.ENV.CI || gitEmail || gitUser || githubToken) &&
|
|
3405
|
+
constants.default.ENV.CI || gitEmail || gitUser || githubToken) &&
|
|
3401
3406
|
// then log about it when in debug mode.
|
|
3402
3407
|
require$$9.isDebug('notice')) {
|
|
3403
|
-
const envVars = [...(constants.ENV.CI ? [] : ['process.env.CI']), ...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']), ...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']), ...(githubToken ? [] : ['process.env.GITHUB_TOKEN'])];
|
|
3408
|
+
const envVars = [...(constants.default.ENV.CI ? [] : ['process.env.CI']), ...(gitEmail ? [] : ['process.env.SOCKET_CLI_GIT_USER_EMAIL']), ...(gitUser ? [] : ['process.env.SOCKET_CLI_GIT_USER_NAME']), ...(githubToken ? [] : ['process.env.GITHUB_TOKEN'])];
|
|
3404
3409
|
require$$9.debugFn('notice', `miss: fixEnv.isCi is false, expected ${arrays.joinAnd(envVars)} to be set`);
|
|
3405
3410
|
}
|
|
3406
3411
|
let repoInfo = null;
|
|
@@ -3844,10 +3849,9 @@ async function run$I(argv, importMeta, {
|
|
|
3844
3849
|
const rawPurls = utils.cmdFlagValueToArray(cli.flags['purl']);
|
|
3845
3850
|
const purls = [];
|
|
3846
3851
|
for (const purl of rawPurls) {
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
} catch {}
|
|
3852
|
+
const version = utils.getPurlObject(purl, {
|
|
3853
|
+
throws: false
|
|
3854
|
+
})?.version;
|
|
3851
3855
|
if (version) {
|
|
3852
3856
|
purls.push(purl);
|
|
3853
3857
|
} else {
|
|
@@ -3874,7 +3878,7 @@ async function run$I(argv, importMeta, {
|
|
|
3874
3878
|
return;
|
|
3875
3879
|
}
|
|
3876
3880
|
if (dryRun) {
|
|
3877
|
-
logger.logger.log(constants.DRY_RUN_NOT_SAVING);
|
|
3881
|
+
logger.logger.log(constants.default.DRY_RUN_NOT_SAVING);
|
|
3878
3882
|
return;
|
|
3879
3883
|
}
|
|
3880
3884
|
const orgSlugCResult = await utils.getDefaultOrgSlug();
|
|
@@ -3896,7 +3900,7 @@ async function run$I(argv, importMeta, {
|
|
|
3896
3900
|
}
|
|
3897
3901
|
const {
|
|
3898
3902
|
spinner
|
|
3899
|
-
} = constants;
|
|
3903
|
+
} = constants.default;
|
|
3900
3904
|
// We patched in this feature with `npx custompatch meow` at
|
|
3901
3905
|
// socket-cli/patches/meow#13.2.0.patch.
|
|
3902
3906
|
const unknownFlags = cli.unknownFlags ?? [];
|
|
@@ -3980,7 +3984,7 @@ async function setupTabCompletion(targetName) {
|
|
|
3980
3984
|
let bashrcUpdated = false;
|
|
3981
3985
|
|
|
3982
3986
|
// Add to ~/.bashrc if not already there
|
|
3983
|
-
const bashrcPath = constants.homePath ? path.join(constants.homePath, '.bashrc') : '';
|
|
3987
|
+
const bashrcPath = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
|
|
3984
3988
|
const foundBashrc = Boolean(bashrcPath && fs$1.existsSync(bashrcPath));
|
|
3985
3989
|
if (foundBashrc) {
|
|
3986
3990
|
const content = fs$1.readFileSync(bashrcPath, 'utf8');
|
|
@@ -4026,7 +4030,7 @@ function updateInstalledTabCompletionScript(targetPath) {
|
|
|
4026
4030
|
|
|
4027
4031
|
// When installing set the current package.json version.
|
|
4028
4032
|
// Later, we can call _socket_completion_version to get the installed version.
|
|
4029
|
-
fs$1.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
|
|
4033
|
+
fs$1.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
|
|
4030
4034
|
return {
|
|
4031
4035
|
ok: true,
|
|
4032
4036
|
data: undefined
|
|
@@ -4090,7 +4094,7 @@ async function run$H(argv, importMeta, {
|
|
|
4090
4094
|
});
|
|
4091
4095
|
const dryRun = !!cli.flags['dryRun'];
|
|
4092
4096
|
if (dryRun) {
|
|
4093
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4097
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4094
4098
|
return;
|
|
4095
4099
|
}
|
|
4096
4100
|
const targetName = cli.input[0] || 'socket';
|
|
@@ -4116,9 +4120,9 @@ const cmdInstall = {
|
|
|
4116
4120
|
};
|
|
4117
4121
|
|
|
4118
4122
|
async function outputCmdJson(cwd) {
|
|
4119
|
-
logger.logger.info('Target cwd:', constants.ENV.VITEST ? '<redacted>' : utils.tildify(cwd));
|
|
4123
|
+
logger.logger.info('Target cwd:', constants.default.ENV.VITEST ? '<redacted>' : utils.tildify(cwd));
|
|
4120
4124
|
const sockJsonPath = path.join(cwd, 'socket.json');
|
|
4121
|
-
const tildeSockJsonPath = constants.ENV.VITEST ? '<redacted>' : utils.tildify(sockJsonPath);
|
|
4125
|
+
const tildeSockJsonPath = constants.default.ENV.VITEST ? '<redacted>' : utils.tildify(sockJsonPath);
|
|
4122
4126
|
if (!fs$1.existsSync(sockJsonPath)) {
|
|
4123
4127
|
logger.logger.fail(`Not found: ${tildeSockJsonPath}`);
|
|
4124
4128
|
process.exitCode = 1;
|
|
@@ -4199,7 +4203,7 @@ async function attemptLogin(apiBaseUrl, apiProxy) {
|
|
|
4199
4203
|
cause: 'Canceled by user'
|
|
4200
4204
|
};
|
|
4201
4205
|
}
|
|
4202
|
-
const apiToken = apiTokenInput || constants.SOCKET_PUBLIC_API_TOKEN;
|
|
4206
|
+
const apiToken = apiTokenInput || constants.default.SOCKET_PUBLIC_API_TOKEN;
|
|
4203
4207
|
const sockSdkCResult = await utils.setupSdk({
|
|
4204
4208
|
apiBaseUrl,
|
|
4205
4209
|
apiProxy,
|
|
@@ -4367,7 +4371,7 @@ async function run$F(argv, importMeta, {
|
|
|
4367
4371
|
});
|
|
4368
4372
|
const dryRun = !!cli.flags['dryRun'];
|
|
4369
4373
|
if (dryRun) {
|
|
4370
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4374
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4371
4375
|
return;
|
|
4372
4376
|
}
|
|
4373
4377
|
if (!vendor.isInteractiveExports()) {
|
|
@@ -4431,7 +4435,7 @@ async function run$E(argv, importMeta, {
|
|
|
4431
4435
|
});
|
|
4432
4436
|
const dryRun = !!cli.flags['dryRun'];
|
|
4433
4437
|
if (dryRun) {
|
|
4434
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4438
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4435
4439
|
return;
|
|
4436
4440
|
}
|
|
4437
4441
|
attemptLogout();
|
|
@@ -4441,8 +4445,8 @@ const {
|
|
|
4441
4445
|
PACKAGE_LOCK_JSON,
|
|
4442
4446
|
YARN,
|
|
4443
4447
|
YARN_LOCK
|
|
4444
|
-
} = constants;
|
|
4445
|
-
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs',
|
|
4448
|
+
} = constants.default;
|
|
4449
|
+
const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', constants.NPM, constants.PNPM, 'ts', 'tsx', 'typescript']);
|
|
4446
4450
|
function argvToArray(argvObj) {
|
|
4447
4451
|
if (argvObj['help']) {
|
|
4448
4452
|
return ['--help'];
|
|
@@ -4485,29 +4489,29 @@ async function runCdxgen(argvObj) {
|
|
|
4485
4489
|
};
|
|
4486
4490
|
const shadowOpts = {
|
|
4487
4491
|
ipc: {
|
|
4488
|
-
[constants.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
|
|
4489
|
-
[constants.SOCKET_CLI_SHADOW_API_TOKEN]: constants.SOCKET_PUBLIC_API_TOKEN,
|
|
4490
|
-
[constants.SOCKET_CLI_SHADOW_SILENT]: true
|
|
4492
|
+
[constants.default.SOCKET_CLI_SHADOW_ACCEPT_RISKS]: true,
|
|
4493
|
+
[constants.default.SOCKET_CLI_SHADOW_API_TOKEN]: constants.default.SOCKET_PUBLIC_API_TOKEN,
|
|
4494
|
+
[constants.default.SOCKET_CLI_SHADOW_SILENT]: true
|
|
4491
4495
|
},
|
|
4492
4496
|
stdio: 'inherit'
|
|
4493
4497
|
};
|
|
4494
4498
|
if (argvMutable['type'] !== YARN && nodejsPlatformTypes.has(argvMutable['type']) && fs$1.existsSync(`./${YARN_LOCK}`)) {
|
|
4495
4499
|
if (fs$1.existsSync(`./${PACKAGE_LOCK_JSON}`)) {
|
|
4496
|
-
argvMutable['type'] =
|
|
4500
|
+
argvMutable['type'] = constants.NPM;
|
|
4497
4501
|
} else {
|
|
4498
4502
|
// Use synp to create a package-lock.json from the yarn.lock,
|
|
4499
4503
|
// based on the node_modules folder, for a more accurate SBOM.
|
|
4500
4504
|
try {
|
|
4501
4505
|
const {
|
|
4502
4506
|
spawnPromise: synpPromise
|
|
4503
|
-
} = await shadowNpmBin('npx', ['--yes', `synp@${constants.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`], shadowOpts);
|
|
4507
|
+
} = await shadowNpmBin('npx', ['--yes', `synp@${constants.default.ENV.INLINED_SOCKET_CLI_SYNP_VERSION}`, '--source-file', `./${YARN_LOCK}`], shadowOpts);
|
|
4504
4508
|
await synpPromise;
|
|
4505
|
-
argvMutable['type'] =
|
|
4509
|
+
argvMutable['type'] = constants.NPM;
|
|
4506
4510
|
cleanupPackageLock = true;
|
|
4507
4511
|
} catch {}
|
|
4508
4512
|
}
|
|
4509
4513
|
}
|
|
4510
|
-
const shadowResult = await shadowNpmBin('npx', ['--yes', `@cyclonedx/cdxgen@${constants.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
|
|
4514
|
+
const shadowResult = await shadowNpmBin('npx', ['--yes', `@cyclonedx/cdxgen@${constants.default.ENV.INLINED_SOCKET_CLI_CYCLONEDX_CDXGEN_VERSION}`, ...argvToArray(argvMutable)], shadowOpts);
|
|
4511
4515
|
shadowResult.spawnPromise.process.on('exit', () => {
|
|
4512
4516
|
if (cleanupPackageLock) {
|
|
4513
4517
|
try {
|
|
@@ -4770,7 +4774,7 @@ async function run$D(argv, importMeta, {
|
|
|
4770
4774
|
return;
|
|
4771
4775
|
}
|
|
4772
4776
|
if (dryRun) {
|
|
4773
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4777
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4774
4778
|
return;
|
|
4775
4779
|
}
|
|
4776
4780
|
|
|
@@ -4878,7 +4882,7 @@ async function run$C(argv, importMeta, {
|
|
|
4878
4882
|
detected
|
|
4879
4883
|
});
|
|
4880
4884
|
if (dryRun) {
|
|
4881
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
4885
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
4882
4886
|
return;
|
|
4883
4887
|
}
|
|
4884
4888
|
if (!detected.count) {
|
|
@@ -5041,7 +5045,7 @@ async function run$B(argv, importMeta, {
|
|
|
5041
5045
|
}
|
|
5042
5046
|
logger.logger.warn('Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk.');
|
|
5043
5047
|
if (dryRun) {
|
|
5044
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5048
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5045
5049
|
return;
|
|
5046
5050
|
}
|
|
5047
5051
|
await handleManifestConda({
|
|
@@ -5192,7 +5196,7 @@ async function run$A(argv, importMeta, {
|
|
|
5192
5196
|
logger.logger.groupEnd();
|
|
5193
5197
|
}
|
|
5194
5198
|
if (dryRun) {
|
|
5195
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5199
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5196
5200
|
return;
|
|
5197
5201
|
}
|
|
5198
5202
|
await convertGradleToMaven({
|
|
@@ -5347,7 +5351,7 @@ async function run$z(argv, importMeta, {
|
|
|
5347
5351
|
logger.logger.groupEnd();
|
|
5348
5352
|
}
|
|
5349
5353
|
if (dryRun) {
|
|
5350
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5354
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5351
5355
|
return;
|
|
5352
5356
|
}
|
|
5353
5357
|
await convertGradleToMaven({
|
|
@@ -5525,7 +5529,7 @@ async function run$y(argv, importMeta, {
|
|
|
5525
5529
|
logger.logger.groupEnd();
|
|
5526
5530
|
}
|
|
5527
5531
|
if (dryRun) {
|
|
5528
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
5532
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
5529
5533
|
return;
|
|
5530
5534
|
}
|
|
5531
5535
|
await convertSbtToMaven({
|
|
@@ -6007,7 +6011,7 @@ async function run$x(argv, importMeta, {
|
|
|
6007
6011
|
// If given path is absolute then cwd should not affect it.
|
|
6008
6012
|
cwd = path.resolve(process.cwd(), cwd);
|
|
6009
6013
|
if (dryRun) {
|
|
6010
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6014
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6011
6015
|
return;
|
|
6012
6016
|
}
|
|
6013
6017
|
await handleManifestSetup(cwd, Boolean(defaultOnReadError));
|
|
@@ -6053,7 +6057,7 @@ async function run$w(argv, importMeta, {
|
|
|
6053
6057
|
}
|
|
6054
6058
|
|
|
6055
6059
|
const require$3 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6056
|
-
const CMD_NAME$p =
|
|
6060
|
+
const CMD_NAME$p = constants.NPM;
|
|
6057
6061
|
const description$u = 'Run npm with the Socket wrapper';
|
|
6058
6062
|
const hidden$o = false;
|
|
6059
6063
|
const cmdNpm = {
|
|
@@ -6096,14 +6100,14 @@ async function run$v(argv, importMeta, {
|
|
|
6096
6100
|
});
|
|
6097
6101
|
const dryRun = !!cli.flags['dryRun'];
|
|
6098
6102
|
if (dryRun) {
|
|
6099
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6103
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6100
6104
|
return;
|
|
6101
6105
|
}
|
|
6102
|
-
const shadowBin = /*@__PURE__*/require$3(constants.shadowNpmBinPath);
|
|
6106
|
+
const shadowBin = /*@__PURE__*/require$3(constants.default.shadowNpmBinPath);
|
|
6103
6107
|
process.exitCode = 1;
|
|
6104
6108
|
const {
|
|
6105
6109
|
spawnPromise
|
|
6106
|
-
} = await shadowBin(
|
|
6110
|
+
} = await shadowBin(constants.NPM, argv, {
|
|
6107
6111
|
stdio: 'inherit'
|
|
6108
6112
|
});
|
|
6109
6113
|
|
|
@@ -6120,7 +6124,7 @@ async function run$v(argv, importMeta, {
|
|
|
6120
6124
|
}
|
|
6121
6125
|
|
|
6122
6126
|
const require$2 = Module.createRequire(require('node:url').pathToFileURL(__filename).href);
|
|
6123
|
-
const CMD_NAME$o =
|
|
6127
|
+
const CMD_NAME$o = constants.NPX;
|
|
6124
6128
|
const description$t = 'Run npx with the Socket wrapper';
|
|
6125
6129
|
const hidden$n = false;
|
|
6126
6130
|
const cmdNpx = {
|
|
@@ -6162,14 +6166,14 @@ async function run$u(argv, importMeta, {
|
|
|
6162
6166
|
});
|
|
6163
6167
|
const dryRun = !!cli.flags['dryRun'];
|
|
6164
6168
|
if (dryRun) {
|
|
6165
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6169
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6166
6170
|
return;
|
|
6167
6171
|
}
|
|
6168
|
-
const shadowBin = /*@__PURE__*/require$2(constants.shadowNpmBinPath);
|
|
6172
|
+
const shadowBin = /*@__PURE__*/require$2(constants.default.shadowNpmBinPath);
|
|
6169
6173
|
process.exitCode = 1;
|
|
6170
6174
|
const {
|
|
6171
6175
|
spawnPromise
|
|
6172
|
-
} = await shadowBin(
|
|
6176
|
+
} = await shadowBin(constants.NPX, argv, {
|
|
6173
6177
|
stdio: 'inherit'
|
|
6174
6178
|
});
|
|
6175
6179
|
|
|
@@ -6226,7 +6230,7 @@ async function run$t(argv, importMeta, {
|
|
|
6226
6230
|
} = cli.flags;
|
|
6227
6231
|
const dryRun = !!cli.flags['dryRun'];
|
|
6228
6232
|
if (dryRun) {
|
|
6229
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
6233
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
6230
6234
|
return;
|
|
6231
6235
|
}
|
|
6232
6236
|
if (json && !justThrow) {
|
|
@@ -6252,7 +6256,7 @@ const {
|
|
|
6252
6256
|
VLT: VLT$5,
|
|
6253
6257
|
YARN_BERRY: YARN_BERRY$4,
|
|
6254
6258
|
YARN_CLASSIC: YARN_CLASSIC$4
|
|
6255
|
-
} = constants;
|
|
6259
|
+
} = constants.default;
|
|
6256
6260
|
function matchLsCmdViewHumanStdout(stdout, name) {
|
|
6257
6261
|
return stdout.includes(` ${name}@`);
|
|
6258
6262
|
}
|
|
@@ -6306,7 +6310,7 @@ const {
|
|
|
6306
6310
|
VLT: VLT$4,
|
|
6307
6311
|
YARN_BERRY: YARN_BERRY$3,
|
|
6308
6312
|
YARN_CLASSIC: YARN_CLASSIC$3
|
|
6309
|
-
} = constants;
|
|
6313
|
+
} = constants.default;
|
|
6310
6314
|
function getOverridesDataBun(pkgEnvDetails, pkgJson = pkgEnvDetails.editablePkgJson.content) {
|
|
6311
6315
|
const overrides = pkgJson?.[RESOLUTIONS$1] ?? {};
|
|
6312
6316
|
return {
|
|
@@ -6381,13 +6385,13 @@ function getOverridesData(pkgEnvDetails, pkgJson) {
|
|
|
6381
6385
|
|
|
6382
6386
|
const {
|
|
6383
6387
|
BUN: BUN$2,
|
|
6384
|
-
|
|
6388
|
+
EXT_LOCK,
|
|
6385
6389
|
NPM: NPM$2,
|
|
6386
6390
|
PNPM: PNPM$2,
|
|
6387
6391
|
VLT: VLT$3,
|
|
6388
6392
|
YARN_BERRY: YARN_BERRY$2,
|
|
6389
6393
|
YARN_CLASSIC: YARN_CLASSIC$2
|
|
6390
|
-
} = constants;
|
|
6394
|
+
} = constants.default;
|
|
6391
6395
|
function npmLockSrcIncludes(lockSrc, name) {
|
|
6392
6396
|
// Detects the package name in the following cases:
|
|
6393
6397
|
// "name":
|
|
@@ -6398,7 +6402,7 @@ function bunLockSrcIncludes(lockSrc, name, lockName) {
|
|
|
6398
6402
|
// we treat it as a yarn.lock. When lockName ends with a .lock we
|
|
6399
6403
|
// treat it as a package-lock.json. The bun.lock format is not identical
|
|
6400
6404
|
// package-lock.json, however it close enough for npmLockIncludes to work.
|
|
6401
|
-
const lockfileScanner = lockName?.endsWith(
|
|
6405
|
+
const lockfileScanner = lockName?.endsWith(EXT_LOCK) ? npmLockSrcIncludes : yarnLockSrcIncludes;
|
|
6402
6406
|
return lockfileScanner(lockSrc, name);
|
|
6403
6407
|
}
|
|
6404
6408
|
function pnpmLockSrcIncludes(lockSrc, name) {
|
|
@@ -6453,7 +6457,7 @@ const {
|
|
|
6453
6457
|
VLT: VLT$2,
|
|
6454
6458
|
YARN_BERRY: YARN_BERRY$1,
|
|
6455
6459
|
YARN_CLASSIC: YARN_CLASSIC$1
|
|
6456
|
-
} = constants;
|
|
6460
|
+
} = constants.default;
|
|
6457
6461
|
function cleanupQueryStdout(stdout) {
|
|
6458
6462
|
if (stdout === '') {
|
|
6459
6463
|
return '';
|
|
@@ -6499,7 +6503,7 @@ async function npmQuery(npmExecPath, cwd) {
|
|
|
6499
6503
|
try {
|
|
6500
6504
|
stdout = (await spawn.spawn(npmExecPath, ['query', ':not(.dev)'], {
|
|
6501
6505
|
cwd,
|
|
6502
|
-
shell: constants.WIN32
|
|
6506
|
+
shell: constants.default.WIN32
|
|
6503
6507
|
})).stdout;
|
|
6504
6508
|
} catch {}
|
|
6505
6509
|
return cleanupQueryStdout(stdout);
|
|
@@ -6516,7 +6520,7 @@ async function lsBun(pkgEnvDetails, options) {
|
|
|
6516
6520
|
// https://github.com/oven-sh/bun/issues/8283
|
|
6517
6521
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['pm', 'ls', '--all'], {
|
|
6518
6522
|
cwd,
|
|
6519
|
-
shell: constants.WIN32
|
|
6523
|
+
shell: constants.default.WIN32
|
|
6520
6524
|
})).stdout;
|
|
6521
6525
|
} catch {}
|
|
6522
6526
|
return '';
|
|
@@ -6551,7 +6555,7 @@ async function lsPnpm(pkgEnvDetails, options) {
|
|
|
6551
6555
|
// https://en.wiktionary.org/wiki/parsable
|
|
6552
6556
|
['ls', '--parseable', '--prod', '--depth', 'Infinity'], {
|
|
6553
6557
|
cwd,
|
|
6554
|
-
shell: constants.WIN32
|
|
6558
|
+
shell: constants.default.WIN32
|
|
6555
6559
|
})).stdout;
|
|
6556
6560
|
} catch {}
|
|
6557
6561
|
return parsableToQueryStdout(stdout);
|
|
@@ -6568,7 +6572,7 @@ async function lsVlt(pkgEnvDetails, options) {
|
|
|
6568
6572
|
// See https://docs.vlt.sh/cli/commands/list#options.
|
|
6569
6573
|
stdout = (await spawn.spawn(pkgEnvDetails.agentExecPath, ['ls', '--view', 'human', ':not(.dev)'], {
|
|
6570
6574
|
cwd,
|
|
6571
|
-
shell: constants.WIN32
|
|
6575
|
+
shell: constants.default.WIN32
|
|
6572
6576
|
})).stdout;
|
|
6573
6577
|
} catch {}
|
|
6574
6578
|
return cleanupQueryStdout(stdout);
|
|
@@ -6585,7 +6589,7 @@ async function lsYarnBerry(pkgEnvDetails, options) {
|
|
|
6585
6589
|
// https://github.com/yarnpkg/berry/issues/5117
|
|
6586
6590
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['info', '--recursive', '--name-only'], {
|
|
6587
6591
|
cwd,
|
|
6588
|
-
shell: constants.WIN32
|
|
6592
|
+
shell: constants.default.WIN32
|
|
6589
6593
|
})).stdout;
|
|
6590
6594
|
} catch {}
|
|
6591
6595
|
return '';
|
|
@@ -6604,7 +6608,7 @@ async function lsYarnClassic(pkgEnvDetails, options) {
|
|
|
6604
6608
|
// environment is production
|
|
6605
6609
|
return (await spawn.spawn(pkgEnvDetails.agentExecPath, ['list', '--prod'], {
|
|
6606
6610
|
cwd,
|
|
6607
|
-
shell: constants.WIN32
|
|
6611
|
+
shell: constants.default.WIN32
|
|
6608
6612
|
})).stdout;
|
|
6609
6613
|
} catch {}
|
|
6610
6614
|
return '';
|
|
@@ -6638,7 +6642,7 @@ const {
|
|
|
6638
6642
|
VLT: VLT$1,
|
|
6639
6643
|
YARN_BERRY,
|
|
6640
6644
|
YARN_CLASSIC
|
|
6641
|
-
} = constants;
|
|
6645
|
+
} = constants.default;
|
|
6642
6646
|
const depFields = ['dependencies', 'devDependencies', 'peerDependencies', 'peerDependenciesMeta', 'optionalDependencies', 'bundleDependencies'];
|
|
6643
6647
|
function getEntryIndexes(entries, keys) {
|
|
6644
6648
|
return keys.map(n => entries.findIndex(p => p[0] === n)).filter(n => n !== -1).sort((a, b) => a - b);
|
|
@@ -6763,7 +6767,7 @@ function updateManifest(agent, editablePkgJson, overrides) {
|
|
|
6763
6767
|
}
|
|
6764
6768
|
}
|
|
6765
6769
|
|
|
6766
|
-
const manifestNpmOverrides = registry.getManifestData(
|
|
6770
|
+
const manifestNpmOverrides = registry.getManifestData(constants.NPM);
|
|
6767
6771
|
async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
6768
6772
|
const {
|
|
6769
6773
|
agent,
|
|
@@ -6789,14 +6793,14 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6789
6793
|
...options
|
|
6790
6794
|
};
|
|
6791
6795
|
const workspacePkgJsonPaths = await utils.globWorkspace(agent, pkgPath);
|
|
6792
|
-
const isPnpm = agent ===
|
|
6796
|
+
const isPnpm = agent === constants.PNPM;
|
|
6793
6797
|
const isWorkspace = workspacePkgJsonPaths.length > 0;
|
|
6794
6798
|
const isWorkspaceRoot = pkgPath === rootPath;
|
|
6795
6799
|
const isLockScanned = isWorkspaceRoot && !prod;
|
|
6796
6800
|
const workspace = isWorkspaceRoot ? 'root' : path.relative(rootPath, pkgPath);
|
|
6797
6801
|
if (isWorkspace && isPnpm &&
|
|
6798
6802
|
// npmExecPath will === the agent name IF it CANNOT be resolved.
|
|
6799
|
-
npmExecPath ===
|
|
6803
|
+
npmExecPath === constants.NPM && !state.warnedPnpmWorkspaceRequiresNpm) {
|
|
6800
6804
|
state.warnedPnpmWorkspaceRequiresNpm = true;
|
|
6801
6805
|
spinner?.stop();
|
|
6802
6806
|
logger?.warn(utils.cmdPrefixMessage(CMD_NAME$n, `${agent} workspace support requires \`npm ls\`, falling back to \`${agent} list\``));
|
|
@@ -6885,7 +6889,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6885
6889
|
const sockRegDepAlias = depAliasMap.get(sockRegPkgName);
|
|
6886
6890
|
const depAlias = sockRegDepAlias ?? origDepAlias;
|
|
6887
6891
|
let newSpec = sockOverrideSpec;
|
|
6888
|
-
if (type ===
|
|
6892
|
+
if (type === constants.NPM && depAlias) {
|
|
6889
6893
|
// With npm one may not set an override for a package that one directly
|
|
6890
6894
|
// depends on unless both the dependency and the override itself share
|
|
6891
6895
|
// the exact same spec. To make this limitation easier to deal with,
|
|
@@ -6965,7 +6969,7 @@ async function addOverrides(pkgEnvDetails, pkgPath, options) {
|
|
|
6965
6969
|
|
|
6966
6970
|
const {
|
|
6967
6971
|
NPM_BUGGY_OVERRIDES_PATCHED_VERSION
|
|
6968
|
-
} = constants;
|
|
6972
|
+
} = constants.default;
|
|
6969
6973
|
async function updateLockfile(pkgEnvDetails, options) {
|
|
6970
6974
|
const {
|
|
6971
6975
|
cmdName = '',
|
|
@@ -7016,7 +7020,7 @@ async function applyOptimization(pkgEnvDetails, {
|
|
|
7016
7020
|
}) {
|
|
7017
7021
|
const {
|
|
7018
7022
|
spinner
|
|
7019
|
-
} = constants;
|
|
7023
|
+
} = constants.default;
|
|
7020
7024
|
spinner.start();
|
|
7021
7025
|
const state = await addOverrides(pkgEnvDetails, pkgEnvDetails.pkgPath, {
|
|
7022
7026
|
logger: logger.logger,
|
|
@@ -7083,7 +7087,7 @@ function createActionMessage(verb, overrideCount, workspaceCount) {
|
|
|
7083
7087
|
|
|
7084
7088
|
const {
|
|
7085
7089
|
VLT
|
|
7086
|
-
} = constants;
|
|
7090
|
+
} = constants.default;
|
|
7087
7091
|
async function handleOptimize({
|
|
7088
7092
|
cwd,
|
|
7089
7093
|
outputKind,
|
|
@@ -7178,7 +7182,7 @@ async function run$s(argv, importMeta, {
|
|
|
7178
7182
|
});
|
|
7179
7183
|
const dryRun = !!cli.flags['dryRun'];
|
|
7180
7184
|
if (dryRun) {
|
|
7181
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7185
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7182
7186
|
return;
|
|
7183
7187
|
}
|
|
7184
7188
|
const {
|
|
@@ -7377,7 +7381,7 @@ async function run$r(argv, importMeta, {
|
|
|
7377
7381
|
return;
|
|
7378
7382
|
}
|
|
7379
7383
|
if (dryRun) {
|
|
7380
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7384
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7381
7385
|
return;
|
|
7382
7386
|
}
|
|
7383
7387
|
await handleDependencies({
|
|
@@ -7514,7 +7518,7 @@ async function run$q(argv, importMeta, {
|
|
|
7514
7518
|
return;
|
|
7515
7519
|
}
|
|
7516
7520
|
if (dryRun) {
|
|
7517
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7521
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7518
7522
|
return;
|
|
7519
7523
|
}
|
|
7520
7524
|
await handleLicensePolicy(orgSlug, outputKind);
|
|
@@ -7648,7 +7652,7 @@ async function run$p(argv, importMeta, {
|
|
|
7648
7652
|
return;
|
|
7649
7653
|
}
|
|
7650
7654
|
if (dryRun) {
|
|
7651
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7655
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7652
7656
|
return;
|
|
7653
7657
|
}
|
|
7654
7658
|
await handleSecurityPolicy(orgSlug, outputKind);
|
|
@@ -7768,7 +7772,7 @@ async function run$o(argv, importMeta, {
|
|
|
7768
7772
|
return;
|
|
7769
7773
|
}
|
|
7770
7774
|
if (dryRun) {
|
|
7771
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7775
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7772
7776
|
return;
|
|
7773
7777
|
}
|
|
7774
7778
|
await handleOrganizationList(outputKind);
|
|
@@ -7898,7 +7902,7 @@ async function run$n(argv, importMeta, {
|
|
|
7898
7902
|
return;
|
|
7899
7903
|
}
|
|
7900
7904
|
if (dryRun) {
|
|
7901
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
7905
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
7902
7906
|
return;
|
|
7903
7907
|
}
|
|
7904
7908
|
await handleQuota(outputKind);
|
|
@@ -8256,7 +8260,7 @@ async function run$m(argv, importMeta, {
|
|
|
8256
8260
|
return;
|
|
8257
8261
|
}
|
|
8258
8262
|
if (dryRun) {
|
|
8259
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
8263
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
8260
8264
|
return;
|
|
8261
8265
|
}
|
|
8262
8266
|
await handlePurlDeepScore(purls[0] || '', outputKind);
|
|
@@ -8638,7 +8642,7 @@ async function run$l(argv, importMeta, {
|
|
|
8638
8642
|
return;
|
|
8639
8643
|
}
|
|
8640
8644
|
if (dryRun) {
|
|
8641
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
8645
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
8642
8646
|
return;
|
|
8643
8647
|
}
|
|
8644
8648
|
await handlePurlsShallowScore({
|
|
@@ -8710,13 +8714,14 @@ async function outputPatchResult(result, outputKind) {
|
|
|
8710
8714
|
return;
|
|
8711
8715
|
}
|
|
8712
8716
|
const {
|
|
8713
|
-
|
|
8717
|
+
patched
|
|
8714
8718
|
} = result.data;
|
|
8715
|
-
if (
|
|
8716
|
-
logger.logger.
|
|
8717
|
-
for (const pkg of
|
|
8719
|
+
if (patched.length) {
|
|
8720
|
+
logger.logger.group(`Successfully processed patches for ${patched.length} package(s):`);
|
|
8721
|
+
for (const pkg of patched) {
|
|
8718
8722
|
logger.logger.success(pkg);
|
|
8719
8723
|
}
|
|
8724
|
+
logger.logger.groupEnd();
|
|
8720
8725
|
} else {
|
|
8721
8726
|
logger.logger.info('No packages found requiring patches');
|
|
8722
8727
|
}
|
|
@@ -8724,144 +8729,96 @@ async function outputPatchResult(result, outputKind) {
|
|
|
8724
8729
|
logger.logger.success('Patch command completed!');
|
|
8725
8730
|
}
|
|
8726
8731
|
|
|
8727
|
-
async function applyNPMPatches(patches,
|
|
8732
|
+
async function applyNPMPatches(patches, purlObjs, socketDir, dryRun) {
|
|
8728
8733
|
const patchLookup = new Map();
|
|
8729
8734
|
for (const patchInfo of patches) {
|
|
8730
|
-
const
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8735
|
+
const key = getLookupKey(patchInfo.purlObj);
|
|
8736
|
+
patchLookup.set(key, patchInfo);
|
|
8737
|
+
}
|
|
8738
|
+
const nmPaths = await findNodeModulesPaths(process.cwd());
|
|
8739
|
+
logger.logger.log(`Found ${nmPaths.length} node_modules ${words.pluralize('folder', nmPaths.length)}`);
|
|
8740
|
+
for (const nmPath of nmPaths) {
|
|
8741
|
+
// eslint-disable-next-line no-await-in-loop
|
|
8742
|
+
const dirNames = await fs$2.readDirNames(nmPath);
|
|
8743
|
+
for (const dirName of dirNames) {
|
|
8744
|
+
const isScoped = dirName.startsWith('@');
|
|
8745
|
+
const pkgPath = path.join(nmPath, dirName);
|
|
8746
|
+
const pkgSubNames = isScoped ?
|
|
8741
8747
|
// eslint-disable-next-line no-await-in-loop
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
const
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8748
|
-
const scopedEntries = await fs$1.promises.readdir(entryPath);
|
|
8749
|
-
for (const scopedEntry of scopedEntries) {
|
|
8750
|
-
const packagePath = path.join(entryPath, scopedEntry);
|
|
8751
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8752
|
-
const pkg = await readPackageJson(packagePath);
|
|
8753
|
-
if (pkg) {
|
|
8754
|
-
// Skip if specific packages requested and this isn't one of them
|
|
8755
|
-
if (packages.length > 0 && !packages.includes(pkg.name)) {
|
|
8756
|
-
continue;
|
|
8757
|
-
}
|
|
8758
|
-
const lookupKey = `${pkg.name}@${pkg.version}`;
|
|
8759
|
-
const patchInfo = patchLookup.get(lookupKey);
|
|
8760
|
-
if (patchInfo) {
|
|
8761
|
-
logger.logger.log(`Found match: ${pkg.name}@${pkg.version} at ${packagePath}`);
|
|
8762
|
-
logger.logger.log(` Patch key: ${patchInfo.key}`);
|
|
8763
|
-
logger.logger.log(` Processing files:`);
|
|
8764
|
-
for (const [fileName, fileInfo] of Object.entries(patchInfo.patch.files)) {
|
|
8765
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8766
|
-
await processFilePatch(packagePath, fileName, fileInfo, dryRun, socketDir);
|
|
8767
|
-
}
|
|
8768
|
-
}
|
|
8769
|
-
}
|
|
8770
|
-
}
|
|
8771
|
-
} catch {
|
|
8772
|
-
// Ignore errors reading scoped packages
|
|
8773
|
-
}
|
|
8774
|
-
} else {
|
|
8748
|
+
await fs$2.readDirNames(pkgPath) : [dirName];
|
|
8749
|
+
try {
|
|
8750
|
+
for (const pkgSubName of pkgSubNames) {
|
|
8751
|
+
const dirFullName = isScoped ? `${dirName}/${pkgSubName}` : pkgSubName;
|
|
8752
|
+
const pkgPath = path.join(nmPath, dirFullName);
|
|
8775
8753
|
// eslint-disable-next-line no-await-in-loop
|
|
8776
|
-
const
|
|
8777
|
-
|
|
8778
|
-
|
|
8779
|
-
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
|
|
8785
|
-
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8754
|
+
const pkgJson = await packages.readPackageJson(pkgPath, {
|
|
8755
|
+
throws: false
|
|
8756
|
+
});
|
|
8757
|
+
if (!strings.isNonEmptyString(pkgJson?.name) || !strings.isNonEmptyString(pkgJson?.version)) {
|
|
8758
|
+
continue;
|
|
8759
|
+
}
|
|
8760
|
+
const pkgFullName = pkgJson.name;
|
|
8761
|
+
const purlObj = utils.getPurlObject(`pkg:npm/${pkgFullName}`);
|
|
8762
|
+
// Skip if specific packages requested and this isn't one of them
|
|
8763
|
+
if (purlObjs.findIndex(p => p.type === 'npm' && p.namespace === purlObj.namespace && p.name === purlObj.name) === -1) {
|
|
8764
|
+
continue;
|
|
8765
|
+
}
|
|
8766
|
+
const patchInfo = patchLookup.get(getLookupKey(purlObj));
|
|
8767
|
+
if (!patchInfo) {
|
|
8768
|
+
continue;
|
|
8769
|
+
}
|
|
8770
|
+
logger.logger.log(`Found match: ${pkgFullName}@${pkgJson.version} at ${pkgPath}`);
|
|
8771
|
+
logger.logger.log(`Patch key: ${patchInfo.key}`);
|
|
8772
|
+
logger.logger.group(`Processing files:`);
|
|
8773
|
+
for (const {
|
|
8774
|
+
0: fileName,
|
|
8775
|
+
1: fileInfo
|
|
8776
|
+
} of Object.entries(patchInfo.patch.files)) {
|
|
8777
|
+
// eslint-disable-next-line no-await-in-loop
|
|
8778
|
+
await processFilePatch(pkgPath, fileName, fileInfo, dryRun, socketDir);
|
|
8793
8779
|
}
|
|
8780
|
+
logger.logger.groupEnd();
|
|
8794
8781
|
}
|
|
8782
|
+
} catch (error) {
|
|
8783
|
+
logger.logger.error(`Error processing ${nmPath}:`, error);
|
|
8795
8784
|
}
|
|
8796
|
-
} catch (error) {
|
|
8797
|
-
logger.logger.error(`Error processing ${nodeModulesPath}:`, error);
|
|
8798
8785
|
}
|
|
8799
8786
|
}
|
|
8800
8787
|
}
|
|
8801
|
-
async function computeSHA256(
|
|
8788
|
+
async function computeSHA256(filepath) {
|
|
8802
8789
|
try {
|
|
8803
|
-
const content = await fs$1.promises.readFile(
|
|
8790
|
+
const content = await fs$1.promises.readFile(filepath);
|
|
8804
8791
|
const hash = require$$0$1.createHash('sha256');
|
|
8805
8792
|
hash.update(content);
|
|
8806
8793
|
return hash.digest('hex');
|
|
8807
|
-
} catch {
|
|
8808
|
-
|
|
8809
|
-
}
|
|
8794
|
+
} catch {}
|
|
8795
|
+
return null;
|
|
8810
8796
|
}
|
|
8811
|
-
async function
|
|
8812
|
-
const
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
continue;
|
|
8819
|
-
}
|
|
8820
|
-
const fullPath = path.join(dir, entry);
|
|
8821
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8822
|
-
const stats = await fs$1.promises.stat(fullPath);
|
|
8823
|
-
if (stats.isDirectory()) {
|
|
8824
|
-
if (entry === 'node_modules') {
|
|
8825
|
-
nodeModulesPaths.push(fullPath);
|
|
8826
|
-
} else {
|
|
8827
|
-
// eslint-disable-next-line no-await-in-loop
|
|
8828
|
-
await searchDir(fullPath);
|
|
8829
|
-
}
|
|
8830
|
-
}
|
|
8831
|
-
}
|
|
8832
|
-
} catch (error) {
|
|
8833
|
-
// Ignore permission errors or missing directories
|
|
8834
|
-
}
|
|
8835
|
-
}
|
|
8836
|
-
await searchDir(rootDir);
|
|
8837
|
-
return nodeModulesPaths;
|
|
8838
|
-
}
|
|
8839
|
-
function parsePURL(purlString) {
|
|
8840
|
-
const [ecosystem, rest] = purlString.split(':', 2);
|
|
8841
|
-
const [nameAndNamespace, version] = (rest ?? '').split('@', 2);
|
|
8842
|
-
let namespace;
|
|
8843
|
-
let name;
|
|
8844
|
-
if (ecosystem === 'npm' && nameAndNamespace?.startsWith('@')) {
|
|
8845
|
-
const parts = nameAndNamespace.split('/');
|
|
8846
|
-
namespace = parts[0]?.substring(1);
|
|
8847
|
-
name = parts.slice(1).join('/');
|
|
8848
|
-
} else {
|
|
8849
|
-
name = nameAndNamespace ?? '';
|
|
8797
|
+
async function findNodeModulesPaths(cwd) {
|
|
8798
|
+
const rootNmPath = await utils.findUp(constants.NODE_MODULES, {
|
|
8799
|
+
cwd,
|
|
8800
|
+
onlyDirectories: true
|
|
8801
|
+
});
|
|
8802
|
+
if (!rootNmPath) {
|
|
8803
|
+
return [];
|
|
8850
8804
|
}
|
|
8851
|
-
return {
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
};
|
|
8805
|
+
return await vendor.outExports.glob([`**/${constants.NODE_MODULES}`], {
|
|
8806
|
+
absolute: true,
|
|
8807
|
+
cwd: path.dirname(rootNmPath),
|
|
8808
|
+
onlyDirectories: true
|
|
8809
|
+
});
|
|
8857
8810
|
}
|
|
8858
|
-
|
|
8859
|
-
const
|
|
8860
|
-
|
|
8811
|
+
function getLookupKey(purlObj) {
|
|
8812
|
+
const fullName = purlObj.namespace ? `${purlObj.namespace}/${purlObj.name}` : purlObj.name;
|
|
8813
|
+
return `${fullName}@${purlObj.version}`;
|
|
8814
|
+
}
|
|
8815
|
+
async function processFilePatch(pkgPath, fileName, fileInfo, dryRun, socketDir) {
|
|
8816
|
+
const filepath = path.join(pkgPath, fileName);
|
|
8817
|
+
if (!fs$1.existsSync(filepath)) {
|
|
8861
8818
|
logger.logger.log(`File not found: ${fileName}`);
|
|
8862
8819
|
return;
|
|
8863
8820
|
}
|
|
8864
|
-
const currentHash = await computeSHA256(
|
|
8821
|
+
const currentHash = await computeSHA256(filepath);
|
|
8865
8822
|
if (!currentHash) {
|
|
8866
8823
|
logger.logger.log(`Failed to compute hash for: ${fileName}`);
|
|
8867
8824
|
return;
|
|
@@ -8870,20 +8827,20 @@ async function processFilePatch(packagePath, fileName, fileInfo, dryRun, socketD
|
|
|
8870
8827
|
logger.logger.success(`File matches expected hash: ${fileName}`);
|
|
8871
8828
|
logger.logger.log(`Current hash: ${currentHash}`);
|
|
8872
8829
|
logger.logger.log(`Ready to patch to: ${fileInfo.afterHash}`);
|
|
8873
|
-
if (
|
|
8830
|
+
if (dryRun) {
|
|
8831
|
+
logger.logger.log(`(dry run - no changes made)`);
|
|
8832
|
+
} else {
|
|
8874
8833
|
const blobPath = path.join(socketDir, 'blobs', fileInfo.afterHash);
|
|
8875
8834
|
if (!fs$1.existsSync(blobPath)) {
|
|
8876
8835
|
logger.logger.fail(`Error: Patch file not found at ${blobPath}`);
|
|
8877
8836
|
return;
|
|
8878
8837
|
}
|
|
8879
8838
|
try {
|
|
8880
|
-
await fs$1.promises.copyFile(blobPath,
|
|
8839
|
+
await fs$1.promises.copyFile(blobPath, filepath);
|
|
8881
8840
|
logger.logger.success(`Patch applied successfully`);
|
|
8882
8841
|
} catch (error) {
|
|
8883
|
-
logger.logger.
|
|
8842
|
+
logger.logger.error('Error applying patch:', error);
|
|
8884
8843
|
}
|
|
8885
|
-
} else {
|
|
8886
|
-
logger.logger.log(`(dry run - no changes made)`);
|
|
8887
8844
|
}
|
|
8888
8845
|
} else if (currentHash === fileInfo.afterHash) {
|
|
8889
8846
|
logger.logger.success(`File already patched: ${fileName}`);
|
|
@@ -8895,65 +8852,60 @@ async function processFilePatch(packagePath, fileName, fileInfo, dryRun, socketD
|
|
|
8895
8852
|
logger.logger.log(`Target: ${fileInfo.afterHash}`);
|
|
8896
8853
|
}
|
|
8897
8854
|
}
|
|
8898
|
-
async function readPackageJson(packagePath) {
|
|
8899
|
-
const pkgJsonPath = path.join(packagePath, 'package.json');
|
|
8900
|
-
const pkg = await fs$2.readJson(pkgJsonPath, {
|
|
8901
|
-
throws: false
|
|
8902
|
-
});
|
|
8903
|
-
if (pkg) {
|
|
8904
|
-
return {
|
|
8905
|
-
name: pkg.name || '',
|
|
8906
|
-
version: pkg.version || ''
|
|
8907
|
-
};
|
|
8908
|
-
}
|
|
8909
|
-
return null;
|
|
8910
|
-
}
|
|
8911
8855
|
async function handlePatch({
|
|
8912
8856
|
cwd,
|
|
8913
8857
|
dryRun,
|
|
8914
8858
|
outputKind,
|
|
8915
|
-
|
|
8859
|
+
purlObjs,
|
|
8916
8860
|
spinner
|
|
8917
8861
|
}) {
|
|
8918
8862
|
try {
|
|
8919
8863
|
const dotSocketDirPath = path.join(cwd, '.socket');
|
|
8920
8864
|
const manifestPath = path.join(dotSocketDirPath, 'manifest.json');
|
|
8921
|
-
|
|
8922
|
-
// Read the manifest file.
|
|
8923
8865
|
const manifestContent = await fs$1.promises.readFile(manifestPath, 'utf-8');
|
|
8924
8866
|
const manifestData = JSON.parse(manifestContent);
|
|
8925
|
-
|
|
8926
|
-
// Validate the schema.
|
|
8867
|
+
const purls = purlObjs.map(String);
|
|
8927
8868
|
const validated = PatchManifestSchema.parse(manifestData);
|
|
8928
8869
|
|
|
8929
8870
|
// Parse PURLs and group by ecosystem.
|
|
8930
|
-
const patchesByEcosystem =
|
|
8931
|
-
for (const
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8871
|
+
const patchesByEcosystem = new Map();
|
|
8872
|
+
for (const {
|
|
8873
|
+
0: key,
|
|
8874
|
+
1: patch
|
|
8875
|
+
} of Object.entries(validated.patches)) {
|
|
8876
|
+
const purlObj = utils.getPurlObject(key, {
|
|
8877
|
+
throws: false
|
|
8878
|
+
});
|
|
8879
|
+
if (!purlObj) {
|
|
8880
|
+
continue;
|
|
8935
8881
|
}
|
|
8936
|
-
patchesByEcosystem
|
|
8882
|
+
let patches = patchesByEcosystem.get(purlObj.type);
|
|
8883
|
+
if (!Array.isArray(patches)) {
|
|
8884
|
+
patches = [];
|
|
8885
|
+
patchesByEcosystem.set(purlObj.type, patches);
|
|
8886
|
+
}
|
|
8887
|
+
patches.push({
|
|
8937
8888
|
key,
|
|
8938
|
-
|
|
8939
|
-
|
|
8889
|
+
patch,
|
|
8890
|
+
purlObj
|
|
8940
8891
|
});
|
|
8941
8892
|
}
|
|
8942
8893
|
spinner.stop();
|
|
8943
8894
|
logger.logger.log('');
|
|
8944
|
-
if (
|
|
8945
|
-
logger.logger.info(`Checking patches for: ${
|
|
8895
|
+
if (purlObjs.length) {
|
|
8896
|
+
logger.logger.info(`Checking patches for: ${arrays.joinAnd(purls)}`);
|
|
8946
8897
|
} else {
|
|
8947
8898
|
logger.logger.info('Scanning all dependencies for available patches');
|
|
8948
8899
|
}
|
|
8949
8900
|
logger.logger.log('');
|
|
8950
|
-
|
|
8951
|
-
|
|
8901
|
+
const npmPatches = patchesByEcosystem.get(constants.NPM);
|
|
8902
|
+
if (npmPatches) {
|
|
8903
|
+
await applyNPMPatches(npmPatches, purlObjs, dotSocketDirPath, dryRun);
|
|
8952
8904
|
}
|
|
8953
8905
|
const result = {
|
|
8954
8906
|
ok: true,
|
|
8955
8907
|
data: {
|
|
8956
|
-
|
|
8908
|
+
patched: purls.length ? purls : ['patched successfully']
|
|
8957
8909
|
}
|
|
8958
8910
|
};
|
|
8959
8911
|
await outputPatchResult(result, outputKind);
|
|
@@ -8996,10 +8948,10 @@ async function run$k(argv, importMeta, {
|
|
|
8996
8948
|
flags: {
|
|
8997
8949
|
...flags.commonFlags,
|
|
8998
8950
|
...flags.outputFlags,
|
|
8999
|
-
|
|
8951
|
+
purl: {
|
|
9000
8952
|
type: 'string',
|
|
9001
8953
|
default: [],
|
|
9002
|
-
description: 'Specify
|
|
8954
|
+
description: 'Specify purls to patch, as either a comma separated value or as multiple flags',
|
|
9003
8955
|
isMultiple: true,
|
|
9004
8956
|
shortFlag: 'p'
|
|
9005
8957
|
}
|
|
@@ -9053,13 +9005,15 @@ async function run$k(argv, importMeta, {
|
|
|
9053
9005
|
}
|
|
9054
9006
|
const {
|
|
9055
9007
|
spinner
|
|
9056
|
-
} = constants;
|
|
9057
|
-
const
|
|
9008
|
+
} = constants.default;
|
|
9009
|
+
const purlObjs = arrays.arrayUnique(utils.cmdFlagValueToArray(cli.flags['purl'])).map(p => utils.getPurlObject(p, {
|
|
9010
|
+
throws: false
|
|
9011
|
+
})).filter(Boolean);
|
|
9058
9012
|
await handlePatch({
|
|
9059
9013
|
cwd,
|
|
9060
9014
|
dryRun,
|
|
9061
9015
|
outputKind,
|
|
9062
|
-
|
|
9016
|
+
purlObjs,
|
|
9063
9017
|
spinner
|
|
9064
9018
|
});
|
|
9065
9019
|
}
|
|
@@ -9067,7 +9021,7 @@ async function run$k(argv, importMeta, {
|
|
|
9067
9021
|
async function runRawNpm(argv) {
|
|
9068
9022
|
process.exitCode = 1;
|
|
9069
9023
|
const spawnPromise = spawn.spawn(utils.getNpmBinPath(), argv, {
|
|
9070
|
-
shell: constants.WIN32,
|
|
9024
|
+
shell: constants.default.WIN32,
|
|
9071
9025
|
stdio: 'inherit'
|
|
9072
9026
|
});
|
|
9073
9027
|
|
|
@@ -9121,7 +9075,7 @@ async function run$j(argv, importMeta, {
|
|
|
9121
9075
|
});
|
|
9122
9076
|
const dryRun = !!cli.flags['dryRun'];
|
|
9123
9077
|
if (dryRun) {
|
|
9124
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9078
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9125
9079
|
return;
|
|
9126
9080
|
}
|
|
9127
9081
|
await runRawNpm(argv);
|
|
@@ -9130,7 +9084,7 @@ async function run$j(argv, importMeta, {
|
|
|
9130
9084
|
async function runRawNpx(argv) {
|
|
9131
9085
|
process.exitCode = 1;
|
|
9132
9086
|
const spawnPromise = spawn.spawn(utils.getNpxBinPath(), argv, {
|
|
9133
|
-
shell: constants.WIN32,
|
|
9087
|
+
shell: constants.default.WIN32,
|
|
9134
9088
|
stdio: 'inherit'
|
|
9135
9089
|
});
|
|
9136
9090
|
|
|
@@ -9184,7 +9138,7 @@ async function run$i(argv, importMeta, {
|
|
|
9184
9138
|
});
|
|
9185
9139
|
const dryRun = !!cli.flags['dryRun'];
|
|
9186
9140
|
if (dryRun) {
|
|
9187
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9141
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9188
9142
|
return;
|
|
9189
9143
|
}
|
|
9190
9144
|
await runRawNpx(argv);
|
|
@@ -9365,7 +9319,7 @@ async function run$h(argv, importMeta, {
|
|
|
9365
9319
|
return;
|
|
9366
9320
|
}
|
|
9367
9321
|
if (dryRun) {
|
|
9368
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9322
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9369
9323
|
return;
|
|
9370
9324
|
}
|
|
9371
9325
|
await handleCreateRepo({
|
|
@@ -9499,7 +9453,7 @@ async function run$g(argv, importMeta, {
|
|
|
9499
9453
|
return;
|
|
9500
9454
|
}
|
|
9501
9455
|
if (dryRun) {
|
|
9502
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9456
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9503
9457
|
return;
|
|
9504
9458
|
}
|
|
9505
9459
|
await handleDeleteRepo(orgSlug, repoName, outputKind);
|
|
@@ -9790,7 +9744,7 @@ async function run$f(argv, importMeta, {
|
|
|
9790
9744
|
return;
|
|
9791
9745
|
}
|
|
9792
9746
|
if (dryRun) {
|
|
9793
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9747
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9794
9748
|
return;
|
|
9795
9749
|
}
|
|
9796
9750
|
await handleListRepos({
|
|
@@ -9982,7 +9936,7 @@ async function run$e(argv, importMeta, {
|
|
|
9982
9936
|
return;
|
|
9983
9937
|
}
|
|
9984
9938
|
if (dryRun) {
|
|
9985
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
9939
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
9986
9940
|
return;
|
|
9987
9941
|
}
|
|
9988
9942
|
await handleUpdateRepo({
|
|
@@ -10147,7 +10101,7 @@ async function run$d(argv, importMeta, {
|
|
|
10147
10101
|
return;
|
|
10148
10102
|
}
|
|
10149
10103
|
if (dryRun) {
|
|
10150
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10104
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10151
10105
|
return;
|
|
10152
10106
|
}
|
|
10153
10107
|
await handleViewRepo(orgSlug, String(repoName), outputKind);
|
|
@@ -10300,6 +10254,11 @@ const generalFlags$1 = {
|
|
|
10300
10254
|
type: 'boolean',
|
|
10301
10255
|
description: 'Wait for the scan creation to complete, then basically run `socket scan report` on it'
|
|
10302
10256
|
},
|
|
10257
|
+
reportLevel: {
|
|
10258
|
+
type: 'string',
|
|
10259
|
+
default: constants.default.REPORT_LEVEL_ERROR,
|
|
10260
|
+
description: `Which policy level alerts should be reported (default '${constants.default.REPORT_LEVEL_ERROR}')`
|
|
10261
|
+
},
|
|
10303
10262
|
setAsAlertsPage: {
|
|
10304
10263
|
type: 'boolean',
|
|
10305
10264
|
default: true,
|
|
@@ -10402,17 +10361,14 @@ async function run$c(argv, importMeta, {
|
|
|
10402
10361
|
reachDisableAnalytics,
|
|
10403
10362
|
reachSkipCache,
|
|
10404
10363
|
readOnly,
|
|
10364
|
+
reportLevel,
|
|
10405
10365
|
setAsAlertsPage: pendingHeadFlag,
|
|
10406
10366
|
tmp
|
|
10407
10367
|
} = cli.flags;
|
|
10408
|
-
const dryRun = !!cli.flags['dryRun'];
|
|
10409
|
-
|
|
10410
|
-
// Process comma-separated values for isMultiple flags.
|
|
10411
|
-
const reachEcosystemsRaw = utils.cmdFlagValueToArray(cli.flags['reachEcosystems']);
|
|
10412
|
-
const reachExcludePaths = utils.cmdFlagValueToArray(cli.flags['reachExcludePaths']);
|
|
10413
10368
|
|
|
10414
10369
|
// Validate ecosystem values.
|
|
10415
10370
|
const reachEcosystems = [];
|
|
10371
|
+
const reachEcosystemsRaw = utils.cmdFlagValueToArray(cli.flags['reachEcosystems']);
|
|
10416
10372
|
const validEcosystems = utils.getEcosystemChoicesForMeow();
|
|
10417
10373
|
for (const ecosystem of reachEcosystemsRaw) {
|
|
10418
10374
|
if (!validEcosystems.includes(ecosystem)) {
|
|
@@ -10420,6 +10376,7 @@ async function run$c(argv, importMeta, {
|
|
|
10420
10376
|
}
|
|
10421
10377
|
reachEcosystems.push(ecosystem);
|
|
10422
10378
|
}
|
|
10379
|
+
const dryRun = !!cli.flags['dryRun'];
|
|
10423
10380
|
let {
|
|
10424
10381
|
autoManifest,
|
|
10425
10382
|
branch: branchName,
|
|
@@ -10519,6 +10476,7 @@ async function run$c(argv, importMeta, {
|
|
|
10519
10476
|
logger.logger.info('You can also run `socket scan setup` to persist these flag defaults to a socket.json file.');
|
|
10520
10477
|
logger.logger.error('');
|
|
10521
10478
|
}
|
|
10479
|
+
const reachExcludePaths = utils.cmdFlagValueToArray(cli.flags['reachExcludePaths']);
|
|
10522
10480
|
|
|
10523
10481
|
// Validation helpers for better readability.
|
|
10524
10482
|
const hasReachEcosystems = reachEcosystems.length > 0;
|
|
@@ -10566,7 +10524,7 @@ async function run$c(argv, importMeta, {
|
|
|
10566
10524
|
return;
|
|
10567
10525
|
}
|
|
10568
10526
|
if (dryRun) {
|
|
10569
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10527
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10570
10528
|
return;
|
|
10571
10529
|
}
|
|
10572
10530
|
await handleCreateNewScan({
|
|
@@ -10594,6 +10552,7 @@ async function run$c(argv, importMeta, {
|
|
|
10594
10552
|
readOnly: Boolean(readOnly),
|
|
10595
10553
|
repoName,
|
|
10596
10554
|
report,
|
|
10555
|
+
reportLevel,
|
|
10597
10556
|
targets,
|
|
10598
10557
|
tmp: Boolean(tmp)
|
|
10599
10558
|
});
|
|
@@ -10715,7 +10674,7 @@ async function run$b(argv, importMeta, {
|
|
|
10715
10674
|
return;
|
|
10716
10675
|
}
|
|
10717
10676
|
if (dryRun) {
|
|
10718
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10677
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
10719
10678
|
return;
|
|
10720
10679
|
}
|
|
10721
10680
|
await handleDeleteScan(orgSlug, scanId, outputKind);
|
|
@@ -10797,7 +10756,7 @@ async function handleJson(data, file, dashboardMessage) {
|
|
|
10797
10756
|
}
|
|
10798
10757
|
}
|
|
10799
10758
|
async function handleMarkdown(data) {
|
|
10800
|
-
const SOCKET_SBOM_URL_PREFIX = `${constants.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10759
|
+
const SOCKET_SBOM_URL_PREFIX = `${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10801
10760
|
logger.logger.log('# Scan diff result');
|
|
10802
10761
|
logger.logger.log('');
|
|
10803
10762
|
logger.logger.log('This Socket.dev report shows the changes between two scans:');
|
|
@@ -10975,7 +10934,7 @@ async function run$a(argv, importMeta, {
|
|
|
10975
10934
|
importMeta,
|
|
10976
10935
|
parentName
|
|
10977
10936
|
});
|
|
10978
|
-
const SOCKET_SBOM_URL_PREFIX = `${constants.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10937
|
+
const SOCKET_SBOM_URL_PREFIX = `${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/SocketDev/sbom/`;
|
|
10979
10938
|
const SOCKET_SBOM_URL_PREFIX_LENGTH = SOCKET_SBOM_URL_PREFIX.length;
|
|
10980
10939
|
const {
|
|
10981
10940
|
depth,
|
|
@@ -11021,7 +10980,7 @@ async function run$a(argv, importMeta, {
|
|
|
11021
10980
|
return;
|
|
11022
10981
|
}
|
|
11023
10982
|
if (dryRun) {
|
|
11024
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
10983
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
11025
10984
|
return;
|
|
11026
10985
|
}
|
|
11027
10986
|
await handleDiffScan({
|
|
@@ -11230,6 +11189,7 @@ async function scanOneRepo(repoSlug, {
|
|
|
11230
11189
|
readOnly: false,
|
|
11231
11190
|
repoName: repoSlug,
|
|
11232
11191
|
report: false,
|
|
11192
|
+
reportLevel: constants.default.REPORT_LEVEL_ERROR,
|
|
11233
11193
|
targets: ['.'],
|
|
11234
11194
|
tmp: false
|
|
11235
11195
|
});
|
|
@@ -11693,6 +11653,7 @@ async function handleCreateGithubScan({
|
|
|
11693
11653
|
}
|
|
11694
11654
|
|
|
11695
11655
|
const CMD_NAME$6 = 'github';
|
|
11656
|
+
const DEFAULT_GITHUB_URL = 'https://api.github.com';
|
|
11696
11657
|
const description$8 = 'Create a scan for given GitHub repo';
|
|
11697
11658
|
const hidden$6 = true;
|
|
11698
11659
|
const cmdScanGithub = {
|
|
@@ -11720,7 +11681,7 @@ async function run$9(argv, importMeta, {
|
|
|
11720
11681
|
},
|
|
11721
11682
|
githubApiUrl: {
|
|
11722
11683
|
type: 'string',
|
|
11723
|
-
description:
|
|
11684
|
+
description: `Base URL of the GitHub API (default: ${DEFAULT_GITHUB_URL})`
|
|
11724
11685
|
},
|
|
11725
11686
|
interactive: {
|
|
11726
11687
|
type: 'boolean',
|
|
@@ -11774,7 +11735,7 @@ async function run$9(argv, importMeta, {
|
|
|
11774
11735
|
parentName
|
|
11775
11736
|
});
|
|
11776
11737
|
const {
|
|
11777
|
-
githubToken = constants.ENV.SOCKET_CLI_GITHUB_TOKEN,
|
|
11738
|
+
githubToken = constants.default.ENV.SOCKET_CLI_GITHUB_TOKEN,
|
|
11778
11739
|
interactive = true,
|
|
11779
11740
|
json,
|
|
11780
11741
|
markdown,
|
|
@@ -11804,7 +11765,7 @@ async function run$9(argv, importMeta, {
|
|
|
11804
11765
|
if (sockJson.defaults?.scan?.github?.githubApiUrl !== undefined) {
|
|
11805
11766
|
githubApiUrl = sockJson.defaults.scan.github.githubApiUrl;
|
|
11806
11767
|
} else {
|
|
11807
|
-
githubApiUrl =
|
|
11768
|
+
githubApiUrl = DEFAULT_GITHUB_URL;
|
|
11808
11769
|
}
|
|
11809
11770
|
}
|
|
11810
11771
|
if (!orgGithub) {
|
|
@@ -11872,7 +11833,7 @@ async function run$9(argv, importMeta, {
|
|
|
11872
11833
|
|
|
11873
11834
|
// Note exiting earlier to skirt a hidden auth requirement
|
|
11874
11835
|
if (dryRun) {
|
|
11875
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
11836
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
11876
11837
|
return;
|
|
11877
11838
|
}
|
|
11878
11839
|
await handleCreateGithubScan({
|
|
@@ -12137,7 +12098,7 @@ async function run$8(argv, importMeta, {
|
|
|
12137
12098
|
return;
|
|
12138
12099
|
}
|
|
12139
12100
|
if (dryRun) {
|
|
12140
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12101
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12141
12102
|
return;
|
|
12142
12103
|
}
|
|
12143
12104
|
await handleListScans({
|
|
@@ -12288,7 +12249,7 @@ async function run$7(argv, importMeta, {
|
|
|
12288
12249
|
return;
|
|
12289
12250
|
}
|
|
12290
12251
|
if (dryRun) {
|
|
12291
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12252
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12292
12253
|
return;
|
|
12293
12254
|
}
|
|
12294
12255
|
await handleOrgScanMetadata(orgSlug, scanId, outputKind);
|
|
@@ -12311,7 +12272,7 @@ async function outputScanReach(result, {
|
|
|
12311
12272
|
}
|
|
12312
12273
|
logger.logger.log('');
|
|
12313
12274
|
logger.logger.success('Reachability analysis completed successfully!');
|
|
12314
|
-
logger.logger.info(`Reachability report has been written to: ${path.join(cwd, constants.DOT_SOCKET_DOT_FACTS_JSON)}`);
|
|
12275
|
+
logger.logger.info(`Reachability report has been written to: ${path.join(cwd, constants.default.DOT_SOCKET_DOT_FACTS_JSON)}`);
|
|
12315
12276
|
}
|
|
12316
12277
|
|
|
12317
12278
|
async function handleScanReach({
|
|
@@ -12324,7 +12285,7 @@ async function handleScanReach({
|
|
|
12324
12285
|
}) {
|
|
12325
12286
|
const {
|
|
12326
12287
|
spinner
|
|
12327
|
-
} = constants;
|
|
12288
|
+
} = constants.default;
|
|
12328
12289
|
|
|
12329
12290
|
// Get supported file names
|
|
12330
12291
|
const supportedFilesCResult = await fetchSupportedScanFileNames({
|
|
@@ -12491,7 +12452,7 @@ async function run$6(argv, importMeta, {
|
|
|
12491
12452
|
return;
|
|
12492
12453
|
}
|
|
12493
12454
|
if (dryRun) {
|
|
12494
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12455
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12495
12456
|
return;
|
|
12496
12457
|
}
|
|
12497
12458
|
await handleScanReach({
|
|
@@ -12531,8 +12492,8 @@ async function run$5(argv, importMeta, {
|
|
|
12531
12492
|
...flags.outputFlags,
|
|
12532
12493
|
fold: {
|
|
12533
12494
|
type: 'string',
|
|
12534
|
-
default:
|
|
12535
|
-
description:
|
|
12495
|
+
default: constants.default.FOLD_SETTING_NONE,
|
|
12496
|
+
description: `Fold reported alerts to some degree (default '${constants.default.FOLD_SETTING_NONE}')`
|
|
12536
12497
|
},
|
|
12537
12498
|
interactive: {
|
|
12538
12499
|
type: 'boolean',
|
|
@@ -12545,8 +12506,8 @@ async function run$5(argv, importMeta, {
|
|
|
12545
12506
|
},
|
|
12546
12507
|
reportLevel: {
|
|
12547
12508
|
type: 'string',
|
|
12548
|
-
default:
|
|
12549
|
-
description:
|
|
12509
|
+
default: constants.default.REPORT_LEVEL_WARN,
|
|
12510
|
+
description: `Which policy level alerts should be reported (default '${constants.default.REPORT_LEVEL_WARN}')`
|
|
12550
12511
|
},
|
|
12551
12512
|
short: {
|
|
12552
12513
|
type: 'boolean',
|
|
@@ -12583,7 +12544,7 @@ async function run$5(argv, importMeta, {
|
|
|
12583
12544
|
|
|
12584
12545
|
You can --fold these up to given level: 'pkg', 'version', 'file', and 'none'.
|
|
12585
12546
|
For example: \`socket scan report --fold=version\` will dedupe alerts to only
|
|
12586
|
-
show one alert of a particular kind, no matter how often it was
|
|
12547
|
+
show one alert of a particular kind, no matter how often it was found in a
|
|
12587
12548
|
file or in how many files it was found. At most one per version that has it.
|
|
12588
12549
|
|
|
12589
12550
|
By default only the warn and error policy level alerts are reported. You can
|
|
@@ -12606,16 +12567,17 @@ async function run$5(argv, importMeta, {
|
|
|
12606
12567
|
parentName
|
|
12607
12568
|
});
|
|
12608
12569
|
const {
|
|
12609
|
-
fold = 'none',
|
|
12610
12570
|
json,
|
|
12611
|
-
license,
|
|
12612
12571
|
markdown,
|
|
12613
|
-
org: orgFlag
|
|
12614
|
-
reportLevel = 'warn'
|
|
12572
|
+
org: orgFlag
|
|
12615
12573
|
} = cli.flags;
|
|
12616
12574
|
const dryRun = !!cli.flags['dryRun'];
|
|
12575
|
+
const fold = cli.flags['fold'];
|
|
12617
12576
|
const interactive = !!cli.flags['interactive'];
|
|
12618
|
-
const
|
|
12577
|
+
const includeLicensePolicy = !!cli.flags['license'];
|
|
12578
|
+
const reportLevel = cli.flags['reportLevel'];
|
|
12579
|
+
const short = !!cli.flags['short'];
|
|
12580
|
+
const [scanId = '', filepath = ''] = cli.input;
|
|
12619
12581
|
const hasApiToken = utils.hasDefaultApiToken();
|
|
12620
12582
|
const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), interactive, dryRun);
|
|
12621
12583
|
const outputKind = utils.getOutputKind(json, markdown);
|
|
@@ -12643,18 +12605,18 @@ async function run$5(argv, importMeta, {
|
|
|
12643
12605
|
return;
|
|
12644
12606
|
}
|
|
12645
12607
|
if (dryRun) {
|
|
12646
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12608
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
12647
12609
|
return;
|
|
12648
12610
|
}
|
|
12649
12611
|
await handleScanReport({
|
|
12650
12612
|
orgSlug,
|
|
12651
12613
|
scanId,
|
|
12652
|
-
includeLicensePolicy
|
|
12614
|
+
includeLicensePolicy,
|
|
12653
12615
|
outputKind,
|
|
12654
|
-
|
|
12655
|
-
fold
|
|
12656
|
-
short
|
|
12657
|
-
reportLevel
|
|
12616
|
+
filepath,
|
|
12617
|
+
fold,
|
|
12618
|
+
short,
|
|
12619
|
+
reportLevel
|
|
12658
12620
|
});
|
|
12659
12621
|
}
|
|
12660
12622
|
|
|
@@ -12899,14 +12861,14 @@ async function configureGithub(config) {
|
|
|
12899
12861
|
}
|
|
12900
12862
|
const defaultGithubApiUrl = await prompts.input({
|
|
12901
12863
|
message: '(--github-api-url) Do you want to override the default github url?',
|
|
12902
|
-
default: config.githubApiUrl || constants.ENV.GITHUB_API_URL,
|
|
12864
|
+
default: config.githubApiUrl || constants.default.ENV.GITHUB_API_URL,
|
|
12903
12865
|
required: false
|
|
12904
12866
|
// validate: async string => bool
|
|
12905
12867
|
});
|
|
12906
12868
|
if (defaultGithubApiUrl === undefined) {
|
|
12907
12869
|
return canceledByUser();
|
|
12908
12870
|
}
|
|
12909
|
-
if (defaultGithubApiUrl && defaultGithubApiUrl !== constants.ENV.GITHUB_API_URL) {
|
|
12871
|
+
if (defaultGithubApiUrl && defaultGithubApiUrl !== constants.default.ENV.GITHUB_API_URL) {
|
|
12910
12872
|
config.githubApiUrl = defaultGithubApiUrl;
|
|
12911
12873
|
} else {
|
|
12912
12874
|
delete config.githubApiUrl;
|
|
@@ -13003,7 +12965,7 @@ async function run$4(argv, importMeta, {
|
|
|
13003
12965
|
});
|
|
13004
12966
|
const dryRun = !!cli.flags['dryRun'];
|
|
13005
12967
|
if (dryRun) {
|
|
13006
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
12968
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13007
12969
|
return;
|
|
13008
12970
|
}
|
|
13009
12971
|
const {
|
|
@@ -13106,7 +13068,7 @@ Scan ID: ${scanId}
|
|
|
13106
13068
|
|
|
13107
13069
|
${md}
|
|
13108
13070
|
|
|
13109
|
-
View this report at: ${constants.SOCKET_WEBSITE_URL}/dashboard/org/${orgSlug}/sbom/${scanId}
|
|
13071
|
+
View this report at: ${constants.default.SOCKET_WEBSITE_URL}/dashboard/org/${orgSlug}/sbom/${scanId}
|
|
13110
13072
|
`.trim() + '\n';
|
|
13111
13073
|
if (filePath && filePath !== '-') {
|
|
13112
13074
|
try {
|
|
@@ -13245,7 +13207,7 @@ async function run$3(argv, importMeta, {
|
|
|
13245
13207
|
return;
|
|
13246
13208
|
}
|
|
13247
13209
|
if (dryRun) {
|
|
13248
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13210
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13249
13211
|
return;
|
|
13250
13212
|
}
|
|
13251
13213
|
if (json && stream) {
|
|
@@ -13332,7 +13294,7 @@ async function outputThreatFeed(result, outputKind) {
|
|
|
13332
13294
|
// Note: this temporarily takes over the terminal (just like `man` does).
|
|
13333
13295
|
const ScreenWidget = /*@__PURE__*/require$1('../external/blessed/lib/widgets/screen.js');
|
|
13334
13296
|
const screen = new ScreenWidget({
|
|
13335
|
-
...constants.blessedOptions
|
|
13297
|
+
...constants.default.blessedOptions
|
|
13336
13298
|
});
|
|
13337
13299
|
// Register these keys first so you can always exit, even when it gets stuck
|
|
13338
13300
|
// If we don't do this and the code crashes, the user must hard-kill the
|
|
@@ -13471,7 +13433,7 @@ async function handleThreatFeed({
|
|
|
13471
13433
|
}
|
|
13472
13434
|
|
|
13473
13435
|
const CMD_NAME = 'threat-feed';
|
|
13474
|
-
const ECOSYSTEMS = new Set(['gem', 'golang', 'maven',
|
|
13436
|
+
const ECOSYSTEMS = new Set(['gem', 'golang', 'maven', constants.NPM, 'nuget', 'pypi']);
|
|
13475
13437
|
const TYPE_FILTERS = new Set(['anom', 'c', 'fp', 'joke', 'mal', 'secret', 'spy', 'tp', 'typo', 'u', 'vuln']);
|
|
13476
13438
|
const description$1 = '[Beta] View the threat-feed';
|
|
13477
13439
|
const hidden = false;
|
|
@@ -13671,7 +13633,7 @@ async function run$2(argv, importMeta, {
|
|
|
13671
13633
|
return;
|
|
13672
13634
|
}
|
|
13673
13635
|
if (dryRun) {
|
|
13674
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13636
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13675
13637
|
return;
|
|
13676
13638
|
}
|
|
13677
13639
|
await handleThreatFeed({
|
|
@@ -13724,7 +13686,7 @@ async function teardownTabCompletion(targetName) {
|
|
|
13724
13686
|
} = result.data;
|
|
13725
13687
|
|
|
13726
13688
|
// Remove from ~/.bashrc if found
|
|
13727
|
-
const bashrc = constants.homePath ? path.join(constants.homePath, '.bashrc') : '';
|
|
13689
|
+
const bashrc = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
|
|
13728
13690
|
if (bashrc && fs$1.existsSync(bashrc)) {
|
|
13729
13691
|
const content = fs$1.readFileSync(bashrc, 'utf8');
|
|
13730
13692
|
if (content.includes(toAddToBashrc)) {
|
|
@@ -13818,7 +13780,7 @@ async function run$1(argv, importMeta, {
|
|
|
13818
13780
|
});
|
|
13819
13781
|
const dryRun = !!cli.flags['dryRun'];
|
|
13820
13782
|
if (dryRun) {
|
|
13821
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
13783
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
13822
13784
|
return;
|
|
13823
13785
|
}
|
|
13824
13786
|
const targetName = cli.input[0] || 'socket';
|
|
@@ -13879,7 +13841,7 @@ async function postinstallWrapper() {
|
|
|
13879
13841
|
const {
|
|
13880
13842
|
bashRcPath,
|
|
13881
13843
|
zshRcPath
|
|
13882
|
-
} = constants;
|
|
13844
|
+
} = constants.default;
|
|
13883
13845
|
const socketWrapperEnabled = fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
|
|
13884
13846
|
if (!socketWrapperEnabled) {
|
|
13885
13847
|
await setupShadowNpm(`
|
|
@@ -13935,7 +13897,7 @@ async function setupShadowNpm(query) {
|
|
|
13935
13897
|
const {
|
|
13936
13898
|
bashRcPath,
|
|
13937
13899
|
zshRcPath
|
|
13938
|
-
} = constants;
|
|
13900
|
+
} = constants.default;
|
|
13939
13901
|
try {
|
|
13940
13902
|
if (fs$1.existsSync(bashRcPath)) {
|
|
13941
13903
|
addSocketWrapper(bashRcPath);
|
|
@@ -14049,13 +14011,13 @@ async function run(argv, importMeta, {
|
|
|
14049
14011
|
return;
|
|
14050
14012
|
}
|
|
14051
14013
|
if (dryRun) {
|
|
14052
|
-
logger.logger.log(constants.DRY_RUN_BAILING_NOW);
|
|
14014
|
+
logger.logger.log(constants.default.DRY_RUN_BAILING_NOW);
|
|
14053
14015
|
return;
|
|
14054
14016
|
}
|
|
14055
14017
|
const {
|
|
14056
14018
|
bashRcPath,
|
|
14057
14019
|
zshRcPath
|
|
14058
|
-
} = constants;
|
|
14020
|
+
} = constants.default;
|
|
14059
14021
|
if (enable) {
|
|
14060
14022
|
if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
|
|
14061
14023
|
addSocketWrapper(bashRcPath);
|
|
@@ -14191,16 +14153,16 @@ void (async () => {
|
|
|
14191
14153
|
authInfo: vendor.registryAuthTokenExports(registryUrl, {
|
|
14192
14154
|
recursive: true
|
|
14193
14155
|
}),
|
|
14194
|
-
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14156
|
+
name: constants.default.SOCKET_CLI_BIN_NAME,
|
|
14195
14157
|
registryUrl,
|
|
14196
14158
|
ttl: 86_400_000 /* 24 hours in milliseconds */,
|
|
14197
|
-
version: constants.ENV.INLINED_SOCKET_CLI_VERSION
|
|
14159
|
+
version: constants.default.ENV.INLINED_SOCKET_CLI_VERSION
|
|
14198
14160
|
});
|
|
14199
14161
|
try {
|
|
14200
14162
|
await utils.meowWithSubcommands(rootCommands, {
|
|
14201
14163
|
aliases: rootAliases,
|
|
14202
14164
|
argv: process.argv.slice(2),
|
|
14203
|
-
name: constants.SOCKET_CLI_BIN_NAME,
|
|
14165
|
+
name: constants.default.SOCKET_CLI_BIN_NAME,
|
|
14204
14166
|
importMeta: {
|
|
14205
14167
|
url: `${require$$0.pathToFileURL(__filename$1)}`
|
|
14206
14168
|
}
|
|
@@ -14262,5 +14224,5 @@ void (async () => {
|
|
|
14262
14224
|
await utils.captureException(e);
|
|
14263
14225
|
}
|
|
14264
14226
|
})();
|
|
14265
|
-
//# debugId=
|
|
14227
|
+
//# debugId=b4ee2d73-3b07-422f-bbc3-db4f36cb62dc
|
|
14266
14228
|
//# sourceMappingURL=cli.js.map
|