Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
npm-only-allow
Advanced tools
The hook about preinstall of
npm
behaves inconsistently across package managers.
The existing solution (
only-allow
) is not working well.
The
npm-only-allow
goal is to fix them.
Add a postinstall
script to your project's package.json
.
If you want to force npm|cnpm|pnpm|yarn
, add:
(If you want to smooth out the difference, you also need to add it in the startup script)
{
"scripts": {
"postinstall": "npx npm-only-allow@latest --PM yarn",
"start": "npx npm-only-allow@latest && vite"
}
}
Set the package manager
Set the language category for error messages to be output , Default to English
node v14.19.0
npm v8.11.0
yarn v1.22.19
pnpm v7.2.7
cnpm v9.0.1
If you are using 'cnpm' as your package manager, try pressing the space bar if loading is going on
This is the testing process after the development is complete
You just have to choose one or the other
Let's take yarn
for example
{
"scripts": {
"postinstall": "npx npm-only-allow@latest --PM yarn",
"start": "npx npm-only-allow@latest && vite"
}
}
/**
* pnpm i | cnpm i | npm i
* => [npm-only-allow]:当前运行的(pnpm)包管理器与设置的(yarn)不一致
*/
/**
* yarn
* => success
*/
/**
* cnpm i lodash | pnpm i lodash | cnpm i lodash
* => success
*/
/**
* yarn start
* => [npm-only-allow]:检测到您可能使用了不匹配的包管理器安装了依赖(lodash),请卸载或使用正确的管理器安装后重试
*/
/**
* yarn add lodash
* => success
*/
/**
* cnpm start
* => success
*/
/**
* yarn add moment
* => success
*/
/**
* cnpm i jquery | pnpm i jquery | cnpm i jquery
* => 关闭正在运行的线程
* => [npm-only-allow]:检测到您可能使用了不匹配的包管理器安装了依赖(jquery),请卸载或使用正确的管理器安装后重试
*/
FAQs
Specification package manager
The npm package npm-only-allow receives a total of 9,016 weekly downloads. As such, npm-only-allow popularity was classified as popular.
We found that npm-only-allow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.