freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

Grype:一款针对容器镜像和文件系统的漏洞扫描器
2020-11-15 20:12:55

Grype

Grype是一款针对容器镜像和文件系统的漏洞扫描器。在该工具的帮助下,广大研究人员可以轻松完成针对容器镜像和文件系统的漏洞扫描和安全审计任务。

功能特性

扫描一个容器镜像或文件系统中的内容,尝试寻找其中存在的已知的安全漏洞;

支持对主流操作系统包进行安全漏洞扫描:

Alpine

BusyBox

CentOS / Red Hat

Debian

Ubuntu

支持对特定语言的软件包进行漏洞扫描:

Ruby (Bundler)

Java (JARs等)

JavaScript (NPM/Yarn)

Python (Egg/Wheel)

Python pip/requirements.txt/setup.py

支持Docker和OCI镜像格式;

工具安装

如果你使用的是macOS或Linux系统,我们建议大家使用下列方式进行工具的安装和配置:

# 将最新版本的Grype安装至/usr/local/bin

curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin

 

# 将特定版本的Grype安装到指定目录中

curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b <SOME_BIN_PATH> <RELEASE_VERSION>

针对macOS,我们也推荐使用Homebrew进行安装:

brew tap anchore/grype

brew install grype

工具配置

配置文件搜索路径如下:

.grype.yaml

.grype/config.yaml

~/.grype.yaml

<XDG_CONFIG_HOME>/grype/config.yaml

配置选项(样例值为默认值):

# enable/disable checking for application updates on startup

check-for-app-update: true

 

# same as --fail-on ; upon scanning, if a severity is found at or above the given severity then the return code will be 1

# default is unset which will skip this validation (options: negligible, low, medium, high, critical)

fail-on-severity: ''

 

# same as -o ; the output format of the vulnerability report (options: table, json, cyclonedx)

output: "table"

 

# same as -s ; the search space to look for packages (options: all-layers, squashed)

scope: "squashed"

 

# same as -q ; suppress all output (except for the vulnerability list)

quiet: false

 

db:

  # check for database updates on execution

  auto-update: true

 

  # location to write the vulnerability database cache

  cache-dir: "$XDG_CACHE_HOME/grype/db"

 

  # URL of the vulnerability database

  update-url: "https://toolbox-data.anchore.io/grype/databases/listing.json"

 

log:

  # location to write the log file (default is not to have a log file)

  file: ""

 

  # the log level; note: detailed logging suppress the ETUI

  level: "error"

 

  # use structured logging

  structured: false

工具使用

安装好Grype之后,我们还需要确保可以直接在命令行中调用Grype。接下来,我们就可以使用下列命令来扫描一个镜像中的安全漏洞了:

grype <image>

上述命令将寻找一个容器镜像中的安全漏洞,如需在漏洞扫描任务中包含所有镜像层的软件,可以使用--scope all-layers选项:

grype <image> --scope all-layers

Grype还可以扫描除了Docker之外的其他各种源:

# scan a container image archive (from the result of `docker image save ...`, `podman save ...`, or `skopeo copy` commands)

grype path/to/image.tar

 

# scan a directory

grype dir:path/to/dir

Grype的输出数据格式同样是可配置的:

grype <image> -o <format>

这里的format可选项如下:

json

cyclonedx

table

Grype还可以获取Anchore Feed服务所提供的漏洞数据库,这个数据库会在每一次扫描任务开始之前进行更新,不过我们也可以使用下列命令来进行手动更新:

grype db update

Shell命令补全

Grype还支持CLI命令行中的Shell补全,我们可以通过运行下列命令来生成针对Shell补全的代码:

grype completion <bash|fish>

go run main.go completion <bash|fish>

上述命令将输出一个Shell脚本,它将作为Grpe的补全脚本使用。

工具使用样例

项目地址

Grype:【GitHub传送门

# 容器安全 # 容器安全分析
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录