Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/core

Package Overview
Dependencies
Maintainers
6
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/core - npm Package Compare versions

Comparing version 3.5.2 to 3.5.3

3

lib/scriptUtils.d.ts

@@ -71,6 +71,7 @@ /// <reference types="node" />

export declare function maybeExecuteWorkspaceLifecycleScript(workspace: Workspace, lifecycleScriptName: string, opts: ExecuteWorkspaceLifecycleScriptOptions): Promise<void>;
export declare function isNodeScript(p: PortablePath): boolean;
type GetPackageAccessibleBinariesOptions = {
project: Project;
};
type Binary = [Locator, NativePath];
type Binary = [Locator, NativePath, boolean];
type PackageAccessibleBinaries = Map<string, Binary>;

@@ -77,0 +78,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.executeWorkspaceAccessibleBinary = exports.executePackageAccessibleBinary = exports.getWorkspaceAccessibleBinaries = exports.getPackageAccessibleBinaries = exports.maybeExecuteWorkspaceLifecycleScript = exports.executeWorkspaceLifecycleScript = exports.hasWorkspaceScript = exports.executeWorkspaceScript = exports.executePackageShellcode = exports.executePackageScript = exports.hasPackageScript = exports.prepareExternalProject = exports.makeScriptEnv = exports.detectPackageManager = exports.PackageManager = void 0;
exports.executeWorkspaceAccessibleBinary = exports.executePackageAccessibleBinary = exports.getWorkspaceAccessibleBinaries = exports.getPackageAccessibleBinaries = exports.isNodeScript = exports.maybeExecuteWorkspaceLifecycleScript = exports.executeWorkspaceLifecycleScript = exports.hasWorkspaceScript = exports.executeWorkspaceScript = exports.executePackageShellcode = exports.executePackageScript = exports.hasPackageScript = exports.prepareExternalProject = exports.makeScriptEnv = exports.detectPackageManager = exports.PackageManager = void 0;
const tslib_1 = require("tslib");

@@ -386,3 +386,3 @@ const fslib_1 = require("@yarnpkg/fslib");

const env = await makeScriptEnv({ project: workspace.project, locator: workspace.anchoredLocator, binFolder, lifecycleScript });
await Promise.all(Array.from(await getWorkspaceAccessibleBinaries(workspace), ([binaryName, [, binaryPath]]) => makePathWrapper(binFolder, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath])));
await installBinaries(binFolder, await getWorkspaceAccessibleBinaries(workspace));
// When operating under PnP, `initializePackageEnvironment`

@@ -427,3 +427,3 @@ // yields package location to the linker, which goes into

const env = await makeScriptEnv({ project, locator, binFolder, lifecycleScript });
await Promise.all(Array.from(await getPackageAccessibleBinaries(locator, { project }), ([binaryName, [, binaryPath]]) => makePathWrapper(binFolder, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath])));
await installBinaries(binFolder, await getPackageAccessibleBinaries(locator, { project }));
const packageLocation = await linker.findPackageLocation(pkg, linkerOptions);

@@ -475,2 +475,33 @@ const packageFs = new fslib_1.CwdFS(packageLocation, { baseFs: zipOpenFs });

exports.maybeExecuteWorkspaceLifecycleScript = maybeExecuteWorkspaceLifecycleScript;
function isNodeScript(p) {
const ext = fslib_2.ppath.extname(p);
if (ext.match(/\.[cm]?[jt]sx?$/))
return true;
if (ext === `.exe` || ext === `.bin`)
return false;
const buf = Buffer.alloc(4);
let fd;
try {
fd = fslib_2.xfs.openSync(p, `r`);
}
catch {
return true;
}
try {
fslib_2.xfs.readSync(fd, buf, 0, buf.length, 0);
}
finally {
fslib_2.xfs.closeSync(fd);
}
// @ts-expect-error - Types are incorrect
const magic = buf.readUint32BE();
if (magic === 0xcafebabe || // OSX Universal Binary
magic === 0xcffaedfe || // Mach-O
magic === 0x7f454c46 || // ELF
(magic & 0xffff0000) === 0x4d5a0000 // DOS MZ Executable
)
return false;
return true;
}
exports.isNodeScript = isNodeScript;
/**

@@ -529,3 +560,4 @@ * Return the binaries that can be accessed by the specified package

for (const [name, target] of dependency.bin) {
binaries.set(name, [dependency, fslib_2.npath.fromPortablePath(fslib_2.ppath.resolve(packageLocation, target))]);
const binaryPath = fslib_2.ppath.resolve(packageLocation, target);
binaries.set(name, [dependency, fslib_2.npath.fromPortablePath(binaryPath), isNodeScript(binaryPath)]);
}

@@ -545,2 +577,9 @@ }

exports.getWorkspaceAccessibleBinaries = getWorkspaceAccessibleBinaries;
async function installBinaries(target, binaries) {
await Promise.all(Array.from(binaries, ([binaryName, [, binaryPath, isScript]]) => {
return isScript
? makePathWrapper(target, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath])
: makePathWrapper(target, (0, fslib_2.toFilename)(binaryName), binaryPath, []);
}));
}
/**

@@ -565,6 +604,9 @@ * Execute a binary from the specified package.

const env = await makeScriptEnv({ project, locator, binFolder });
await Promise.all(Array.from(packageAccessibleBinaries, ([binaryName, [, binaryPath]]) => makePathWrapper(env.BERRY_BIN_FOLDER, (0, fslib_2.toFilename)(binaryName), process.execPath, [binaryPath])));
await installBinaries(env.BERRY_BIN_FOLDER, packageAccessibleBinaries);
const promise = isNodeScript(fslib_2.npath.toPortablePath(binaryPath))
? execUtils.pipevp(process.execPath, [...nodeArgs, binaryPath, ...args], { cwd, env, stdin, stdout, stderr })
: execUtils.pipevp(binaryPath, args, { cwd, env, stdin, stdout, stderr });
let result;
try {
result = await execUtils.pipevp(process.execPath, [...nodeArgs, binaryPath, ...args], { cwd, env, stdin, stdout, stderr });
result = await promise;
}

@@ -571,0 +613,0 @@ finally {

{
"name": "@yarnpkg/core",
"version": "3.5.2",
"version": "3.5.3",
"license": "BSD-2-Clause",

@@ -15,3 +15,3 @@ "main": "./lib/index.js",

"@yarnpkg/parsers": "^2.5.1",
"@yarnpkg/pnp": "^3.3.3",
"@yarnpkg/pnp": "^3.3.4",
"@yarnpkg/shell": "^3.2.5",

@@ -53,6 +53,6 @@ "camelcase": "^5.3.1",

"@types/tunnel": "^0.0.0",
"@yarnpkg/cli": "^3.6.0",
"@yarnpkg/cli": "^3.6.2",
"@yarnpkg/plugin-link": "^2.2.1",
"@yarnpkg/plugin-npm": "^2.7.4",
"@yarnpkg/plugin-pnp": "^3.2.10",
"@yarnpkg/plugin-pnp": "^3.2.12",
"esbuild": "npm:esbuild-wasm@^0.15.15",

@@ -59,0 +59,0 @@ "rollup": "^2.59.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc