@socketsecurity/cli-with-sentry 1.1.20 → 1.1.21
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 +25 -10
- package/dist/cli.js +179 -137
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +25 -4
- package/dist/constants.js.map +1 -1
- package/dist/flags.js +21 -3
- package/dist/flags.js.map +1 -1
- package/dist/shadow-npm-bin2.js +2 -29
- package/dist/shadow-npm-bin2.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +2 -29
- package/dist/shadow-pnpm-bin2.js.map +1 -1
- package/dist/shadow-yarn-bin.js +4 -27
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest.d.mts.map +1 -1
- package/dist/types/commands/optimize/handle-optimize.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-policy.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization.d.mts.map +1 -1
- package/dist/types/commands/package/cmd-package.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.map +1 -1
- package/dist/types/commands/scan/cmd-scan.d.mts.map +1 -1
- package/dist/types/commands/scan/perform-reachability-analysis.d.mts.map +1 -1
- package/dist/types/constants.d.mts +6 -1
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/flags.d.mts.map +1 -1
- package/dist/types/shadow/npm-base.d.mts.map +1 -1
- package/dist/types/test/json-output-validation.d.mts +37 -0
- package/dist/types/test/json-output-validation.d.mts.map +1 -0
- package/dist/types/test/mocks/socket-auth.d.mts +88 -0
- package/dist/types/test/mocks/socket-auth.d.mts.map +1 -0
- package/dist/types/utils/config.d.mts +1 -1
- package/dist/types/utils/dlx-binary.d.mts +58 -0
- package/dist/types/utils/dlx-binary.d.mts.map +1 -0
- package/dist/types/utils/dlx-detection.d.mts +29 -0
- package/dist/types/utils/dlx-detection.d.mts.map +1 -0
- package/dist/types/utils/meow-with-subcommands.d.mts +33 -12
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/shadow-links.d.mts +5 -0
- package/dist/types/utils/shadow-links.d.mts.map +1 -0
- package/dist/types/utils/terminal-link.d.mts +19 -12
- package/dist/types/utils/terminal-link.d.mts.map +1 -1
- package/dist/utils.js +451 -126
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
- package/dist/types/shadow/npm/link.d.mts +0 -2
- package/dist/types/shadow/npm/link.d.mts.map +0 -1
- package/dist/types/shadow/pnpm/link.d.mts +0 -2
- package/dist/types/shadow/pnpm/link.d.mts.map +0 -1
- package/dist/types/shadow/yarn/link.d.mts +0 -2
- package/dist/types/shadow/yarn/link.d.mts.map +0 -1
package/dist/utils.js
CHANGED
|
@@ -23,9 +23,10 @@ var require$$13 = require('../external/@socketsecurity/registry/lib/url');
|
|
|
23
23
|
var agent = require('../external/@socketsecurity/registry/lib/agent');
|
|
24
24
|
var bin = require('../external/@socketsecurity/registry/lib/bin');
|
|
25
25
|
var packages = require('../external/@socketsecurity/registry/lib/packages');
|
|
26
|
-
var
|
|
26
|
+
var require$$0 = require('node:url');
|
|
27
27
|
var globs = require('../external/@socketsecurity/registry/lib/globs');
|
|
28
28
|
var streams = require('../external/@socketsecurity/registry/lib/streams');
|
|
29
|
+
var promises = require('node:timers/promises');
|
|
29
30
|
|
|
30
31
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
31
32
|
/**
|
|
@@ -400,8 +401,8 @@ function getSupportedConfigEntries() {
|
|
|
400
401
|
function getSupportedConfigKeys() {
|
|
401
402
|
return [...supportedConfigKeys];
|
|
402
403
|
}
|
|
403
|
-
function
|
|
404
|
-
return
|
|
404
|
+
function isConfigFromFlag() {
|
|
405
|
+
return _configFromFlag;
|
|
405
406
|
}
|
|
406
407
|
function isSensitiveConfigKey(key) {
|
|
407
408
|
return sensitiveConfigKeyLookup.has(key);
|
|
@@ -411,7 +412,7 @@ function isSupportedConfigKey(key) {
|
|
|
411
412
|
}
|
|
412
413
|
let _cachedConfig;
|
|
413
414
|
// When using --config or SOCKET_CLI_CONFIG, do not persist the config.
|
|
414
|
-
let
|
|
415
|
+
let _configFromFlag = false;
|
|
415
416
|
function overrideCachedConfig(jsonConfig) {
|
|
416
417
|
require$$9.debugFn('notice', 'override: full config (not stored)');
|
|
417
418
|
let config;
|
|
@@ -429,7 +430,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
429
430
|
} catch {
|
|
430
431
|
// Force set an empty config to prevent accidentally using system settings.
|
|
431
432
|
_cachedConfig = {};
|
|
432
|
-
|
|
433
|
+
_configFromFlag = true;
|
|
433
434
|
return {
|
|
434
435
|
ok: false,
|
|
435
436
|
message: 'Could not parse Config as JSON',
|
|
@@ -439,7 +440,7 @@ function overrideCachedConfig(jsonConfig) {
|
|
|
439
440
|
|
|
440
441
|
// @ts-ignore Override an illegal object.
|
|
441
442
|
_cachedConfig = config;
|
|
442
|
-
|
|
443
|
+
_configFromFlag = true;
|
|
443
444
|
|
|
444
445
|
// Normalize apiKey to apiToken.
|
|
445
446
|
if (_cachedConfig['apiKey']) {
|
|
@@ -463,7 +464,7 @@ function overrideConfigApiToken(apiToken) {
|
|
|
463
464
|
apiToken: String(apiToken)
|
|
464
465
|
})
|
|
465
466
|
};
|
|
466
|
-
|
|
467
|
+
_configFromFlag = true;
|
|
467
468
|
}
|
|
468
469
|
let _pendingSave = false;
|
|
469
470
|
function updateConfigValue(configKey, value) {
|
|
@@ -488,7 +489,7 @@ function updateConfigValue(configKey, value) {
|
|
|
488
489
|
}
|
|
489
490
|
localConfig[key] = value;
|
|
490
491
|
}
|
|
491
|
-
if (
|
|
492
|
+
if (_configFromFlag) {
|
|
492
493
|
return {
|
|
493
494
|
ok: true,
|
|
494
495
|
message: `Config key '${key}' was ${wasDeleted ? 'deleted' : `updated`}`,
|
|
@@ -528,7 +529,7 @@ function updateConfigValue(configKey, value) {
|
|
|
528
529
|
* - Used for permission validation and help text
|
|
529
530
|
*/
|
|
530
531
|
|
|
531
|
-
const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require
|
|
532
|
+
const require$3 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
532
533
|
let _requirements;
|
|
533
534
|
function getRequirements() {
|
|
534
535
|
if (_requirements === undefined) {
|
|
@@ -1251,16 +1252,6 @@ function mailtoLink(email, text) {
|
|
|
1251
1252
|
return vendor.terminalLinkExports(email, `mailto:${email}`);
|
|
1252
1253
|
}
|
|
1253
1254
|
|
|
1254
|
-
/**
|
|
1255
|
-
* Creates a terminal link to a web URL.
|
|
1256
|
-
* @param url The web URL to link to
|
|
1257
|
-
* @param text Optional display text (defaults to the URL itself)
|
|
1258
|
-
* @returns A terminal link to the URL
|
|
1259
|
-
*/
|
|
1260
|
-
function webLink(url, text) {
|
|
1261
|
-
return vendor.terminalLinkExports(text ?? url, url);
|
|
1262
|
-
}
|
|
1263
|
-
|
|
1264
1255
|
/**
|
|
1265
1256
|
* Creates a terminal link to the Socket.dev dashboard.
|
|
1266
1257
|
* @param path The path within the dashboard (e.g., '/org/YOURORG/alerts')
|
|
@@ -1272,6 +1263,16 @@ function socketDashboardLink(dashPath, text) {
|
|
|
1272
1263
|
return vendor.terminalLinkExports(text, url);
|
|
1273
1264
|
}
|
|
1274
1265
|
|
|
1266
|
+
/**
|
|
1267
|
+
* Creates a terminal link to the Socket.dev website.
|
|
1268
|
+
* @param text Display text for the link (defaults to 'Socket.dev')
|
|
1269
|
+
* @param urlPath Optional path to append to the base URL (e.g., '/pricing')
|
|
1270
|
+
* @returns A terminal link to Socket.dev
|
|
1271
|
+
*/
|
|
1272
|
+
function socketDevLink(text, urlPath) {
|
|
1273
|
+
return vendor.terminalLinkExports(text ?? 'Socket.dev', `${constants.SOCKET_WEBSITE_URL}${urlPath || ''}`);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1275
1276
|
/**
|
|
1276
1277
|
* Creates a terminal link to Socket.dev documentation.
|
|
1277
1278
|
* @param docPath The documentation path (e.g., '/docs/api-keys')
|
|
@@ -1303,7 +1304,17 @@ function socketPackageLink(ecosystem, packageName, version, text) {
|
|
|
1303
1304
|
} else {
|
|
1304
1305
|
url = `https://socket.dev/${ecosystem}/package/${packageName}`;
|
|
1305
1306
|
}
|
|
1306
|
-
return vendor.terminalLinkExports(text, url);
|
|
1307
|
+
return vendor.terminalLinkExports(text ?? url, url);
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Creates a terminal link to a web URL.
|
|
1312
|
+
* @param url The web URL to link to
|
|
1313
|
+
* @param text Optional display text (defaults to the URL itself)
|
|
1314
|
+
* @returns A terminal link to the URL
|
|
1315
|
+
*/
|
|
1316
|
+
function webLink(url, text) {
|
|
1317
|
+
return vendor.terminalLinkExports(text ?? url, url);
|
|
1307
1318
|
}
|
|
1308
1319
|
|
|
1309
1320
|
function checkCommandInput(outputKind, ...checks) {
|
|
@@ -1542,30 +1553,65 @@ function findBestCommandMatch(input, subcommands, aliases) {
|
|
|
1542
1553
|
return bestMatch;
|
|
1543
1554
|
}
|
|
1544
1555
|
|
|
1556
|
+
/**
|
|
1557
|
+
* Determine the origin of the API token.
|
|
1558
|
+
*/
|
|
1559
|
+
function getTokenOrigin() {
|
|
1560
|
+
if (constants.default.ENV.SOCKET_CLI_NO_API_TOKEN) {
|
|
1561
|
+
return '';
|
|
1562
|
+
}
|
|
1563
|
+
if (constants.default.ENV.SOCKET_CLI_API_TOKEN) {
|
|
1564
|
+
return '(env)';
|
|
1565
|
+
}
|
|
1566
|
+
const configToken = getConfigValueOrUndef(constants.CONFIG_KEY_API_TOKEN);
|
|
1567
|
+
if (configToken) {
|
|
1568
|
+
return isConfigFromFlag() ? '(--config flag)' : '(config)';
|
|
1569
|
+
}
|
|
1570
|
+
return '';
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1545
1573
|
/**
|
|
1546
1574
|
* Generate the ASCII banner header for Socket CLI commands.
|
|
1547
1575
|
*/
|
|
1548
|
-
function getAsciiHeader(command, orgFlag) {
|
|
1576
|
+
function getAsciiHeader(command, orgFlag, compactMode = false) {
|
|
1549
1577
|
// Note: In tests we return <redacted> because otherwise snapshots will fail.
|
|
1550
1578
|
const {
|
|
1551
1579
|
REDACTED
|
|
1552
1580
|
} = constants.default;
|
|
1553
1581
|
const redacting = constants.default.ENV.VITEST;
|
|
1554
|
-
|
|
1582
|
+
|
|
1583
|
+
// Version display: show hash in debug mode, otherwise show semantic version.
|
|
1584
|
+
const fullVersion = constants.default.ENV.INLINED_SOCKET_CLI_VERSION;
|
|
1585
|
+
const versionHash = constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH;
|
|
1586
|
+
const cliVersion = redacting ? REDACTED : require$$9.isDebug() ? versionHash : `v${fullVersion}`;
|
|
1555
1587
|
const nodeVersion = redacting ? REDACTED : process.version;
|
|
1588
|
+
const showNodeVersion = require$$9.isDebug();
|
|
1556
1589
|
const defaultOrg = getConfigValueOrUndef(constants.CONFIG_KEY_DEFAULT_ORG);
|
|
1557
|
-
const readOnlyConfig =
|
|
1558
|
-
|
|
1590
|
+
const readOnlyConfig = isConfigFromFlag() ? '*' : '.';
|
|
1591
|
+
|
|
1592
|
+
// Token display with origin indicator.
|
|
1593
|
+
const tokenPrefix = getVisibleTokenPrefix();
|
|
1594
|
+
const tokenOrigin = redacting ? '' : getTokenOrigin();
|
|
1595
|
+
const noApiToken = constants.default.ENV.SOCKET_CLI_NO_API_TOKEN;
|
|
1596
|
+
const shownToken = redacting ? REDACTED : noApiToken ? vendor.yoctocolorsCjsExports.red('(disabled)') : tokenPrefix ? `${vendor.yoctocolorsCjsExports.green(tokenPrefix)}***${tokenOrigin ? ` ${tokenOrigin}` : ''}` : vendor.yoctocolorsCjsExports.yellow('(not set)');
|
|
1559
1597
|
const relCwd = redacting ? REDACTED : path$1.normalizePath(tildify(process.cwd()));
|
|
1560
|
-
|
|
1561
|
-
//
|
|
1562
|
-
const orgPart =
|
|
1598
|
+
|
|
1599
|
+
// Consolidated org display format.
|
|
1600
|
+
const orgPart = redacting ? `org: ${REDACTED}` : orgFlag ? `org: ${vendor.yoctocolorsCjsExports.cyan(orgFlag)} (${constants.FLAG_ORG} flag)` : defaultOrg && defaultOrg !== 'null' ? `org: ${vendor.yoctocolorsCjsExports.cyan(defaultOrg)} (config)` : vendor.yoctocolorsCjsExports.yellow('org: (not set)');
|
|
1601
|
+
|
|
1602
|
+
// Compact mode for CI/automation.
|
|
1603
|
+
if (compactMode) {
|
|
1604
|
+
const compactToken = noApiToken ? '(disabled)' : tokenPrefix ? `${tokenPrefix}***${tokenOrigin ? ` ${tokenOrigin}` : ''}` : '(not set)';
|
|
1605
|
+
const compactOrg = orgFlag || (defaultOrg && defaultOrg !== 'null' ? defaultOrg : '(not set)');
|
|
1606
|
+
return `CLI: ${cliVersion} | cmd: ${command} | org: ${compactOrg} | token: ${compactToken}`;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1563
1609
|
// Note: We could draw these with ascii box art instead but I worry about
|
|
1564
1610
|
// portability and paste-ability. "simple" ascii chars just work.
|
|
1565
1611
|
const body = `
|
|
1566
1612
|
_____ _ _ /---------------
|
|
1567
|
-
| __|___ ___| |_ ___| |_ |
|
|
1568
|
-
|__ | ${readOnlyConfig} | _| '_| -_| _| | Node: ${nodeVersion},
|
|
1613
|
+
| __|___ ___| |_ ___| |_ | ${socketDevLink()} CLI: ${cliVersion}
|
|
1614
|
+
|__ | ${readOnlyConfig} | _| '_| -_| _| | ${showNodeVersion ? `Node: ${nodeVersion}, ` : ''}token: ${shownToken}, ${orgPart}
|
|
1569
1615
|
|_____|___|___|_,_|___|_|.dev | Command: \`${command}\`, cwd: ${relCwd}
|
|
1570
1616
|
`.trim();
|
|
1571
1617
|
// Note: logger will auto-append a newline.
|
|
@@ -1610,7 +1656,7 @@ function shouldSuppressBanner(flags) {
|
|
|
1610
1656
|
/**
|
|
1611
1657
|
* Emit the Socket CLI banner to stderr for branding and debugging.
|
|
1612
1658
|
*/
|
|
1613
|
-
function emitBanner(name, orgFlag) {
|
|
1659
|
+
function emitBanner(name, orgFlag, compactMode = false) {
|
|
1614
1660
|
// Print a banner at the top of each command.
|
|
1615
1661
|
// This helps with brand recognition and marketing.
|
|
1616
1662
|
// It also helps with debugging since it contains version and command details.
|
|
@@ -1619,19 +1665,32 @@ function emitBanner(name, orgFlag) {
|
|
|
1619
1665
|
// and pipe the result to other tools. By emitting the banner over stderr
|
|
1620
1666
|
// you can do something like `socket scan view xyz | jq | process`.
|
|
1621
1667
|
// The spinner also emits over stderr for example.
|
|
1622
|
-
logger.logger.error(getAsciiHeader(name, orgFlag));
|
|
1668
|
+
logger.logger.error(getAsciiHeader(name, orgFlag, compactMode));
|
|
1623
1669
|
}
|
|
1624
1670
|
|
|
1625
1671
|
/**
|
|
1626
1672
|
* Main function for handling CLI with subcommands using meow.
|
|
1673
|
+
* @param config Configuration object with name, argv, importMeta, and subcommands.
|
|
1674
|
+
* @param options Optional settings like aliases and defaultSub.
|
|
1675
|
+
* @example
|
|
1676
|
+
* meowWithSubcommands(
|
|
1677
|
+
* { name, argv, importMeta, subcommands },
|
|
1678
|
+
* { aliases, defaultSub }
|
|
1679
|
+
* )
|
|
1627
1680
|
*/
|
|
1628
|
-
async function meowWithSubcommands(
|
|
1681
|
+
async function meowWithSubcommands(config, options) {
|
|
1629
1682
|
const {
|
|
1630
|
-
aliases = {},
|
|
1631
1683
|
argv,
|
|
1632
|
-
defaultSub,
|
|
1633
1684
|
importMeta,
|
|
1634
1685
|
name,
|
|
1686
|
+
subcommands
|
|
1687
|
+
} = {
|
|
1688
|
+
__proto__: null,
|
|
1689
|
+
...config
|
|
1690
|
+
};
|
|
1691
|
+
const {
|
|
1692
|
+
aliases = {},
|
|
1693
|
+
defaultSub,
|
|
1635
1694
|
...additionalOptions
|
|
1636
1695
|
} = {
|
|
1637
1696
|
__proto__: null,
|
|
@@ -1659,24 +1718,29 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1659
1718
|
if (!isRootCommand) {
|
|
1660
1719
|
if (commandOrAliasName?.startsWith('pkg:')) {
|
|
1661
1720
|
logger.logger.info('Invoking `socket package score`.');
|
|
1662
|
-
return await meowWithSubcommands(
|
|
1663
|
-
|
|
1664
|
-
argv: ['package', 'deep', ...argv]
|
|
1665
|
-
|
|
1721
|
+
return await meowWithSubcommands({
|
|
1722
|
+
name,
|
|
1723
|
+
argv: ['package', 'deep', ...argv],
|
|
1724
|
+
importMeta,
|
|
1725
|
+
subcommands
|
|
1726
|
+
}, options);
|
|
1666
1727
|
}
|
|
1667
1728
|
// Support `socket npm/lodash` or whatever as a shorthand, too.
|
|
1668
1729
|
// Accept any ecosystem and let the remote sort it out.
|
|
1669
1730
|
if (/^[a-z]+\//.test(commandOrAliasName || '')) {
|
|
1670
1731
|
logger.logger.info('Invoking `socket package score`.');
|
|
1671
|
-
return await meowWithSubcommands(
|
|
1672
|
-
|
|
1673
|
-
argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv]
|
|
1674
|
-
|
|
1732
|
+
return await meowWithSubcommands({
|
|
1733
|
+
name,
|
|
1734
|
+
argv: ['package', 'deep', `pkg:${commandOrAliasName}`, ...rawCommandArgv],
|
|
1735
|
+
importMeta,
|
|
1736
|
+
subcommands
|
|
1737
|
+
}, options);
|
|
1675
1738
|
}
|
|
1676
1739
|
}
|
|
1677
1740
|
if (isRootCommand) {
|
|
1678
|
-
|
|
1679
|
-
|
|
1741
|
+
const hiddenDebugFlag = !require$$9.isDebug();
|
|
1742
|
+
flags$1['compactHeader'] = {
|
|
1743
|
+
...flags$1['compactHeader'],
|
|
1680
1744
|
hidden: false
|
|
1681
1745
|
};
|
|
1682
1746
|
flags$1['config'] = {
|
|
@@ -1687,13 +1751,21 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1687
1751
|
...flags$1['dryRun'],
|
|
1688
1752
|
hidden: false
|
|
1689
1753
|
};
|
|
1754
|
+
flags$1['help'] = {
|
|
1755
|
+
...flags$1['help'],
|
|
1756
|
+
hidden: false
|
|
1757
|
+
};
|
|
1758
|
+
flags$1['helpFull'] = {
|
|
1759
|
+
...flags$1['helpFull'],
|
|
1760
|
+
hidden: false
|
|
1761
|
+
};
|
|
1690
1762
|
flags$1['maxOldSpaceSize'] = {
|
|
1691
1763
|
...flags$1['maxOldSpaceSize'],
|
|
1692
|
-
hidden:
|
|
1764
|
+
hidden: hiddenDebugFlag
|
|
1693
1765
|
};
|
|
1694
1766
|
flags$1['maxSemiSpaceSize'] = {
|
|
1695
1767
|
...flags$1['maxSemiSpaceSize'],
|
|
1696
|
-
hidden:
|
|
1768
|
+
hidden: hiddenDebugFlag
|
|
1697
1769
|
};
|
|
1698
1770
|
flags$1['version'] = {
|
|
1699
1771
|
...flags$1['version'],
|
|
@@ -1703,6 +1775,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1703
1775
|
delete flags$1['markdown'];
|
|
1704
1776
|
} else {
|
|
1705
1777
|
delete flags$1['help'];
|
|
1778
|
+
delete flags$1['helpFull'];
|
|
1706
1779
|
delete flags$1['version'];
|
|
1707
1780
|
}
|
|
1708
1781
|
|
|
@@ -1722,10 +1795,12 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1722
1795
|
booleanDefault: undefined
|
|
1723
1796
|
});
|
|
1724
1797
|
const {
|
|
1798
|
+
compactHeader: compactHeaderFlag,
|
|
1725
1799
|
config: configFlag,
|
|
1726
1800
|
org: orgFlag,
|
|
1727
1801
|
spinner: spinnerFlag
|
|
1728
1802
|
} = cli1.flags;
|
|
1803
|
+
const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
|
|
1729
1804
|
const noSpinner = spinnerFlag === false || require$$9.isDebug();
|
|
1730
1805
|
|
|
1731
1806
|
// Use CI spinner style when --no-spinner is passed or debug mode is enabled.
|
|
@@ -1756,7 +1831,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1756
1831
|
}
|
|
1757
1832
|
if (configOverrideResult?.ok === false) {
|
|
1758
1833
|
if (!shouldSuppressBanner(cli1.flags)) {
|
|
1759
|
-
emitBanner(name, orgFlag);
|
|
1834
|
+
emitBanner(name, orgFlag, compactMode);
|
|
1760
1835
|
// Add newline in stderr.
|
|
1761
1836
|
logger.logger.error('');
|
|
1762
1837
|
}
|
|
@@ -1793,7 +1868,7 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1793
1868
|
}
|
|
1794
1869
|
const lines = ['', 'Usage', ` $ ${name} <command>`];
|
|
1795
1870
|
if (isRootCommand) {
|
|
1796
|
-
lines.push(` $ ${name} scan create
|
|
1871
|
+
lines.push(` $ ${name} scan create${constants.FLAG_JSON}`, ` $ ${name} package score ${constants.NPM} lodash ${constants.FLAG_MARKDOWN}`);
|
|
1797
1872
|
}
|
|
1798
1873
|
lines.push('');
|
|
1799
1874
|
if (isRootCommand) {
|
|
@@ -1866,7 +1941,15 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1866
1941
|
padName: HELP_PAD_NAME
|
|
1867
1942
|
})}`);
|
|
1868
1943
|
if (isRootCommand) {
|
|
1869
|
-
|
|
1944
|
+
// Check if we should show full help with environment variables.
|
|
1945
|
+
const showFullHelp = argv.includes(constants.FLAG_HELP_FULL);
|
|
1946
|
+
if (showFullHelp) {
|
|
1947
|
+
// Show full help with environment variables.
|
|
1948
|
+
lines.push('', 'Environment variables', ' SOCKET_CLI_API_TOKEN Set the Socket API token', ' SOCKET_CLI_CONFIG A JSON stringified Socket configuration object', ' SOCKET_CLI_GITHUB_API_URL Change the base URL for GitHub REST API calls', ' SOCKET_CLI_GIT_USER_EMAIL The git config `user.email` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]@users.noreply.github.com`, ' SOCKET_CLI_GIT_USER_NAME The git config `user.name` used by Socket CLI', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} github-actions[bot]`, ` SOCKET_CLI_GITHUB_TOKEN A classic or fine-grained ${vendor.terminalLinkExports('GitHub personal access token', 'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens')}`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} GITHUB_TOKEN`, ' SOCKET_CLI_NO_API_TOKEN Make the default API token `undefined`', ' SOCKET_CLI_NPM_PATH The absolute location of the npm directory', ' SOCKET_CLI_ORG_SLUG Specify the Socket organization slug', '', ' SOCKET_CLI_ACCEPT_RISKS Accept risks of a Socket wrapped npm/npx run', ' SOCKET_CLI_VIEW_ALL_RISKS View all risks of a Socket wrapped npm/npx run', '', 'Environment variables for development', ' SOCKET_CLI_API_BASE_URL Change the base URL for Socket API calls', ` ${vendor.yoctocolorsCjsExports.italic('Defaults:')} The "apiBaseUrl" value of socket/settings local app data`, ` if present, else ${constants.API_V0_URL}`, ' SOCKET_CLI_API_PROXY Set the proxy Socket API requests are routed through, e.g. if set to', ` ${vendor.terminalLinkExports('http://127.0.0.1:9090', 'https://docs.proxyman.io/troubleshooting/couldnt-see-any-requests-from-3rd-party-network-libraries')} then all request are passed through that proxy`, ` ${vendor.yoctocolorsCjsExports.italic('Aliases:')} HTTPS_PROXY, https_proxy, HTTP_PROXY, and http_proxy`, ' SOCKET_CLI_API_TIMEOUT Set the timeout in milliseconds for Socket API requests', ' SOCKET_CLI_DEBUG Enable debug logging in Socket CLI', ` DEBUG Enable debug logging based on the ${socketPackageLink('npm', 'debug', undefined, 'debug')} package`);
|
|
1949
|
+
} else {
|
|
1950
|
+
// Show condensed help with hint about --help-full.
|
|
1951
|
+
lines.push('', 'Environment variables [more...]', ` Use ${vendor.yoctocolorsCjsExports.bold(constants.FLAG_HELP_FULL)} to view all environment variables`);
|
|
1952
|
+
}
|
|
1870
1953
|
}
|
|
1871
1954
|
|
|
1872
1955
|
// Parse it again. Config overrides should now be applied (may affect help).
|
|
@@ -1887,34 +1970,53 @@ async function meowWithSubcommands(subcommands, options) {
|
|
|
1887
1970
|
booleanDefault: undefined,
|
|
1888
1971
|
help: lines.map(l => strings.indentString(l, HELP_INDENT)).join('\n')
|
|
1889
1972
|
});
|
|
1973
|
+
const {
|
|
1974
|
+
dryRun,
|
|
1975
|
+
help: helpFlag
|
|
1976
|
+
} = cli2.flags;
|
|
1890
1977
|
|
|
1891
1978
|
// ...else we provide basic instructions and help.
|
|
1892
1979
|
if (!shouldSuppressBanner(cli2.flags)) {
|
|
1893
|
-
emitBanner(name, orgFlag);
|
|
1980
|
+
emitBanner(name, orgFlag, compactMode);
|
|
1894
1981
|
// Meow will add newline so don't add stderr spacing here.
|
|
1895
1982
|
}
|
|
1896
|
-
if (!
|
|
1983
|
+
if (!helpFlag && dryRun) {
|
|
1897
1984
|
process.exitCode = 0;
|
|
1898
1985
|
logger.logger.log(`${constants.default.DRY_RUN_LABEL}: No-op, call a sub-command; ok`);
|
|
1899
1986
|
} else {
|
|
1900
1987
|
// When you explicitly request --help, the command should be successful
|
|
1901
1988
|
// so we exit(0). If we do it because we need more input, we exit(2).
|
|
1902
|
-
cli2.showHelp(
|
|
1989
|
+
cli2.showHelp(helpFlag ? 0 : 2);
|
|
1903
1990
|
}
|
|
1904
1991
|
}
|
|
1905
|
-
|
|
1906
1992
|
/**
|
|
1907
1993
|
* Create meow CLI instance or exit with help/error (meow will exit immediately
|
|
1908
1994
|
* if it calls .showHelp()).
|
|
1995
|
+
* @param config Configuration object with argv, config, parentName, and importMeta.
|
|
1996
|
+
* @param options Optional settings like allowUnknownFlags.
|
|
1997
|
+
* @example
|
|
1998
|
+
* meowOrExit(
|
|
1999
|
+
* { argv, config, parentName, importMeta },
|
|
2000
|
+
* { allowUnknownFlags: false }
|
|
2001
|
+
* )
|
|
1909
2002
|
*/
|
|
1910
|
-
function meowOrExit({
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
}
|
|
1917
|
-
|
|
2003
|
+
function meowOrExit(config, options) {
|
|
2004
|
+
const {
|
|
2005
|
+
argv,
|
|
2006
|
+
config: cliConfig,
|
|
2007
|
+
importMeta,
|
|
2008
|
+
parentName
|
|
2009
|
+
} = {
|
|
2010
|
+
__proto__: null,
|
|
2011
|
+
...config
|
|
2012
|
+
};
|
|
2013
|
+
const {
|
|
2014
|
+
allowUnknownFlags = true
|
|
2015
|
+
} = {
|
|
2016
|
+
__proto__: null,
|
|
2017
|
+
...options
|
|
2018
|
+
};
|
|
2019
|
+
const command = `${parentName} ${cliConfig.commandName}`;
|
|
1918
2020
|
|
|
1919
2021
|
// This exits if .printHelp() is called either by meow itself or by us.
|
|
1920
2022
|
const cli = vendor.meow({
|
|
@@ -1925,17 +2027,19 @@ function meowOrExit({
|
|
|
1925
2027
|
// We want to detect whether a bool flag is given at all.
|
|
1926
2028
|
booleanDefault: undefined,
|
|
1927
2029
|
collectUnknownFlags: true,
|
|
1928
|
-
description:
|
|
1929
|
-
flags:
|
|
1930
|
-
help: strings.trimNewlines(
|
|
2030
|
+
description: cliConfig.description,
|
|
2031
|
+
flags: cliConfig.flags,
|
|
2032
|
+
help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
|
|
1931
2033
|
importMeta
|
|
1932
2034
|
});
|
|
1933
2035
|
const {
|
|
2036
|
+
compactHeader: compactHeaderFlag,
|
|
1934
2037
|
help: helpFlag,
|
|
1935
2038
|
org: orgFlag,
|
|
1936
2039
|
spinner: spinnerFlag,
|
|
1937
2040
|
version: versionFlag
|
|
1938
2041
|
} = cli.flags;
|
|
2042
|
+
const compactMode = compactHeaderFlag || constants.default.ENV.CI && !constants.default.ENV.VITEST;
|
|
1939
2043
|
const noSpinner = spinnerFlag === false || require$$9.isDebug();
|
|
1940
2044
|
|
|
1941
2045
|
// Use CI spinner style when --no-spinner is passed.
|
|
@@ -1944,7 +2048,7 @@ function meowOrExit({
|
|
|
1944
2048
|
constants.default.spinner.spinner = spinner.getCliSpinners('ci');
|
|
1945
2049
|
}
|
|
1946
2050
|
if (!shouldSuppressBanner(cli.flags)) {
|
|
1947
|
-
emitBanner(command, orgFlag);
|
|
2051
|
+
emitBanner(command, orgFlag, compactMode);
|
|
1948
2052
|
// Add newline in stderr.
|
|
1949
2053
|
// Meow help adds a newline too so we do it here.
|
|
1950
2054
|
logger.logger.error('');
|
|
@@ -1973,7 +2077,7 @@ function meowOrExit({
|
|
|
1973
2077
|
}
|
|
1974
2078
|
|
|
1975
2079
|
// Meow doesn't detect 'version' as an unknown flag, so we do the leg work here.
|
|
1976
|
-
if (versionFlag && !require$$11.hasOwn(
|
|
2080
|
+
if (versionFlag && !require$$11.hasOwn(cliConfig.flags, 'version')) {
|
|
1977
2081
|
// Use `console.error` here instead of `logger.error` to match Meow behavior.
|
|
1978
2082
|
console.error('Unknown flag\n--version');
|
|
1979
2083
|
// eslint-disable-next-line n/no-process-exit
|
|
@@ -1994,10 +2098,10 @@ function meowOrExit({
|
|
|
1994
2098
|
// Prevent meow from potentially exiting early.
|
|
1995
2099
|
autoHelp: false,
|
|
1996
2100
|
autoVersion: false,
|
|
1997
|
-
description:
|
|
1998
|
-
help: strings.trimNewlines(
|
|
2101
|
+
description: cliConfig.description,
|
|
2102
|
+
help: strings.trimNewlines(cliConfig.help(command, cliConfig)),
|
|
1999
2103
|
importMeta,
|
|
2000
|
-
flags:
|
|
2104
|
+
flags: cliConfig.flags
|
|
2001
2105
|
});
|
|
2002
2106
|
// Ok, no help, reset to default.
|
|
2003
2107
|
process.exitCode = 0;
|
|
@@ -3251,7 +3355,7 @@ function isYarnBerry() {
|
|
|
3251
3355
|
* - Configures environment for third-party tools
|
|
3252
3356
|
*/
|
|
3253
3357
|
|
|
3254
|
-
const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require
|
|
3358
|
+
const require$2 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
3255
3359
|
const {
|
|
3256
3360
|
PACKAGE_LOCK_JSON,
|
|
3257
3361
|
PNPM_LOCK_YAML,
|
|
@@ -4772,6 +4876,275 @@ function getEcosystemChoicesForMeow() {
|
|
|
4772
4876
|
return [...ALL_ECOSYSTEMS];
|
|
4773
4877
|
}
|
|
4774
4878
|
|
|
4879
|
+
/**
|
|
4880
|
+
* Temporary package executor detection utilities for Socket CLI.
|
|
4881
|
+
* Identifies and handles temporary execution contexts.
|
|
4882
|
+
*
|
|
4883
|
+
* Key Functions:
|
|
4884
|
+
* - isRunningInTemporaryExecutor: Detects if running in npx/dlx/exec context
|
|
4885
|
+
* - shouldSkipShadow: Determines if shadow installation should be skipped
|
|
4886
|
+
*
|
|
4887
|
+
* Temporary Execution Contexts:
|
|
4888
|
+
* - npm exec/npx: Runs packages in temporary npm cache
|
|
4889
|
+
* - pnpm dlx: Executes packages in temporary pnpm store
|
|
4890
|
+
* - yarn dlx: Runs packages in temporary yarn environment
|
|
4891
|
+
*
|
|
4892
|
+
* Detection Methods:
|
|
4893
|
+
* - Environment variable analysis (npm_config_user_agent)
|
|
4894
|
+
* - Path pattern matching for temporary directories
|
|
4895
|
+
* - Cache directory identification
|
|
4896
|
+
*
|
|
4897
|
+
* Usage:
|
|
4898
|
+
* - Prevents shadow installation in temporary contexts
|
|
4899
|
+
* - Avoids PATH pollution in ephemeral environments
|
|
4900
|
+
* - Ensures package manager commands work correctly
|
|
4901
|
+
*/
|
|
4902
|
+
|
|
4903
|
+
/**
|
|
4904
|
+
* Determines if shadow binaries should be installed.
|
|
4905
|
+
* Shadows should NOT be installed when:
|
|
4906
|
+
* - Running in a temporary execution context (exec/npx/dlx)
|
|
4907
|
+
* - On Windows with an existing binary path (required for Windows to function)
|
|
4908
|
+
*
|
|
4909
|
+
* @param binPath - Path to the binary being shadowed
|
|
4910
|
+
* @param options - Configuration options
|
|
4911
|
+
* @param options.cwd - Current working directory path to check
|
|
4912
|
+
* @param options.win32 - Whether running on Windows
|
|
4913
|
+
* @returns true if shadow installation should be skipped
|
|
4914
|
+
*/
|
|
4915
|
+
function shouldSkipShadow(binPath, options) {
|
|
4916
|
+
const {
|
|
4917
|
+
cwd = process.cwd(),
|
|
4918
|
+
win32 = false
|
|
4919
|
+
} = {
|
|
4920
|
+
__proto__: null,
|
|
4921
|
+
...options
|
|
4922
|
+
};
|
|
4923
|
+
|
|
4924
|
+
// Windows compatibility: Skip shadow installation if binary is already found.
|
|
4925
|
+
//
|
|
4926
|
+
// This check is required because Windows handles executables differently than Unix:
|
|
4927
|
+
// 1. File locking - Windows locks running executables, so cmd-shim creation would
|
|
4928
|
+
// fail with EBUSY/EACCES errors when trying to create wrapper files.
|
|
4929
|
+
// 2. PATH conflicts - Attempting to shadow an already-resolved binary can create
|
|
4930
|
+
// circular references or ambiguous command resolution.
|
|
4931
|
+
// 3. Registry integration - Windows package managers often use system-level
|
|
4932
|
+
// integrations beyond just PATH that our shadowing would interfere with.
|
|
4933
|
+
//
|
|
4934
|
+
// Without this check, users would see "Access Denied" or file locking errors
|
|
4935
|
+
// that are difficult to debug. This is not a performance optimization - the
|
|
4936
|
+
// shadow installation will fail without it.
|
|
4937
|
+
if (win32 && binPath) {
|
|
4938
|
+
return true;
|
|
4939
|
+
}
|
|
4940
|
+
|
|
4941
|
+
// Check environment variable for exec/npx/dlx indicators.
|
|
4942
|
+
const userAgent = constants.default.ENV.npm_config_user_agent;
|
|
4943
|
+
if (userAgent?.includes('exec') || userAgent?.includes('npx') || userAgent?.includes('dlx')) {
|
|
4944
|
+
return true;
|
|
4945
|
+
}
|
|
4946
|
+
|
|
4947
|
+
// Normalize the cwd path for consistent checking across platforms.
|
|
4948
|
+
const normalizedCwd = path$1.normalizePath(cwd);
|
|
4949
|
+
|
|
4950
|
+
// Check if running from npm's npx cache.
|
|
4951
|
+
const npmCache = constants.default.ENV.npm_config_cache;
|
|
4952
|
+
if (npmCache && normalizedCwd.includes(path$1.normalizePath(npmCache))) {
|
|
4953
|
+
return true;
|
|
4954
|
+
}
|
|
4955
|
+
|
|
4956
|
+
// Check common temporary execution path patterns.
|
|
4957
|
+
const tempPatterns = ['_npx',
|
|
4958
|
+
// npm's npx cache directory
|
|
4959
|
+
'.pnpm-store',
|
|
4960
|
+
// pnpm dlx temporary store
|
|
4961
|
+
'dlx-',
|
|
4962
|
+
// Common dlx directory prefix
|
|
4963
|
+
'.yarn/$$',
|
|
4964
|
+
// Yarn Berry PnP virtual packages
|
|
4965
|
+
path.sep === '\\' ? 'AppData\\Local\\Temp\\xfs-' : 'AppData/Local/Temp/xfs-' // Yarn on Windows
|
|
4966
|
+
];
|
|
4967
|
+
return tempPatterns.some(pattern => normalizedCwd.includes(pattern));
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
/**
|
|
4971
|
+
* PNPM path resolution utilities for Socket CLI.
|
|
4972
|
+
* Locates and caches PNPM binary paths.
|
|
4973
|
+
*
|
|
4974
|
+
* Key Functions:
|
|
4975
|
+
* - getPnpmBinPath: Get cached PNPM binary path
|
|
4976
|
+
* - getPnpmBinPathDetails: Get detailed PNPM path information
|
|
4977
|
+
*
|
|
4978
|
+
* Error Handling:
|
|
4979
|
+
* - Exits with code 127 if PNPM not found
|
|
4980
|
+
* - Provides clear error messages for missing binaries
|
|
4981
|
+
*
|
|
4982
|
+
* Caching:
|
|
4983
|
+
* - Caches binary path lookups for performance
|
|
4984
|
+
* - Prevents repeated PATH searches
|
|
4985
|
+
*/
|
|
4986
|
+
|
|
4987
|
+
function exitWithBinPathError(binName) {
|
|
4988
|
+
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
4989
|
+
// The exit code 127 indicates that the command or binary being executed
|
|
4990
|
+
// could not be found.
|
|
4991
|
+
// eslint-disable-next-line n/no-process-exit
|
|
4992
|
+
process.exit(127);
|
|
4993
|
+
// This line is never reached in production, but helps tests.
|
|
4994
|
+
throw new Error('process.exit called');
|
|
4995
|
+
}
|
|
4996
|
+
let _pnpmBinPath;
|
|
4997
|
+
function getPnpmBinPath() {
|
|
4998
|
+
if (_pnpmBinPath === undefined) {
|
|
4999
|
+
_pnpmBinPath = getPnpmBinPathDetails().path;
|
|
5000
|
+
if (!_pnpmBinPath) {
|
|
5001
|
+
exitWithBinPathError('pnpm');
|
|
5002
|
+
}
|
|
5003
|
+
}
|
|
5004
|
+
return _pnpmBinPath;
|
|
5005
|
+
}
|
|
5006
|
+
let _pnpmBinPathDetails;
|
|
5007
|
+
function getPnpmBinPathDetails() {
|
|
5008
|
+
if (_pnpmBinPathDetails === undefined) {
|
|
5009
|
+
_pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
|
|
5010
|
+
}
|
|
5011
|
+
return _pnpmBinPathDetails;
|
|
5012
|
+
}
|
|
5013
|
+
function isPnpmBinPathShadowed() {
|
|
5014
|
+
return getPnpmBinPathDetails().shadowed;
|
|
5015
|
+
}
|
|
5016
|
+
|
|
5017
|
+
/**
|
|
5018
|
+
* Shadow binary link installation utilities for Socket CLI.
|
|
5019
|
+
* Manages installation of shadow binaries for package managers.
|
|
5020
|
+
*
|
|
5021
|
+
* Key Functions:
|
|
5022
|
+
* - installNpmLinks: Install shadow links for npm binary
|
|
5023
|
+
* - installNpxLinks: Install shadow links for npx binary
|
|
5024
|
+
* - installPnpmLinks: Install shadow links for pnpm binary
|
|
5025
|
+
* - installYarnLinks: Install shadow links for yarn binary
|
|
5026
|
+
*
|
|
5027
|
+
* Shadow Installation:
|
|
5028
|
+
* - Creates symlinks/cmd-shims to intercept package manager commands
|
|
5029
|
+
* - Modifies PATH to prioritize shadow binaries
|
|
5030
|
+
* - Skips installation in temporary execution contexts
|
|
5031
|
+
*
|
|
5032
|
+
* Security Integration:
|
|
5033
|
+
* - Enables security scanning before package operations
|
|
5034
|
+
* - Transparent interception of package manager commands
|
|
5035
|
+
* - Preserves original binary functionality
|
|
5036
|
+
*/
|
|
5037
|
+
|
|
5038
|
+
const __filename$1 = require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
5039
|
+
const __dirname$1 = path.dirname(__filename$1);
|
|
5040
|
+
async function installNpmLinks(shadowBinPath) {
|
|
5041
|
+
// Find npm being shadowed by this process.
|
|
5042
|
+
const binPath = getNpmBinPath();
|
|
5043
|
+
const {
|
|
5044
|
+
WIN32
|
|
5045
|
+
} = constants.default;
|
|
5046
|
+
|
|
5047
|
+
// Skip shadow installation when in temporary execution context or when required for Windows.
|
|
5048
|
+
if (shouldSkipShadow(binPath, {
|
|
5049
|
+
cwd: __dirname$1,
|
|
5050
|
+
win32: WIN32
|
|
5051
|
+
})) {
|
|
5052
|
+
return binPath;
|
|
5053
|
+
}
|
|
5054
|
+
const shadowed = isNpmBinPathShadowed();
|
|
5055
|
+
// Move our bin directory to front of PATH so its found first.
|
|
5056
|
+
if (!shadowed) {
|
|
5057
|
+
if (WIN32) {
|
|
5058
|
+
await vendor.libExports(path.join(constants.default.distPath, 'npm-cli.js'), path.join(shadowBinPath, 'npm'));
|
|
5059
|
+
}
|
|
5060
|
+
const {
|
|
5061
|
+
env
|
|
5062
|
+
} = process;
|
|
5063
|
+
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
5064
|
+
}
|
|
5065
|
+
return binPath;
|
|
5066
|
+
}
|
|
5067
|
+
async function installNpxLinks(shadowBinPath) {
|
|
5068
|
+
// Find npx being shadowed by this process.
|
|
5069
|
+
const binPath = getNpxBinPath();
|
|
5070
|
+
const {
|
|
5071
|
+
WIN32
|
|
5072
|
+
} = constants.default;
|
|
5073
|
+
|
|
5074
|
+
// Skip shadow installation when in temporary execution context or when required for Windows.
|
|
5075
|
+
if (shouldSkipShadow(binPath, {
|
|
5076
|
+
cwd: __dirname$1,
|
|
5077
|
+
win32: WIN32
|
|
5078
|
+
})) {
|
|
5079
|
+
return binPath;
|
|
5080
|
+
}
|
|
5081
|
+
const shadowed = isNpxBinPathShadowed();
|
|
5082
|
+
// Move our bin directory to front of PATH so its found first.
|
|
5083
|
+
if (!shadowed) {
|
|
5084
|
+
if (WIN32) {
|
|
5085
|
+
await vendor.libExports(path.join(constants.default.distPath, 'npx-cli.js'), path.join(shadowBinPath, 'npx'));
|
|
5086
|
+
}
|
|
5087
|
+
const {
|
|
5088
|
+
env
|
|
5089
|
+
} = process;
|
|
5090
|
+
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
5091
|
+
}
|
|
5092
|
+
return binPath;
|
|
5093
|
+
}
|
|
5094
|
+
async function installPnpmLinks(shadowBinPath) {
|
|
5095
|
+
// Find pnpm being shadowed by this process.
|
|
5096
|
+
const binPath = getPnpmBinPath();
|
|
5097
|
+
const {
|
|
5098
|
+
WIN32
|
|
5099
|
+
} = constants.default;
|
|
5100
|
+
|
|
5101
|
+
// Skip shadow installation when in temporary execution context or when required for Windows.
|
|
5102
|
+
if (shouldSkipShadow(binPath, {
|
|
5103
|
+
cwd: __dirname$1,
|
|
5104
|
+
win32: WIN32
|
|
5105
|
+
})) {
|
|
5106
|
+
return binPath;
|
|
5107
|
+
}
|
|
5108
|
+
const shadowed = isPnpmBinPathShadowed();
|
|
5109
|
+
|
|
5110
|
+
// Move our bin directory to front of PATH so its found first.
|
|
5111
|
+
if (!shadowed) {
|
|
5112
|
+
if (WIN32) {
|
|
5113
|
+
await vendor.libExports(path.join(constants.default.distPath, 'pnpm-cli.js'), path.join(shadowBinPath, 'pnpm'));
|
|
5114
|
+
}
|
|
5115
|
+
const {
|
|
5116
|
+
env
|
|
5117
|
+
} = process;
|
|
5118
|
+
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
5119
|
+
}
|
|
5120
|
+
return binPath;
|
|
5121
|
+
}
|
|
5122
|
+
async function installYarnLinks(shadowBinPath) {
|
|
5123
|
+
const binPath = getYarnBinPath();
|
|
5124
|
+
const {
|
|
5125
|
+
WIN32
|
|
5126
|
+
} = constants.default;
|
|
5127
|
+
|
|
5128
|
+
// Skip shadow installation when in temporary execution context or when required for Windows.
|
|
5129
|
+
if (shouldSkipShadow(binPath, {
|
|
5130
|
+
cwd: __dirname$1,
|
|
5131
|
+
win32: WIN32
|
|
5132
|
+
})) {
|
|
5133
|
+
return binPath;
|
|
5134
|
+
}
|
|
5135
|
+
const shadowed = isYarnBinPathShadowed();
|
|
5136
|
+
if (!shadowed) {
|
|
5137
|
+
if (WIN32) {
|
|
5138
|
+
await vendor.libExports(path.join(constants.default.distPath, 'yarn-cli.js'), path.join(shadowBinPath, 'yarn'));
|
|
5139
|
+
}
|
|
5140
|
+
const {
|
|
5141
|
+
env
|
|
5142
|
+
} = process;
|
|
5143
|
+
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
5144
|
+
}
|
|
5145
|
+
return binPath;
|
|
5146
|
+
}
|
|
5147
|
+
|
|
4775
5148
|
/**
|
|
4776
5149
|
* Filter configuration utilities for Socket CLI.
|
|
4777
5150
|
* Manages filter configuration normalization for security scanning.
|
|
@@ -4943,7 +5316,7 @@ class ColorOrMarkdown {
|
|
|
4943
5316
|
}
|
|
4944
5317
|
}
|
|
4945
5318
|
|
|
4946
|
-
const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require
|
|
5319
|
+
const require$1 = require$$5.createRequire((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('utils.js', document.baseURI).href)));
|
|
4947
5320
|
let _translations;
|
|
4948
5321
|
function getTranslations() {
|
|
4949
5322
|
if (_translations === undefined) {
|
|
@@ -5568,53 +5941,6 @@ function safeNpmSpecToPurl(pkgSpec) {
|
|
|
5568
5941
|
return purlObj?.toString() ?? `pkg:${constants.NPM}/${name}${version ? `@${version}` : ''}`;
|
|
5569
5942
|
}
|
|
5570
5943
|
|
|
5571
|
-
/**
|
|
5572
|
-
* PNPM path resolution utilities for Socket CLI.
|
|
5573
|
-
* Locates and caches PNPM binary paths.
|
|
5574
|
-
*
|
|
5575
|
-
* Key Functions:
|
|
5576
|
-
* - getPnpmBinPath: Get cached PNPM binary path
|
|
5577
|
-
* - getPnpmBinPathDetails: Get detailed PNPM path information
|
|
5578
|
-
*
|
|
5579
|
-
* Error Handling:
|
|
5580
|
-
* - Exits with code 127 if PNPM not found
|
|
5581
|
-
* - Provides clear error messages for missing binaries
|
|
5582
|
-
*
|
|
5583
|
-
* Caching:
|
|
5584
|
-
* - Caches binary path lookups for performance
|
|
5585
|
-
* - Prevents repeated PATH searches
|
|
5586
|
-
*/
|
|
5587
|
-
|
|
5588
|
-
function exitWithBinPathError(binName) {
|
|
5589
|
-
logger.logger.fail(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable`);
|
|
5590
|
-
// The exit code 127 indicates that the command or binary being executed
|
|
5591
|
-
// could not be found.
|
|
5592
|
-
// eslint-disable-next-line n/no-process-exit
|
|
5593
|
-
process.exit(127);
|
|
5594
|
-
// This line is never reached in production, but helps tests.
|
|
5595
|
-
throw new Error('process.exit called');
|
|
5596
|
-
}
|
|
5597
|
-
let _pnpmBinPath;
|
|
5598
|
-
function getPnpmBinPath() {
|
|
5599
|
-
if (_pnpmBinPath === undefined) {
|
|
5600
|
-
_pnpmBinPath = getPnpmBinPathDetails().path;
|
|
5601
|
-
if (!_pnpmBinPath) {
|
|
5602
|
-
exitWithBinPathError('pnpm');
|
|
5603
|
-
}
|
|
5604
|
-
}
|
|
5605
|
-
return _pnpmBinPath;
|
|
5606
|
-
}
|
|
5607
|
-
let _pnpmBinPathDetails;
|
|
5608
|
-
function getPnpmBinPathDetails() {
|
|
5609
|
-
if (_pnpmBinPathDetails === undefined) {
|
|
5610
|
-
_pnpmBinPathDetails = findBinPathDetailsSync('pnpm');
|
|
5611
|
-
}
|
|
5612
|
-
return _pnpmBinPathDetails;
|
|
5613
|
-
}
|
|
5614
|
-
function isPnpmBinPathShadowed() {
|
|
5615
|
-
return getPnpmBinPathDetails().shadowed;
|
|
5616
|
-
}
|
|
5617
|
-
|
|
5618
5944
|
exports.AuthError = AuthError;
|
|
5619
5945
|
exports.COMPLETION_CMD_PREFIX = COMPLETION_CMD_PREFIX;
|
|
5620
5946
|
exports.InputError = InputError;
|
|
@@ -5663,7 +5989,6 @@ exports.getOctokitGraphql = getOctokitGraphql;
|
|
|
5663
5989
|
exports.getOrgSlugs = getOrgSlugs;
|
|
5664
5990
|
exports.getOutputKind = getOutputKind;
|
|
5665
5991
|
exports.getPackageFilesForScan = getPackageFilesForScan;
|
|
5666
|
-
exports.getPnpmBinPath = getPnpmBinPath;
|
|
5667
5992
|
exports.getPublicApiToken = getPublicApiToken;
|
|
5668
5993
|
exports.getPurlObject = getPurlObject;
|
|
5669
5994
|
exports.getRepoInfo = getRepoInfo;
|
|
@@ -5672,7 +5997,6 @@ exports.getSocketDevPackageOverviewUrlFromPurl = getSocketDevPackageOverviewUrlF
|
|
|
5672
5997
|
exports.getSupportedConfigEntries = getSupportedConfigEntries;
|
|
5673
5998
|
exports.getSupportedConfigKeys = getSupportedConfigKeys;
|
|
5674
5999
|
exports.getVisibleTokenPrefix = getVisibleTokenPrefix;
|
|
5675
|
-
exports.getYarnBinPath = getYarnBinPath;
|
|
5676
6000
|
exports.gitBranch = gitBranch;
|
|
5677
6001
|
exports.gitCheckoutBranch = gitCheckoutBranch;
|
|
5678
6002
|
exports.gitCommit = gitCommit;
|
|
@@ -5688,16 +6012,16 @@ exports.handleApiCallNoSpinner = handleApiCallNoSpinner;
|
|
|
5688
6012
|
exports.hasDefaultApiToken = hasDefaultApiToken;
|
|
5689
6013
|
exports.hasEnterpriseOrgPlan = hasEnterpriseOrgPlan;
|
|
5690
6014
|
exports.idToNpmPurl = idToNpmPurl;
|
|
6015
|
+
exports.installNpmLinks = installNpmLinks;
|
|
6016
|
+
exports.installNpxLinks = installNpxLinks;
|
|
6017
|
+
exports.installPnpmLinks = installPnpmLinks;
|
|
6018
|
+
exports.installYarnLinks = installYarnLinks;
|
|
6019
|
+
exports.isConfigFromFlag = isConfigFromFlag;
|
|
5691
6020
|
exports.isHelpFlag = isHelpFlag;
|
|
5692
|
-
exports.isNpmBinPathShadowed = isNpmBinPathShadowed;
|
|
5693
|
-
exports.isNpxBinPathShadowed = isNpxBinPathShadowed;
|
|
5694
|
-
exports.isPnpmBinPathShadowed = isPnpmBinPathShadowed;
|
|
5695
|
-
exports.isReadOnlyConfig = isReadOnlyConfig;
|
|
5696
6021
|
exports.isReportSupportedFile = isReportSupportedFile;
|
|
5697
6022
|
exports.isSensitiveConfigKey = isSensitiveConfigKey;
|
|
5698
6023
|
exports.isSupportedConfigKey = isSupportedConfigKey;
|
|
5699
6024
|
exports.isYarnBerry = isYarnBerry;
|
|
5700
|
-
exports.isYarnBinPathShadowed = isYarnBinPathShadowed;
|
|
5701
6025
|
exports.logAlertsMap = logAlertsMap;
|
|
5702
6026
|
exports.mailtoLink = mailtoLink;
|
|
5703
6027
|
exports.mapToObject = mapToObject;
|
|
@@ -5723,6 +6047,7 @@ exports.serializeResultJson = serializeResultJson;
|
|
|
5723
6047
|
exports.setGitRemoteGithubRepoUrl = setGitRemoteGithubRepoUrl;
|
|
5724
6048
|
exports.setupSdk = setupSdk;
|
|
5725
6049
|
exports.socketDashboardLink = socketDashboardLink;
|
|
6050
|
+
exports.socketDevLink = socketDevLink;
|
|
5726
6051
|
exports.socketDocsLink = socketDocsLink;
|
|
5727
6052
|
exports.socketPackageLink = socketPackageLink;
|
|
5728
6053
|
exports.spawnCdxgenDlx = spawnCdxgenDlx;
|
|
@@ -5735,5 +6060,5 @@ exports.updateConfigValue = updateConfigValue;
|
|
|
5735
6060
|
exports.walkNestedMap = walkNestedMap;
|
|
5736
6061
|
exports.webLink = webLink;
|
|
5737
6062
|
exports.writeSocketJson = writeSocketJson;
|
|
5738
|
-
//# debugId=
|
|
6063
|
+
//# debugId=aca3fb2c-1435-481e-a911-c0547052c313
|
|
5739
6064
|
//# sourceMappingURL=utils.js.map
|