[英] 通过 npm audit 命令行来检查项目内是否有安全隐患

npm@6引入了npmaudit命令,用于对项目依赖树进行实时安全审查,报告中包含安全漏洞信息并提供修复建议。当安装带有已知安全风险的代码时,系统会自动发出警报。此更新提高了整个JavaScript生态系统的安全性,鼓励开发者及时处理潜在风险。
摘要由CSDN通过智能技术生成

Last month, we announced npm@6, which includes a powerful new tool to protect the safety of your code, npm audit. Together with new automatic alerts when a user installs code with a known security risk, audit is a dramatic step to ensure the quality and integrity of the code you use, and protect the world’s largest community of open source software developers.

Read on to learn more about audit and how we’re working to help you develop with confidence.

What is npm audit?

npm audit is a new command that performs a moment-in-time security review of your project’s dependency tree. Audit reports contain information about security vulnerabilities in your dependencies and can help you fix a vulnerability by providing simple-to-run npm commands and recommendations for further troubleshooting.

You can start using npm audit right now by updating to the latest version of npm. Just type npm install npm -g.

Here is an example of running npm audit against your-fantastic-app:

cd your-fantastic-app
npm audit 

The results should look like this:

We’ve also built in a summary security report into npm install if vulnerabilities are found during installation:

Or when no vulnerabilities are found:

You can learn more about how to run a security audit here: About audit reports | npm documentation

What if I’m using a previous version of npm?

npm audit is available in npm@5.10.0 and npm@6. Prior versions of npm will receive vulnerability messages similar to the following:

npm-notice: [SECURITY] marked has 3 high, and 2 moderate vulnerabilities. Go here for more details: https://nodesecurity.io/advisories?search=marked&version=0.3.0 - Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info. 

We’re not aware of any third-party registry clients that currently support displaying the npm-notify header, so users of these tools will not receive vulnerability messages. For maximum protection against unsafe code, all users should use npm@6.

How does this impact the JavaScript ecosystem?

In the short term, these new alerts and npm audit will raise developers’ awareness of known security vulnerabilities within their applications.They also provide actionable guidance to eliminate the identified risks.

In the longer term, prominent vulnerability warnings and actionable security alerts will raise the floor for everyone. When a developer of a popular package notices they have been bringing in a vulnerable dependency and switches to using a fixed version, instead, every package that depends upon this popular package will now grow safer, too. Everyone stands to benefit from this network effect.

What’s next?

Security is a process, not a project—it’s never done. We will continue to work to improve the security of the npm Registry and the code you write, and we’re excited by what’s in the works in coming weeks and months.

Already, we’ve announced that package signing is on its way. This will allow users of npm packages to verify the integrity of the package regardless of the tools they use to retrieve it or the registry from which they download it.

After this, expect a summer full of products that empower security-focused teams and enterprises by augmenting the tools we’ve announced today. Watch this space.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值