@socketsecurity/cli-with-sentry 1.0.96 → 1.0.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +850 -493
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +3 -3
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-bin.js +3 -3
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-npm-inject.js +29 -49
- package/dist/shadow-npm-inject.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts +6 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/commands/fix/shared.d.mts +2 -1
- package/dist/types/commands/fix/shared.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts +11 -0
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -0
- package/dist/types/commands/patch/handle-patch.d.mts +10 -0
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -0
- package/dist/types/commands/patch/output-patch-result.d.mts +5 -0
- package/dist/types/commands/patch/output-patch-result.d.mts.map +1 -0
- package/dist/types/commands.d.mts +7 -0
- package/dist/types/commands.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist/lib/arborist/index.d.mts.map +1 -1
- package/dist/types/shadow/npm/arborist-helpers.d.mts +5 -5
- package/dist/types/shadow/npm/arborist-helpers.d.mts.map +1 -1
- package/dist/types/utils/alert/severity.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts +4 -3
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts +5 -4
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/filter-config.d.mts +5 -0
- package/dist/types/utils/filter-config.d.mts.map +1 -0
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/sdk.d.mts +3 -3
- package/dist/types/utils/sdk.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts +7 -5
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/utils.js +246 -244
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +5124 -5114
- package/external/@coana-tech/cli/cli-wrapper.mjs +1 -0
- package/external/@coana-tech/cli/cli.mjs +302 -184
- package/external/@coana-tech/cli/reachability-analyzers-cli.mjs +134 -63
- package/external/@coana-tech/cli/repos/coana-tech/alucard/alucard.jar +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/class-graph-analysis/dist/bundle/class-graph-analysis-cli.mjs +2337 -2821
- package/external/@coana-tech/cli/repos/coana-tech/cocoa/release/Coana.Cocoa.dll +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-amd64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-darwin-arm64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-amd64.gz +0 -0
- package/external/@coana-tech/cli/repos/coana-tech/goana/bin/goana-linux-arm64.gz +0 -0
- package/external/@socketsecurity/registry/lib/objects.js +16 -0
- package/package.json +8 -8
- package/dist/types/commands/scan/suggest-repo-slug.d.mts +0 -9
- package/dist/types/commands/scan/suggest-repo-slug.d.mts.map +0 -1
- package/dist/types/utils/strings.d.mts +0 -2
- package/dist/types/utils/strings.d.mts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
var vendor = require('./vendor.js');
|
|
4
4
|
var logger = require('../external/@socketsecurity/registry/lib/logger');
|
|
5
5
|
var strings = require('../external/@socketsecurity/registry/lib/strings');
|
|
6
|
-
var require$$
|
|
7
|
-
var require$$
|
|
6
|
+
var require$$8 = require('../external/@socketsecurity/registry/lib/debug');
|
|
7
|
+
var require$$9 = require('../external/@socketsecurity/registry/lib/objects');
|
|
8
8
|
var arrays = require('../external/@socketsecurity/registry/lib/arrays');
|
|
9
9
|
var path$1 = require('../external/@socketsecurity/registry/lib/path');
|
|
10
10
|
var sorts = require('../external/@socketsecurity/registry/lib/sorts');
|
|
@@ -94,14 +94,17 @@ function findSocketYmlSync(dir = process.cwd()) {
|
|
|
94
94
|
path: ymlPath,
|
|
95
95
|
parsed: vendor.configExports.parseSocketConfig(yml)
|
|
96
96
|
};
|
|
97
|
-
} catch {
|
|
97
|
+
} catch (e) {
|
|
98
|
+
require$$8.debugDir('inspect', {
|
|
99
|
+
error: e
|
|
100
|
+
});
|
|
98
101
|
throw new Error(`Found file but was unable to parse ${ymlPath}`);
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
prevDir = dir;
|
|
102
105
|
dir = path.join(dir, '..');
|
|
103
106
|
}
|
|
104
|
-
return
|
|
107
|
+
return undefined;
|
|
105
108
|
}
|
|
106
109
|
function getConfigValue(key) {
|
|
107
110
|
const localConfig = getConfigValues();
|
|
@@ -148,7 +151,7 @@ let _cachedConfig;
|
|
|
148
151
|
// When using --config or SOCKET_CLI_CONFIG, do not persist the config.
|
|
149
152
|
let _readOnlyConfig = false;
|
|
150
153
|
function overrideCachedConfig(jsonConfig) {
|
|
151
|
-
require$$
|
|
154
|
+
require$$8.debugFn('notice', 'override: full config (not stored)');
|
|
152
155
|
let config;
|
|
153
156
|
try {
|
|
154
157
|
config = JSON.parse(String(jsonConfig));
|
|
@@ -190,7 +193,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
190
193
|
};
|
|
191
194
|
}
|
|
192
195
|
function overrideConfigApiToken(apiToken) {
|
|
193
|
-
require$$
|
|
196
|
+
require$$8.debugFn('notice', 'override: Socket API token (not stored)');
|
|
194
197
|
// Set token to the local cached config and mark it read-only so it doesn't persist.
|
|
195
198
|
_cachedConfig = {
|
|
196
199
|
...vendor.configExports,
|
|
@@ -282,39 +285,39 @@ function isUrl(value) {
|
|
|
282
285
|
|
|
283
286
|
// This Socket API token should be stored globally for the duration of the CLI execution.
|
|
284
287
|
let _defaultToken;
|
|
285
|
-
function
|
|
288
|
+
function getDefaultApiToken() {
|
|
286
289
|
// Lazily access constants.ENV.SOCKET_CLI_NO_API_TOKEN.
|
|
287
290
|
if (constants.ENV.SOCKET_CLI_NO_API_TOKEN) {
|
|
288
291
|
_defaultToken = undefined;
|
|
289
|
-
|
|
290
|
-
const key =
|
|
291
|
-
// Lazily access constants.ENV.SOCKET_CLI_API_TOKEN.
|
|
292
|
-
constants.ENV.SOCKET_CLI_API_TOKEN || getConfigValueOrUndef('apiToken') || _defaultToken;
|
|
293
|
-
_defaultToken = strings.isNonEmptyString(key) ? key : undefined;
|
|
292
|
+
return _defaultToken;
|
|
294
293
|
}
|
|
294
|
+
const key =
|
|
295
|
+
// Lazily access constants.ENV.SOCKET_CLI_API_TOKEN.
|
|
296
|
+
constants.ENV.SOCKET_CLI_API_TOKEN || getConfigValueOrUndef('apiToken') || _defaultToken;
|
|
297
|
+
_defaultToken = strings.isNonEmptyString(key) ? key : undefined;
|
|
295
298
|
return _defaultToken;
|
|
296
299
|
}
|
|
297
|
-
function
|
|
298
|
-
|
|
299
|
-
return apiToken ? apiToken.slice(TOKEN_PREFIX_LENGTH, TOKEN_PREFIX_LENGTH + TOKEN_VISIBLE_LENGTH) : '';
|
|
300
|
-
}
|
|
301
|
-
function hasDefaultToken() {
|
|
302
|
-
return !!getDefaultToken();
|
|
303
|
-
}
|
|
304
|
-
function getPublicToken() {
|
|
305
|
-
return getDefaultToken() ||
|
|
300
|
+
function getPublicApiToken() {
|
|
301
|
+
return getDefaultApiToken() ||
|
|
306
302
|
// Lazily access constants.ENV.SOCKET_CLI_API_TOKEN.
|
|
307
303
|
constants.ENV.SOCKET_CLI_API_TOKEN ||
|
|
308
304
|
// Lazily access constants.SOCKET_PUBLIC_API_TOKEN.
|
|
309
305
|
constants.SOCKET_PUBLIC_API_TOKEN;
|
|
310
306
|
}
|
|
307
|
+
function getVisibleTokenPrefix() {
|
|
308
|
+
const apiToken = getDefaultApiToken();
|
|
309
|
+
return apiToken ? apiToken.slice(TOKEN_PREFIX_LENGTH, TOKEN_PREFIX_LENGTH + TOKEN_VISIBLE_LENGTH) : '';
|
|
310
|
+
}
|
|
311
|
+
function hasDefaultApiToken() {
|
|
312
|
+
return !!getDefaultApiToken();
|
|
313
|
+
}
|
|
311
314
|
async function setupSdk(options) {
|
|
312
315
|
const opts = {
|
|
313
316
|
__proto__: null,
|
|
314
317
|
...options
|
|
315
318
|
};
|
|
316
319
|
let {
|
|
317
|
-
apiToken =
|
|
320
|
+
apiToken = getDefaultApiToken()
|
|
318
321
|
} = opts;
|
|
319
322
|
if (typeof apiToken !== 'string' && vendor.isInteractiveExports()) {
|
|
320
323
|
apiToken = await prompts.password({
|
|
@@ -423,11 +426,11 @@ async function handleApiCall(value, options) {
|
|
|
423
426
|
};
|
|
424
427
|
if (desc) {
|
|
425
428
|
logger.logger.fail(`An error was thrown while requesting ${desc}`);
|
|
426
|
-
require$$
|
|
429
|
+
require$$8.debugFn('error', `caught: ${desc} error`);
|
|
427
430
|
} else {
|
|
428
|
-
require$$
|
|
431
|
+
require$$8.debugFn('error', `caught: Socket API request error`);
|
|
429
432
|
}
|
|
430
|
-
require$$
|
|
433
|
+
require$$8.debugDir('inspect', {
|
|
431
434
|
error: e,
|
|
432
435
|
socketSdkErrorResult
|
|
433
436
|
});
|
|
@@ -449,8 +452,8 @@ async function handleApiCall(value, options) {
|
|
|
449
452
|
code: sdkResult.status
|
|
450
453
|
}
|
|
451
454
|
};
|
|
452
|
-
require$$
|
|
453
|
-
require$$
|
|
455
|
+
require$$8.debugFn('error', `fail:${desc ? ` ${desc}` : ''} bad response`);
|
|
456
|
+
require$$8.debugDir('inspect', {
|
|
454
457
|
sdkResult
|
|
455
458
|
});
|
|
456
459
|
return socketSdkErrorResult;
|
|
@@ -468,8 +471,8 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
468
471
|
} catch (e) {
|
|
469
472
|
const message = `${e || NO_ERROR_MESSAGE}`;
|
|
470
473
|
const reason = `${e || NO_ERROR_MESSAGE}`;
|
|
471
|
-
require$$
|
|
472
|
-
require$$
|
|
474
|
+
require$$8.debugFn('error', `caught: ${description} error`);
|
|
475
|
+
require$$8.debugDir('inspect', {
|
|
473
476
|
error: e
|
|
474
477
|
});
|
|
475
478
|
return {
|
|
@@ -483,8 +486,8 @@ async function handleApiCallNoSpinner(value, description) {
|
|
|
483
486
|
if (result.success === false) {
|
|
484
487
|
const error = result;
|
|
485
488
|
const message = `${error.error || NO_ERROR_MESSAGE}`;
|
|
486
|
-
require$$
|
|
487
|
-
require$$
|
|
489
|
+
require$$8.debugFn('error', `fail: ${description} bad response`);
|
|
490
|
+
require$$8.debugDir('inspect', {
|
|
488
491
|
error
|
|
489
492
|
});
|
|
490
493
|
return {
|
|
@@ -516,7 +519,7 @@ async function queryApi(path, apiToken) {
|
|
|
516
519
|
});
|
|
517
520
|
}
|
|
518
521
|
async function queryApiSafeText(path, fetchSpinnerDesc) {
|
|
519
|
-
const apiToken =
|
|
522
|
+
const apiToken = getDefaultApiToken();
|
|
520
523
|
if (!apiToken) {
|
|
521
524
|
return {
|
|
522
525
|
ok: false,
|
|
@@ -543,8 +546,8 @@ async function queryApiSafeText(path, fetchSpinnerDesc) {
|
|
|
543
546
|
spinner.failAndStop(`An error was thrown while requesting ${fetchSpinnerDesc}.`);
|
|
544
547
|
}
|
|
545
548
|
const cause = e?.message;
|
|
546
|
-
require$$
|
|
547
|
-
require$$
|
|
549
|
+
require$$8.debugFn('error', 'caught: await queryApi() error');
|
|
550
|
+
require$$8.debugDir('inspect', {
|
|
548
551
|
error: e
|
|
549
552
|
});
|
|
550
553
|
return {
|
|
@@ -570,8 +573,8 @@ async function queryApiSafeText(path, fetchSpinnerDesc) {
|
|
|
570
573
|
data
|
|
571
574
|
};
|
|
572
575
|
} catch (e) {
|
|
573
|
-
require$$
|
|
574
|
-
require$$
|
|
576
|
+
require$$8.debugFn('error', 'caught: await result.text() error');
|
|
577
|
+
require$$8.debugDir('inspect', {
|
|
575
578
|
error: e
|
|
576
579
|
});
|
|
577
580
|
return {
|
|
@@ -600,7 +603,7 @@ async function queryApiSafeJson(path, fetchSpinnerDesc = '') {
|
|
|
600
603
|
}
|
|
601
604
|
}
|
|
602
605
|
async function sendApiRequest(path, options) {
|
|
603
|
-
const apiToken =
|
|
606
|
+
const apiToken = getDefaultApiToken();
|
|
604
607
|
if (!apiToken) {
|
|
605
608
|
return {
|
|
606
609
|
ok: false,
|
|
@@ -641,8 +644,8 @@ async function sendApiRequest(path, options) {
|
|
|
641
644
|
spinner.failAndStop(`An error was thrown while requesting ${options.fetchSpinnerDesc}.`);
|
|
642
645
|
}
|
|
643
646
|
const cause = e?.message;
|
|
644
|
-
require$$
|
|
645
|
-
require$$
|
|
647
|
+
require$$8.debugFn('error', `caught: await fetch() ${options.method} error`);
|
|
648
|
+
require$$8.debugDir('inspect', {
|
|
646
649
|
error: e
|
|
647
650
|
});
|
|
648
651
|
return {
|
|
@@ -671,8 +674,8 @@ async function sendApiRequest(path, options) {
|
|
|
671
674
|
data: data
|
|
672
675
|
};
|
|
673
676
|
} catch (e) {
|
|
674
|
-
require$$
|
|
675
|
-
require$$
|
|
677
|
+
require$$8.debugFn('error', 'caught: await result.json() error');
|
|
678
|
+
require$$8.debugDir('inspect', {
|
|
676
679
|
error: e
|
|
677
680
|
});
|
|
678
681
|
return {
|
|
@@ -781,9 +784,9 @@ cols) {
|
|
|
781
784
|
// Serialize the final result object before printing it
|
|
782
785
|
// All commands that support the --json flag should call this before printing
|
|
783
786
|
function serializeResultJson(data) {
|
|
784
|
-
if (!require$$
|
|
787
|
+
if (!require$$9.isObject(data)) {
|
|
785
788
|
process.exitCode = 1;
|
|
786
|
-
require$$
|
|
789
|
+
require$$8.debugFn('inspect', {
|
|
787
790
|
data
|
|
788
791
|
});
|
|
789
792
|
|
|
@@ -801,7 +804,7 @@ function serializeResultJson(data) {
|
|
|
801
804
|
process.exitCode = 1;
|
|
802
805
|
const message = 'There was a problem converting the data set to JSON. Please try again without --json';
|
|
803
806
|
logger.logger.fail(message);
|
|
804
|
-
require$$
|
|
807
|
+
require$$8.debugDir('inspect', {
|
|
805
808
|
error: e
|
|
806
809
|
});
|
|
807
810
|
|
|
@@ -939,7 +942,7 @@ function getHelpListOutput(list, options) {
|
|
|
939
942
|
const names = Object.keys(list).sort(sorts.naturalCompare);
|
|
940
943
|
for (const name of names) {
|
|
941
944
|
const entry = list[name];
|
|
942
|
-
const entryIsObj = require$$
|
|
945
|
+
const entryIsObj = require$$9.isObject(entry);
|
|
943
946
|
if (entryIsObj && 'hidden' in entry && entry?.hidden) {
|
|
944
947
|
continue;
|
|
945
948
|
}
|
|
@@ -1190,14 +1193,16 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1190
1193
|
// "Bucket" some commands for easier usage.
|
|
1191
1194
|
const commands = new Set(['analytics', 'audit-log', 'ci', 'cdxgen', 'config', 'dependencies', 'fix', 'install',
|
|
1192
1195
|
//'json',
|
|
1193
|
-
'license', 'login', 'logout', 'manifest', 'npm', 'npx', 'optimize', 'organization', 'package',
|
|
1196
|
+
'license', 'login', 'logout', 'manifest', 'npm', 'npx', 'optimize', 'organization', 'package',
|
|
1197
|
+
//'patch',
|
|
1198
|
+
'raw-npm', 'raw-npx', 'repository', 'scan',
|
|
1194
1199
|
//'security',
|
|
1195
1200
|
'threat-feed', 'uninstall', 'wrapper']);
|
|
1196
1201
|
Object.entries(subcommands).filter(([_name, subcommand]) => !subcommand.hidden).map(([name]) => name).forEach(name => {
|
|
1197
1202
|
if (commands.has(name)) {
|
|
1198
1203
|
commands.delete(name);
|
|
1199
1204
|
} else {
|
|
1200
|
-
logger.logger.fail('Received
|
|
1205
|
+
logger.logger.fail('Received an unknown command:', name);
|
|
1201
1206
|
}
|
|
1202
1207
|
});
|
|
1203
1208
|
if (commands.size) {
|
|
@@ -1210,10 +1215,10 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1210
1215
|
} else {
|
|
1211
1216
|
lines.push('Commands');
|
|
1212
1217
|
lines.push(` ${getHelpListOutput({
|
|
1213
|
-
...require$$
|
|
1218
|
+
...require$$9.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(({
|
|
1214
1219
|
1: subcommand
|
|
1215
1220
|
}) => !subcommand.hidden))),
|
|
1216
|
-
...require$$
|
|
1221
|
+
...require$$9.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(({
|
|
1217
1222
|
1: alias
|
|
1218
1223
|
}) => {
|
|
1219
1224
|
const {
|
|
@@ -1333,7 +1338,7 @@ function meowOrExit({
|
|
|
1333
1338
|
}
|
|
1334
1339
|
|
|
1335
1340
|
// meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
|
|
1336
|
-
if (!require$$
|
|
1341
|
+
if (!require$$9.hasOwn(config.flags, 'version') && cli.flags['version']) {
|
|
1337
1342
|
// Use `console.error` here instead of `logger.error` to match meow behavior.
|
|
1338
1343
|
console.error('Unknown flag\n--version');
|
|
1339
1344
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -1567,7 +1572,7 @@ async function determineOrgSlug(orgFlag, interactive, dryRun) {
|
|
|
1567
1572
|
async function getDefaultOrgSlug() {
|
|
1568
1573
|
const defaultOrgResult = getConfigValueOrUndef('defaultOrg');
|
|
1569
1574
|
if (defaultOrgResult) {
|
|
1570
|
-
require$$
|
|
1575
|
+
require$$8.debugFn('notice', 'use: org from "defaultOrg" value of socket/settings local app data', defaultOrgResult);
|
|
1571
1576
|
return {
|
|
1572
1577
|
ok: true,
|
|
1573
1578
|
data: defaultOrgResult
|
|
@@ -1577,7 +1582,7 @@ async function getDefaultOrgSlug() {
|
|
|
1577
1582
|
// Lazily access constants.ENV.SOCKET_CLI_ORG_SLUG.
|
|
1578
1583
|
const envOrgSlug = constants.ENV.SOCKET_CLI_ORG_SLUG;
|
|
1579
1584
|
if (envOrgSlug) {
|
|
1580
|
-
require$$
|
|
1585
|
+
require$$8.debugFn('notice', 'use: org from SOCKET_CLI_ORG_SLUG environment variable', envOrgSlug);
|
|
1581
1586
|
return {
|
|
1582
1587
|
ok: true,
|
|
1583
1588
|
data: envOrgSlug
|
|
@@ -1606,7 +1611,7 @@ async function getDefaultOrgSlug() {
|
|
|
1606
1611
|
data: `Cannot determine the default organization for the API token. Unable to continue.`
|
|
1607
1612
|
};
|
|
1608
1613
|
}
|
|
1609
|
-
require$$
|
|
1614
|
+
require$$8.debugFn('notice', 'resolve: org from Socket API', slug);
|
|
1610
1615
|
return {
|
|
1611
1616
|
ok: true,
|
|
1612
1617
|
message: 'Retrieved default org from server',
|
|
@@ -1659,21 +1664,21 @@ async function getBaseBranch(cwd = process.cwd()) {
|
|
|
1659
1664
|
async function getRepoInfo(cwd = process.cwd()) {
|
|
1660
1665
|
let info = null;
|
|
1661
1666
|
const quotedCmd = '`git remote get-url origin`';
|
|
1662
|
-
require$$
|
|
1667
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1663
1668
|
try {
|
|
1664
1669
|
const remoteUrl = (await spawn.spawn('git', ['remote', 'get-url', 'origin'], {
|
|
1665
1670
|
cwd
|
|
1666
1671
|
})).stdout;
|
|
1667
1672
|
info = parseGitRemoteUrl(remoteUrl);
|
|
1668
1673
|
if (!info) {
|
|
1669
|
-
require$$
|
|
1670
|
-
require$$
|
|
1674
|
+
require$$8.debugFn('error', 'git: unmatched git remote URL format');
|
|
1675
|
+
require$$8.debugDir('inspect', {
|
|
1671
1676
|
remoteUrl
|
|
1672
1677
|
});
|
|
1673
1678
|
}
|
|
1674
1679
|
} catch (e) {
|
|
1675
|
-
require$$
|
|
1676
|
-
require$$
|
|
1680
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1681
|
+
require$$8.debugDir('inspect', {
|
|
1677
1682
|
error: e
|
|
1678
1683
|
});
|
|
1679
1684
|
}
|
|
@@ -1689,19 +1694,19 @@ async function gitBranch(cwd = process.cwd()) {
|
|
|
1689
1694
|
cwd
|
|
1690
1695
|
};
|
|
1691
1696
|
let quotedCmd = '`git symbolic-ref --short HEAD`';
|
|
1692
|
-
require$$
|
|
1697
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1693
1698
|
// Try symbolic-ref first which returns the branch name or fails in a
|
|
1694
1699
|
// detached HEAD state.
|
|
1695
1700
|
try {
|
|
1696
1701
|
const gitSymbolicRefResult = await spawn.spawn('git', ['symbolic-ref', '--short', 'HEAD'], stdioPipeOptions);
|
|
1697
|
-
require$$
|
|
1702
|
+
require$$8.debugDir('stdio', {
|
|
1698
1703
|
gitSymbolicRefResult
|
|
1699
1704
|
});
|
|
1700
1705
|
return gitSymbolicRefResult.stdout;
|
|
1701
1706
|
} catch (e) {
|
|
1702
|
-
if (require$$
|
|
1703
|
-
require$$
|
|
1704
|
-
require$$
|
|
1707
|
+
if (require$$8.isDebug('stdio')) {
|
|
1708
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1709
|
+
require$$8.debugDir('inspect', {
|
|
1705
1710
|
error: e
|
|
1706
1711
|
});
|
|
1707
1712
|
}
|
|
@@ -1709,17 +1714,17 @@ async function gitBranch(cwd = process.cwd()) {
|
|
|
1709
1714
|
// Fallback to using rev-parse to get the short commit hash in a
|
|
1710
1715
|
// detached HEAD state.
|
|
1711
1716
|
quotedCmd = '`git rev-parse --short HEAD`';
|
|
1712
|
-
require$$
|
|
1717
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1713
1718
|
try {
|
|
1714
1719
|
const gitRevParseResult = await spawn.spawn('git', ['rev-parse', '--short', 'HEAD'], stdioPipeOptions);
|
|
1715
|
-
require$$
|
|
1720
|
+
require$$8.debugDir('stdio', {
|
|
1716
1721
|
gitRevParseResult
|
|
1717
1722
|
});
|
|
1718
1723
|
return gitRevParseResult.stdout;
|
|
1719
1724
|
} catch (e) {
|
|
1720
|
-
if (require$$
|
|
1721
|
-
require$$
|
|
1722
|
-
require$$
|
|
1725
|
+
if (require$$8.isDebug('stdio')) {
|
|
1726
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1727
|
+
require$$8.debugDir('inspect', {
|
|
1723
1728
|
error: e
|
|
1724
1729
|
});
|
|
1725
1730
|
}
|
|
@@ -1752,16 +1757,16 @@ async function detectDefaultBranch(cwd = process.cwd()) {
|
|
|
1752
1757
|
async function gitCleanFdx(cwd = process.cwd()) {
|
|
1753
1758
|
const stdioIgnoreOptions = {
|
|
1754
1759
|
cwd,
|
|
1755
|
-
stdio: require$$
|
|
1760
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1756
1761
|
};
|
|
1757
1762
|
const quotedCmd = '`git clean -fdx`';
|
|
1758
|
-
require$$
|
|
1763
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1759
1764
|
try {
|
|
1760
1765
|
await spawn.spawn('git', ['clean', '-fdx'], stdioIgnoreOptions);
|
|
1761
1766
|
return true;
|
|
1762
1767
|
} catch (e) {
|
|
1763
|
-
require$$
|
|
1764
|
-
require$$
|
|
1768
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1769
|
+
require$$8.debugDir('inspect', {
|
|
1765
1770
|
error: e
|
|
1766
1771
|
});
|
|
1767
1772
|
}
|
|
@@ -1770,16 +1775,16 @@ async function gitCleanFdx(cwd = process.cwd()) {
|
|
|
1770
1775
|
async function gitCheckoutBranch(branch, cwd = process.cwd()) {
|
|
1771
1776
|
const stdioIgnoreOptions = {
|
|
1772
1777
|
cwd,
|
|
1773
|
-
stdio: require$$
|
|
1778
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1774
1779
|
};
|
|
1775
1780
|
const quotedCmd = `\`git checkout ${branch}\``;
|
|
1776
|
-
require$$
|
|
1781
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1777
1782
|
try {
|
|
1778
1783
|
await spawn.spawn('git', ['checkout', branch], stdioIgnoreOptions);
|
|
1779
1784
|
return true;
|
|
1780
1785
|
} catch (e) {
|
|
1781
|
-
require$$
|
|
1782
|
-
require$$
|
|
1786
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1787
|
+
require$$8.debugDir('inspect', {
|
|
1783
1788
|
error: e
|
|
1784
1789
|
});
|
|
1785
1790
|
}
|
|
@@ -1791,16 +1796,16 @@ async function gitCreateBranch(branch, cwd = process.cwd()) {
|
|
|
1791
1796
|
}
|
|
1792
1797
|
const stdioIgnoreOptions = {
|
|
1793
1798
|
cwd,
|
|
1794
|
-
stdio: require$$
|
|
1799
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1795
1800
|
};
|
|
1796
1801
|
const quotedCmd = `\`git branch ${branch}\``;
|
|
1797
|
-
require$$
|
|
1802
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1798
1803
|
try {
|
|
1799
1804
|
await spawn.spawn('git', ['branch', branch], stdioIgnoreOptions);
|
|
1800
1805
|
return true;
|
|
1801
1806
|
} catch (e) {
|
|
1802
|
-
require$$
|
|
1803
|
-
require$$
|
|
1807
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1808
|
+
require$$8.debugDir('inspect', {
|
|
1804
1809
|
error: e
|
|
1805
1810
|
});
|
|
1806
1811
|
}
|
|
@@ -1809,19 +1814,19 @@ async function gitCreateBranch(branch, cwd = process.cwd()) {
|
|
|
1809
1814
|
async function gitPushBranch(branch, cwd = process.cwd()) {
|
|
1810
1815
|
const stdioIgnoreOptions = {
|
|
1811
1816
|
cwd,
|
|
1812
|
-
stdio: require$$
|
|
1817
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1813
1818
|
};
|
|
1814
1819
|
const quotedCmd = `\`git push --force --set-upstream origin ${branch}\``;
|
|
1815
|
-
require$$
|
|
1820
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1816
1821
|
try {
|
|
1817
1822
|
await spawn.spawn('git', ['push', '--force', '--set-upstream', 'origin', branch], stdioIgnoreOptions);
|
|
1818
1823
|
return true;
|
|
1819
1824
|
} catch (e) {
|
|
1820
|
-
require$$
|
|
1825
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1821
1826
|
if (spawn.isSpawnError(e) && e.code === 128) {
|
|
1822
|
-
require$$
|
|
1827
|
+
require$$8.debugFn('error', "denied: token requires write permissions for 'contents' and 'pull-requests'");
|
|
1823
1828
|
}
|
|
1824
|
-
require$$
|
|
1829
|
+
require$$8.debugDir('inspect', {
|
|
1825
1830
|
error: e
|
|
1826
1831
|
});
|
|
1827
1832
|
}
|
|
@@ -1829,7 +1834,7 @@ async function gitPushBranch(branch, cwd = process.cwd()) {
|
|
|
1829
1834
|
}
|
|
1830
1835
|
async function gitCommit(commitMsg, filepaths, options) {
|
|
1831
1836
|
if (!filepaths.length) {
|
|
1832
|
-
require$$
|
|
1837
|
+
require$$8.debugFn('notice', `miss: no filepaths to add`);
|
|
1833
1838
|
return false;
|
|
1834
1839
|
}
|
|
1835
1840
|
const {
|
|
@@ -1845,26 +1850,26 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
1845
1850
|
await gitEnsureIdentity(user, email, cwd);
|
|
1846
1851
|
const stdioIgnoreOptions = {
|
|
1847
1852
|
cwd,
|
|
1848
|
-
stdio: require$$
|
|
1853
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1849
1854
|
};
|
|
1850
1855
|
const quotedAddCmd = `\`git add ${filepaths.join(' ')}\``;
|
|
1851
|
-
require$$
|
|
1856
|
+
require$$8.debugFn('stdio', `spawn: ${quotedAddCmd}`);
|
|
1852
1857
|
try {
|
|
1853
1858
|
await spawn.spawn('git', ['add', ...filepaths], stdioIgnoreOptions);
|
|
1854
1859
|
} catch (e) {
|
|
1855
|
-
require$$
|
|
1856
|
-
require$$
|
|
1860
|
+
require$$8.debugFn('error', `caught: ${quotedAddCmd} failed`);
|
|
1861
|
+
require$$8.debugDir('inspect', {
|
|
1857
1862
|
error: e
|
|
1858
1863
|
});
|
|
1859
1864
|
}
|
|
1860
1865
|
const quotedCommitCmd = `\`git commit -m ${commitMsg}\``;
|
|
1861
|
-
require$$
|
|
1866
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCommitCmd}`);
|
|
1862
1867
|
try {
|
|
1863
1868
|
await spawn.spawn('git', ['commit', '-m', commitMsg], stdioIgnoreOptions);
|
|
1864
1869
|
return true;
|
|
1865
1870
|
} catch (e) {
|
|
1866
|
-
require$$
|
|
1867
|
-
require$$
|
|
1871
|
+
require$$8.debugFn('error', `caught: ${quotedCommitCmd} failed`);
|
|
1872
|
+
require$$8.debugDir('inspect', {
|
|
1868
1873
|
error: e
|
|
1869
1874
|
});
|
|
1870
1875
|
}
|
|
@@ -1873,18 +1878,18 @@ async function gitCommit(commitMsg, filepaths, options) {
|
|
|
1873
1878
|
async function gitDeleteBranch(branch, cwd = process.cwd()) {
|
|
1874
1879
|
const stdioIgnoreOptions = {
|
|
1875
1880
|
cwd,
|
|
1876
|
-
stdio: require$$
|
|
1881
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1877
1882
|
};
|
|
1878
1883
|
const quotedCmd = `\`git branch -D ${branch}\``;
|
|
1879
|
-
require$$
|
|
1884
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1880
1885
|
try {
|
|
1881
1886
|
// Will throw with exit code 1 if branch does not exist.
|
|
1882
1887
|
await spawn.spawn('git', ['branch', '-D', branch], stdioIgnoreOptions);
|
|
1883
1888
|
return true;
|
|
1884
1889
|
} catch (e) {
|
|
1885
|
-
if (require$$
|
|
1886
|
-
require$$
|
|
1887
|
-
require$$
|
|
1890
|
+
if (require$$8.isDebug('stdio')) {
|
|
1891
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1892
|
+
require$$8.debugDir('inspect', {
|
|
1888
1893
|
error: e
|
|
1889
1894
|
});
|
|
1890
1895
|
}
|
|
@@ -1903,18 +1908,18 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
1903
1908
|
let configValue;
|
|
1904
1909
|
{
|
|
1905
1910
|
const quotedCmd = `\`git config --get ${prop}\``;
|
|
1906
|
-
require$$
|
|
1911
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1907
1912
|
try {
|
|
1908
1913
|
// Will throw with exit code 1 if the config property is not set.
|
|
1909
1914
|
const gitConfigResult = await spawn.spawn('git', ['config', '--get', prop], stdioPipeOptions);
|
|
1910
|
-
require$$
|
|
1915
|
+
require$$8.debugDir('stdio', {
|
|
1911
1916
|
gitConfigResult
|
|
1912
1917
|
});
|
|
1913
1918
|
configValue = gitConfigResult.stdout;
|
|
1914
1919
|
} catch (e) {
|
|
1915
|
-
if (require$$
|
|
1916
|
-
require$$
|
|
1917
|
-
require$$
|
|
1920
|
+
if (require$$8.isDebug('stdio')) {
|
|
1921
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1922
|
+
require$$8.debugDir('inspect', {
|
|
1918
1923
|
error: e
|
|
1919
1924
|
});
|
|
1920
1925
|
}
|
|
@@ -1923,16 +1928,16 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
1923
1928
|
if (configValue !== value) {
|
|
1924
1929
|
const stdioIgnoreOptions = {
|
|
1925
1930
|
cwd,
|
|
1926
|
-
stdio: require$$
|
|
1931
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1927
1932
|
};
|
|
1928
1933
|
const quotedCmd = `\`git config ${prop} ${value}\``;
|
|
1929
|
-
require$$
|
|
1934
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1930
1935
|
try {
|
|
1931
1936
|
await spawn.spawn('git', ['config', prop, value], stdioIgnoreOptions);
|
|
1932
1937
|
} catch (e) {
|
|
1933
|
-
if (require$$
|
|
1934
|
-
require$$
|
|
1935
|
-
require$$
|
|
1938
|
+
if (require$$8.isDebug('stdio')) {
|
|
1939
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1940
|
+
require$$8.debugDir('inspect', {
|
|
1936
1941
|
error: e
|
|
1937
1942
|
});
|
|
1938
1943
|
}
|
|
@@ -1943,18 +1948,18 @@ async function gitEnsureIdentity(name, email, cwd = process.cwd()) {
|
|
|
1943
1948
|
async function gitLocalBranchExists(branch, cwd = process.cwd()) {
|
|
1944
1949
|
const stdioIgnoreOptions = {
|
|
1945
1950
|
cwd,
|
|
1946
|
-
stdio: require$$
|
|
1951
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1947
1952
|
};
|
|
1948
1953
|
const quotedCmd = `\`git show-ref --quiet refs/heads/${branch}\``;
|
|
1949
|
-
require$$
|
|
1954
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1950
1955
|
try {
|
|
1951
1956
|
// Will throw with exit code 1 if the branch does not exist.
|
|
1952
1957
|
await spawn.spawn('git', ['show-ref', '--quiet', `refs/heads/${branch}`], stdioIgnoreOptions);
|
|
1953
1958
|
return true;
|
|
1954
1959
|
} catch (e) {
|
|
1955
|
-
if (require$$
|
|
1956
|
-
require$$
|
|
1957
|
-
require$$
|
|
1960
|
+
if (require$$8.isDebug('stdio')) {
|
|
1961
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1962
|
+
require$$8.debugDir('inspect', {
|
|
1958
1963
|
error: e
|
|
1959
1964
|
});
|
|
1960
1965
|
}
|
|
@@ -1966,17 +1971,17 @@ async function gitRemoteBranchExists(branch, cwd = process.cwd()) {
|
|
|
1966
1971
|
cwd
|
|
1967
1972
|
};
|
|
1968
1973
|
const quotedCmd = `\`git ls-remote --heads origin ${branch}\``;
|
|
1969
|
-
require$$
|
|
1974
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1970
1975
|
try {
|
|
1971
1976
|
const lsRemoteResult = await spawn.spawn('git', ['ls-remote', '--heads', 'origin', branch], stdioPipeOptions);
|
|
1972
|
-
require$$
|
|
1977
|
+
require$$8.debugDir('stdio', {
|
|
1973
1978
|
lsRemoteResult
|
|
1974
1979
|
});
|
|
1975
1980
|
return lsRemoteResult.stdout.length > 0;
|
|
1976
1981
|
} catch (e) {
|
|
1977
|
-
if (require$$
|
|
1978
|
-
require$$
|
|
1979
|
-
require$$
|
|
1982
|
+
if (require$$8.isDebug('stdio')) {
|
|
1983
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
1984
|
+
require$$8.debugDir('inspect', {
|
|
1980
1985
|
error: e
|
|
1981
1986
|
});
|
|
1982
1987
|
}
|
|
@@ -1992,16 +1997,16 @@ async function gitResetAndClean(branch = 'HEAD', cwd = process.cwd()) {
|
|
|
1992
1997
|
async function gitResetHard(branch = 'HEAD', cwd = process.cwd()) {
|
|
1993
1998
|
const stdioIgnoreOptions = {
|
|
1994
1999
|
cwd,
|
|
1995
|
-
stdio: require$$
|
|
2000
|
+
stdio: require$$8.isDebug('stdio') ? 'inherit' : 'ignore'
|
|
1996
2001
|
};
|
|
1997
2002
|
const quotedCmd = `\`git reset --hard ${branch}\``;
|
|
1998
|
-
require$$
|
|
2003
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
1999
2004
|
try {
|
|
2000
2005
|
await spawn.spawn('git', ['reset', '--hard', branch], stdioIgnoreOptions);
|
|
2001
2006
|
return true;
|
|
2002
2007
|
} catch (e) {
|
|
2003
|
-
require$$
|
|
2004
|
-
require$$
|
|
2008
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
2009
|
+
require$$8.debugDir('inspect', {
|
|
2005
2010
|
error: e
|
|
2006
2011
|
});
|
|
2007
2012
|
}
|
|
@@ -2012,10 +2017,10 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
2012
2017
|
cwd
|
|
2013
2018
|
};
|
|
2014
2019
|
const quotedCmd = `\`git diff --name-only\``;
|
|
2015
|
-
require$$
|
|
2020
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
2016
2021
|
try {
|
|
2017
2022
|
const gitDiffResult = await spawn.spawn('git', ['diff', '--name-only'], stdioPipeOptions);
|
|
2018
|
-
require$$
|
|
2023
|
+
require$$8.debugDir('stdio', {
|
|
2019
2024
|
gitDiffResult
|
|
2020
2025
|
});
|
|
2021
2026
|
const changedFilesDetails = gitDiffResult.stdout;
|
|
@@ -2025,8 +2030,8 @@ async function gitUnstagedModifiedFiles(cwd = process.cwd()) {
|
|
|
2025
2030
|
data: relPaths.map(p => path$1.normalizePath(p))
|
|
2026
2031
|
};
|
|
2027
2032
|
} catch (e) {
|
|
2028
|
-
require$$
|
|
2029
|
-
require$$
|
|
2033
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
2034
|
+
require$$8.debugDir('inspect', {
|
|
2030
2035
|
error: e
|
|
2031
2036
|
});
|
|
2032
2037
|
return {
|
|
@@ -2112,10 +2117,10 @@ function mapToObject(map) {
|
|
|
2112
2117
|
function* walkNestedMap(map, keys = []) {
|
|
2113
2118
|
for (const [key, value] of map.entries()) {
|
|
2114
2119
|
if (value instanceof Map) {
|
|
2115
|
-
yield* walkNestedMap(value, keys
|
|
2120
|
+
yield* walkNestedMap(value, [...keys, key]);
|
|
2116
2121
|
} else {
|
|
2117
2122
|
yield {
|
|
2118
|
-
keys: keys
|
|
2123
|
+
keys: [...keys, key],
|
|
2119
2124
|
value: value
|
|
2120
2125
|
};
|
|
2121
2126
|
}
|
|
@@ -2140,7 +2145,7 @@ async function spawnCoana(args, orgSlug, options, extra) {
|
|
|
2140
2145
|
// Lazily access constants.ENV.INLINED_SOCKET_CLI_VERSION.
|
|
2141
2146
|
SOCKET_CLI_VERSION: constants.ENV.INLINED_SOCKET_CLI_VERSION
|
|
2142
2147
|
};
|
|
2143
|
-
const defaultApiToken =
|
|
2148
|
+
const defaultApiToken = getDefaultApiToken();
|
|
2144
2149
|
if (defaultApiToken) {
|
|
2145
2150
|
mixinsEnv['SOCKET_CLI_API_TOKEN'] = defaultApiToken;
|
|
2146
2151
|
}
|
|
@@ -2512,7 +2517,7 @@ function getDefaultSocketJson() {
|
|
|
2512
2517
|
function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
2513
2518
|
const sockJsonPath = path.join(cwd, 'socket.json');
|
|
2514
2519
|
if (!fs$1.existsSync(sockJsonPath)) {
|
|
2515
|
-
require$$
|
|
2520
|
+
require$$8.debugFn('notice', `miss: socket.json not found at ${cwd}`);
|
|
2516
2521
|
return {
|
|
2517
2522
|
ok: true,
|
|
2518
2523
|
data: getDefaultSocketJson()
|
|
@@ -2524,7 +2529,7 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2524
2529
|
} catch (e) {
|
|
2525
2530
|
if (defaultOnError) {
|
|
2526
2531
|
logger.logger.warn('Failed to read socket.json, using default');
|
|
2527
|
-
require$$
|
|
2532
|
+
require$$8.debugDir('inspect', {
|
|
2528
2533
|
error: e
|
|
2529
2534
|
});
|
|
2530
2535
|
return {
|
|
@@ -2533,7 +2538,7 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2533
2538
|
};
|
|
2534
2539
|
}
|
|
2535
2540
|
const msg = e?.message;
|
|
2536
|
-
require$$
|
|
2541
|
+
require$$8.debugDir('inspect', {
|
|
2537
2542
|
error: e
|
|
2538
2543
|
});
|
|
2539
2544
|
return {
|
|
@@ -2546,8 +2551,8 @@ function readSocketJsonSync(cwd, defaultOnError = false) {
|
|
|
2546
2551
|
try {
|
|
2547
2552
|
obj = JSON.parse(json);
|
|
2548
2553
|
} catch (e) {
|
|
2549
|
-
require$$
|
|
2550
|
-
require$$
|
|
2554
|
+
require$$8.debugFn('error', 'caught: JSON.parse error');
|
|
2555
|
+
require$$8.debugDir('inspect', {
|
|
2551
2556
|
error: e,
|
|
2552
2557
|
json
|
|
2553
2558
|
});
|
|
@@ -2584,8 +2589,8 @@ async function writeSocketJson(cwd, sockJson) {
|
|
|
2584
2589
|
try {
|
|
2585
2590
|
json = JSON.stringify(sockJson, null, 2);
|
|
2586
2591
|
} catch (e) {
|
|
2587
|
-
require$$
|
|
2588
|
-
require$$
|
|
2592
|
+
require$$8.debugFn('error', 'caught: JSON.stringify error');
|
|
2593
|
+
require$$8.debugDir('inspect', {
|
|
2589
2594
|
error: e,
|
|
2590
2595
|
sockJson
|
|
2591
2596
|
});
|
|
@@ -2603,6 +2608,41 @@ async function writeSocketJson(cwd, sockJson) {
|
|
|
2603
2608
|
};
|
|
2604
2609
|
}
|
|
2605
2610
|
|
|
2611
|
+
const helpFlags = new Set(['--help', '-h']);
|
|
2612
|
+
function cmdFlagsToString(args) {
|
|
2613
|
+
const result = [];
|
|
2614
|
+
for (let i = 0, {
|
|
2615
|
+
length
|
|
2616
|
+
} = args; i < length; i += 1) {
|
|
2617
|
+
if (args[i].startsWith('--')) {
|
|
2618
|
+
// Check if the next item exists and is NOT another flag.
|
|
2619
|
+
if (i + 1 < length && !args[i + 1].startsWith('--')) {
|
|
2620
|
+
result.push(`${args[i]}=${args[i + 1]}`);
|
|
2621
|
+
i += 1;
|
|
2622
|
+
} else {
|
|
2623
|
+
result.push(args[i]);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
return result.join(' ');
|
|
2628
|
+
}
|
|
2629
|
+
function cmdFlagValueToArray(flagValue) {
|
|
2630
|
+
if (typeof flagValue === 'string') {
|
|
2631
|
+
return flagValue.trim().split(/, */);
|
|
2632
|
+
}
|
|
2633
|
+
if (Array.isArray(flagValue)) {
|
|
2634
|
+
return flagValue.flatMap(v => v.split(/, */));
|
|
2635
|
+
}
|
|
2636
|
+
return [];
|
|
2637
|
+
}
|
|
2638
|
+
function cmdPrefixMessage(cmdName, text) {
|
|
2639
|
+
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
2640
|
+
return `${cmdPrefix}${text}`;
|
|
2641
|
+
}
|
|
2642
|
+
function isHelpFlag(cmdArg) {
|
|
2643
|
+
return helpFlags.has(cmdArg);
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2606
2646
|
const {
|
|
2607
2647
|
NODE_MODULES,
|
|
2608
2648
|
NPM: NPM$3,
|
|
@@ -2759,6 +2799,20 @@ class ColorOrMarkdown {
|
|
|
2759
2799
|
}
|
|
2760
2800
|
}
|
|
2761
2801
|
|
|
2802
|
+
function toFilterConfig(obj) {
|
|
2803
|
+
const normalized = {
|
|
2804
|
+
__proto__: null
|
|
2805
|
+
};
|
|
2806
|
+
const keys = require$$9.isObject(obj) ? Object.keys(obj) : [];
|
|
2807
|
+
for (const key of keys) {
|
|
2808
|
+
const value = obj[key];
|
|
2809
|
+
if (typeof value === 'boolean' || Array.isArray(value)) {
|
|
2810
|
+
normalized[key] = value;
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
return normalized;
|
|
2814
|
+
}
|
|
2815
|
+
|
|
2762
2816
|
const RangeStyles = ['caret', 'gt', 'gte', 'lt', 'lte', 'pin', 'preserve', 'tilde'];
|
|
2763
2817
|
function applyRange(refRange, version, style = 'preserve') {
|
|
2764
2818
|
switch (style) {
|
|
@@ -2889,33 +2943,28 @@ async function addArtifactToAlertsMap(artifact, alertsByPurl, options) {
|
|
|
2889
2943
|
if (!artifact.name || !artifact.version || !artifact.alerts?.length) {
|
|
2890
2944
|
return alertsByPurl;
|
|
2891
2945
|
}
|
|
2946
|
+
const {
|
|
2947
|
+
type: ecosystem,
|
|
2948
|
+
version
|
|
2949
|
+
} = artifact;
|
|
2892
2950
|
const {
|
|
2893
2951
|
consolidate = false,
|
|
2894
|
-
|
|
2895
|
-
|
|
2952
|
+
overrides,
|
|
2953
|
+
socketYml
|
|
2896
2954
|
} = {
|
|
2897
2955
|
__proto__: null,
|
|
2898
2956
|
...options
|
|
2899
2957
|
};
|
|
2900
|
-
const
|
|
2901
|
-
const
|
|
2902
|
-
const include = {
|
|
2903
|
-
__proto__: null,
|
|
2958
|
+
const name = packages.resolvePackageName(artifact);
|
|
2959
|
+
const filterConfig = toFilterConfig({
|
|
2904
2960
|
blocked: true,
|
|
2905
2961
|
critical: true,
|
|
2906
2962
|
cve: true,
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
..._include
|
|
2910
|
-
};
|
|
2911
|
-
const name = packages.resolvePackageName(artifact);
|
|
2912
|
-
const {
|
|
2913
|
-
type: ecosystem,
|
|
2914
|
-
version
|
|
2915
|
-
} = artifact;
|
|
2963
|
+
...require$$9.getOwn(options, 'filter')
|
|
2964
|
+
});
|
|
2916
2965
|
const enabledState = {
|
|
2917
2966
|
__proto__: null,
|
|
2918
|
-
...
|
|
2967
|
+
...socketYml?.issueRules
|
|
2919
2968
|
};
|
|
2920
2969
|
let sockPkgAlerts = [];
|
|
2921
2970
|
for (const alert of artifact.alerts) {
|
|
@@ -2931,8 +2980,8 @@ async function addArtifactToAlertsMap(artifact, alertsByPurl, options) {
|
|
|
2931
2980
|
const fixableCve = fixType === ALERT_FIX_TYPE.cve;
|
|
2932
2981
|
const fixableUpgrade = fixType === ALERT_FIX_TYPE.upgrade;
|
|
2933
2982
|
const fixable = fixableCve || fixableUpgrade;
|
|
2934
|
-
const upgradable = fixableUpgrade && !require$$
|
|
2935
|
-
if (
|
|
2983
|
+
const upgradable = fixableUpgrade && !require$$9.hasOwn(overrides, name);
|
|
2984
|
+
if (filterConfig.blocked && blocked || filterConfig.critical && critical || filterConfig.cve && cve || filterConfig.fixable && fixable || filterConfig.upgradable && upgradable) {
|
|
2936
2985
|
sockPkgAlerts.push({
|
|
2937
2986
|
name,
|
|
2938
2987
|
version,
|
|
@@ -3024,16 +3073,7 @@ function getAlertsSeverityOrder(alerts) {
|
|
|
3024
3073
|
return alertsHaveBlocked(alerts) || alertsHaveSeverity(alerts, ALERT_SEVERITY.critical) ? 0 : alertsHaveSeverity(alerts, ALERT_SEVERITY.high) ? 1 : alertsHaveSeverity(alerts, ALERT_SEVERITY.middle) ? 2 : alertsHaveSeverity(alerts, ALERT_SEVERITY.low) ? 3 : 4;
|
|
3025
3074
|
}
|
|
3026
3075
|
function getCveInfoFromAlertsMap(alertsMap, options) {
|
|
3027
|
-
const
|
|
3028
|
-
exclude: exclude_
|
|
3029
|
-
} = {
|
|
3030
|
-
__proto__: null,
|
|
3031
|
-
...options
|
|
3032
|
-
};
|
|
3033
|
-
const exclude = {
|
|
3034
|
-
__proto__: null,
|
|
3035
|
-
...exclude_
|
|
3036
|
-
};
|
|
3076
|
+
const filterConfig = toFilterConfig(require$$9.getOwn(options, 'filter'));
|
|
3037
3077
|
let infoByPartialPurl = null;
|
|
3038
3078
|
// eslint-disable-next-line no-unused-labels
|
|
3039
3079
|
for (const {
|
|
@@ -3045,7 +3085,7 @@ function getCveInfoFromAlertsMap(alertsMap, options) {
|
|
|
3045
3085
|
const name = packages.resolvePackageName(purlObj);
|
|
3046
3086
|
sockPkgAlertsLoop: for (const sockPkgAlert of sockPkgAlerts) {
|
|
3047
3087
|
const alert = sockPkgAlert.raw;
|
|
3048
|
-
if (alert.fix?.type !== ALERT_FIX_TYPE.cve ||
|
|
3088
|
+
if (alert.fix?.type !== ALERT_FIX_TYPE.cve || filterConfig.upgradable === false && registry.getManifestData(sockPkgAlert.ecosystem, name)) {
|
|
3049
3089
|
continue sockPkgAlertsLoop;
|
|
3050
3090
|
}
|
|
3051
3091
|
if (!infoByPartialPurl) {
|
|
@@ -3080,8 +3120,8 @@ function getCveInfoFromAlertsMap(alertsMap, options) {
|
|
|
3080
3120
|
error = e;
|
|
3081
3121
|
}
|
|
3082
3122
|
}
|
|
3083
|
-
require$$
|
|
3084
|
-
require$$
|
|
3123
|
+
require$$8.debugFn('error', 'fail: invalid SocketPackageAlert');
|
|
3124
|
+
require$$8.debugDir('inspect', {
|
|
3085
3125
|
alert,
|
|
3086
3126
|
error
|
|
3087
3127
|
});
|
|
@@ -3296,7 +3336,7 @@ function parsePnpmLockfile(lockfileContent) {
|
|
|
3296
3336
|
result = vendor.jsYaml.load(strings.stripBom(lockfileContent));
|
|
3297
3337
|
} catch {}
|
|
3298
3338
|
}
|
|
3299
|
-
return require$$
|
|
3339
|
+
return require$$9.isObjectObject(result) ? result : null;
|
|
3300
3340
|
}
|
|
3301
3341
|
function parsePnpmLockfileVersion(version) {
|
|
3302
3342
|
try {
|
|
@@ -3321,28 +3361,8 @@ async function getAlertsMapFromPnpmLockfile(lockfile, options) {
|
|
|
3321
3361
|
});
|
|
3322
3362
|
}
|
|
3323
3363
|
async function getAlertsMapFromPurls(purls, options) {
|
|
3324
|
-
const opts = {
|
|
3325
|
-
__proto__: null,
|
|
3326
|
-
consolidate: false,
|
|
3327
|
-
include: undefined,
|
|
3328
|
-
nothrow: false,
|
|
3329
|
-
...options
|
|
3330
|
-
};
|
|
3331
|
-
opts.include = {
|
|
3332
|
-
__proto__: null,
|
|
3333
|
-
// Leave 'actions' unassigned so it can be given a default value in
|
|
3334
|
-
// subsequent functions where `options` is passed.
|
|
3335
|
-
// actions: undefined,
|
|
3336
|
-
blocked: true,
|
|
3337
|
-
critical: true,
|
|
3338
|
-
cve: true,
|
|
3339
|
-
existing: false,
|
|
3340
|
-
unfixable: true,
|
|
3341
|
-
upgradable: false,
|
|
3342
|
-
...opts.include
|
|
3343
|
-
};
|
|
3344
3364
|
const uniqPurls = arrays.arrayUnique(purls);
|
|
3345
|
-
require$$
|
|
3365
|
+
require$$8.debugDir('silly', {
|
|
3346
3366
|
purls: uniqPurls
|
|
3347
3367
|
});
|
|
3348
3368
|
let {
|
|
@@ -3352,23 +3372,35 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
3352
3372
|
if (!remaining) {
|
|
3353
3373
|
return alertsByPurl;
|
|
3354
3374
|
}
|
|
3375
|
+
const opts = {
|
|
3376
|
+
__proto__: null,
|
|
3377
|
+
consolidate: false,
|
|
3378
|
+
nothrow: false,
|
|
3379
|
+
...options,
|
|
3380
|
+
filter: toFilterConfig(require$$9.getOwn(options, 'filter'))
|
|
3381
|
+
};
|
|
3382
|
+
if (opts.onlyFixable) {
|
|
3383
|
+
opts.filter.fixable = true;
|
|
3384
|
+
}
|
|
3355
3385
|
const {
|
|
3356
3386
|
spinner
|
|
3357
3387
|
} = opts;
|
|
3358
3388
|
const getText = () => `Looking up data for ${remaining} packages`;
|
|
3359
3389
|
spinner?.start(getText());
|
|
3360
3390
|
const sockSdkCResult = await setupSdk({
|
|
3361
|
-
apiToken:
|
|
3391
|
+
apiToken: getPublicApiToken()
|
|
3362
3392
|
});
|
|
3363
3393
|
if (!sockSdkCResult.ok) {
|
|
3364
3394
|
spinner?.stop();
|
|
3365
|
-
throw new Error('Auth error:
|
|
3395
|
+
throw new Error('Auth error: Run `socket login` first');
|
|
3366
3396
|
}
|
|
3367
3397
|
const sockSdk = sockSdkCResult.data;
|
|
3398
|
+
const socketYml = findSocketYmlSync()?.parsed;
|
|
3368
3399
|
const alertsMapOptions = {
|
|
3369
3400
|
overrides: opts.overrides,
|
|
3370
3401
|
consolidate: opts.consolidate,
|
|
3371
|
-
|
|
3402
|
+
filter: opts.filter,
|
|
3403
|
+
socketYml,
|
|
3372
3404
|
spinner
|
|
3373
3405
|
};
|
|
3374
3406
|
for await (const batchResult of sockSdk.batchPackageStream({
|
|
@@ -3379,24 +3411,28 @@ async function getAlertsMapFromPurls(purls, options) {
|
|
|
3379
3411
|
queryParams: {
|
|
3380
3412
|
alerts: 'true',
|
|
3381
3413
|
compact: 'true',
|
|
3382
|
-
...(opts.
|
|
3383
|
-
|
|
3414
|
+
...(opts.onlyFixable ? {
|
|
3415
|
+
fixable: 'true '
|
|
3384
3416
|
} : {}),
|
|
3385
|
-
...(opts.
|
|
3386
|
-
|
|
3387
|
-
})
|
|
3417
|
+
...(Array.isArray(opts.filter.actions) ? {
|
|
3418
|
+
actions: opts.filter.actions.join(',')
|
|
3419
|
+
} : {})
|
|
3388
3420
|
}
|
|
3389
3421
|
})) {
|
|
3390
3422
|
if (batchResult.success) {
|
|
3391
|
-
|
|
3423
|
+
const artifact = batchResult.data;
|
|
3424
|
+
await addArtifactToAlertsMap(artifact, alertsByPurl, alertsMapOptions);
|
|
3392
3425
|
} else if (!opts.nothrow) {
|
|
3426
|
+
spinner?.stop();
|
|
3427
|
+
if (strings.isNonEmptyString(batchResult.error)) {
|
|
3428
|
+
throw new Error(batchResult.error);
|
|
3429
|
+
}
|
|
3393
3430
|
const statusCode = batchResult.status ?? 'unknown';
|
|
3394
|
-
|
|
3395
|
-
throw new Error(`Socket API server error (${statusCode}): ${statusMessage}`);
|
|
3431
|
+
throw new Error(`Socket API server error (${statusCode}): No status message`);
|
|
3396
3432
|
} else {
|
|
3397
3433
|
spinner?.stop();
|
|
3398
3434
|
logger.logger.fail(`Received a ${batchResult.status} response from Socket API which we consider a permanent failure:`, batchResult.error, batchResult.cause ? `( ${batchResult.cause} )` : '');
|
|
3399
|
-
require$$
|
|
3435
|
+
require$$8.debugDir('inspect', {
|
|
3400
3436
|
batchResult
|
|
3401
3437
|
});
|
|
3402
3438
|
break;
|
|
@@ -3455,41 +3491,6 @@ async function findUp(name, {
|
|
|
3455
3491
|
return undefined;
|
|
3456
3492
|
}
|
|
3457
3493
|
|
|
3458
|
-
const helpFlags = new Set(['--help', '-h']);
|
|
3459
|
-
function cmdFlagsToString(args) {
|
|
3460
|
-
const result = [];
|
|
3461
|
-
for (let i = 0, {
|
|
3462
|
-
length
|
|
3463
|
-
} = args; i < length; i += 1) {
|
|
3464
|
-
if (args[i].startsWith('--')) {
|
|
3465
|
-
// Check if the next item exists and is NOT another flag.
|
|
3466
|
-
if (i + 1 < length && !args[i + 1].startsWith('--')) {
|
|
3467
|
-
result.push(`${args[i]}=${args[i + 1]}`);
|
|
3468
|
-
i += 1;
|
|
3469
|
-
} else {
|
|
3470
|
-
result.push(args[i]);
|
|
3471
|
-
}
|
|
3472
|
-
}
|
|
3473
|
-
}
|
|
3474
|
-
return result.join(' ');
|
|
3475
|
-
}
|
|
3476
|
-
function cmdFlagValueToArray(flagValue) {
|
|
3477
|
-
if (typeof flagValue === 'string') {
|
|
3478
|
-
return flagValue.trim().split(/, */);
|
|
3479
|
-
}
|
|
3480
|
-
if (Array.isArray(flagValue)) {
|
|
3481
|
-
return flagValue.flatMap(v => v.split(/, */));
|
|
3482
|
-
}
|
|
3483
|
-
return [];
|
|
3484
|
-
}
|
|
3485
|
-
function cmdPrefixMessage(cmdName, text) {
|
|
3486
|
-
const cmdPrefix = cmdName ? `${cmdName}: ` : '';
|
|
3487
|
-
return `${cmdPrefix}${text}`;
|
|
3488
|
-
}
|
|
3489
|
-
function isHelpFlag(cmdArg) {
|
|
3490
|
-
return helpFlags.has(cmdArg);
|
|
3491
|
-
}
|
|
3492
|
-
|
|
3493
3494
|
const {
|
|
3494
3495
|
NPM: NPM$2,
|
|
3495
3496
|
SOCKET_CLI_SAFE_BIN,
|
|
@@ -3508,7 +3509,7 @@ function safeNpmInstall(options) {
|
|
|
3508
3509
|
...options
|
|
3509
3510
|
};
|
|
3510
3511
|
let stdio = spawnOptions.stdio;
|
|
3511
|
-
const useIpc = require$$
|
|
3512
|
+
const useIpc = require$$9.isObject(ipc);
|
|
3512
3513
|
// Include 'ipc' in the spawnOptions.stdio when an options.ipc object is provided.
|
|
3513
3514
|
// See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
|
|
3514
3515
|
// and https://github.com/nodejs/node/blob/v23.6.0/lib/internal/child_process.js#L238.
|
|
@@ -3517,7 +3518,7 @@ function safeNpmInstall(options) {
|
|
|
3517
3518
|
} else if (useIpc && Array.isArray(stdio) && !stdio.includes('ipc')) {
|
|
3518
3519
|
stdio = stdio.concat('ipc');
|
|
3519
3520
|
}
|
|
3520
|
-
const useDebug = require$$
|
|
3521
|
+
const useDebug = require$$8.isDebug('stdio');
|
|
3521
3522
|
const terminatorPos = args.indexOf('--');
|
|
3522
3523
|
const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos);
|
|
3523
3524
|
const progressArg = rawBinArgs.findLast(npm.isNpmProgressFlag) !== '--no-progress';
|
|
@@ -3748,7 +3749,7 @@ async function getAgentExecPath(agent) {
|
|
|
3748
3749
|
async function getAgentVersion(agent, agentExecPath, cwd) {
|
|
3749
3750
|
let result;
|
|
3750
3751
|
const quotedCmd = `\`${agent} --version\``;
|
|
3751
|
-
require$$
|
|
3752
|
+
require$$8.debugFn('stdio', `spawn: ${quotedCmd}`);
|
|
3752
3753
|
try {
|
|
3753
3754
|
result =
|
|
3754
3755
|
// Coerce version output into a valid semver version by passing it through
|
|
@@ -3762,8 +3763,8 @@ async function getAgentVersion(agent, agentExecPath, cwd) {
|
|
|
3762
3763
|
shell: constants.WIN32
|
|
3763
3764
|
})).stdout) ?? undefined;
|
|
3764
3765
|
} catch (e) {
|
|
3765
|
-
require$$
|
|
3766
|
-
require$$
|
|
3766
|
+
require$$8.debugFn('error', `caught: ${quotedCmd} failed`);
|
|
3767
|
+
require$$8.debugDir('inspect', {
|
|
3767
3768
|
error: e
|
|
3768
3769
|
});
|
|
3769
3770
|
}
|
|
@@ -4086,7 +4087,7 @@ function captureExceptionSync(exception, hint) {
|
|
|
4086
4087
|
if (!Sentry) {
|
|
4087
4088
|
return '';
|
|
4088
4089
|
}
|
|
4089
|
-
require$$
|
|
4090
|
+
require$$8.debugFn('notice', 'send: exception to Sentry');
|
|
4090
4091
|
return Sentry.captureException(exception, hint);
|
|
4091
4092
|
}
|
|
4092
4093
|
|
|
@@ -4155,7 +4156,7 @@ exports.gitUnstagedModifiedFiles = gitUnstagedModifiedFiles;
|
|
|
4155
4156
|
exports.globWorkspace = globWorkspace;
|
|
4156
4157
|
exports.handleApiCall = handleApiCall;
|
|
4157
4158
|
exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
|
|
4158
|
-
exports.
|
|
4159
|
+
exports.hasDefaultApiToken = hasDefaultApiToken;
|
|
4159
4160
|
exports.hasEnterpriseOrgPlan = hasEnterpriseOrgPlan;
|
|
4160
4161
|
exports.idToNpmPurl = idToNpmPurl;
|
|
4161
4162
|
exports.idToPurl = idToPurl;
|
|
@@ -4190,8 +4191,9 @@ exports.setupSdk = setupSdk;
|
|
|
4190
4191
|
exports.spawnCoana = spawnCoana;
|
|
4191
4192
|
exports.suggestOrgSlug = suggestOrgSlug;
|
|
4192
4193
|
exports.tildify = tildify;
|
|
4194
|
+
exports.toFilterConfig = toFilterConfig;
|
|
4193
4195
|
exports.updateConfigValue = updateConfigValue;
|
|
4194
4196
|
exports.walkNestedMap = walkNestedMap;
|
|
4195
4197
|
exports.writeSocketJson = writeSocketJson;
|
|
4196
|
-
//# debugId=
|
|
4198
|
+
//# debugId=1548800f-eb54-4ca4-b24f-724bfdaf19db
|
|
4197
4199
|
//# sourceMappingURL=utils.js.map
|