@socketsecurity/cli-with-sentry 1.1.17 → 1.1.19
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 +11 -0
- package/bin/npm-cli.js +2 -2
- package/bin/npx-cli.js +2 -2
- package/bin/pnpm-cli.js +2 -2
- package/bin/yarn-cli.js +2 -2
- package/dist/cli.js +238 -94
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +5 -3
- package/dist/constants.js.map +1 -1
- package/dist/flags.js +3 -2
- package/dist/flags.js.map +1 -1
- package/dist/npm-cli.js +3 -4
- package/dist/npm-cli.js.map +1 -1
- package/dist/npx-cli.js +3 -3
- package/dist/npx-cli.js.map +1 -1
- package/dist/pnpm-cli.js +3 -3
- package/dist/pnpm-cli.js.map +1 -1
- package/dist/shadow-npm-bin.js +3 -106
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-npm-bin2.js +125 -0
- package/dist/shadow-npm-bin2.js.map +1 -0
- package/dist/shadow-npx-bin.js +12 -0
- package/dist/shadow-npx-bin.js.map +1 -0
- package/dist/shadow-pnpm-bin.js +3 -228
- package/dist/shadow-pnpm-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin2.js +319 -0
- package/dist/shadow-pnpm-bin2.js.map +1 -0
- package/dist/shadow-yarn-bin.js +58 -150
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/analytics/cmd-analytics.d.mts.map +1 -1
- package/dist/types/commands/analytics/output-analytics.d.mts.map +1 -1
- package/dist/types/commands/audit-log/cmd-audit-log.d.mts.map +1 -1
- package/dist/types/commands/audit-log/output-audit-log.d.mts.map +1 -1
- package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-auto.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-get.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-list.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-set.d.mts.map +1 -1
- package/dist/types/commands/config/cmd-config-unset.d.mts.map +1 -1
- package/dist/types/commands/config/handle-config-set.d.mts.map +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/pull-request.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-conda.d.mts.map +1 -1
- package/dist/types/commands/npm/cmd-npm.d.mts.map +1 -1
- package/dist/types/commands/optimize/handle-optimize.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-dependencies.d.mts.map +1 -1
- package/dist/types/commands/organization/cmd-organization-list.d.mts.map +1 -1
- package/dist/types/commands/organization/handle-dependencies.d.mts.map +1 -1
- package/dist/types/commands/organization/handle-organization-list.d.mts.map +1 -1
- package/dist/types/commands/package/handle-purl-deep-score.d.mts.map +1 -1
- package/dist/types/commands/package/handle-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/pnpm/cmd-pnpm.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-list.d.mts.map +1 -1
- package/dist/types/commands/repository/cmd-repository-view.d.mts.map +1 -1
- package/dist/types/commands/repository/handle-create-repo.d.mts.map +1 -1
- package/dist/types/commands/scan/cmd-scan-diff.d.mts.map +1 -1
- package/dist/types/commands/scan/create-scan-from-github.d.mts.map +1 -1
- package/dist/types/commands/scan/fetch-report-data.d.mts.map +1 -1
- package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
- package/dist/types/commands/wrapper/postinstall-wrapper.d.mts.map +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
- package/dist/types/constants.d.mts +1 -0
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/flags.d.mts.map +1 -1
- package/dist/types/shadow/common.d.mts +31 -0
- package/dist/types/shadow/common.d.mts.map +1 -0
- package/dist/types/shadow/npm/bin.d.mts +4 -10
- package/dist/types/shadow/npm/bin.d.mts.map +1 -1
- package/dist/types/shadow/npm-base.d.mts +11 -0
- package/dist/types/shadow/npm-base.d.mts.map +1 -0
- package/dist/types/shadow/npx/bin.d.mts +5 -0
- package/dist/types/shadow/npx/bin.d.mts.map +1 -0
- package/dist/types/shadow/pnpm/bin.d.mts +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
- package/dist/types/shadow/stdio-ipc.d.mts +7 -0
- package/dist/types/shadow/stdio-ipc.d.mts.map +1 -0
- package/dist/types/shadow/yarn/bin.d.mts +1 -1
- package/dist/types/shadow/yarn/bin.d.mts.map +1 -1
- package/dist/types/utils/agent.d.mts.map +1 -1
- package/dist/types/utils/alerts-map.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/cmd.d.mts.map +1 -1
- package/dist/types/utils/coana.d.mts.map +1 -1
- package/dist/types/utils/color-or-markdown.d.mts.map +1 -1
- package/dist/types/utils/config.d.mts.map +1 -1
- package/dist/types/utils/cve-to-ghsa.d.mts.map +1 -1
- package/dist/types/utils/debug.d.mts +45 -0
- package/dist/types/utils/debug.d.mts.map +1 -0
- package/dist/types/utils/dlx.d.mts +1 -1
- package/dist/types/utils/dlx.d.mts.map +1 -1
- package/dist/types/utils/ecosystem.d.mts.map +1 -1
- package/dist/types/utils/errors.d.mts +48 -0
- package/dist/types/utils/errors.d.mts.map +1 -1
- package/dist/types/utils/filter-config.d.mts.map +1 -1
- package/dist/types/utils/fs.d.mts.map +1 -1
- package/dist/types/utils/get-output-kind.d.mts.map +1 -1
- package/dist/types/utils/git.d.mts.map +1 -1
- package/dist/types/utils/github.d.mts.map +1 -1
- package/dist/types/utils/markdown.d.mts +17 -0
- package/dist/types/utils/markdown.d.mts.map +1 -1
- package/dist/types/utils/meow-with-subcommands.d.mts.map +1 -1
- package/dist/types/utils/npm-package-arg.d.mts +5 -1
- package/dist/types/utils/npm-package-arg.d.mts.map +1 -1
- package/dist/types/utils/npm-paths.d.mts.map +1 -1
- package/dist/types/utils/npm-spec.d.mts +57 -0
- package/dist/types/utils/npm-spec.d.mts.map +1 -0
- package/dist/types/utils/output-formatting.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/pnpm-paths.d.mts.map +1 -1
- package/dist/types/utils/purl-to-ghsa.d.mts.map +1 -1
- package/dist/types/utils/purl.d.mts +24 -0
- package/dist/types/utils/purl.d.mts.map +1 -1
- package/dist/types/utils/requirements.d.mts.map +1 -1
- package/dist/types/utils/sdk.d.mts.map +1 -1
- package/dist/types/utils/serialize-result-json.d.mts.map +1 -1
- package/dist/types/utils/socket-json.d.mts.map +1 -1
- package/dist/types/utils/socket-package-alert.d.mts.map +1 -1
- package/dist/types/utils/socket-url.d.mts.map +1 -1
- package/dist/types/utils/strings.d.mts +12 -0
- package/dist/types/utils/strings.d.mts.map +1 -1
- package/dist/types/utils/tildify.d.mts +0 -2
- package/dist/types/utils/tildify.d.mts.map +1 -1
- package/dist/types/utils/yarn-paths.d.mts.map +1 -1
- package/dist/utils.js +1303 -457
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +317 -316
- package/package.json +4 -4
- package/shadow-bin/npm +2 -2
- package/shadow-bin/npx +2 -2
- package/shadow-bin/pnpm +2 -2
- package/shadow-bin/yarn +2 -2
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.js');
|
|
4
|
+
var agent = require('../external/@socketsecurity/registry/lib/agent');
|
|
5
|
+
var require$$9 = require('../external/@socketsecurity/registry/lib/debug');
|
|
6
|
+
var require$$11 = require('../external/@socketsecurity/registry/lib/objects');
|
|
7
|
+
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
8
|
+
var path = require('node:path');
|
|
9
|
+
var vendor = require('./vendor.js');
|
|
10
|
+
var utils = require('./utils.js');
|
|
11
|
+
|
|
12
|
+
async function installLinks(shadowBinPath, binName) {
|
|
13
|
+
const isNpx = binName === 'npx';
|
|
14
|
+
// Find package manager being shadowed by this process.
|
|
15
|
+
const binPath = isNpx ? utils.getNpxBinPath() : utils.getNpmBinPath();
|
|
16
|
+
const {
|
|
17
|
+
WIN32
|
|
18
|
+
} = constants.default;
|
|
19
|
+
// TODO: Is this early exit needed?
|
|
20
|
+
if (WIN32 && binPath) {
|
|
21
|
+
return binPath;
|
|
22
|
+
}
|
|
23
|
+
const shadowed = isNpx ? utils.isNpxBinPathShadowed() : utils.isNpmBinPathShadowed();
|
|
24
|
+
// Move our bin directory to front of PATH so its found first.
|
|
25
|
+
if (!shadowed) {
|
|
26
|
+
if (WIN32) {
|
|
27
|
+
await vendor.libExports(path.join(constants.default.distPath, `${binName}-cli.js`), path.join(shadowBinPath, binName));
|
|
28
|
+
}
|
|
29
|
+
const {
|
|
30
|
+
env
|
|
31
|
+
} = process;
|
|
32
|
+
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
33
|
+
}
|
|
34
|
+
return binPath;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Ensures stdio configuration includes IPC channel for process communication.
|
|
39
|
+
* Converts various stdio formats to include 'ipc' as the fourth element.
|
|
40
|
+
*/
|
|
41
|
+
function ensureIpcInStdio(stdio) {
|
|
42
|
+
if (typeof stdio === 'string') {
|
|
43
|
+
return [stdio, stdio, stdio, 'ipc'];
|
|
44
|
+
} else if (Array.isArray(stdio)) {
|
|
45
|
+
if (!stdio.includes('ipc')) {
|
|
46
|
+
return stdio.concat('ipc');
|
|
47
|
+
}
|
|
48
|
+
return stdio;
|
|
49
|
+
} else {
|
|
50
|
+
return ['pipe', 'pipe', 'pipe', 'ipc'];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function shadowNpmBase(binName, args = process.argv.slice(2), options, extra) {
|
|
55
|
+
const {
|
|
56
|
+
env: spawnEnv,
|
|
57
|
+
ipc,
|
|
58
|
+
...spawnOpts
|
|
59
|
+
} = {
|
|
60
|
+
__proto__: null,
|
|
61
|
+
...options
|
|
62
|
+
};
|
|
63
|
+
const cwd = require$$11.getOwn(spawnOpts, 'cwd') ?? process.cwd();
|
|
64
|
+
const isShadowNpm = binName === constants.NPM;
|
|
65
|
+
const terminatorPos = args.indexOf('--');
|
|
66
|
+
const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos);
|
|
67
|
+
const nodeOptionsArg = rawBinArgs.findLast(agent.isNpmNodeOptionsFlag);
|
|
68
|
+
const progressArg = rawBinArgs.findLast(agent.isNpmProgressFlag) !== '--no-progress';
|
|
69
|
+
const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
|
|
70
|
+
const permArgs = isShadowNpm && constants.default.SUPPORTS_NODE_PERMISSION_FLAG ? ['--permission', '--allow-child-process',
|
|
71
|
+
// '--allow-addons',
|
|
72
|
+
// '--allow-wasi',
|
|
73
|
+
// Allow all reads because npm walks up directories looking for config
|
|
74
|
+
// and package.json files.
|
|
75
|
+
'--allow-fs-read=*', `--allow-fs-write=${cwd}/*`, `--allow-fs-write=${constants.default.npmGlobalPrefix}/*`, `--allow-fs-write=${constants.default.npmCachePath}/*`] : [];
|
|
76
|
+
const useAudit = rawBinArgs.includes('--audit');
|
|
77
|
+
const useDebug = require$$9.isDebug('stdio');
|
|
78
|
+
const useNodeOptions = nodeOptionsArg || permArgs.length;
|
|
79
|
+
const binArgs = rawBinArgs.filter(a => !agent.isNpmAuditFlag(a) && !agent.isNpmProgressFlag(a));
|
|
80
|
+
const isSilent = !useDebug && !binArgs.some(agent.isNpmLoglevelFlag);
|
|
81
|
+
// The default value of loglevel is "notice". We default to "error" which is
|
|
82
|
+
// two levels quieter.
|
|
83
|
+
const logLevelArgs = isSilent ? ['--loglevel', 'error'] : [];
|
|
84
|
+
const noAuditArgs = useAudit || !(await utils.findUp(constants.NODE_MODULES, {
|
|
85
|
+
cwd,
|
|
86
|
+
onlyDirectories: true
|
|
87
|
+
})) ? [] : ['--no-audit'];
|
|
88
|
+
const stdio = ensureIpcInStdio(require$$11.getOwn(spawnOpts, 'stdio'));
|
|
89
|
+
const realBinPath = await installLinks(constants.default.shadowBinPath, binName);
|
|
90
|
+
const spawnPromise = spawn.spawn(constants.default.execPath, [...constants.default.nodeNoWarningsFlags, ...constants.default.nodeDebugFlags, ...constants.default.nodeHardenFlags, ...constants.default.nodeMemoryFlags, ...(constants.default.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? ['--require', constants.default.instrumentWithSentryPath] : []), '--require', constants.default.shadowNpmInjectPath, realBinPath, ...noAuditArgs, ...(useNodeOptions ? [`--node-options='${nodeOptionsArg ? nodeOptionsArg.slice(15) : ''}${utils.cmdFlagsToString(permArgs)}'`] : []), '--no-fund',
|
|
91
|
+
// Add '--no-progress' to fix input being swallowed by the npm spinner.
|
|
92
|
+
'--no-progress',
|
|
93
|
+
// Add '--loglevel=error' if a loglevel flag is not provided and the
|
|
94
|
+
// SOCKET_CLI_DEBUG environment variable is not truthy.
|
|
95
|
+
...logLevelArgs, ...binArgs, ...otherArgs], {
|
|
96
|
+
...spawnOpts,
|
|
97
|
+
env: {
|
|
98
|
+
...process.env,
|
|
99
|
+
...constants.default.processEnv,
|
|
100
|
+
...spawnEnv
|
|
101
|
+
},
|
|
102
|
+
stdio
|
|
103
|
+
}, extra);
|
|
104
|
+
spawnPromise.process.send({
|
|
105
|
+
[constants.default.SOCKET_IPC_HANDSHAKE]: {
|
|
106
|
+
[constants.default.SOCKET_CLI_SHADOW_API_TOKEN]: utils.getPublicApiToken(),
|
|
107
|
+
[constants.default.SOCKET_CLI_SHADOW_BIN]: binName,
|
|
108
|
+
[constants.default.SOCKET_CLI_SHADOW_PROGRESS]: progressArg,
|
|
109
|
+
...ipc
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
spawnPromise
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async function shadowNpmBin(args = process.argv.slice(2), options, extra) {
|
|
118
|
+
return await shadowNpmBase(constants.NPM, args, options, extra);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
exports.ensureIpcInStdio = ensureIpcInStdio;
|
|
122
|
+
exports.shadowNpmBase = shadowNpmBase;
|
|
123
|
+
exports.shadowNpmBin = shadowNpmBin;
|
|
124
|
+
//# debugId=2c1bb1bc-32c9-4dd7-8742-11961fead20c
|
|
125
|
+
//# sourceMappingURL=shadow-npm-bin2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow-npm-bin2.js","sources":["../src/shadow/npm/link.mts","../src/shadow/stdio-ipc.mts","../src/shadow/npm-base.mts","../src/shadow/npm/bin.mts"],"sourcesContent":["import path from 'node:path'\n\nimport cmdShim from 'cmd-shim'\n\nimport constants from '../../constants.mts'\nimport {\n getNpmBinPath,\n getNpxBinPath,\n isNpmBinPathShadowed,\n isNpxBinPathShadowed,\n} from '../../utils/npm-paths.mts'\n\nexport async function installLinks(\n shadowBinPath: string,\n binName: 'npm' | 'npx',\n): Promise<string> {\n const isNpx = binName === 'npx'\n // Find package manager being shadowed by this process.\n const binPath = isNpx ? getNpxBinPath() : getNpmBinPath()\n const { WIN32 } = constants\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n const shadowed = isNpx ? isNpxBinPathShadowed() : isNpmBinPathShadowed()\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n path.join(constants.distPath, `${binName}-cli.js`),\n path.join(shadowBinPath, binName),\n )\n }\n const { env } = process\n env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`\n }\n return binPath\n}\n","import type { StdioOptions } from 'node:child_process'\n\n/**\n * Ensures stdio configuration includes IPC channel for process communication.\n * Converts various stdio formats to include 'ipc' as the fourth element.\n */\nexport function ensureIpcInStdio(\n stdio: StdioOptions | undefined,\n): StdioOptions {\n if (typeof stdio === 'string') {\n return [stdio, stdio, stdio, 'ipc']\n } else if (Array.isArray(stdio)) {\n if (!stdio.includes('ipc')) {\n return stdio.concat('ipc')\n }\n return stdio\n } else {\n return ['pipe', 'pipe', 'pipe', 'ipc']\n }\n}\n","import {\n isNpmAuditFlag,\n isNpmLoglevelFlag,\n isNpmNodeOptionsFlag,\n isNpmProgressFlag,\n} from '@socketsecurity/registry/lib/agent'\nimport { isDebug } from '@socketsecurity/registry/lib/debug'\nimport { getOwn } from '@socketsecurity/registry/lib/objects'\nimport { spawn } from '@socketsecurity/registry/lib/spawn'\n\nimport { installLinks } from './npm/link.mts'\nimport { ensureIpcInStdio } from './stdio-ipc.mts'\nimport constants, { NODE_MODULES, NPM, NPX } from '../constants.mts'\nimport { cmdFlagsToString } from '../utils/cmd.mts'\nimport { findUp } from '../utils/fs.mts'\nimport { getPublicApiToken } from '../utils/sdk.mts'\n\nimport type { IpcObject } from '../constants.mts'\nimport type {\n SpawnExtra,\n SpawnOptions,\n SpawnResult,\n} from '@socketsecurity/registry/lib/spawn'\n\nexport type ShadowBinOptions = SpawnOptions & {\n ipc?: IpcObject | undefined\n}\n\nexport type ShadowBinResult = {\n spawnPromise: SpawnResult<string, SpawnExtra | undefined>\n}\n\nexport default async function shadowNpmBase(\n binName: typeof NPM | typeof NPX,\n args: string[] | readonly string[] = process.argv.slice(2),\n options?: ShadowBinOptions | undefined,\n extra?: SpawnExtra | undefined,\n): Promise<ShadowBinResult> {\n const {\n env: spawnEnv,\n ipc,\n ...spawnOpts\n } = { __proto__: null, ...options } as ShadowBinOptions\n const cwd = getOwn(spawnOpts, 'cwd') ?? process.cwd()\n const isShadowNpm = binName === NPM\n const terminatorPos = args.indexOf('--')\n const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n const nodeOptionsArg = rawBinArgs.findLast(isNpmNodeOptionsFlag)\n const progressArg = rawBinArgs.findLast(isNpmProgressFlag) !== '--no-progress'\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n const permArgs =\n isShadowNpm && constants.SUPPORTS_NODE_PERMISSION_FLAG\n ? [\n '--permission',\n '--allow-child-process',\n // '--allow-addons',\n // '--allow-wasi',\n // Allow all reads because npm walks up directories looking for config\n // and package.json files.\n '--allow-fs-read=*',\n `--allow-fs-write=${cwd}/*`,\n `--allow-fs-write=${constants.npmGlobalPrefix}/*`,\n `--allow-fs-write=${constants.npmCachePath}/*`,\n ]\n : []\n\n const useAudit = rawBinArgs.includes('--audit')\n const useDebug = isDebug('stdio')\n const useNodeOptions = nodeOptionsArg || permArgs.length\n const binArgs = rawBinArgs.filter(\n a => !isNpmAuditFlag(a) && !isNpmProgressFlag(a),\n )\n const isSilent = !useDebug && !binArgs.some(isNpmLoglevelFlag)\n // The default value of loglevel is \"notice\". We default to \"error\" which is\n // two levels quieter.\n const logLevelArgs = isSilent ? ['--loglevel', 'error'] : []\n const noAuditArgs =\n useAudit || !(await findUp(NODE_MODULES, { cwd, onlyDirectories: true }))\n ? []\n : ['--no-audit']\n\n const stdio = ensureIpcInStdio(getOwn(spawnOpts, 'stdio'))\n\n const realBinPath = await installLinks(constants.shadowBinPath, binName)\n\n const spawnPromise = spawn(\n constants.execPath,\n [\n ...constants.nodeNoWarningsFlags,\n ...constants.nodeDebugFlags,\n ...constants.nodeHardenFlags,\n ...constants.nodeMemoryFlags,\n ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD\n ? ['--require', constants.instrumentWithSentryPath]\n : []),\n '--require',\n constants.shadowNpmInjectPath,\n realBinPath,\n ...noAuditArgs,\n ...(useNodeOptions\n ? [\n `--node-options='${nodeOptionsArg ? nodeOptionsArg.slice(15) : ''}${cmdFlagsToString(permArgs)}'`,\n ]\n : []),\n '--no-fund',\n // Add '--no-progress' to fix input being swallowed by the npm spinner.\n '--no-progress',\n // Add '--loglevel=error' if a loglevel flag is not provided and the\n // SOCKET_CLI_DEBUG environment variable is not truthy.\n ...logLevelArgs,\n ...binArgs,\n ...otherArgs,\n ],\n {\n ...spawnOpts,\n env: {\n ...process.env,\n ...constants.processEnv,\n ...spawnEnv,\n },\n stdio,\n },\n extra,\n )\n\n spawnPromise.process.send({\n [constants.SOCKET_IPC_HANDSHAKE]: {\n [constants.SOCKET_CLI_SHADOW_API_TOKEN]: getPublicApiToken(),\n [constants.SOCKET_CLI_SHADOW_BIN]: binName,\n [constants.SOCKET_CLI_SHADOW_PROGRESS]: progressArg,\n ...ipc,\n },\n })\n\n return { spawnPromise }\n}\n","import { NPM } from '../../constants.mts'\nimport shadowNpmBase from '../npm-base.mts'\n\nimport type { ShadowBinOptions, ShadowBinResult } from '../npm-base.mts'\nimport type { SpawnExtra } from '@socketsecurity/registry/lib/spawn'\n\nexport type { ShadowBinOptions, ShadowBinResult }\n\nexport default async function shadowNpmBin(\n args: string[] | readonly string[] = process.argv.slice(2),\n options?: ShadowBinOptions | undefined,\n extra?: SpawnExtra | undefined,\n): Promise<ShadowBinResult> {\n return await shadowNpmBase(NPM, args, options, extra)\n}\n"],"names":["WIN32","env","__proto__","onlyDirectories","stdio","spawnPromise"],"mappings":";;;;;;;;;;;AAYO;AAIL;AACA;;;AAEQA;AAAM;AACd;;AAEE;AACF;;AAEA;;AAEE;;AAKA;;AACQC;AAAI;AACZA;AACF;AACA;AACF;;ACnCA;AACA;AACA;AACA;AACO;AAGL;;;AAGE;AACE;AACF;AACA;AACF;;AAEA;AACF;;ACae;;AAOXA;;;AAGF;AAAMC;;;AACN;AACA;AACA;AACA;AACA;;AAEA;;AAMQ;AACA;AACA;AACA;AACA;AAOR;AACA;AACA;AACA;;AAIA;AACA;;;;AAGkDC;AAAsB;;;AAQxE;AAoBI;;AAEA;AACA;;AAMA;AACAF;;;;;AAKAG;;AAKJC;;AAEI;AACA;AACA;;AAEF;AACF;;AAESA;;AACX;;AC/He;;AAMf;;;;","debugId":"2c1bb1bc-32c9-4dd7-8742-11961fead20c"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('./constants.js');
|
|
4
|
+
var shadowNpmBin = require('./shadow-npm-bin2.js');
|
|
5
|
+
|
|
6
|
+
async function shadowNpxBin(args = process.argv.slice(2), options, extra) {
|
|
7
|
+
return await shadowNpmBin.shadowNpmBase(constants.NPX, args, options, extra);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
module.exports = shadowNpxBin;
|
|
11
|
+
//# debugId=78c6da12-4727-423f-9815-2c7486bbf7e5
|
|
12
|
+
//# sourceMappingURL=shadow-npx-bin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow-npx-bin.js","sources":["../src/shadow/npx/bin.mts"],"sourcesContent":["import { NPX } from '../../constants.mts'\nimport shadowNpmBase from '../npm-base.mts'\n\nimport type { ShadowBinOptions, ShadowBinResult } from '../npm-base.mts'\nimport type { SpawnExtra } from '@socketsecurity/registry/lib/spawn'\n\nexport type { ShadowBinOptions, ShadowBinResult }\n\nexport default async function shadowNpxBin(\n args: string[] | readonly string[] = process.argv.slice(2),\n options?: ShadowBinOptions | undefined,\n extra?: SpawnExtra | undefined,\n): Promise<ShadowBinResult> {\n return await shadowNpmBase(NPX, args, options, extra)\n}\n"],"names":[],"mappings":";;;;;AAQe;;AAMf;;","debugId":"78c6da12-4727-423f-9815-2c7486bbf7e5"}
|
package/dist/shadow-pnpm-bin.js
CHANGED
|
@@ -1,233 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
var shadowPnpmBin = require('./shadow-pnpm-bin2.js');
|
|
2
3
|
|
|
3
|
-
var fs = require('node:fs');
|
|
4
|
-
var path = require('node:path');
|
|
5
|
-
var require$$0 = require('node:url');
|
|
6
|
-
var require$$9 = require('../external/@socketsecurity/registry/lib/debug');
|
|
7
|
-
var logger = require('../external/@socketsecurity/registry/lib/logger');
|
|
8
|
-
var spawn = require('../external/@socketsecurity/registry/lib/spawn');
|
|
9
|
-
var vendor = require('./vendor.js');
|
|
10
|
-
var constants = require('./constants.js');
|
|
11
|
-
var utils = require('./utils.js');
|
|
12
4
|
|
|
13
|
-
async function installLinks(shadowBinPath, _binName) {
|
|
14
|
-
// Find pnpm being shadowed by this process.
|
|
15
|
-
const binPath = utils.getPnpmBinPath();
|
|
16
|
-
const {
|
|
17
|
-
WIN32
|
|
18
|
-
} = constants.default;
|
|
19
5
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return binPath;
|
|
23
|
-
}
|
|
24
|
-
const shadowed = utils.isPnpmBinPathShadowed();
|
|
25
|
-
|
|
26
|
-
// Move our bin directory to front of PATH so its found first.
|
|
27
|
-
if (!shadowed) {
|
|
28
|
-
if (WIN32) {
|
|
29
|
-
await vendor.libExports(path.join(constants.default.distPath, 'pnpm-cli.js'), path.join(shadowBinPath, 'pnpm'));
|
|
30
|
-
}
|
|
31
|
-
const {
|
|
32
|
-
env
|
|
33
|
-
} = process;
|
|
34
|
-
env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`;
|
|
35
|
-
}
|
|
36
|
-
return binPath;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const INSTALL_COMMANDS = new Set(['add', 'i', 'install', 'install-test', 'it', 'update', 'up']);
|
|
40
|
-
async function shadowPnpm(args = process.argv.slice(2), options, extra) {
|
|
41
|
-
const opts = {
|
|
42
|
-
__proto__: null,
|
|
43
|
-
...options
|
|
44
|
-
};
|
|
45
|
-
const {
|
|
46
|
-
env: spawnEnv,
|
|
47
|
-
ipc,
|
|
48
|
-
...spawnOpts
|
|
49
|
-
} = opts;
|
|
50
|
-
let {
|
|
51
|
-
cwd = process.cwd()
|
|
52
|
-
} = opts;
|
|
53
|
-
if (cwd instanceof URL) {
|
|
54
|
-
cwd = require$$0.fileURLToPath(cwd);
|
|
55
|
-
}
|
|
56
|
-
const terminatorPos = args.indexOf('--');
|
|
57
|
-
const rawPnpmArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos);
|
|
58
|
-
const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos);
|
|
59
|
-
|
|
60
|
-
// Check if this is an install-type command that needs security scanning
|
|
61
|
-
const command = rawPnpmArgs[0];
|
|
62
|
-
const needsScanning = command && INSTALL_COMMANDS.has(command);
|
|
63
|
-
|
|
64
|
-
// Get pnpm path
|
|
65
|
-
const realPnpmPath = await installLinks(constants.default.shadowBinPath);
|
|
66
|
-
const permArgs = ['--reporter=silent'];
|
|
67
|
-
const prefixArgs = [];
|
|
68
|
-
const suffixArgs = [...rawPnpmArgs, ...permArgs, ...otherArgs];
|
|
69
|
-
if (needsScanning && !rawPnpmArgs.includes(constants.FLAG_DRY_RUN)) {
|
|
70
|
-
const acceptRisks = Boolean(process.env['SOCKET_CLI_ACCEPT_RISKS']);
|
|
71
|
-
const viewAllRisks = Boolean(process.env['SOCKET_CLI_VIEW_ALL_RISKS']);
|
|
72
|
-
|
|
73
|
-
// Extract package names from command arguments before any downloads
|
|
74
|
-
const packagePurls = [];
|
|
75
|
-
if (command === 'add') {
|
|
76
|
-
// For 'pnpm add package1 package2@version', get packages from args
|
|
77
|
-
const packageArgs = rawPnpmArgs.slice(1).filter(arg => !arg.startsWith('-') && arg !== '--');
|
|
78
|
-
for (const pkgSpec of packageArgs) {
|
|
79
|
-
// Handle package specs like 'lodash', 'lodash@4.17.21', '@types/node@^20.0.0'
|
|
80
|
-
let name;
|
|
81
|
-
let version;
|
|
82
|
-
if (pkgSpec.startsWith('@')) {
|
|
83
|
-
// Scoped package: @scope/name or @scope/name@version
|
|
84
|
-
const parts = pkgSpec.split('@');
|
|
85
|
-
if (parts.length === 2) {
|
|
86
|
-
// @scope/name (no version)
|
|
87
|
-
name = pkgSpec;
|
|
88
|
-
} else {
|
|
89
|
-
// @scope/name@version
|
|
90
|
-
name = `@${parts[1]}`;
|
|
91
|
-
version = parts[2];
|
|
92
|
-
}
|
|
93
|
-
} else {
|
|
94
|
-
// Regular package: name or name@version
|
|
95
|
-
const atIndex = pkgSpec.indexOf('@');
|
|
96
|
-
if (atIndex === -1) {
|
|
97
|
-
name = pkgSpec;
|
|
98
|
-
} else {
|
|
99
|
-
name = pkgSpec.slice(0, atIndex);
|
|
100
|
-
version = pkgSpec.slice(atIndex + 1);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (name) {
|
|
104
|
-
packagePurls.push(version ? utils.idToNpmPurl(`${name}@${version}`) : utils.idToNpmPurl(name));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
} else if (['install', 'i', 'update', 'up'].includes(command)) {
|
|
108
|
-
// For install/update, scan all dependencies from pnpm-lock.yaml
|
|
109
|
-
const pnpmLockPath = path.join(cwd, constants.PNPM_LOCK_YAML);
|
|
110
|
-
if (fs.existsSync(pnpmLockPath)) {
|
|
111
|
-
try {
|
|
112
|
-
const lockfileContent = await utils.readPnpmLockfile(pnpmLockPath);
|
|
113
|
-
if (lockfileContent) {
|
|
114
|
-
const lockfile = utils.parsePnpmLockfile(lockfileContent);
|
|
115
|
-
if (lockfile) {
|
|
116
|
-
// Use existing function to scan the entire lockfile
|
|
117
|
-
if (require$$9.isDebug()) {
|
|
118
|
-
require$$9.debugFn('notice', `scanning: all dependencies from ${constants.PNPM_LOCK_YAML}`);
|
|
119
|
-
}
|
|
120
|
-
const alertsMap = await utils.getAlertsMapFromPnpmLockfile(lockfile, {
|
|
121
|
-
nothrow: true,
|
|
122
|
-
filter: acceptRisks ? {
|
|
123
|
-
actions: ['error'],
|
|
124
|
-
blocked: true
|
|
125
|
-
} : {
|
|
126
|
-
actions: ['error', 'monitor', 'warn']
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
if (alertsMap.size) {
|
|
130
|
-
process.exitCode = 1;
|
|
131
|
-
utils.logAlertsMap(alertsMap, {
|
|
132
|
-
hideAt: viewAllRisks ? 'none' : 'middle',
|
|
133
|
-
output: process.stderr
|
|
134
|
-
});
|
|
135
|
-
const errorMessage = `Socket pnpm exiting due to risks.${viewAllRisks ? '' : `\nView all risks - Rerun with environment variable ${constants.default.SOCKET_CLI_VIEW_ALL_RISKS}=1.`}${acceptRisks ? '' : `\nAccept risks - Rerun with environment variable ${constants.default.SOCKET_CLI_ACCEPT_RISKS}=1.`}`.trim();
|
|
136
|
-
logger.logger.error(errorMessage);
|
|
137
|
-
// eslint-disable-next-line n/no-process-exit
|
|
138
|
-
process.exit(1);
|
|
139
|
-
// This line is never reached in production, but helps tests.
|
|
140
|
-
throw new Error('process.exit called');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Return early since we've already done the scanning
|
|
144
|
-
if (require$$9.isDebug()) {
|
|
145
|
-
require$$9.debugFn('notice', 'complete: lockfile scanning, proceeding with install');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
} catch (e) {
|
|
150
|
-
if (require$$9.isDebug()) {
|
|
151
|
-
require$$9.debugFn('error', 'caught: pnpm lockfile scanning error');
|
|
152
|
-
require$$9.debugDir('inspect', {
|
|
153
|
-
error: e
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} else if (require$$9.isDebug()) {
|
|
158
|
-
require$$9.debugFn('notice', 'skip: no pnpm-lock.yaml found, skipping bulk install scanning');
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
if (packagePurls.length > 0) {
|
|
162
|
-
if (require$$9.isDebug()) {
|
|
163
|
-
require$$9.debugFn('notice', 'scanning: packages before download');
|
|
164
|
-
require$$9.debugDir('inspect', {
|
|
165
|
-
packagePurls
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
const alertsMap = await utils.getAlertsMapFromPurls(packagePurls, {
|
|
170
|
-
nothrow: true,
|
|
171
|
-
filter: acceptRisks ? {
|
|
172
|
-
actions: ['error'],
|
|
173
|
-
blocked: true
|
|
174
|
-
} : {
|
|
175
|
-
actions: ['error', 'monitor', 'warn']
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
if (alertsMap.size) {
|
|
179
|
-
process.exitCode = 1;
|
|
180
|
-
utils.logAlertsMap(alertsMap, {
|
|
181
|
-
hideAt: viewAllRisks ? 'none' : 'middle',
|
|
182
|
-
output: process.stderr
|
|
183
|
-
});
|
|
184
|
-
const errorMessage = `
|
|
185
|
-
Socket pnpm exiting due to risks.${viewAllRisks ? '' : `\nView all risks - Rerun with environment variable ${constants.default.SOCKET_CLI_VIEW_ALL_RISKS}=1.`}${acceptRisks ? '' : `\nAccept risks - Rerun with environment variable ${constants.default.SOCKET_CLI_ACCEPT_RISKS}=1.`}`.trim();
|
|
186
|
-
logger.logger.error(errorMessage);
|
|
187
|
-
// eslint-disable-next-line n/no-process-exit
|
|
188
|
-
process.exit(1);
|
|
189
|
-
// This line is never reached in production, but helps tests.
|
|
190
|
-
throw new Error('process.exit called');
|
|
191
|
-
}
|
|
192
|
-
} catch (e) {
|
|
193
|
-
// Re-throw process.exit errors from tests.
|
|
194
|
-
if (e instanceof Error && e.message === 'process.exit called') {
|
|
195
|
-
throw e;
|
|
196
|
-
}
|
|
197
|
-
if (require$$9.isDebug()) {
|
|
198
|
-
require$$9.debugFn('error', 'caught: package scanning error');
|
|
199
|
-
require$$9.debugDir('inspect', {
|
|
200
|
-
error: e
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
// Continue with installation if scanning fails
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (require$$9.isDebug()) {
|
|
207
|
-
require$$9.debugFn('notice', 'complete: scanning, proceeding with install');
|
|
208
|
-
require$$9.debugDir('inspect', {
|
|
209
|
-
args: rawPnpmArgs.slice(1)
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
const argsToString = utils.cmdFlagsToString([...prefixArgs, ...suffixArgs]);
|
|
214
|
-
const env = {
|
|
215
|
-
...process.env,
|
|
216
|
-
...spawnEnv
|
|
217
|
-
};
|
|
218
|
-
if (require$$9.isDebug()) {
|
|
219
|
-
require$$9.debugFn('notice', `spawn: pnpm shadow bin ${realPnpmPath} ${argsToString}`);
|
|
220
|
-
}
|
|
221
|
-
const spawnPromise = spawn.spawn(realPnpmPath, [...prefixArgs, ...suffixArgs], {
|
|
222
|
-
...spawnOpts,
|
|
223
|
-
env,
|
|
224
|
-
extra
|
|
225
|
-
});
|
|
226
|
-
return {
|
|
227
|
-
spawnPromise
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
module.exports = shadowPnpm;
|
|
232
|
-
//# debugId=f69cd503-77eb-4641-a4ae-622c377f99cb
|
|
6
|
+
module.exports = shadowPnpmBin.shadowPnpmBin;
|
|
7
|
+
//# debugId=26f08621-821f-4156-93c1-18cf372d6d32
|
|
233
8
|
//# sourceMappingURL=shadow-pnpm-bin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shadow-pnpm-bin.js","sources":["../src/shadow/pnpm/link.mts","../src/shadow/pnpm/bin.mts"],"sourcesContent":["import path from 'node:path'\n\nimport cmdShim from 'cmd-shim'\n\nimport constants from '../../constants.mts'\nimport {\n getPnpmBinPath,\n isPnpmBinPathShadowed,\n} from '../../utils/pnpm-paths.mts'\n\nexport async function installLinks(\n shadowBinPath: string,\n _binName: 'pnpm',\n): Promise<string> {\n // Find pnpm being shadowed by this process.\n const binPath = getPnpmBinPath()\n const { WIN32 } = constants\n\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n\n const shadowed = isPnpmBinPathShadowed()\n\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n path.join(constants.distPath, 'pnpm-cli.js'),\n path.join(shadowBinPath, 'pnpm'),\n )\n }\n const { env } = process\n env['PATH'] = `${shadowBinPath}${path.delimiter}${env['PATH']}`\n }\n\n return binPath\n}\n","import { existsSync } from 'node:fs'\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nimport { debugDir, debugFn, isDebug } from '@socketsecurity/registry/lib/debug'\nimport { logger } from '@socketsecurity/registry/lib/logger'\nimport { spawn } from '@socketsecurity/registry/lib/spawn'\n\nimport { installLinks } from './link.mts'\nimport constants, { FLAG_DRY_RUN, PNPM_LOCK_YAML } from '../../constants.mts'\nimport {\n getAlertsMapFromPnpmLockfile,\n getAlertsMapFromPurls,\n} from '../../utils/alerts-map.mts'\nimport { cmdFlagsToString } from '../../utils/cmd.mts'\nimport { parsePnpmLockfile, readPnpmLockfile } from '../../utils/pnpm.mts'\nimport { logAlertsMap } from '../../utils/socket-package-alert.mts'\nimport { idToNpmPurl } from '../../utils/spec.mts'\n\nimport type { IpcObject } from '../../constants.mts'\nimport type {\n SpawnExtra,\n SpawnOptions,\n SpawnResult,\n} from '@socketsecurity/registry/lib/spawn'\n\nexport type ShadowPnpmOptions = SpawnOptions & {\n ipc?: IpcObject | undefined\n}\n\nexport type ShadowPnpmResult = {\n spawnPromise: SpawnResult<string, SpawnExtra | undefined>\n}\n\nconst INSTALL_COMMANDS = new Set([\n 'add',\n 'i',\n 'install',\n 'install-test',\n 'it',\n 'update',\n 'up',\n])\n\nexport default async function shadowPnpm(\n args: string[] | readonly string[] = process.argv.slice(2),\n options?: ShadowPnpmOptions | undefined,\n extra?: SpawnExtra | undefined,\n): Promise<ShadowPnpmResult> {\n const opts = { __proto__: null, ...options } as ShadowPnpmOptions\n const { env: spawnEnv, ipc, ...spawnOpts } = opts\n\n let { cwd = process.cwd() } = opts\n if (cwd instanceof URL) {\n cwd = fileURLToPath(cwd)\n }\n\n const terminatorPos = args.indexOf('--')\n const rawPnpmArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n\n // Check if this is an install-type command that needs security scanning\n const command = rawPnpmArgs[0]\n const needsScanning = command && INSTALL_COMMANDS.has(command)\n\n // Get pnpm path\n const realPnpmPath = await installLinks(constants.shadowBinPath, 'pnpm')\n\n const permArgs = ['--reporter=silent']\n\n const prefixArgs: string[] = []\n const suffixArgs = [...rawPnpmArgs, ...permArgs, ...otherArgs]\n\n if (needsScanning && !rawPnpmArgs.includes(FLAG_DRY_RUN)) {\n const acceptRisks = Boolean(process.env['SOCKET_CLI_ACCEPT_RISKS'])\n const viewAllRisks = Boolean(process.env['SOCKET_CLI_VIEW_ALL_RISKS'])\n\n // Extract package names from command arguments before any downloads\n const packagePurls: string[] = []\n\n if (command === 'add') {\n // For 'pnpm add package1 package2@version', get packages from args\n const packageArgs = rawPnpmArgs\n .slice(1)\n .filter(arg => !arg.startsWith('-') && arg !== '--')\n\n for (const pkgSpec of packageArgs) {\n // Handle package specs like 'lodash', 'lodash@4.17.21', '@types/node@^20.0.0'\n let name: string\n let version: string | undefined\n\n if (pkgSpec.startsWith('@')) {\n // Scoped package: @scope/name or @scope/name@version\n const parts = pkgSpec.split('@')\n if (parts.length === 2) {\n // @scope/name (no version)\n name = pkgSpec\n } else {\n // @scope/name@version\n name = `@${parts[1]}`\n version = parts[2]\n }\n } else {\n // Regular package: name or name@version\n const atIndex = pkgSpec.indexOf('@')\n if (atIndex === -1) {\n name = pkgSpec\n } else {\n name = pkgSpec.slice(0, atIndex)\n version = pkgSpec.slice(atIndex + 1)\n }\n }\n\n if (name) {\n packagePurls.push(\n version ? idToNpmPurl(`${name}@${version}`) : idToNpmPurl(name),\n )\n }\n }\n } else if (['install', 'i', 'update', 'up'].includes(command)) {\n // For install/update, scan all dependencies from pnpm-lock.yaml\n const pnpmLockPath = path.join(cwd, PNPM_LOCK_YAML)\n if (existsSync(pnpmLockPath)) {\n try {\n const lockfileContent = await readPnpmLockfile(pnpmLockPath)\n if (lockfileContent) {\n const lockfile = parsePnpmLockfile(lockfileContent)\n if (lockfile) {\n // Use existing function to scan the entire lockfile\n if (isDebug()) {\n debugFn(\n 'notice',\n `scanning: all dependencies from ${PNPM_LOCK_YAML}`,\n )\n }\n\n const alertsMap = await getAlertsMapFromPnpmLockfile(lockfile, {\n nothrow: true,\n filter: acceptRisks\n ? { actions: ['error'], blocked: true }\n : { actions: ['error', 'monitor', 'warn'] },\n })\n\n if (alertsMap.size) {\n process.exitCode = 1\n logAlertsMap(alertsMap, {\n hideAt: viewAllRisks ? 'none' : 'middle',\n output: process.stderr,\n })\n\n const errorMessage = `Socket pnpm exiting due to risks.${\n viewAllRisks\n ? ''\n : `\\nView all risks - Rerun with environment variable ${constants.SOCKET_CLI_VIEW_ALL_RISKS}=1.`\n }${\n acceptRisks\n ? ''\n : `\\nAccept risks - Rerun with environment variable ${constants.SOCKET_CLI_ACCEPT_RISKS}=1.`\n }`.trim()\n\n logger.error(errorMessage)\n // eslint-disable-next-line n/no-process-exit\n process.exit(1)\n // This line is never reached in production, but helps tests.\n throw new Error('process.exit called')\n }\n\n // Return early since we've already done the scanning\n if (isDebug()) {\n debugFn(\n 'notice',\n 'complete: lockfile scanning, proceeding with install',\n )\n }\n }\n }\n } catch (e) {\n if (isDebug()) {\n debugFn('error', 'caught: pnpm lockfile scanning error')\n debugDir('inspect', { error: e })\n }\n }\n } else if (isDebug()) {\n debugFn(\n 'notice',\n 'skip: no pnpm-lock.yaml found, skipping bulk install scanning',\n )\n }\n }\n\n if (packagePurls.length > 0) {\n if (isDebug()) {\n debugFn('notice', 'scanning: packages before download')\n debugDir('inspect', { packagePurls })\n }\n\n try {\n const alertsMap = await getAlertsMapFromPurls(packagePurls, {\n nothrow: true,\n filter: acceptRisks\n ? { actions: ['error'], blocked: true }\n : { actions: ['error', 'monitor', 'warn'] },\n })\n\n if (alertsMap.size) {\n process.exitCode = 1\n logAlertsMap(alertsMap, {\n hideAt: viewAllRisks ? 'none' : 'middle',\n output: process.stderr,\n })\n\n const errorMessage = `\nSocket pnpm exiting due to risks.${\n viewAllRisks\n ? ''\n : `\\nView all risks - Rerun with environment variable ${constants.SOCKET_CLI_VIEW_ALL_RISKS}=1.`\n }${\n acceptRisks\n ? ''\n : `\\nAccept risks - Rerun with environment variable ${constants.SOCKET_CLI_ACCEPT_RISKS}=1.`\n }`.trim()\n\n logger.error(errorMessage)\n // eslint-disable-next-line n/no-process-exit\n process.exit(1)\n // This line is never reached in production, but helps tests.\n throw new Error('process.exit called')\n }\n } catch (e) {\n // Re-throw process.exit errors from tests.\n if (e instanceof Error && e.message === 'process.exit called') {\n throw e\n }\n if (isDebug()) {\n debugFn('error', 'caught: package scanning error')\n debugDir('inspect', { error: e })\n }\n // Continue with installation if scanning fails\n }\n }\n\n if (isDebug()) {\n debugFn('notice', 'complete: scanning, proceeding with install')\n debugDir('inspect', { args: rawPnpmArgs.slice(1) })\n }\n }\n\n const argsToString = cmdFlagsToString([...prefixArgs, ...suffixArgs])\n const env = {\n ...process.env,\n ...spawnEnv,\n } as Record<string, string>\n\n if (isDebug()) {\n debugFn('notice', `spawn: pnpm shadow bin ${realPnpmPath} ${argsToString}`)\n }\n\n const spawnPromise = spawn(realPnpmPath, [...prefixArgs, ...suffixArgs], {\n ...spawnOpts,\n env,\n extra,\n })\n\n return { spawnPromise }\n}\n"],"names":["WIN32","env","__proto__","cwd","name","version","packagePurls","debugFn","nothrow","blocked","actions","hideAt","logger","process","error","args","extra","spawnPromise"],"mappings":";;;;;;;;;;;;AAUO;AAIL;AACA;;AACQA;AAAM;;AAEd;;AAEE;AACF;AAEA;;AAEA;;AAEE;;AAKA;;AACQC;AAAI;AACZA;AACF;AAEA;AACF;;ACJA;AAUe;AAKb;AAAeC;;;;AACPD;;;AAAiC;;AAEnCE;AAAoB;;AAExBA;AACF;AAEA;AACA;AACA;;AAEA;AACA;;;AAGA;;AAGA;;;;;;;AASE;;;AAIE;;AAKA;AACE;AACA;AACA;AAEA;AACE;AACA;AACA;AACE;AACAC;AACF;AACE;AACAA;AACAC;AACF;AACF;AACE;AACA;AACA;AACED;AACF;;;AAGA;AACF;AAEA;AACEE;AAGF;AACF;AACF;AACE;;AAEA;;AAEI;AACA;AACE;AACA;AACE;;AAEEC;AAIF;AAEA;AACEC;;;AAE0BC;AAAc;AAClCC;AAAsC;AAC9C;;;;AAKIC;;AAEF;;AAYAC;AACA;AACAC;AACA;AACA;AACF;;AAEA;;AAEEN;AAIF;AACF;AACF;;;AAGEA;;AACsBO;AAAS;AACjC;AACF;AACF;AACEP;AAIF;AACF;AAEA;;AAEIA;;AACsBD;AAAa;AACrC;;AAGE;AACEE;;;AAE0BC;AAAc;AAClCC;AAAsC;AAC9C;;;;AAKIC;;AAEF;AAEA;AACV;AAUUC;AACA;AACAC;AACA;AACA;AACF;;AAEA;;AAEE;AACF;;AAEEN;;AACsBO;AAAS;AACjC;AACA;AACF;AACF;;AAGEP;;AACsBQ;AAA2B;AACnD;AACF;;AAGA;;;;;;AAOA;AAEA;AACE;;AAEAC;AACF;;AAESC;;AACX;;","debugId":"f69cd503-77eb-4641-a4ae-622c377f99cb"}
|
|
1
|
+
{"version":3,"file":"shadow-pnpm-bin.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;","debugId":"26f08621-821f-4156-93c1-18cf372d6d32"}
|