当前位置:网站首页>如何检测出你们安装的依赖是否安全
如何检测出你们安装的依赖是否安全
2022-07-29 15:03:00 【紫微前端】
如何确保所有 npm install
的依赖都是安全的?
当有一个库偷偷在你的笔记本后台挖矿怎么办?
比如,不久前一个周下载量超过八百万的库被侵入,它在你的笔记本运行时会偷偷挖矿。
Audit
Audit
,审计,检测你的所有依赖是否安全。npm audit
/yarn audit
均有效。
通过审计,可看出有风险的 package
、依赖库的依赖链、风险原因及其解决方案。
$ npm audit
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ high │ Regular Expression Denial of Service in trim │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ trim │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=0.0.3 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ @mdx-js/loader │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ @mdx-js/loader > @mdx-js/mdx > remark-mdx > remark-parse > │
│ │ trim │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://www.npmjs.com/advisories/1002775 │
└───────────────┴──────────────────────────────────────────────────────────────┘
76 vulnerabilities found - Packages audited: 1076
Severity: 49 Moderate | 27 High
Done in 4.60s.
你可以在我的笔记本上挖矿,但绝不能在生产环境服务器下挖矿,此时可使用以下两条命令。
$ npm audit production
$ yarn audit dependencies
通过 npm audit fix
可以自动修复该库的风险,原理就是升级依赖库,升级至已修复了风险的版本号。
$ npm audit fix
yarn audit
无法自动修复,需要使用 yarn upgrade
手动更新版本号,不够智能。
synk (opens new window)是一个高级版的 npm audit
,可自动修复,且支持 CICD 集成与多种语言。
$ npx snyk
$ npx wizard
CI 机器人
可通过 CI/gitlab/github 中配置机器人,使他们每天轮询一次检查仓库的依赖中是否有风险。
在 Github 中,可单独设置 dependabot
机器人,在仓库设置中开启小机器人,当它检测到有问题时,会自动向该仓库提交 PR。
而它的解决方案也是升级版本号。
边栏推荐
- [yolov7 series two] positive and negative sample allocation strategy
- Why does APP use the JSON protocol to interact with the server: serialization related knowledge
- Altair SimSolid complex assembly meshless rapid structure simulation online seminars
- 【微服务】(十六)—— 分布式事务Seata
- 【LeetCode】1. 两数之和
- 展讯模块读写IMEI
- Replay Online Traffic Tool - GoReplay
- Shell脚本编程-运算
- I/O代码实践
- 微机原理之指令系统和汇编程序设计
猜你喜欢
CNCF Keith Chan:分布式云时代,云原生社区的发展与趋势
基于C语言实现一个社交系统
C语言 5:bool类型,关系表达式,逻辑表达式,分支语句,函数调用机制,break,continue,goto,return/exit跳转语句
ES6 从入门到精通 # 11:Map 数据类型
网络知识大集合(最详细)与网络通信过程
文件管理:文件的物理结构
双线机房、多线机房、BGP机房的关系和对比
Replay Online Traffic Tool - GoReplay
Qt learning on the first day
Why does APP use the JSON protocol to interact with the server: serialization related knowledge
随机推荐
不会多线程还想进BAT?精选19道多线程面试题,有答案边看边学
正斜杠 “/” 与反斜杠 “\”辨析
【LeetCode】121. 买卖股票的最佳时机
数据挖掘场景-发票虚开
Qt learning on the first day
NLP自然语言处理-机器学习和自然语言处理介绍(三)
行业资讯|俄罗斯决定绕过5G直接开发6G网络;Twitter将在全球缩减办公空间…
LeetCode·621.任务调度器·构造法
进入中国27年,又一美妆巨头要离场
bit field in c language
redis常见面试题(背诵篇)
AC自动机笔记与例题整理
AOP实现企业级API访问接口监控(通过Google Guava缓存数据)
【左连接】坑点
Face key point prediction and normalization
使用Xshell和Xftp7跑学校服务器记录
qt vs2015中无法打开源文件“QtWidgets”的解决方案
【LeetCode】566. 重塑矩阵
大模型轻量化实践路径
文件管理:文件的逻辑结构