Node 安全平台服务自今年 9 月 30 日起开始折旧。我一直在继续使用 NSP package直到今天终于失败了。我想公开记录错误,以便其他人以后可以找到它。
我今天遇到的错误:
Error: Client request error: getaddrinfo ENOTFOUND api.nodesecurity.io api.nodesecurity.io:443
> eslint . && nsp check
(+) Error: Client request error: getaddrinfo ENOTFOUND api.nodesecurity.io api.nodesecurity.io:443
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! htm-gateway@1.0.1 lint: `eslint . && nsp check`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@1.0.1 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
最佳答案
"beginning with npm@6, a new command, npm audit, recursively analyzes your dependency trees to identify specifically what’s insecure, recommend a replacement, or fix it automatically with
npm audit fix
."
因此,更新
nsp check
到
npm audit --audit-level high
其他配置和选项可以找到here
请注意,--audit-level high
标志可能仅适用于 NPM 版本 > v6.4.0(阅读 v6.4.0-next.0 commits)
非零退出的可配置审计级别 npm audit 当前以退出代码 1 退出,如果发现任何级别的任何漏洞。在 npm audit
中添加了 --audit-level
标志,以允许它在仅发现低于某个级别的漏洞时通过。
示例:npm audit --audit-level=high
如果仅检测到低级或中等级别的漏洞,则会以 0 退出。
NPM 文档:https://docs.npmjs.com/auditing-package-dependencies-for-security-vulnerabilities
官方博客:https://blog.npmjs.org/post/175511531085/the-node-security-platform-service-is-shutting
Updates about ignoring security advisory
有 NPM 包可用于扩展新 npm-audit
命令的功能(例如忽略某些建议),例如:
- audit-filter
- better-npm-audit (无法让上面的包正常工作,所以我自己创建了这个包)
关于node.js - Node 安全服务关闭 : getaddrinfo ENOTFOUND api. nodesecurity.io,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53716991/