容器镜像安全漏洞扫描工具Trivy

发布时间 2023-07-28 14:29:38作者: GaoYanbing

概述
最近做镜像分析扫描工作,需要扫描镜像的安全漏洞,评估镜像安全性,调研了几款漏洞扫描工具,最后决定使用Trivy 工具,Trivy是一家以色列安全公司开源的一个漏洞扫描工具,支持容器镜像、虚机镜像、文件系统的安全扫描。
官网地址: https://aquasecurity.github.io/trivy/v0.42/
github地址: https://github.com/aquasecurity/trivy

安装
可以通过添加软件源的方式,也可以在github的发布页下载安装包,下面展示软件源方式安装。

RHEL/CentOS
通过新增yum仓库源的方式安装


RELEASE_VERSION=$(grep -Po '(?<=VERSION_ID=")[0-9]' /etc/os-release)
cat << EOF | sudo tee -a /etc/yum.repos.d/trivy.repo
[trivy]
name=Trivy repository
baseurl=https://aquasecurity.github.io/trivy-repo/rpm/releases/$RELEASE_VERSION/\$basearch/
gpgcheck=1
enabled=1
gpgkey=https://aquasecurity.github.io/trivy-repo/rpm/public.key
EOF
sudo yum -y update
sudo yum -y install trivy
1
2
3
4
5
6
7
8
9
10
11
12
Debian/Ubuntu
添加apt软件源

sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | gpg --dearmor | sudo tee /usr/share/keyrings/trivy.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/trivy.gpg] https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy

1
2
3
4
5
6
MacOS
brew install trivy
1
使用
安装完成后直接输入 trivy 命令就可以使用了
例如,扫描nginx镜像的安全漏洞,默认扫描所有的级别的漏洞

trivy image nginx
1
也可以只扫描高危漏洞

trivy image --severity CRITICAL nginx
1
输出如下,可以看到存在的高危漏洞,和漏洞说明的URL

————————————————
版权声明:本文为CSDN博主「俞兆鹏」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhaopeng_yu/article/details/131132455